[MM-58518] Migrate tooltips of "components/copy_text.tsx" to WithTooltip (#27413)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
705679e875
Коммит
6ddf796384
@@ -51,21 +51,12 @@ describe('Incoming webhook', () => {
|
|||||||
cy.findByText('Setup Successful').should('be.visible');
|
cy.findByText('Setup Successful').should('be.visible');
|
||||||
|
|
||||||
// * You should see a "copy" icon to the right of the URL in the "Setup Successful" screen
|
// * You should see a "copy" icon to the right of the URL in the "Setup Successful" screen
|
||||||
copyIconIsVisible('.backstage-form__confirmation');
|
cy.findByTestId('copyText').should('be.visible');
|
||||||
|
|
||||||
// # Click "Done" in the "Setup Successful" screen
|
// # Click "Done" in the "Setup Successful" screen
|
||||||
cy.findByText('Done').should('be.visible').click();
|
cy.findByText('Done').should('be.visible').click();
|
||||||
|
|
||||||
// # You should see a "copy" icon to the right of the webhook's URL
|
// # You should see a "copy" icon to the right of the webhook's URL
|
||||||
copyIconIsVisible('.item-details__url');
|
cy.findByTestId('copyText').should('be.visible');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function copyIconIsVisible(element) {
|
|
||||||
cy.get(element).within(() => {
|
|
||||||
cy.get('.fa.fa-copy').
|
|
||||||
should('be.visible').
|
|
||||||
trigger('mouseover').
|
|
||||||
should('have.attr', 'aria-describedby', 'copy');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -248,8 +248,7 @@ describe('Integrations page', () => {
|
|||||||
cy.findByText('Token').should('exist').and('be.visible');
|
cy.findByText('Token').should('exist').and('be.visible');
|
||||||
|
|
||||||
// * Verify copy icon is shown
|
// * Verify copy icon is shown
|
||||||
cy.get('.fa.fa-copy').should('exist').and('be.visible').
|
cy.findByTestId('copyText').should('be.visible');
|
||||||
trigger('mouseover').and('have.attr', 'aria-describedby', 'copy');
|
|
||||||
|
|
||||||
// # Hit done to move from confirm screen
|
// # Hit done to move from confirm screen
|
||||||
cy.findByText('Done').should('exist').and('be.visible').click();
|
cy.findByText('Done').should('exist').and('be.visible').click();
|
||||||
@@ -265,8 +264,7 @@ describe('Integrations page', () => {
|
|||||||
// # For each custom slash command was created
|
// # For each custom slash command was created
|
||||||
cy.wrap(el).within(() => {
|
cy.wrap(el).within(() => {
|
||||||
// Verify copy icon for token is present
|
// Verify copy icon for token is present
|
||||||
cy.get('.fa.fa-copy').should('exist').and('be.visible').
|
cy.findByTestId('copyText').should('be.visible');
|
||||||
trigger('mouseover').and('have.attr', 'aria-describedby', 'copy');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
|
import type {ReactNode} from 'react';
|
||||||
import React, {useCallback} from 'react';
|
import React, {useCallback} from 'react';
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
import OverlayTrigger from 'components/overlay_trigger';
|
import WithTooltip from 'components/with_tooltip';
|
||||||
import Tooltip from 'components/tooltip';
|
|
||||||
|
|
||||||
import Constants from 'utils/constants';
|
|
||||||
import {copyToClipboard} from 'utils/utils';
|
import {copyToClipboard} from 'utils/utils';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
value: string;
|
value: string;
|
||||||
defaultMessage?: string;
|
tooltip?: ReactNode;
|
||||||
idMessage?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const CopyText = ({
|
const CopyText = ({
|
||||||
value,
|
value,
|
||||||
defaultMessage = 'Copy',
|
tooltip,
|
||||||
idMessage = 'integrations.copy',
|
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const copyText = useCallback((e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
const copyText = useCallback((e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -30,20 +27,18 @@ const CopyText = ({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tooltip = (
|
|
||||||
<Tooltip id='copy'>
|
|
||||||
<FormattedMessage
|
|
||||||
id={idMessage}
|
|
||||||
defaultMessage={defaultMessage}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OverlayTrigger
|
<WithTooltip
|
||||||
delayShow={Constants.OVERLAY_TIME_DELAY}
|
id='copyTextTooltip'
|
||||||
placement='top'
|
placement='top'
|
||||||
overlay={tooltip}
|
title={
|
||||||
|
tooltip || (
|
||||||
|
<FormattedMessage
|
||||||
|
id='copyTextTooltip.copy'
|
||||||
|
defaultMessage='Copy'
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href='#'
|
href='#'
|
||||||
@@ -51,7 +46,7 @@ const CopyText = ({
|
|||||||
className='fa fa-copy ml-2'
|
className='fa fa-copy ml-2'
|
||||||
onClick={copyText}
|
onClick={copyText}
|
||||||
/>
|
/>
|
||||||
</OverlayTrigger>
|
</WithTooltip>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -210,8 +210,12 @@ exports[`components/integrations/ConfirmIntegration should match snapshot, oauth
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Memo(CopyText)
|
<Memo(CopyText)
|
||||||
defaultMessage="Copy Client Id"
|
tooltip={
|
||||||
idMessage="integrations.copy_client_id"
|
<Memo(MemoizedFormattedMessage)
|
||||||
|
defaultMessage="Copy Client Id"
|
||||||
|
id="integrations.copy_client_id"
|
||||||
|
/>
|
||||||
|
}
|
||||||
value="r5tpgt4iepf45jt768jz84djic"
|
value="r5tpgt4iepf45jt768jz84djic"
|
||||||
/>
|
/>
|
||||||
<br />
|
<br />
|
||||||
@@ -225,8 +229,12 @@ exports[`components/integrations/ConfirmIntegration should match snapshot, oauth
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Memo(CopyText)
|
<Memo(CopyText)
|
||||||
defaultMessage="Copy Client Secret"
|
tooltip={
|
||||||
idMessage="integrations.copy_client_secret"
|
<Memo(MemoizedFormattedMessage)
|
||||||
|
defaultMessage="Copy Client Secret"
|
||||||
|
id="integrations.copy_client_secret"
|
||||||
|
/>
|
||||||
|
}
|
||||||
value="<==secret==>"
|
value="<==secret==>"
|
||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -209,8 +209,12 @@ const ConfirmIntegration = ({team, location, commands, oauthApps, incomingHooks,
|
|||||||
values={{id: oauthAppToken}}
|
values={{id: oauthAppToken}}
|
||||||
/>
|
/>
|
||||||
<CopyText
|
<CopyText
|
||||||
idMessage='integrations.copy_client_id'
|
tooltip={
|
||||||
defaultMessage='Copy Client Id'
|
<FormattedMessage
|
||||||
|
id='integrations.copy_client_id'
|
||||||
|
defaultMessage='Copy Client Id'
|
||||||
|
/>
|
||||||
|
}
|
||||||
value={oauthAppToken}
|
value={oauthAppToken}
|
||||||
/>
|
/>
|
||||||
<br/>
|
<br/>
|
||||||
@@ -220,8 +224,12 @@ const ConfirmIntegration = ({team, location, commands, oauthApps, incomingHooks,
|
|||||||
values={{secret: oauthAppSecret}}
|
values={{secret: oauthAppSecret}}
|
||||||
/>
|
/>
|
||||||
<CopyText
|
<CopyText
|
||||||
idMessage='integrations.copy_client_secret'
|
tooltip={
|
||||||
defaultMessage='Copy Client Secret'
|
<FormattedMessage
|
||||||
|
id='integrations.copy_client_secret'
|
||||||
|
defaultMessage='Copy Client Secret'
|
||||||
|
/>
|
||||||
|
}
|
||||||
value={oauthAppSecret}
|
value={oauthAppSecret}
|
||||||
/>
|
/>
|
||||||
</p>,
|
</p>,
|
||||||
@@ -302,8 +310,12 @@ const ConfirmIntegration = ({team, location, commands, oauthApps, incomingHooks,
|
|||||||
values={{username}}
|
values={{username}}
|
||||||
/>
|
/>
|
||||||
<CopyText
|
<CopyText
|
||||||
idMessage='integrations.copy_username'
|
tooltip={
|
||||||
defaultMessage='Copy Username'
|
<FormattedMessage
|
||||||
|
id='integrations.copy_username'
|
||||||
|
defaultMessage='Copy Username'
|
||||||
|
/>
|
||||||
|
}
|
||||||
value={username || ''}
|
value={username || ''}
|
||||||
/>
|
/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|||||||
@@ -112,8 +112,12 @@ exports[`components/integrations/InstalledOAuthApp should match snapshot 1`] = `
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Memo(CopyText)
|
<Memo(CopyText)
|
||||||
defaultMessage="Copy Client Id"
|
tooltip={
|
||||||
idMessage="integrations.copy_client_id"
|
<Memo(MemoizedFormattedMessage)
|
||||||
|
defaultMessage="Copy Client Id"
|
||||||
|
id="integrations.copy_client_id"
|
||||||
|
/>
|
||||||
|
}
|
||||||
value="facxd9wpzpbpfp8pad78xj75pr"
|
value="facxd9wpzpbpfp8pad78xj75pr"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
@@ -340,8 +344,12 @@ exports[`components/integrations/InstalledOAuthApp should match snapshot, on err
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Memo(CopyText)
|
<Memo(CopyText)
|
||||||
defaultMessage="Copy Client Id"
|
tooltip={
|
||||||
idMessage="integrations.copy_client_id"
|
<Memo(MemoizedFormattedMessage)
|
||||||
|
defaultMessage="Copy Client Id"
|
||||||
|
id="integrations.copy_client_id"
|
||||||
|
/>
|
||||||
|
}
|
||||||
value="facxd9wpzpbpfp8pad78xj75pr"
|
value="facxd9wpzpbpfp8pad78xj75pr"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
@@ -515,8 +523,12 @@ exports[`components/integrations/InstalledOAuthApp should match snapshot, when o
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Memo(CopyText)
|
<Memo(CopyText)
|
||||||
defaultMessage="Copy Client Id"
|
tooltip={
|
||||||
idMessage="integrations.copy_client_id"
|
<Memo(MemoizedFormattedMessage)
|
||||||
|
defaultMessage="Copy Client Id"
|
||||||
|
id="integrations.copy_client_id"
|
||||||
|
/>
|
||||||
|
}
|
||||||
value="facxd9wpzpbpfp8pad78xj75pr"
|
value="facxd9wpzpbpfp8pad78xj75pr"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -214,8 +214,12 @@ export default class InstalledOAuthApp extends React.PureComponent<InstalledOAut
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<CopyText
|
<CopyText
|
||||||
idMessage='integrations.copy_client_secret'
|
tooltip={
|
||||||
defaultMessage='Copy Client Secret'
|
<FormattedMessage
|
||||||
|
id='integrations.copy_client_secret'
|
||||||
|
defaultMessage='Copy Client Secret'
|
||||||
|
/>
|
||||||
|
}
|
||||||
value={this.state.clientSecret}
|
value={this.state.clientSecret}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
@@ -309,8 +313,12 @@ export default class InstalledOAuthApp extends React.PureComponent<InstalledOAut
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<CopyText
|
<CopyText
|
||||||
idMessage='integrations.copy_client_id'
|
tooltip={
|
||||||
defaultMessage='Copy Client Id'
|
<FormattedMessage
|
||||||
|
id='integrations.copy_client_id'
|
||||||
|
defaultMessage='Copy Client Id'
|
||||||
|
/>
|
||||||
|
}
|
||||||
value={oauthApp.id}
|
value={oauthApp.id}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -3333,6 +3333,7 @@
|
|||||||
"copied.message": "Copied",
|
"copied.message": "Copied",
|
||||||
"copy.code.message": "Copy code",
|
"copy.code.message": "Copy code",
|
||||||
"copy.text.message": "Copy text",
|
"copy.text.message": "Copy text",
|
||||||
|
"copyTextTooltip.copy": "Copy",
|
||||||
"create_category_modal.create": "Create",
|
"create_category_modal.create": "Create",
|
||||||
"create_category_modal.createCategory": "Create New Category",
|
"create_category_modal.createCategory": "Create New Category",
|
||||||
"create_comment.addComment": "Reply to this thread...",
|
"create_comment.addComment": "Reply to this thread...",
|
||||||
@@ -3908,6 +3909,9 @@
|
|||||||
"integrations.add": "Add",
|
"integrations.add": "Add",
|
||||||
"integrations.command.description": "Slash commands send events to external integrations",
|
"integrations.command.description": "Slash commands send events to external integrations",
|
||||||
"integrations.command.title": "Slash Commands",
|
"integrations.command.title": "Slash Commands",
|
||||||
|
"integrations.copy_client_id": "Copy Client Id",
|
||||||
|
"integrations.copy_client_secret": "Copy Client Secret",
|
||||||
|
"integrations.copy_username": "Copy Username",
|
||||||
"integrations.delete.confirm.button": "Yes, delete it",
|
"integrations.delete.confirm.button": "Yes, delete it",
|
||||||
"integrations.delete.confirm.title": "Delete Integration",
|
"integrations.delete.confirm.title": "Delete Integration",
|
||||||
"integrations.done": "Done",
|
"integrations.done": "Done",
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user