diff --git a/webapp/channels/src/components/copy_url_context_menu/__snapshots__/copy_url_context_menu.test.tsx.snap b/webapp/channels/src/components/copy_url_context_menu/__snapshots__/copy_url_context_menu.test.tsx.snap deleted file mode 100644 index 128fad6d8f..0000000000 --- a/webapp/channels/src/components/copy_url_context_menu/__snapshots__/copy_url_context_menu.test.tsx.snap +++ /dev/null @@ -1,107 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`components/CopyUrlContextMenu should copy absolute url on click 1`] = ` - - - - - - - - - Click - - - -`; - -exports[`components/CopyUrlContextMenu should copy relative url on click 1`] = ` - - - - - - - - - Click - - - -`; diff --git a/webapp/channels/src/components/copy_url_context_menu/copy_url_context_menu.test.tsx b/webapp/channels/src/components/copy_url_context_menu/copy_url_context_menu.test.tsx deleted file mode 100644 index 32e789242a..0000000000 --- a/webapp/channels/src/components/copy_url_context_menu/copy_url_context_menu.test.tsx +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -import {shallow} from 'enzyme'; -import React from 'react'; - -import CopyUrlContextMenu from 'components/copy_url_context_menu/copy_url_context_menu'; - -describe('components/CopyUrlContextMenu', () => { - test('should copy relative url on click', () => { - const props = { - siteURL: 'http://example.com', - link: '/path/to/resource', - menuId: 'resource', - actions: { - copyToClipboard: jest.fn(), - }, - }; - - const wrapper = shallow( - - {'Click'} - , - ); - - expect(wrapper).toMatchSnapshot(); - wrapper.find('MenuItem').simulate('click'); - expect(props.actions.copyToClipboard).toBeCalledWith('http://example.com/path/to/resource'); - }); - - test('should copy absolute url on click', () => { - const props = { - siteURL: 'http://example.com', - link: 'http://site.example.com/path/to/resource', - menuId: 'resource', - actions: { - copyToClipboard: jest.fn(), - }, - }; - - const wrapper = shallow( - - {'Click'} - , - ); - - expect(wrapper).toMatchSnapshot(); - wrapper.find('MenuItem').simulate('click'); - expect(props.actions.copyToClipboard).toBeCalledWith('http://site.example.com/path/to/resource'); - }); -}); diff --git a/webapp/channels/src/components/copy_url_context_menu/copy_url_context_menu.tsx b/webapp/channels/src/components/copy_url_context_menu/copy_url_context_menu.tsx deleted file mode 100644 index d8e92e7f9f..0000000000 --- a/webapp/channels/src/components/copy_url_context_menu/copy_url_context_menu.tsx +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -import React, {memo, useCallback} from 'react'; -import {ContextMenu, ContextMenuTrigger, MenuItem} from 'react-contextmenu'; -import {FormattedMessage} from 'react-intl'; - -type Props = { - - /** - * The child component that will be right-clicked on to show the context menu - */ - children: React.ReactNode; - - /** - * The link to copy to the user's clipboard when the 'Copy' option is selected from the context menu - */ - link: string; - - /** - * A unique id differentiating this instance of context menu from others on the page - */ - menuId: string; - - siteURL?: string; - - actions: { - copyToClipboard: (link: string) => void; - }; -} - -const CopyUrlContextMenu = ({ - link, - siteURL, - actions, - menuId, - children, -}: Props) => { - const copy = useCallback(() => { - let siteLink = link; - - // Transform relative links to absolute ones for copy and paste. - if (siteLink.indexOf('http://') === -1 && siteLink.indexOf('https://') === -1) { - siteLink = siteURL + link; - } - - actions.copyToClipboard(siteLink); - }, [actions, link, siteURL]); - - const contextMenu = ( - - - - - - ); - - const contextMenuTrigger = ( - - {children} - - ); - - return ( - - {contextMenu} - {contextMenuTrigger} - - ); -}; - -export default memo(CopyUrlContextMenu); diff --git a/webapp/channels/src/components/copy_url_context_menu/index.ts b/webapp/channels/src/components/copy_url_context_menu/index.ts deleted file mode 100644 index f986fa1859..0000000000 --- a/webapp/channels/src/components/copy_url_context_menu/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -import {connect} from 'react-redux'; - -import {getConfig} from 'mattermost-redux/selectors/entities/general'; - -import {copyToClipboard} from 'utils/utils'; - -import type {GlobalState} from 'types/store/index.js'; - -import CopyUrlContextMenu from './copy_url_context_menu'; - -function mapStateToProps(state: GlobalState) { - const config = getConfig(state); - - return { - siteURL: config.SiteURL, - }; -} - -function mapDispatchToProps() { - return { - actions: { - copyToClipboard, - }, - }; -} - -export default connect(mapStateToProps, mapDispatchToProps)(CopyUrlContextMenu); diff --git a/webapp/channels/src/components/sidebar/sidebar_channel/sidebar_channel_link/sidebar_channel_link.tsx b/webapp/channels/src/components/sidebar/sidebar_channel/sidebar_channel_link/sidebar_channel_link.tsx index 79d921cde5..42a3efea85 100644 --- a/webapp/channels/src/components/sidebar/sidebar_channel/sidebar_channel_link/sidebar_channel_link.tsx +++ b/webapp/channels/src/components/sidebar/sidebar_channel/sidebar_channel_link/sidebar_channel_link.tsx @@ -9,7 +9,6 @@ import type {Channel} from '@mattermost/types/channels'; import {mark, trackEvent} from 'actions/telemetry_actions'; -import CopyUrlContextMenu from 'components/copy_url_context_menu'; import CustomStatusEmoji from 'components/custom_status/custom_status_emoji'; import OverlayTrigger from 'components/overlay_trigger'; import Tooltip from 'components/tooltip'; @@ -19,7 +18,6 @@ import Pluggable from 'plugins/pluggable'; import Constants, {RHSStates} from 'utils/constants'; import {wrapEmojis} from 'utils/emoji_utils'; import {cmdOrCtrlPressed} from 'utils/keyboard'; -import {isDesktopApp} from 'utils/user_agent'; import {localizeMessage} from 'utils/utils'; import type {RhsState} from 'types/store/rhs'; @@ -290,7 +288,7 @@ export default class SidebarChannelLink extends React.PureComponent ); - - if (isDesktopApp()) { - element = ( - - {element} - - ); - } - - return element; } } diff --git a/webapp/channels/src/components/team_sidebar/components/team_button.tsx b/webapp/channels/src/components/team_sidebar/components/team_button.tsx index 1a9a79cd5c..704f64f9ac 100644 --- a/webapp/channels/src/components/team_sidebar/components/team_button.tsx +++ b/webapp/channels/src/components/team_sidebar/components/team_button.tsx @@ -9,13 +9,10 @@ import {Link} from 'react-router-dom'; import {mark, trackEvent} from 'actions/telemetry_actions.jsx'; -import CopyUrlContextMenu from 'components/copy_url_context_menu'; import TeamIcon from 'components/widgets/team_icon/team_icon'; import WithTooltip from 'components/with_tooltip'; import {ShortcutKeys} from 'components/with_tooltip/shortcut'; -import {isDesktopApp} from 'utils/user_agent'; - const messages = defineMessages({ nameUndefined: { id: 'team.button.name_undefined', @@ -163,7 +160,7 @@ export default function TeamButton({ ); - let teamButton = ( + const teamButton = ( ); - if (isDesktopApp()) { - // if this is not a "special" team button, give it a context menu - if (isNotCreateTeamButton) { - teamButton = ( - - {teamButton} - - ); - } - } - return isDraggable ? (