From 91fe807305e89ecd9df3b6f4f221540fd451659e Mon Sep 17 00:00:00 2001 From: Grégoire Aubert Date: Thu, 8 Feb 2018 17:43:32 +0100 Subject: SONAR-10347 Create a CodeSnippet component and use it in project badges and onboarding tutorial --- .../main/js/apps/overview/badges/BadgeSnippet.tsx | 34 ------- .../main/js/apps/overview/badges/BadgesModal.tsx | 4 +- .../__snapshots__/BadgesModal-test.tsx.snap | 3 +- .../src/main/js/apps/overview/badges/styles.css | 35 ------- .../apps/tutorials/onboarding/commands/ClangGCC.js | 6 +- .../apps/tutorials/onboarding/commands/Command.js | 53 ---------- .../apps/tutorials/onboarding/commands/DotNet.js | 8 +- .../tutorials/onboarding/commands/JavaGradle.js | 6 +- .../tutorials/onboarding/commands/JavaMaven.js | 4 +- .../js/apps/tutorials/onboarding/commands/Msvc.js | 8 +- .../js/apps/tutorials/onboarding/commands/Other.js | 4 +- .../onboarding/commands/__tests__/Command-test.js | 27 ----- .../__tests__/__snapshots__/ClangGCC-test.js.snap | 30 +++--- .../__tests__/__snapshots__/Command-test.js.snap | 39 -------- .../__tests__/__snapshots__/DotNet-test.js.snap | 32 +++--- .../__snapshots__/JavaGradle-test.js.snap | 16 +-- .../__tests__/__snapshots__/JavaMaven-test.js.snap | 8 +- .../__tests__/__snapshots__/Msvc-test.js.snap | 32 +++--- .../__tests__/__snapshots__/Other-test.js.snap | 18 ++-- .../main/js/apps/tutorials/onboarding/styles.css | 42 -------- .../src/main/js/components/common/CodeSnippet.css | 59 +++++++++++ .../src/main/js/components/common/CodeSnippet.tsx | 47 +++++++++ .../common/__tests__/CodeSnippet-test.tsx | 32 ++++++ .../__snapshots__/CodeSnippet-test.tsx.snap | 111 +++++++++++++++++++++ 24 files changed, 339 insertions(+), 319 deletions(-) delete mode 100644 server/sonar-web/src/main/js/apps/overview/badges/BadgeSnippet.tsx delete mode 100644 server/sonar-web/src/main/js/apps/tutorials/onboarding/commands/Command.js delete mode 100644 server/sonar-web/src/main/js/apps/tutorials/onboarding/commands/__tests__/Command-test.js delete mode 100644 server/sonar-web/src/main/js/apps/tutorials/onboarding/commands/__tests__/__snapshots__/Command-test.js.snap create mode 100644 server/sonar-web/src/main/js/components/common/CodeSnippet.css create mode 100644 server/sonar-web/src/main/js/components/common/CodeSnippet.tsx create mode 100644 server/sonar-web/src/main/js/components/common/__tests__/CodeSnippet-test.tsx create mode 100644 server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/CodeSnippet-test.tsx.snap diff --git a/server/sonar-web/src/main/js/apps/overview/badges/BadgeSnippet.tsx b/server/sonar-web/src/main/js/apps/overview/badges/BadgeSnippet.tsx deleted file mode 100644 index 5deaf71cbbd..00000000000 --- a/server/sonar-web/src/main/js/apps/overview/badges/BadgeSnippet.tsx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import * as React from 'react'; -import ClipboardButton from '../../../components/controls/ClipboardButton'; - -interface Props { - snippet: string; -} - -export default function BadgeSnippet({ snippet }: Props) { - return ( -
-
{snippet}
- -
- ); -} diff --git a/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx b/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx index fc98e4eb71a..3592c4daea3 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx @@ -19,10 +19,10 @@ */ import * as React from 'react'; import BadgeButton from './BadgeButton'; -import BadgeSnippet from './BadgeSnippet'; import BadgeParams from './BadgeParams'; import { BadgeType, BadgeOptions, getBadgeUrl } from './utils'; import { Metric } from '../../../app/types'; +import CodeSnippet from '../../../components/common/CodeSnippet'; import Modal from '../../../components/controls/Modal'; import { translate } from '../../../helpers/l10n'; import './styles.css'; @@ -101,7 +101,7 @@ export default class BadgesModal extends React.PureComponent { type={selectedType} updateOptions={this.handleUpdateOptions} /> - +