From f51011c87bcd75c4d0fe97249dcab145b8da8dc5 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Mon, 7 Dec 2020 14:34:16 +0100 Subject: SONAR-12872 Rename Markdown Syntax to Formatting Syntax --- .../src/main/js/app/components/FormattingHelp.tsx | 145 ++++++++++++++ .../src/main/js/app/components/MarkdownHelp.tsx | 147 -------------- .../components/__tests__/FormattingHelp-test.tsx | 27 +++ .../__snapshots__/FormattingHelp-test.tsx.snap | 220 +++++++++++++++++++++ server/sonar-web/src/main/js/app/index.ts | 2 +- .../src/main/js/app/utils/startReactApp.tsx | 5 +- .../components/CustomRuleFormModal.tsx | 4 +- .../components/RuleDetailsDescription.tsx | 4 +- .../CustomRuleFormModal-test.tsx.snap | 4 +- .../js/apps/issues/components/BulkChangeModal.tsx | 4 +- .../components/HotspotCommentPopup.tsx | 4 +- .../components/HotspotReviewHistoryAndComments.tsx | 4 +- .../HotspotCommentPopup-test.tsx.snap | 2 +- .../HotspotReviewHistoryAndComments-test.tsx.snap | 2 +- .../components/status/StatusSelectionRenderer.tsx | 4 +- .../StatusSelectionRenderer-test.tsx.snap | 4 +- .../main/js/components/common/FormattingTips.tsx | 56 ++++++ .../src/main/js/components/common/MarkdownTips.tsx | 52 ----- .../common/__tests__/FormattingTips-test.tsx | 55 ++++++ .../common/__tests__/MarkdownTips-test.tsx | 26 --- .../__snapshots__/FormattingTips-test.tsx.snap | 36 ++++ .../__snapshots__/MarkdownTips-test.tsx.snap | 36 ---- .../js/components/issue/popups/CommentPopup.tsx | 4 +- .../__snapshots__/CommentPopup-test.tsx.snap | 4 +- server/sonar-web/src/main/js/helpers/urls.ts | 4 +- 25 files changed, 567 insertions(+), 288 deletions(-) create mode 100644 server/sonar-web/src/main/js/app/components/FormattingHelp.tsx delete mode 100644 server/sonar-web/src/main/js/app/components/MarkdownHelp.tsx create mode 100644 server/sonar-web/src/main/js/app/components/__tests__/FormattingHelp-test.tsx create mode 100644 server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/FormattingHelp-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/components/common/FormattingTips.tsx delete mode 100644 server/sonar-web/src/main/js/components/common/MarkdownTips.tsx create mode 100644 server/sonar-web/src/main/js/components/common/__tests__/FormattingTips-test.tsx delete mode 100644 server/sonar-web/src/main/js/components/common/__tests__/MarkdownTips-test.tsx create mode 100644 server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/FormattingTips-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/MarkdownTips-test.tsx.snap (limited to 'server/sonar-web') diff --git a/server/sonar-web/src/main/js/app/components/FormattingHelp.tsx b/server/sonar-web/src/main/js/app/components/FormattingHelp.tsx new file mode 100644 index 00000000000..a6e29c00405 --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/FormattingHelp.tsx @@ -0,0 +1,145 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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'; + +export default function FormattingHelp() { + return ( +
+

