diff options
author | Siegfried Ehret <siegfried.ehret@sonarsource.com> | 2019-07-25 11:47:28 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-08-05 20:21:12 +0200 |
commit | 1b2ae497dcc8e926906ec09bcecee9088fe44119 (patch) | |
tree | bde7eb2c052d6727cbe9dbb5c0b5413987caef0f | |
parent | 09534faa716dc27bdcc9597cbe27cbae672267f5 (diff) | |
download | sonarqube-1b2ae497dcc8e926906ec09bcecee9088fe44119.tar.gz sonarqube-1b2ae497dcc8e926906ec09bcecee9088fe44119.zip |
SONAR-12199 Add Copy button to file header and update ClipboardButton
usage
19 files changed, 150 insertions, 96 deletions
diff --git a/server/sonar-vsts/package.json b/server/sonar-vsts/package.json index 338563630cc..dda838f5f1a 100644 --- a/server/sonar-vsts/package.json +++ b/server/sonar-vsts/package.json @@ -12,7 +12,7 @@ "react": "16.8.6", "react-dom": "16.8.6", "regenerator-runtime": "0.13.2", - "sonar-ui-common": "0.0.18", + "sonar-ui-common": "0.0.19", "whatwg-fetch": "2.0.4" }, "devDependencies": { diff --git a/server/sonar-vsts/yarn.lock b/server/sonar-vsts/yarn.lock index 6ee2e3a7b89..3cc2103e06a 100644 --- a/server/sonar-vsts/yarn.lock +++ b/server/sonar-vsts/yarn.lock @@ -8421,10 +8421,10 @@ sockjs@0.3.19: faye-websocket "^0.10.0" uuid "^3.0.1" -sonar-ui-common@0.0.18: - version "0.0.18" - resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-0.0.18.tgz#93b71859f83b85cc23e8c201bb9ed0420fcbb479" - integrity sha1-k7cYWfg7hcwj6MIBu57QQg/LtHk= +sonar-ui-common@0.0.19: + version "0.0.19" + resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-0.0.19.tgz#c3d97ca6c40c491000eabf86fdf3629dc4c6bfcb" + integrity sha1-w9l8psQMSRAA6r+G/fNincTGv8s= dependencies: "@types/react-select" "1.2.6" classnames "2.2.6" diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 7d31341e47f..d31730a77ac 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -35,7 +35,7 @@ "regenerator-runtime": "0.13.2", "remark-custom-blocks": "2.3.0", "remark-slug": "5.1.0", - "sonar-ui-common": "0.0.18", + "sonar-ui-common": "0.0.19", "unist-util-visit": "1.4.0", "valid-url": "1.0.9", "whatwg-fetch": "2.0.4" diff --git a/server/sonar-web/src/main/js/app/styles/init/misc.css b/server/sonar-web/src/main/js/app/styles/init/misc.css index 2c6c537f8db..7a424f4ee38 100644 --- a/server/sonar-web/src/main/js/app/styles/init/misc.css +++ b/server/sonar-web/src/main/js/app/styles/init/misc.css @@ -433,10 +433,6 @@ td.big-spacer-top { cursor: not-allowed !important; } -.no-select { - user-select: none !important; -} - .no-outline, .no-outline:focus { outline: none !important; diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaKey.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaKey.tsx index 282516fa475..bb32da506ce 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaKey.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaKey.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import ClipboardButton from 'sonar-ui-common/components/controls/ClipboardButton'; +import { ClipboardButton } from 'sonar-ui-common/components/controls/clipboard'; import { translate } from 'sonar-ui-common/helpers/l10n'; interface Props { diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaOrganizationKey.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaOrganizationKey.tsx index 75cce62c63e..9fa147ad8af 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaOrganizationKey.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaOrganizationKey.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import ClipboardButton from 'sonar-ui-common/components/controls/ClipboardButton'; +import { ClipboardButton } from 'sonar-ui-common/components/controls/clipboard'; import { translate } from 'sonar-ui-common/helpers/l10n'; interface Props { diff --git a/server/sonar-web/src/main/js/apps/settings/encryption/EncryptionForm.tsx b/server/sonar-web/src/main/js/apps/settings/encryption/EncryptionForm.tsx index 62ecc6cfb5c..84988fefac8 100644 --- a/server/sonar-web/src/main/js/apps/settings/encryption/EncryptionForm.tsx +++ b/server/sonar-web/src/main/js/apps/settings/encryption/EncryptionForm.tsx @@ -20,7 +20,7 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { SubmitButton } from 'sonar-ui-common/components/controls/buttons'; -import ClipboardButton from 'sonar-ui-common/components/controls/ClipboardButton'; +import { ClipboardButton } from 'sonar-ui-common/components/controls/clipboard'; import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner'; import { translate } from 'sonar-ui-common/helpers/l10n'; import { encryptValue } from '../../../api/settings'; diff --git a/server/sonar-web/src/main/js/apps/settings/encryption/GenerateSecretKeyForm.tsx b/server/sonar-web/src/main/js/apps/settings/encryption/GenerateSecretKeyForm.tsx index d5a4bf7feeb..235e12a7e21 100644 --- a/server/sonar-web/src/main/js/apps/settings/encryption/GenerateSecretKeyForm.tsx +++ b/server/sonar-web/src/main/js/apps/settings/encryption/GenerateSecretKeyForm.tsx @@ -20,7 +20,7 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { SubmitButton } from 'sonar-ui-common/components/controls/buttons'; -import ClipboardButton from 'sonar-ui-common/components/controls/ClipboardButton'; +import { ClipboardButton } from 'sonar-ui-common/components/controls/clipboard'; import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner'; import { translate } from 'sonar-ui-common/helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx index 7f508bb9810..d5e15b0c58d 100644 --- a/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import ClipboardButton from 'sonar-ui-common/components/controls/ClipboardButton'; +import { ClipboardButton } from 'sonar-ui-common/components/controls/clipboard'; import { toShortNotSoISOString } from 'sonar-ui-common/helpers/dates'; import { translate } from 'sonar-ui-common/helpers/l10n'; import PageActions from './PageActions'; @@ -79,9 +79,9 @@ export default function PageHeader(props: Props) { Server ID: ${serverId} Version: ${version} Date: ${toShortNotSoISOString(Date.now())} -`} - label={translate('system.copy_id_info')} - /> +`}> + {translate('system.copy_id_info')} + </ClipboardButton> </div> )} </header> diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap index 84f459faba7..b9fce7a55af 100644 --- a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap @@ -95,8 +95,9 @@ Server ID: foo-bar Version: 7.7.0.1234 Date: 2019-01-01 " - label="system.copy_id_info" - /> + > + system.copy_id_info + </ClipboardButton> </div> </header> `; diff --git a/server/sonar-web/src/main/js/apps/users/components/TokensFormNewToken.tsx b/server/sonar-web/src/main/js/apps/users/components/TokensFormNewToken.tsx index 359303bf8f9..8610d9fc471 100644 --- a/server/sonar-web/src/main/js/apps/users/components/TokensFormNewToken.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/TokensFormNewToken.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import ClipboardButton from 'sonar-ui-common/components/controls/ClipboardButton'; +import { ClipboardButton } from 'sonar-ui-common/components/controls/clipboard'; import { Alert } from 'sonar-ui-common/components/ui/Alert'; import { translateWithParameters } from 'sonar-ui-common/helpers/l10n'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx index 8e6d57513c5..75db58070d6 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx @@ -21,6 +21,7 @@ import { stringify } from 'querystring'; import * as React from 'react'; import { Link } from 'react-router'; import { ButtonIcon } from 'sonar-ui-common/components/controls/buttons'; +import { ClipboardIconButton } from 'sonar-ui-common/components/controls/clipboard'; import Dropdown from 'sonar-ui-common/components/controls/Dropdown'; import ListIcon from 'sonar-ui-common/components/icons/ListIcon'; import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon'; @@ -142,10 +143,13 @@ export default class SourceViewerHeader extends React.PureComponent<Props, State <div className="component-name-path"> <QualifierIcon qualifier={q} /> <span>{collapsedDirFromPath(path)}</span> <span className="component-name-file">{fileFromPath(path)}</span> + <span className="nudged-up spacer-left"> + <ClipboardIconButton className="button-link link-no-underline" copyValue={path} /> + </span> {this.props.sourceViewerFile.canMarkAsFavorite && (!this.props.branchLike || isMainBranch(this.props.branchLike)) && ( <Favorite - className="component-name-favorite" + className="component-name-favorite spacer-left" component={key} favorite={this.props.sourceViewerFile.fav || false} qualifier={this.props.sourceViewerFile.q} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx index 613df85a998..b7c2199ab81 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx @@ -21,6 +21,7 @@ import * as classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { ButtonIcon } from 'sonar-ui-common/components/controls/buttons'; +import { ClipboardIconButton } from 'sonar-ui-common/components/controls/clipboard'; import ExpandSnippetIcon from 'sonar-ui-common/components/icons/ExpandSnippetIcon'; import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon'; import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner'; @@ -60,7 +61,7 @@ export default function SourceViewerHeaderSlim({ return ( <div className="source-viewer-header-slim display-flex-row display-flex-space-between"> - <div className="display-flex-row flex-1"> + <div className="display-flex-center flex-1"> <div> <a className="link-with-icon" @@ -79,8 +80,13 @@ export default function SourceViewerHeaderSlim({ <QualifierIcon qualifier={q} /> <span>{collapsedDirFromPath(path)}</span> <span className="component-name-file">{fileFromPath(path)}</span> </div> + + <div className="spacer-left"> + <ClipboardIconButton className="button-link link-no-underline" copyValue={path} /> + </div> + {sourceViewerFile.canMarkAsFavorite && (!branchLike || isMainBranch(branchLike)) && ( - <div className="nudged-up"> + <div className="nudged-up spacer-left"> <Favorite className="component-name-favorite" component={key} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeader-test.tsx.snap b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeader-test.tsx.snap index 73167d83070..2c93433fef1 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeader-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeader-test.tsx.snap @@ -41,6 +41,14 @@ exports[`should render correctly for a regular file 1`] = ` > bar.ts </span> + <span + className="nudged-up spacer-left" + > + <ClipboardIconButton + className="button-link link-no-underline" + copyValue="foo/bar.ts" + /> + </span> </div> </div> </div> @@ -153,6 +161,14 @@ exports[`should render correctly for a unit test 1`] = ` > bar.ts </span> + <span + className="nudged-up spacer-left" + > + <ClipboardIconButton + className="button-link link-no-underline" + copyValue="foo/bar.ts" + /> + </span> </div> </div> </div> @@ -283,6 +299,14 @@ exports[`should render correctly if issue details are passed 1`] = ` > bar.ts </span> + <span + className="nudged-up spacer-left" + > + <ClipboardIconButton + className="button-link link-no-underline" + copyValue="foo/bar.ts" + /> + </span> </div> </div> </div> diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeaderSlim-test.tsx.snap b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeaderSlim-test.tsx.snap index c237d08a24c..29201d1a3fd 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeaderSlim-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeaderSlim-test.tsx.snap @@ -5,7 +5,7 @@ exports[`should render correctly 1`] = ` className="source-viewer-header-slim display-flex-row display-flex-space-between" > <div - className="display-flex-row flex-1" + className="display-flex-center flex-1" > <div> <a @@ -37,6 +37,14 @@ exports[`should render correctly 1`] = ` bar.ts </span> </div> + <div + className="spacer-left" + > + <ClipboardIconButton + className="button-link link-no-underline" + copyValue="foo/bar.ts" + /> + </div> </div> <div className="flex-0 big-spacer-left" @@ -81,7 +89,7 @@ exports[`should render correctly for subproject 1`] = ` className="source-viewer-header-slim display-flex-row display-flex-space-between" > <div - className="display-flex-row flex-1" + className="display-flex-center flex-1" > <div> <a @@ -120,6 +128,14 @@ exports[`should render correctly for subproject 1`] = ` bar.ts </span> </div> + <div + className="spacer-left" + > + <ClipboardIconButton + className="button-link link-no-underline" + copyValue="foo/bar.ts" + /> + </div> </div> <div className="flex-0 big-spacer-left" diff --git a/server/sonar-web/src/main/js/components/common/CodeSnippet.tsx b/server/sonar-web/src/main/js/components/common/CodeSnippet.tsx index c6b8c04646e..788bc784215 100644 --- a/server/sonar-web/src/main/js/components/common/CodeSnippet.tsx +++ b/server/sonar-web/src/main/js/components/common/CodeSnippet.tsx @@ -19,7 +19,7 @@ */ import * as classNames from 'classnames'; import * as React from 'react'; -import ClipboardButton from 'sonar-ui-common/components/controls/ClipboardButton'; +import { ClipboardButton } from 'sonar-ui-common/components/controls/clipboard'; import './CodeSnippet.css'; interface Props { diff --git a/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/CodeSnippet-test.tsx.snap b/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/CodeSnippet-test.tsx.snap index 57eb740cd03..1b16baeff81 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/CodeSnippet-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/CodeSnippet-test.tsx.snap @@ -16,37 +16,39 @@ bar copyValue="foo bar" > - <Tooltip - overlay="copied_action" - visible={false} - > - <TooltipInner - mouseEnterDelay={0.1} + <ClipboardBase> + <Tooltip overlay="copied_action" visible={false} > - <Button - className="no-select" - data-clipboard-text="foo -bar" - innerRef={[Function]} - onMouseEnter={[Function]} - onMouseLeave={[Function]} + <TooltipInner + mouseEnterDelay={0.1} + overlay="copied_action" + visible={false} > - <button - className="button no-select" + <Button + className="no-select" data-clipboard-text="foo bar" - onClick={[Function]} + innerRef={[Function]} onMouseEnter={[Function]} onMouseLeave={[Function]} - type="button" > - copy - </button> - </Button> - </TooltipInner> - </Tooltip> + <button + className="button no-select" + data-clipboard-text="foo +bar" + onClick={[Function]} + onMouseEnter={[Function]} + onMouseLeave={[Function]} + type="button" + > + copy + </button> + </Button> + </TooltipInner> + </Tooltip> + </ClipboardBase> </ClipboardButton> </div> </CodeSnippet> @@ -89,37 +91,39 @@ exports[`renders correctly with array snippet 1`] = ` copyValue="foo \\\\ bar" > - <Tooltip - overlay="copied_action" - visible={false} - > - <TooltipInner - mouseEnterDelay={0.1} + <ClipboardBase> + <Tooltip overlay="copied_action" visible={false} > - <Button - className="no-select" - data-clipboard-text="foo \\\\ - bar" - innerRef={[Function]} - onMouseEnter={[Function]} - onMouseLeave={[Function]} + <TooltipInner + mouseEnterDelay={0.1} + overlay="copied_action" + visible={false} > - <button - className="button no-select" + <Button + className="no-select" data-clipboard-text="foo \\\\ bar" - onClick={[Function]} + innerRef={[Function]} onMouseEnter={[Function]} onMouseLeave={[Function]} - type="button" > - copy - </button> - </Button> - </TooltipInner> - </Tooltip> + <button + className="button no-select" + data-clipboard-text="foo \\\\ + bar" + onClick={[Function]} + onMouseEnter={[Function]} + onMouseLeave={[Function]} + type="button" + > + copy + </button> + </Button> + </TooltipInner> + </Tooltip> + </ClipboardBase> </ClipboardButton> </div> </CodeSnippet> @@ -144,35 +148,37 @@ exports[`renders correctly with array snippet 2`] = ` <ClipboardButton copyValue="foo bar" > - <Tooltip - overlay="copied_action" - visible={false} - > - <TooltipInner - mouseEnterDelay={0.1} + <ClipboardBase> + <Tooltip overlay="copied_action" visible={false} > - <Button - className="no-select" - data-clipboard-text="foo bar" - innerRef={[Function]} - onMouseEnter={[Function]} - onMouseLeave={[Function]} + <TooltipInner + mouseEnterDelay={0.1} + overlay="copied_action" + visible={false} > - <button - className="button no-select" + <Button + className="no-select" data-clipboard-text="foo bar" - onClick={[Function]} + innerRef={[Function]} onMouseEnter={[Function]} onMouseLeave={[Function]} - type="button" > - copy - </button> - </Button> - </TooltipInner> - </Tooltip> + <button + className="button no-select" + data-clipboard-text="foo bar" + onClick={[Function]} + onMouseEnter={[Function]} + onMouseLeave={[Function]} + type="button" + > + copy + </button> + </Button> + </TooltipInner> + </Tooltip> + </ClipboardBase> </ClipboardButton> </div> </CodeSnippet> diff --git a/server/sonar-web/yarn.lock b/server/sonar-web/yarn.lock index 7c3ded45533..696150231b1 100644 --- a/server/sonar-web/yarn.lock +++ b/server/sonar-web/yarn.lock @@ -9268,10 +9268,10 @@ sockjs@0.3.19: faye-websocket "^0.10.0" uuid "^3.0.1" -sonar-ui-common@0.0.18: - version "0.0.18" - resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-0.0.18.tgz#93b71859f83b85cc23e8c201bb9ed0420fcbb479" - integrity sha1-k7cYWfg7hcwj6MIBu57QQg/LtHk= +sonar-ui-common@0.0.19: + version "0.0.19" + resolved "https://repox.jfrog.io/repox/api/npm/npm/sonar-ui-common/-/sonar-ui-common-0.0.19.tgz#c3d97ca6c40c491000eabf86fdf3629dc4c6bfcb" + integrity sha1-w9l8psQMSRAA6r+G/fNincTGv8s= dependencies: "@types/react-select" "1.2.6" classnames "2.2.6" diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index eb22b0b96af..b0dbd4c6f49 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -233,6 +233,7 @@ bulleted_point=Bulleted point clear=Clear clear_all_filters=Clear All Filters coding_rules=Rules +copy_to_clipboard=Click to copy to Clipboard copied_action=Copied to Clipboard created_by=Created by default_error_message=The request cannot be processed. Try again later. |