From 7c707a301f8a970f67a0bd34a7f02dace253c579 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Thu, 17 Oct 2019 17:58:46 +0200 Subject: [PATCH] SONAR-12515 UI for azure PR decoration configuration --- .../sonar-web/src/main/js/api/almSettings.ts | 8 + .../AlmDefinitionFormField.tsx | 72 ++++++++ .../AlmPRDecorationFormModal.tsx | 38 +++-- .../AlmPRDecorationFormModalRenderer.tsx | 94 +---------- .../pullRequestDecoration/AzureFormModal.tsx | 54 ++++++ .../pullRequestDecoration/AzureTab.tsx | 89 ++++++++++ .../AzureTabRenderer.tsx | 61 +++++++ .../pullRequestDecoration/AzureTable.tsx | 72 ++++++++ .../pullRequestDecoration/DeleteModal.tsx | 1 + .../pullRequestDecoration/GithubFormModal.tsx | 72 ++++++++ .../pullRequestDecoration/GithubTab.tsx | 70 +++----- .../GithubTabRenderer.tsx | 61 +++++++ .../pullRequestDecoration/GithubTable.tsx | 70 ++++++++ .../PRDecorationTable.tsx | 71 -------- .../PRDecorationTabs.tsx | 47 ++++-- .../PullRequestDecoration.tsx | 38 ++++- .../{TabRenderer.tsx => TabHeader.tsx} | 42 +---- .../__tests__/AlmDefinitionFormField-test.tsx | 57 +++++++ .../AlmPRDecorationFormModal-test.tsx | 13 +- .../AlmPRDecorationFormModalRenderer-test.tsx | 10 +- .../__tests__/AzureFormModal-test.tsx | 38 +++++ .../__tests__/AzureTab-test.tsx | 96 +++++++++++ .../__tests__/AzureTabRenderer-test.tsx | 44 +++++ .../__tests__/AzureTable-test.tsx | 40 +++++ .../__tests__/GithubFormModal-test.tsx | 38 +++++ .../__tests__/GithubTab-test.tsx | 82 +++------- ...er-test.tsx => GithubTabRenderer-test.tsx} | 14 +- ...ionTable-test.tsx => GithubTable-test.tsx} | 9 +- .../__tests__/PRDecorationTabs-test.tsx | 13 +- .../__tests__/PullRequestDecoration-test.tsx | 32 +++- .../__tests__/TabHeader-test.tsx | 32 ++++ .../AlmDefinitionFormField-test.tsx.snap | 87 ++++++++++ .../AlmPRDecorationFormModal-test.tsx.snap | 10 -- ...RDecorationFormModalRenderer-test.tsx.snap | 104 +----------- .../AzureFormModal-test.tsx.snap | 69 ++++++++ .../__snapshots__/AzureTab-test.tsx.snap | 13 ++ .../AzureTabRenderer-test.tsx.snap | 58 +++++++ .../__snapshots__/AzureTable-test.tsx.snap | 79 +++++++++ .../__snapshots__/DeleteModal-test.tsx.snap | 2 + .../GithubFormModal-test.tsx.snap | 141 ++++++++++++++++ .../__snapshots__/GithubTab-test.tsx.snap | 7 +- .../GithubTabRenderer-test.tsx.snap | 60 +++++++ .../__snapshots__/GithubTable-test.tsx.snap | 89 ++++++++++ .../PRDecorationTable-test.tsx.snap | 95 ----------- .../PRDecorationTabs-test.tsx.snap | 146 ++++++++++++++++- .../PullRequestDecoration-test.tsx.snap | 4 + .../__snapshots__/TabHeader-test.tsx.snap | 79 +++++++++ .../__snapshots__/TabRenderer-test.tsx.snap | 154 ------------------ .../PRDecorationBindingRenderer.tsx | 6 +- .../src/main/js/apps/settings/utils.ts | 10 +- .../src/main/js/helpers/testMocks.ts | 10 ++ .../src/main/js/types/alm-settings.d.ts | 11 +- .../resources/org/sonar/l10n/core.properties | 3 + 53 files changed, 1975 insertions(+), 740 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/AlmDefinitionFormField.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/AzureFormModal.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/AzureTab.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/AzureTabRenderer.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/AzureTable.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/GithubFormModal.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/GithubTabRenderer.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/GithubTable.tsx delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/PRDecorationTable.tsx rename server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/{TabRenderer.tsx => TabHeader.tsx} (58%) create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/AlmDefinitionFormField-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/AzureFormModal-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/AzureTab-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/AzureTabRenderer-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/AzureTable-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/GithubFormModal-test.tsx rename server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/{TabRenderer-test.tsx => GithubTabRenderer-test.tsx} (75%) rename server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/{PRDecorationTable-test.tsx => GithubTable-test.tsx} (83%) create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/TabHeader-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/AlmDefinitionFormField-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/AzureFormModal-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/AzureTab-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/AzureTabRenderer-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/AzureTable-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/GithubFormModal-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/GithubTabRenderer-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/GithubTable-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/PRDecorationTable-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/TabHeader-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/TabRenderer-test.tsx.snap diff --git a/server/sonar-web/src/main/js/api/almSettings.ts b/server/sonar-web/src/main/js/api/almSettings.ts index 655394cd658..52cf1b61366 100644 --- a/server/sonar-web/src/main/js/api/almSettings.ts +++ b/server/sonar-web/src/main/js/api/almSettings.ts @@ -38,6 +38,14 @@ export function updateGithubConfiguration(data: T.GithubBindingDefinition & { ne return post('/api/alm_settings/update_github', data).catch(throwGlobalError); } +export function createAzureConfiguration(data: T.AzureBindingDefinition) { + return post('/api/alm_settings/create_azure', data).catch(throwGlobalError); +} + +export function updateAzureConfiguration(data: T.AzureBindingDefinition & { newKey: string }) { + return post('/api/alm_settings/update_azure', data).catch(throwGlobalError); +} + export function deleteConfiguration(key: string) { return post('/api/alm_settings/delete', { key }).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/AlmDefinitionFormField.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/AlmDefinitionFormField.tsx new file mode 100644 index 00000000000..814930d4774 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/AlmDefinitionFormField.tsx @@ -0,0 +1,72 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 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 HelpTooltip from 'sonar-ui-common/components/controls/HelpTooltip'; +import { translate } from 'sonar-ui-common/helpers/l10n'; + +export interface AlmDefinitionFormFieldProps { + autoFocus?: boolean; + formData: B; + help: boolean; + id: string; + isTextArea: boolean; + maxLength: number; + onFieldChange: (id: keyof B, value: string) => void; + propKey: keyof B; +} + +export function AlmDefinitionFormField( + props: AlmDefinitionFormFieldProps +) { + const { autoFocus, formData, help, id, isTextArea, maxLength, onFieldChange, propKey } = props; + + return ( +
+ + {isTextArea ? ( +