Formatting Syntax

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Write:To display:
*this text is bold* + this text is bold +
https://sonarqube.org + https://sonarqube.org +
[SonarQube™ Home Page](https://www.sonarqube.org) + SonarQube™ Home Page +
+ * first item +
* second item +
+
    +
  • first item
  • +
  • second item
  • +
+
+ 1. first item +
+ 1. second item +
+
    +
  1. first item
  2. +
  3. second item
  4. +
+
+ = Heading Level 1
+ == Heading Level 2
+ === Heading Level 3
+ ==== Heading Level 4
+ ===== Heading Level 5
+ ====== Heading Level 6
+
+

Heading Level 1

+

Heading Level 2

+

Heading Level 3

+

Heading Level 4

+
Heading Level 5
+
Heading Level 6
+
``Lists#newArrayList()`` + Lists#newArrayList() +
+ `` +
+ {'// code on multiple lines'} +
+ {'public void foo() {'} +
+    + {'// do some logic here'} +
+ {'}'} +
+ `` +
+
+                {'// code on multiple lines\npublic void foo() {\n  // do some logic here\n}'}
+              
+
+ Standard text +
+ > Blockquoted text +
+ > that spans multiple lines +
+
+

Standard text

+
+ Blockquoted text +
+ that spans multiple lines +
+
+
+
+ ); +} diff --git a/server/sonar-web/src/main/js/app/components/MarkdownHelp.tsx b/server/sonar-web/src/main/js/app/components/MarkdownHelp.tsx deleted file mode 100644 index 278d742295c..00000000000 --- a/server/sonar-web/src/main/js/app/components/MarkdownHelp.tsx +++ /dev/null @@ -1,147 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 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'; - -export default function MarkdownHelp() { - return ( -
-

