From f51011c87bcd75c4d0fe97249dcab145b8da8dc5 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Mon, 7 Dec 2020 14:34:16 +0100 Subject: [PATCH] SONAR-12872 Rename Markdown Syntax to Formatting Syntax --- .../{MarkdownHelp.tsx => FormattingHelp.tsx} | 14 +- .../__tests__/FormattingHelp-test.tsx} | 7 +- .../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 +- .../issues/components/BulkChangeModal.tsx | 4 +- .../components/HotspotCommentPopup.tsx | 4 +- .../HotspotReviewHistoryAndComments.tsx | 4 +- .../HotspotCommentPopup-test.tsx.snap | 2 +- ...spotReviewHistoryAndComments-test.tsx.snap | 2 +- .../status/StatusSelectionRenderer.tsx | 4 +- .../StatusSelectionRenderer-test.tsx.snap | 4 +- .../{MarkdownTips.tsx => FormattingTips.tsx} | 12 +- .../common/__tests__/FormattingTips-test.tsx | 55 +++++ ....tsx.snap => FormattingTips-test.tsx.snap} | 4 +- .../components/issue/popups/CommentPopup.tsx | 4 +- .../__snapshots__/CommentPopup-test.tsx.snap | 4 +- server/sonar-web/src/main/js/helpers/urls.ts | 4 +- .../resources/org/sonar/l10n/core.properties | 2 +- 22 files changed, 324 insertions(+), 45 deletions(-) rename server/sonar-web/src/main/js/app/components/{MarkdownHelp.tsx => FormattingHelp.tsx} (91%) rename server/sonar-web/src/main/js/{components/common/__tests__/MarkdownTips-test.tsx => app/components/__tests__/FormattingHelp-test.tsx} (86%) create mode 100644 server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/FormattingHelp-test.tsx.snap rename server/sonar-web/src/main/js/components/common/{MarkdownTips.tsx => FormattingTips.tsx} (83%) create mode 100644 server/sonar-web/src/main/js/components/common/__tests__/FormattingTips-test.tsx rename server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/{MarkdownTips-test.tsx.snap => FormattingTips-test.tsx.snap} (86%) diff --git a/server/sonar-web/src/main/js/app/components/MarkdownHelp.tsx b/server/sonar-web/src/main/js/app/components/FormattingHelp.tsx similarity index 91% rename from server/sonar-web/src/main/js/app/components/MarkdownHelp.tsx rename to server/sonar-web/src/main/js/app/components/FormattingHelp.tsx index 278d742295c..a6e29c00405 100644 --- a/server/sonar-web/src/main/js/app/components/MarkdownHelp.tsx +++ b/server/sonar-web/src/main/js/app/components/FormattingHelp.tsx @@ -19,10 +19,10 @@ */ import * as React from 'react'; -export default function MarkdownHelp() { +export default function FormattingHelp() { return (
-

Markdown Syntax

+

Formatting Syntax

@@ -38,17 +38,15 @@ export default function MarkdownHelp() { - + - + diff --git a/server/sonar-web/src/main/js/components/common/__tests__/MarkdownTips-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/FormattingHelp-test.tsx similarity index 86% rename from server/sonar-web/src/main/js/components/common/__tests__/MarkdownTips-test.tsx rename to server/sonar-web/src/main/js/app/components/__tests__/FormattingHelp-test.tsx index a54a1f52454..e5cd6729a2c 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/MarkdownTips-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/FormattingHelp-test.tsx @@ -17,10 +17,11 @@ * 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'; +import FormattingHelp from '../FormattingHelp'; -it('should render the tips', () => { - expect(shallow()).toMatchSnapshot(); +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 +

+
http://sonarqube.orghttps://sonarqube.org - http://sonarqube.org + https://sonarqube.org
[SonarQube™ Home Page](http://www.sonarqube.org)[SonarQube™ Home Page](https://www.sonarqube.org) - - SonarQube™ Home Page - + SonarQube™ Home Page
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 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/MarkdownTips.tsx b/server/sonar-web/src/main/js/components/common/FormattingTips.tsx similarity index 83% rename from server/sonar-web/src/main/js/components/common/MarkdownTips.tsx rename to server/sonar-web/src/main/js/components/common/FormattingTips.tsx index 52b8e3110b0..f01ae64b0ad 100644 --- a/server/sonar-web/src/main/js/components/common/MarkdownTips.tsx +++ b/server/sonar-web/src/main/js/components/common/FormattingTips.tsx @@ -20,23 +20,27 @@ import * as classNames from 'classnames'; import * as React from 'react'; import { translate } from 'sonar-ui-common/helpers/l10n'; -import { getMarkdownHelpUrl } from '../../helpers/urls'; +import { getFormattingHelpUrl } from '../../helpers/urls'; interface Props { className?: string; } -export default class MarkdownTips extends React.PureComponent { +export default class FormattingTips extends React.PureComponent { handleClick(evt: React.SyntheticEvent) { evt.preventDefault(); - window.open(getMarkdownHelpUrl(), 'Markdown', 'height=300,width=600,scrollbars=1,resizable=1'); + window.open( + getFormattingHelpUrl(), + 'Formatting', + 'height=300,width=600,scrollbars=1,resizable=1' + ); } render() { return (
- {translate('markdown.helplink')} + {translate('formatting.helplink')} {':'} *{translate('bold')}* 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__/__snapshots__/MarkdownTips-test.tsx.snap b/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/FormattingTips-test.tsx.snap similarity index 86% rename from server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/MarkdownTips-test.tsx.snap rename to server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/FormattingTips-test.tsx.snap index baeceb6aa90..422fb77bc9b 100644 --- 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__/FormattingTips-test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`should render the tips 1`] = ` +exports[`should render correctly 1`] = `
@@ -9,7 +9,7 @@ exports[`should render the tips 1`] = ` href="#" onClick={[Function]} > - markdown.helplink + formatting.helplink : ; @@ -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( 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 3ea97aac1d0..f7e924fe00e 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2527,7 +2527,7 @@ permission_templates.delete_selected=Delete all selected items # HELP # #------------------------------------------------------------------------------ -markdown.helplink=Markdown Help +formatting.helplink=Formatting Help #------------------------------------------------------------------------------ # -- 2.39.5