From 1e58f09d173213658d66c46ff2c2db93fa437e2d Mon Sep 17 00:00:00 2001 From: Revanshu Paliwal Date: Wed, 5 Jul 2023 11:21:57 +0200 Subject: [PATCH] SONAR-19709 Migrating project list header to MIUI --- .../src/components/icons/SortAscendIcon.tsx} | 13 +- .../src/components/icons/SortDescendIcon.tsx} | 16 +- .../src/components/icons/index.ts | 2 + .../src/components/input/FormField.tsx | 6 +- .../src/components/modal/Modal.tsx | 2 +- .../js/app/components/GlobalContainer.tsx | 1 + .../components/GlobalMessagesContainer.tsx | 1 + .../extensions/CreateApplicationForm.tsx | 202 ++++++------ .../__tests__/CreateApplicationForm-test.tsx | 76 ----- .../CreateApplicationForm-test.tsx.snap | 147 --------- .../apps/projects/components/AllProjects.tsx | 31 +- .../components/ApplicationCreation.tsx | 10 +- .../apps/projects/components/PageHeader.tsx | 97 +++--- .../projects/components/PerspectiveSelect.tsx | 42 +-- .../components/ProjectCreationMenu.tsx | 45 ++- .../components/ProjectCreationMenuItem.tsx | 11 +- .../components/ProjectsSortingSelect.tsx | 49 +-- .../__tests__/ApplicationCreation-test.tsx | 100 ------ .../__tests__/CreateApplication-test.tsx | 129 ++++++++ .../components/__tests__/PageHeader-test.tsx | 210 +++++++++--- .../__tests__/PerspectiveSelect-test.tsx | 51 --- .../__tests__/ProjectCreationMenu-test.tsx | 145 --------- .../ProjectCreationMenuItem-test.tsx | 32 -- .../__tests__/ProjectsSortingSelect-test.tsx | 102 ------ .../__snapshots__/AllProjects-test.tsx.snap | 93 +++--- .../ApplicationCreation-test.tsx.snap | 16 - .../__snapshots__/PageHeader-test.tsx.snap | 169 ---------- .../PerspectiveSelect-test.tsx.snap | 57 ---- .../ProjectCreationMenu-test.tsx.snap | 49 --- .../ProjectCreationMenuItem-test.tsx.snap | 38 --- .../ProjectsSortingSelect-test.tsx.snap | 300 ------------------ .../filters/SearchFilterContainer.tsx | 46 --- .../SearchFilterContainer-test.tsx.snap | 14 - .../ui/MandatoryFieldsExplanation.tsx | 8 +- .../MandatoryFieldsExplanation-test.tsx.snap | 43 --- server/sonar-web/tailwind.base.config.js | 1 + 36 files changed, 612 insertions(+), 1742 deletions(-) rename server/sonar-web/{src/main/js/apps/projects/filters/__tests__/SearchFilterContainer-test.tsx => design-system/src/components/icons/SortAscendIcon.tsx} (65%) rename server/sonar-web/{src/main/js/components/ui/__tests__/MandatoryFieldsExplanation-test.tsx => design-system/src/components/icons/SortDescendIcon.tsx} (61%) delete mode 100644 server/sonar-web/src/main/js/app/components/extensions/__tests__/CreateApplicationForm-test.tsx delete mode 100644 server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/CreateApplicationForm-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/ApplicationCreation-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/CreateApplication-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/PerspectiveSelect-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCreationMenu-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCreationMenuItem-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectsSortingSelect-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ApplicationCreation-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PageHeader-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PerspectiveSelect-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCreationMenu-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCreationMenuItem-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectsSortingSelect-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SearchFilterContainer-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/components/ui/__tests__/__snapshots__/MandatoryFieldsExplanation-test.tsx.snap diff --git a/server/sonar-web/src/main/js/apps/projects/filters/__tests__/SearchFilterContainer-test.tsx b/server/sonar-web/design-system/src/components/icons/SortAscendIcon.tsx similarity index 65% rename from server/sonar-web/src/main/js/apps/projects/filters/__tests__/SearchFilterContainer-test.tsx rename to server/sonar-web/design-system/src/components/icons/SortAscendIcon.tsx index 31144b69bc8..11c3d4a5235 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/__tests__/SearchFilterContainer-test.tsx +++ b/server/sonar-web/design-system/src/components/icons/SortAscendIcon.tsx @@ -17,14 +17,7 @@ * 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 SearchFilterContainer from '../SearchFilterContainer'; +import { SortAscIcon } from '@primer/octicons-react'; +import { OcticonHoc } from './Icon'; -it('searches', () => { - const onQueryChange = jest.fn(); - const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); - wrapper.find('SearchBox').prop('onChange')('foo'); - expect(onQueryChange).toHaveBeenCalledWith({ search: 'foo' }); -}); +export const SortAscendIcon = OcticonHoc(SortAscIcon, 'SortAscendIcon'); diff --git a/server/sonar-web/src/main/js/components/ui/__tests__/MandatoryFieldsExplanation-test.tsx b/server/sonar-web/design-system/src/components/icons/SortDescendIcon.tsx similarity index 61% rename from server/sonar-web/src/main/js/components/ui/__tests__/MandatoryFieldsExplanation-test.tsx rename to server/sonar-web/design-system/src/components/icons/SortDescendIcon.tsx index 8c2f733e459..f319d5f4b4a 100644 --- a/server/sonar-web/src/main/js/components/ui/__tests__/MandatoryFieldsExplanation-test.tsx +++ b/server/sonar-web/design-system/src/components/icons/SortDescendIcon.tsx @@ -17,17 +17,7 @@ * 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 MandatoryFieldsExplanation, { - MandatoryFieldsExplanationProps, -} from '../MandatoryFieldsExplanation'; +import { SortDescIcon } from '@primer/octicons-react'; +import { OcticonHoc } from './Icon'; -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ className: 'foo-bar' })).toMatchSnapshot('with className'); -}); - -function shallowRender(props: Partial = {}) { - return shallow(); -} +export const SortDescendIcon = OcticonHoc(SortDescIcon, 'SortDescendIcon'); diff --git a/server/sonar-web/design-system/src/components/icons/index.ts b/server/sonar-web/design-system/src/components/icons/index.ts index 1c00421fac7..858487bffaa 100644 --- a/server/sonar-web/design-system/src/components/icons/index.ts +++ b/server/sonar-web/design-system/src/components/icons/index.ts @@ -69,6 +69,8 @@ export { SeverityCriticalIcon } from './SeverityCriticalIcon'; export { SeverityInfoIcon } from './SeverityInfoIcon'; export { SeverityMajorIcon } from './SeverityMajorIcon'; export { SeverityMinorIcon } from './SeverityMinorIcon'; +export { SortAscendIcon } from './SortAscendIcon'; +export { SortDescendIcon } from './SortDescendIcon'; export { StarIcon } from './StarIcon'; export { StatusConfirmedIcon } from './StatusConfirmedIcon'; export { StatusOpenIcon } from './StatusOpenIcon'; diff --git a/server/sonar-web/design-system/src/components/input/FormField.tsx b/server/sonar-web/design-system/src/components/input/FormField.tsx index 3397bc41381..1f525a01ea7 100644 --- a/server/sonar-web/design-system/src/components/input/FormField.tsx +++ b/server/sonar-web/design-system/src/components/input/FormField.tsx @@ -33,6 +33,7 @@ interface Props { id?: string; label: string | ReactNode; required?: boolean; + requiredAriaLabel?: string; title?: string; } @@ -47,13 +48,16 @@ export function FormField({ htmlFor, title, ariaLabel, + requiredAriaLabel, }: Props) { return ( diff --git a/server/sonar-web/design-system/src/components/modal/Modal.tsx b/server/sonar-web/design-system/src/components/modal/Modal.tsx index 12d52760a33..db54a652555 100644 --- a/server/sonar-web/design-system/src/components/modal/Modal.tsx +++ b/server/sonar-web/design-system/src/components/modal/Modal.tsx @@ -89,7 +89,7 @@ export function Modal({ { @@ -50,6 +54,7 @@ export default class CreateApplicationForm extends React.PureComponent { const { name, description, key, visibility } = this.state; - return createApplication(name, description, key.length > 0 ? key : undefined, visibility).then( - ({ application }) => { + this.setState({ submitting: true }); + return createApplication(name, description, key.length > 0 ? key : undefined, visibility) + .then(({ application }) => { if (this.mounted) { + this.setState({ submitting: false }); this.props.onCreate({ key: application.key, qualifier: ComponentQualifier.Application, }); } - } + }) + .catch(() => { + this.setState({ submitting: false }); + }); + }; + + renderForm = () => { + const { name, description, key, visibility } = this.state; + + return ( +
+ + + + + + + + + + + + + + {[Visibility.Public, Visibility.Private].map((v) => ( + + {translate('visibility', v)} + + ))} + + ); }; render() { - const { name, description, key, visibility } = this.state; + const { submitting } = this.state; const header = translate('qualifiers.create.APP'); const submitDisabled = !this.state.name.length; return ( - - {({ onCloseClick, onFormSubmit, submitting }) => ( -
-
-

{header}

-
- -
- - -
- - -
-
- -