Markdown Syntax

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Write:To display:
*this text is bold* - this text is bold -
http://sonarqube.org - http://sonarqube.org -
[SonarQube™ Home Page](http://www.sonarqube.org) - - SonarQube™ Home Page - -
- * first item -
* second item -
-
    -
  • first item
  • -
  • second item
  • -
-
- 1. first item -
- 1. second item -
-
    -
  1. first item
  2. -
  3. second item
  4. -
-
- = Heading Level 1
- == Heading Level 2
- === Heading Level 3
- ==== Heading Level 4
- ===== Heading Level 5
- ====== Heading Level 6
-
-

Heading Level 1

-

Heading Level 2

-

Heading Level 3

-

Heading Level 4

-
Heading Level 5
-
Heading Level 6
-
``Lists#newArrayList()`` - Lists#newArrayList() -
- `` -
- {'// code on multiple lines'} -
- {'public void foo() {'} -
-    - {'// do some logic here'} -
- {'}'} -
- `` -
-
-                {'// code on multiple lines\npublic void foo() {\n  // do some logic here\n}'}
-              
-
- Standard text -
- > Blockquoted text -
- > that spans multiple lines -
-
-

Standard text

-
- Blockquoted text -
- that spans multiple lines -
-
-
-
- ); -} diff --git a/server/sonar-web/src/main/js/app/components/__tests__/FormattingHelp-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/FormattingHelp-test.tsx new file mode 100644 index 00000000000..e5cd6729a2c --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/__tests__/FormattingHelp-test.tsx @@ -0,0 +1,27 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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 { shallow } from 'enzyme'; +import * as React from 'react'; +import FormattingHelp from '../FormattingHelp'; + +it('should render correctly', () => { + expect(shallow()).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/FormattingHelp-test.tsx.snap b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/FormattingHelp-test.tsx.snap new file mode 100644 index 00000000000..031748e845e --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/FormattingHelp-test.tsx.snap @@ -0,0 +1,220 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +
+

+ Formatting Syntax +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Write: + + To display: +
+ *this text is bold* + + + this text is bold + +
+ https://sonarqube.org + + + https://sonarqube.org + +
+ [SonarQube™ Home Page](https://www.sonarqube.org) + + + SonarQube™ Home Page + +
+ * first item +
+ * second item +
+
    +
  • + first item +
  • +
  • + second item +
  • +
+
+ 1. first item +
+ 1. second item +
+
    +
  1. + first item +
  2. +
  3. + second item +
  4. +
+
+ = Heading Level 1 +
+ == Heading Level 2 +
+ === Heading Level 3 +
+ ==== Heading Level 4 +
+ ===== Heading Level 5 +
+ ====== Heading Level 6 +
+
+

+ Heading Level 1 +

+

+ Heading Level 2 +

+

+ Heading Level 3 +

+

+ Heading Level 4 +

+
+ Heading Level 5 +
+
+ Heading Level 6 +
+
+ \`\`Lists#newArrayList()\`\` + + + Lists#newArrayList() + +
+ \`\` +
+ // code on multiple lines +
+ public void foo() { +
+    + // do some logic here +
+ } +
+ \`\` +
+
+            // code on multiple lines
+public void foo() {
+  // do some logic here
+}
+          
+
+ Standard text +
+ > Blockquoted text +
+ > that spans multiple lines +
+
+

+ Standard text +

+
+ Blockquoted text +
+ that spans multiple lines +
+
+
+
+`; diff --git a/server/sonar-web/src/main/js/app/index.ts b/server/sonar-web/src/main/js/app/index.ts index 715df897aa9..f58c8112b97 100644 --- a/server/sonar-web/src/main/js/app/index.ts +++ b/server/sonar-web/src/main/js/app/index.ts @@ -112,6 +112,6 @@ function isMainApp() { !pathname.startsWith(`${getBaseUrl()}/sessions`) && !pathname.startsWith(`${getBaseUrl()}/maintenance`) && !pathname.startsWith(`${getBaseUrl()}/setup`) && - !pathname.startsWith(`${getBaseUrl()}/markdown/help`) + !pathname.startsWith(`${getBaseUrl()}/formatting/help`) ); } diff --git a/server/sonar-web/src/main/js/app/utils/startReactApp.tsx b/server/sonar-web/src/main/js/app/utils/startReactApp.tsx index d48e43e2a9f..b667bf0d37e 100644 --- a/server/sonar-web/src/main/js/app/utils/startReactApp.tsx +++ b/server/sonar-web/src/main/js/app/utils/startReactApp.tsx @@ -142,6 +142,7 @@ function renderRedirects() { + ); } @@ -263,8 +264,8 @@ export default function startReactApp( {renderRedirects()} import('../components/MarkdownHelp'))} + path="formatting/help" + component={lazyLoadComponent(() => import('../components/FormattingHelp'))} /> import('../components/SimpleContainer'))}> diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx index d0d03f69fca..d66c9ba70cc 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx @@ -27,7 +27,7 @@ import { csvEscape } from 'sonar-ui-common/helpers/csv'; import { translate } from 'sonar-ui-common/helpers/l10n'; import { latinize } from 'sonar-ui-common/helpers/strings'; import { createRule, updateRule } from '../../../api/rules'; -import MarkdownTips from '../../../components/common/MarkdownTips'; +import FormattingTips from '../../../components/common/FormattingTips'; import SeverityHelper from '../../../components/shared/SeverityHelper'; import TypeHelper from '../../../components/shared/TypeHelper'; import { RULE_STATUSES, RULE_TYPES, SEVERITIES } from '../../../helpers/constants'; @@ -204,7 +204,7 @@ export default class CustomRuleFormModal extends React.PureComponent - + ); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx index be9fdf20515..54195c680a5 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx @@ -22,7 +22,7 @@ import * as React from 'react'; import { Button, ResetButtonLink } from 'sonar-ui-common/components/controls/buttons'; import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; import { updateRule } from '../../../api/rules'; -import MarkdownTips from '../../../components/common/MarkdownTips'; +import FormattingTips from '../../../components/common/FormattingTips'; import RemoveExtendedDescriptionModal from './RemoveExtendedDescriptionModal'; interface Props { @@ -176,7 +176,7 @@ export default class RuleDetailsDescription extends React.PureComponent} - + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/CustomRuleFormModal-test.tsx.snap b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/CustomRuleFormModal-test.tsx.snap index f244d57d3dd..e51c719d869 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/CustomRuleFormModal-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/CustomRuleFormModal-test.tsx.snap @@ -211,7 +211,7 @@ exports[`should handle re-activation 1`] = ` rows={5} value="" /> - @@ -442,7 +442,7 @@ exports[`should render correctly 1`] = ` rows={5} value="" /> - diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx index cf8413ca5a9..a5c94c651a6 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx @@ -32,7 +32,7 @@ import { Alert } from 'sonar-ui-common/components/ui/Alert'; import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; import { bulkChangeIssues, searchIssueTags } from '../../../api/issues'; import throwGlobalError from '../../../app/utils/throwGlobalError'; -import MarkdownTips from '../../../components/common/MarkdownTips'; +import FormattingTips from '../../../components/common/FormattingTips'; import SeverityHelper from '../../../components/shared/SeverityHelper'; import Avatar from '../../../components/ui/Avatar'; import { isLoggedIn, isUserActive } from '../../../helpers/users'; @@ -476,7 +476,7 @@ export default class BulkChangeModal extends React.PureComponent { rows={4} value={this.state.comment || ''} /> - + ); }; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotCommentPopup.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotCommentPopup.tsx index bcde5657fb5..18c2e74f0fc 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotCommentPopup.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotCommentPopup.tsx @@ -20,7 +20,7 @@ import * as React from 'react'; import { Button, ResetButtonLink } from 'sonar-ui-common/components/controls/buttons'; import { translate } from 'sonar-ui-common/helpers/l10n'; -import MarkdownTips from '../../../components/common/MarkdownTips'; +import FormattingTips from '../../../components/common/FormattingTips'; export interface HotspotCommentPopupProps { markdownComment: string; @@ -43,7 +43,7 @@ export default function HotspotCommentPopup(props: HotspotCommentPopupProps) {
- +
-
diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusSelectionRenderer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusSelectionRenderer.tsx index 16487044701..fc07fe3a1e7 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusSelectionRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusSelectionRenderer.tsx @@ -22,7 +22,7 @@ import * as React from 'react'; import { SubmitButton } from 'sonar-ui-common/components/controls/buttons'; import Radio from 'sonar-ui-common/components/controls/Radio'; import { translate } from 'sonar-ui-common/helpers/l10n'; -import MarkdownTips from '../../../../components/common/MarkdownTips'; +import FormattingTips from '../../../../components/common/FormattingTips'; import { HotspotStatusOption } from '../../../../types/security-hotspots'; import StatusDescription from './StatusDescription'; @@ -76,7 +76,7 @@ export default function StatusSelectionRenderer(props: StatusSelectionRendererPr rows={4} value={comment} /> - +
diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusSelectionRenderer-test.tsx.snap b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusSelectionRenderer-test.tsx.snap index 482dd86bb54..c5a7d5aed2d 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusSelectionRenderer-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusSelectionRenderer-test.tsx.snap @@ -53,7 +53,7 @@ exports[`should render correctly 1`] = ` rows={4} value="TEST-COMMENT" /> - +
@@ -121,7 +121,7 @@ exports[`should render correctly: loading 1`] = ` rows={4} value="TEST-COMMENT" /> - +
diff --git a/server/sonar-web/src/main/js/components/common/FormattingTips.tsx b/server/sonar-web/src/main/js/components/common/FormattingTips.tsx new file mode 100644 index 00000000000..f01ae64b0ad --- /dev/null +++ b/server/sonar-web/src/main/js/components/common/FormattingTips.tsx @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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 classNames from 'classnames'; +import * as React from 'react'; +import { translate } from 'sonar-ui-common/helpers/l10n'; +import { getFormattingHelpUrl } from '../../helpers/urls'; + +interface Props { + className?: string; +} + +export default class FormattingTips extends React.PureComponent { + handleClick(evt: React.SyntheticEvent) { + evt.preventDefault(); + window.open( + getFormattingHelpUrl(), + 'Formatting', + 'height=300,width=600,scrollbars=1,resizable=1' + ); + } + + render() { + return ( +
+ + {translate('formatting.helplink')} + + {':'} + *{translate('bold')}* + + `` + {translate('code')} + `` + + * {translate('bulleted_point')} +
+ ); + } +} diff --git a/server/sonar-web/src/main/js/components/common/MarkdownTips.tsx b/server/sonar-web/src/main/js/components/common/MarkdownTips.tsx deleted file mode 100644 index 52b8e3110b0..00000000000 --- a/server/sonar-web/src/main/js/components/common/MarkdownTips.tsx +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 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 classNames from 'classnames'; -import * as React from 'react'; -import { translate } from 'sonar-ui-common/helpers/l10n'; -import { getMarkdownHelpUrl } from '../../helpers/urls'; - -interface Props { - className?: string; -} - -export default class MarkdownTips extends React.PureComponent { - handleClick(evt: React.SyntheticEvent) { - evt.preventDefault(); - window.open(getMarkdownHelpUrl(), 'Markdown', 'height=300,width=600,scrollbars=1,resizable=1'); - } - - render() { - return ( -
- - {translate('markdown.helplink')} - - {':'} - *{translate('bold')}* - - `` - {translate('code')} - `` - - * {translate('bulleted_point')} -
- ); - } -} diff --git a/server/sonar-web/src/main/js/components/common/__tests__/FormattingTips-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/FormattingTips-test.tsx new file mode 100644 index 00000000000..3dcca255ef8 --- /dev/null +++ b/server/sonar-web/src/main/js/components/common/__tests__/FormattingTips-test.tsx @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 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 { shallow } from 'enzyme'; +import * as React from 'react'; +import { click } from 'sonar-ui-common/helpers/testUtils'; +import FormattingTips from '../FormattingTips'; + +const originalOpen = window.open; + +beforeAll(() => { + Object.defineProperty(window, 'open', { + writable: true, + value: jest.fn() + }); +}); + +afterAll(() => { + Object.defineProperty(window, 'open', { + writable: true, + value: originalOpen + }); +}); + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +it('should correctly open a new window', () => { + const wrapper = shallowRender(); + expect(window.open).not.toBeCalled(); + click(wrapper.find('a')); + expect(window.open).toBeCalled(); +}); + +function shallowRender(props: Partial = {}) { + return shallow(); +} diff --git a/server/sonar-web/src/main/js/components/common/__tests__/MarkdownTips-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/MarkdownTips-test.tsx deleted file mode 100644 index a54a1f52454..00000000000 --- a/server/sonar-web/src/main/js/components/common/__tests__/MarkdownTips-test.tsx +++ /dev/null @@ -1,26 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 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 { shallow } from 'enzyme'; -import * as React from 'react'; -import MarkdownTips from '../MarkdownTips'; - -it('should render the tips', () => { - expect(shallow()).toMatchSnapshot(); -}); diff --git a/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/FormattingTips-test.tsx.snap b/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/FormattingTips-test.tsx.snap new file mode 100644 index 00000000000..422fb77bc9b --- /dev/null +++ b/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/FormattingTips-test.tsx.snap @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +
+ + formatting.helplink + + : + + * + bold + * + + + \`\` + code + \`\` + + + * + bulleted_point + +
+`; diff --git a/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/MarkdownTips-test.tsx.snap b/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/MarkdownTips-test.tsx.snap deleted file mode 100644 index baeceb6aa90..00000000000 --- a/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/MarkdownTips-test.tsx.snap +++ /dev/null @@ -1,36 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render the tips 1`] = ` -
- - markdown.helplink - - : - - * - bold - * - - - \`\` - code - \`\` - - - * - bulleted_point - -
-`; diff --git a/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx index d81d8217e58..0a6a9ba2af2 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx @@ -22,7 +22,7 @@ import { Button, ResetButtonLink } from 'sonar-ui-common/components/controls/but import { DropdownOverlay } from 'sonar-ui-common/components/controls/Dropdown'; import { PopupPlacement } from 'sonar-ui-common/components/ui/popups'; import { translate } from 'sonar-ui-common/helpers/l10n'; -import MarkdownTips from '../../common/MarkdownTips'; +import FormattingTips from '../../common/FormattingTips'; interface Props { comment?: Pick; @@ -98,7 +98,7 @@ export default class CommentPopup extends React.PureComponent {
- +
diff --git a/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/CommentPopup-test.tsx.snap b/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/CommentPopup-test.tsx.snap index d6ad2e18439..9962424c1c3 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/CommentPopup-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/CommentPopup-test.tsx.snap @@ -40,7 +40,7 @@ exports[`should render the comment popup correctly when changing a comment 1`] =
- +
@@ -87,7 +87,7 @@ exports[`should render the comment popup correctly without existing comment 1`]
- +
diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts index 1e45ca3cf47..05864ca8404 100644 --- a/server/sonar-web/src/main/js/helpers/urls.ts +++ b/server/sonar-web/src/main/js/helpers/urls.ts @@ -239,8 +239,8 @@ export function getRuleUrl(rule: string) { return getRulesUrl({ open: rule, rule_key: rule }); } -export function getMarkdownHelpUrl(): string { - return getBaseUrl() + '/markdown/help'; +export function getFormattingHelpUrl(): string { + return getBaseUrl() + '/formatting/help'; } export function getCodeUrl( -- cgit v1.2.3