From 1b2ae497dcc8e926906ec09bcecee9088fe44119 Mon Sep 17 00:00:00 2001 From: Siegfried Ehret Date: Thu, 25 Jul 2019 11:47:28 +0200 Subject: [PATCH] SONAR-12199 Add Copy button to file header and update ClipboardButton usage --- server/sonar-vsts/package.json | 2 +- server/sonar-vsts/yarn.lock | 8 +- server/sonar-web/package.json | 2 +- .../src/main/js/app/styles/init/misc.css | 4 - .../main/js/apps/overview/meta/MetaKey.tsx | 2 +- .../overview/meta/MetaOrganizationKey.tsx | 2 +- .../settings/encryption/EncryptionForm.tsx | 2 +- .../encryption/GenerateSecretKeyForm.tsx | 2 +- .../js/apps/system/components/PageHeader.tsx | 8 +- .../__snapshots__/PageHeader-test.tsx.snap | 5 +- .../users/components/TokensFormNewToken.tsx | 2 +- .../SourceViewer/SourceViewerHeader.tsx | 6 +- .../SourceViewer/SourceViewerHeaderSlim.tsx | 10 +- .../SourceViewerHeader-test.tsx.snap | 24 ++++ .../SourceViewerHeaderSlim-test.tsx.snap | 20 ++- .../main/js/components/common/CodeSnippet.tsx | 2 +- .../__snapshots__/CodeSnippet-test.tsx.snap | 136 +++++++++--------- server/sonar-web/yarn.lock | 8 +- .../resources/org/sonar/l10n/core.properties | 1 + 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')} + )} 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 + `; 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 {collapsedDirFromPath(path)} {fileFromPath(path)} + + + {this.props.sourceViewerFile.canMarkAsFavorite && (!this.props.branchLike || isMainBranch(this.props.branchLike)) && ( -
+ @@ -153,6 +161,14 @@ exports[`should render correctly for a unit test 1`] = ` > bar.ts + + +
@@ -283,6 +299,14 @@ exports[`should render correctly if issue details are passed 1`] = ` > bar.ts + + + 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" >
+
+ +
- - + - - - - + + + + +
@@ -89,37 +91,39 @@ exports[`renders correctly with array snippet 1`] = ` copyValue="foo \\\\ bar" > - - + - - - - + + + + +
@@ -144,35 +148,37 @@ exports[`renders correctly with array snippet 2`] = ` - - + - - - - + + + + + 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. -- 2.39.5