Skip to content

Commit

Permalink
[MM-22129] - Remove post link modal and copy permalink directly (matt…
Browse files Browse the repository at this point in the history
…ermost#4930)

* [MM-22129] - Remove post link modal and copy permalink directly

* Remove redundant translations

* Change Permalink text

* Fix test
  • Loading branch information
nevyangelova authored Feb 25, 2020
1 parent 32c15be commit ac2b083
Show file tree
Hide file tree
Showing 30 changed files with 30 additions and 246 deletions.
8 changes: 0 additions & 8 deletions actions/global_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ export function showChannelNameUpdateModal(channel) {
});
}

export function showGetPostLinkModal(post) {
AppDispatcher.handleViewAction({
type: ActionTypes.TOGGLE_GET_POST_LINK_MODAL,
value: true,
post,
});
}

export function showGetPublicLinkModal(fileId) {
AppDispatcher.handleViewAction({
type: ActionTypes.TOGGLE_GET_PUBLIC_LINK_MODAL,
Expand Down
3 changes: 1 addition & 2 deletions components/channel_layout/channel_controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import AnnouncementBarController from 'components/announcement_bar';
import Pluggable from 'plugins/pluggable';
import SystemNotice from 'components/system_notice';
import EditPostModal from 'components/edit_post_modal';
import GetPostLinkModal from 'components/get_post_link_modal';

import GetPublicLinkModal from 'components/get_public_link_modal';
import LeavePrivateChannelModal from 'components/leave_private_channel_modal';
import ResetStatusModal from 'components/reset_status_modal';
Expand Down Expand Up @@ -76,7 +76,6 @@ export default class ChannelController extends React.Component {
{!this.props.fetchingChannels && <Route component={CenterChannel}/>}
{this.props.fetchingChannels && <LoadingScreen/>}
<Pluggable pluggableName='Root'/>
<GetPostLinkModal/>
<GetPublicLinkModal/>
<ImportThemeModal/>
<EditPostModal/>
Expand Down
4 changes: 2 additions & 2 deletions components/dot_menu/__snapshots__/dot_menu.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ exports[`components/dot_menu/DotMenu should match snapshot, canDelete 1`] = `
id="permalink_post_id_1"
onClick={[Function]}
show={true}
text="Permalink"
text="Copy Link"
/>
<MenuItemAction
onClick={[Function]}
Expand Down Expand Up @@ -200,7 +200,7 @@ exports[`components/dot_menu/DotMenu should match snapshot, on Center 1`] = `
id="permalink_post_id_1"
onClick={[Function]}
show={true}
text="Permalink"
text="Copy Link"
/>
<MenuItemAction
onClick={[Function]}
Expand Down
23 changes: 18 additions & 5 deletions components/dot_menu/dot_menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {Tooltip} from 'react-bootstrap';

import Permissions from 'mattermost-redux/constants/permissions';

import {showGetPostLinkModal} from 'actions/global_actions.jsx';
import {Locations, ModalIdentifiers, Constants} from 'utils/constants';
import DeletePostModal from 'components/delete_post_modal';
import OverlayTrigger from 'components/overlay_trigger';
Expand Down Expand Up @@ -42,6 +41,7 @@ export default class DotMenu extends React.PureComponent {
postEditTimeLimit: PropTypes.string.isRequired,
enableEmojiPicker: PropTypes.bool.isRequired,
channelIsArchived: PropTypes.bool.isRequired,
currentTeamUrl: PropTypes.string.isRequired,

/*
* Components for overriding provided by plugins
Expand Down Expand Up @@ -162,9 +162,22 @@ export default class DotMenu extends React.PureComponent {
}
}

handlePermalinkMenuItemActivated = (e) => {
copyLink = (e) => {
e.preventDefault();
showGetPostLinkModal(this.props.post);
const postUrl = `${this.props.currentTeamUrl}/pl/${this.props.post.id}`;

const clipboard = navigator.clipboard;
if (clipboard) {
clipboard.writeText(postUrl);
} else {
const hiddenInput = document.createElement('textarea');
hiddenInput.value = postUrl;
document.body.appendChild(hiddenInput);
hiddenInput.focus();
hiddenInput.select();
document.execCommand('copy');
document.body.removeChild(hiddenInput);
}
}

handlePinMenuItemActivated = () => {
Expand Down Expand Up @@ -337,8 +350,8 @@ export default class DotMenu extends React.PureComponent {
<Menu.ItemAction
id={`permalink_${this.props.post.id}`}
show={!isSystemMessage}
text={Utils.localizeMessage('post_info.permalink', 'Permalink')}
onClick={this.handlePermalinkMenuItemActivated}
text={Utils.localizeMessage('post_info.permalink', 'Copy Link')}
onClick={this.copyLink}
/>
<Menu.ItemAction
show={isMobile && !isSystemMessage && this.props.isFlagged}
Expand Down
1 change: 1 addition & 0 deletions components/dot_menu/dot_menu.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('components/dot_menu/DotMenu', () => {
enableEmojiPicker: true,
components: {},
channelIsArchived: false,
currentTeamUrl: '',
actions: {
flagPost: jest.fn(),
unflagPost: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions components/dot_menu/dot_menu_empty.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('components/dot_menu/DotMenu returning empty ("")', () => {
enableEmojiPicker: true,
components: {},
channelIsArchived: false,
currentTeamUrl: '',
actions: {
flagPost: jest.fn(),
unflagPost: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions components/dot_menu/dot_menu_mobile.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('components/dot_menu/DotMenu on mobile view', () => {
enableEmojiPicker: true,
components: {},
channelIsArchived: false,
currentTeamUrl: '',
actions: {
flagPost: jest.fn(),
unflagPost: jest.fn(),
Expand Down
6 changes: 5 additions & 1 deletion components/dot_menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {bindActionCreators} from 'redux';

import {getChannel} from 'mattermost-redux/selectors/entities/channels';
import {getLicense, getConfig} from 'mattermost-redux/selectors/entities/general';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentTeamId, getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';

import {openModal} from 'actions/views/modals';
import {
Expand All @@ -19,11 +19,14 @@ import {
} from 'actions/post_actions.jsx';

import {isArchivedChannel} from 'utils/channel_utils';
import {getSiteURL} from 'utils/url';

import DotMenu from './dot_menu.jsx';

function mapStateToProps(state, ownProps) {
const channel = getChannel(state, ownProps.post.channel_id);
const currentTeam = getCurrentTeam(state) || {};
const currentTeamUrl = `${getSiteURL()}/${currentTeam.name}`;

return {
channelIsArchived: isArchivedChannel(channel),
Expand All @@ -32,6 +35,7 @@ function mapStateToProps(state, ownProps) {
isLicensed: getLicense(state).IsLicensed === 'true',
teamId: getCurrentTeamId(state),
pluginMenuItems: state.plugins.components.PostDropdownMenu,
currentTeamUrl,
};
}

Expand Down

This file was deleted.

81 changes: 0 additions & 81 deletions components/get_post_link_modal/get_post_link_modal.test.tsx

This file was deleted.

79 changes: 0 additions & 79 deletions components/get_post_link_modal/get_post_link_modal.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions components/get_post_link_modal/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2002,8 +2002,6 @@
"get_link.clipboard": " Link kopiert",
"get_link.close": "Schließen",
"get_link.copy": "Link kopieren",
"get_post_link_modal.help": "Der Link erlaubt berechtigten Benutzern diese Nachricht zu sehen.",
"get_post_link_modal.title": "Kopiere Permalink",
"get_public_link_modal.help": "Der unten stehende Link erlaubt jedem diese Datei zu sehen ohne auf diesem Server registriert zu sein.",
"get_public_link_modal.title": "Öffentlichen Link kopieren",
"get_team_invite_link_modal.help": "Senden Sie Teammitgliedern den unten stehenden Link, damit diese sich für dieses Team registrieren können. Der Team-Einladungslink kann mit mehreren Teammitgliedern geteilt werden, da er sich nicht ändert, sofern er nicht in den Teameinstellungen durch den Teamadmin geändert wird.",
Expand Down
4 changes: 1 addition & 3 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2391,8 +2391,6 @@
"get_link.clipboard": " Link copied",
"get_link.close": "Close",
"get_link.copy": "Copy Link",
"get_post_link_modal.help": "The link below allows authorized users to see your post.",
"get_post_link_modal.title": "Copy Permalink",
"get_public_link_modal.help": "The link below allows anyone to see this file without being registered on this server.",
"get_public_link_modal.title": "Copy Public Link",
"gif_picker.gfycat": "Search Gfycat",
Expand Down Expand Up @@ -2959,7 +2957,7 @@
"post_info.message.show_more": "Show More",
"post_info.message.visible": "(Only visible to you)",
"post_info.message.visible.compact": " (Only visible to you)",
"post_info.permalink": "Permalink",
"post_info.permalink": "Copy Link",
"post_info.pin": "Pin to Channel",
"post_info.pinned": "Pinned",
"post_info.reply": "Reply",
Expand Down
2 changes: 0 additions & 2 deletions i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2005,8 +2005,6 @@
"get_link.clipboard": " Enlace copiado",
"get_link.close": "Cerrar",
"get_link.copy": "Copiar Enlace",
"get_post_link_modal.help": "En enlace de abajo permite a los usuarios autorizados a ver tu mensaje.",
"get_post_link_modal.title": "Copiar enlace Permanente",
"get_public_link_modal.help": "El siguiente enlace permite a cualquier persona visualizar este archivo sin necesidad de estar registrado en este servidor.",
"get_public_link_modal.title": "Copiar Enlace Público",
"get_team_invite_link_modal.help": "Envía el siguiente enlace a tus compañeros para que se registren a este equipo. El enlace de invitación al equipo puede ser compartido con multiples compañeros y el mismo no cambiará a menos que sea regenerado en la Configuración del Equipo por un Administrador del Equipo.",
Expand Down
Loading

0 comments on commit ac2b083

Please sign in to comment.