diff options
author | Mathieu Suen <mathieu.suen@sonarsource.com> | 2020-11-16 11:46:30 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-11-18 20:05:41 +0000 |
commit | 412aeb529f65d310dcbd777a42b2fd0a8814e828 (patch) | |
tree | 6c6b5d62443bc5d782fa4a8da137783cc8d8dbe0 | |
parent | 1842a8550f4e4ec8ddaf163a10d251509f0019bb (diff) | |
download | sonarqube-412aeb529f65d310dcbd777a42b2fd0a8814e828.tar.gz sonarqube-412aeb529f65d310dcbd777a42b2fd0a8814e828.zip |
SONAR-14047 Remove delete button on app console.
5 files changed, 4 insertions, 69 deletions
diff --git a/server/sonar-web/src/main/js/apps/application-console/ApplicationConsoleApp.tsx b/server/sonar-web/src/main/js/apps/application-console/ApplicationConsoleApp.tsx index 4313a936f6e..6a9633246c7 100644 --- a/server/sonar-web/src/main/js/apps/application-console/ApplicationConsoleApp.tsx +++ b/server/sonar-web/src/main/js/apps/application-console/ApplicationConsoleApp.tsx @@ -22,12 +22,7 @@ import { Location } from 'history'; import * as React from 'react'; import { InjectedRouter } from 'react-router'; import { translate } from 'sonar-ui-common/helpers/l10n'; -import { - deleteApplication, - editApplication, - getApplicationDetails, - refreshApplication -} from '../../api/application'; +import { editApplication, getApplicationDetails, refreshApplication } from '../../api/application'; import addGlobalSuccessMessage from '../../app/utils/addGlobalSuccessMessage'; import { Application, ApplicationProject } from '../../types/application'; import ApplicationConsoleAppRenderer from './ApplicationConsoleAppRenderer'; @@ -96,20 +91,10 @@ export default class ApplicationView extends React.PureComponent<Props, State> { } }; - handleDelete = async () => { - if (this.mounted) { - if (this.state.application) { - await deleteApplication(this.state.application.key); - } - this.props.router.replace('/'); - } - }; - handleEdit = async (name: string, description: string) => { if (this.state.application) { await editApplication(this.state.application.key, name, description); } - if (this.mounted) { this.updateApplicationState(() => ({ name, description })); } @@ -141,7 +126,6 @@ export default class ApplicationView extends React.PureComponent<Props, State> { loading={loading} application={application} onAddProject={this.handleAddProject} - onDelete={this.handleDelete} onEdit={this.handleEdit} onRefresh={this.handleRefreshClick} onRemoveProject={this.handleRemoveProject} diff --git a/server/sonar-web/src/main/js/apps/application-console/ApplicationConsoleAppRenderer.tsx b/server/sonar-web/src/main/js/apps/application-console/ApplicationConsoleAppRenderer.tsx index 8da536476cf..2ca99b172fe 100644 --- a/server/sonar-web/src/main/js/apps/application-console/ApplicationConsoleAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/application-console/ApplicationConsoleAppRenderer.tsx @@ -20,8 +20,7 @@ import * as React from 'react'; import { Button } from 'sonar-ui-common/components/controls/buttons'; -import ConfirmButton from 'sonar-ui-common/components/controls/ConfirmButton'; -import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; +import { translate } from 'sonar-ui-common/helpers/l10n'; import { Application, ApplicationProject } from '../../types/application'; import { Branch } from '../../types/branch-like'; import ApplicationBranches from './ApplicationBranches'; @@ -32,7 +31,6 @@ export interface ApplicationConsoleAppRendererProps { loading: boolean; application: Application; onAddProject: (project: ApplicationProject) => void; - onDelete: () => void; onRefresh: () => void; onEdit: (name: string, description: string) => Promise<void>; onRemoveProject: (projectKey: string) => void; @@ -61,22 +59,6 @@ export default function ApplicationConsoleAppRenderer(props: ApplicationConsoleA <Button className="little-spacer-right" onClick={props.onRefresh}> {translate('application_console.recompute')} </Button> - - <ConfirmButton - confirmButtonText={translate('delete')} - isDestructive={true} - modalBody={translateWithParameters( - 'application_console.do_you_want_to_delete', - application.name - )} - modalHeader={translate('application_console.delete_application')} - onConfirm={props.onDelete}> - {({ onClick }) => ( - <Button className="button-red" id="view-details-delete" onClick={onClick}> - {translate('delete')} - </Button> - )} - </ConfirmButton> </div> <header className="boxed-group-header" id="view-details-header"> diff --git a/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleApp-test.tsx b/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleApp-test.tsx index 840da580ef1..8185795bdbc 100644 --- a/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleApp-test.tsx @@ -21,7 +21,6 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; import { - deleteApplication, editApplication, getApplicationDetails, refreshApplication @@ -35,7 +34,6 @@ import ApplicationConsoleApp from '../ApplicationConsoleApp'; jest.mock('../../../api/application', () => ({ getApplicationDetails: jest.fn().mockResolvedValue({}), refreshApplication: jest.fn().mockResolvedValue({}), - deleteApplication: jest.fn(), editApplication: jest.fn().mockResolvedValue({}) })); @@ -123,16 +121,6 @@ it('should handle refreshing', async () => { expect(refreshApplication).toBeCalledWith('foo'); expect(addGlobalSuccessMessage).toBeCalled(); }); -it('should handle deleting', async () => { - const app = mockApplication(); - - (getApplicationDetails as jest.Mock<Promise<Application>>).mockResolvedValueOnce(app); - const wrapper = shallowRender({}); - await waitAndUpdate(wrapper); - wrapper.instance().handleDelete(); - await waitAndUpdate(wrapper); - expect(deleteApplication).toBeCalledWith(app.key); -}); function shallowRender(props: Partial<ApplicationConsoleApp['props']> = {}) { return shallow<ApplicationConsoleApp>( diff --git a/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleRender-test.tsx b/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleRender-test.tsx index 4bb410e28cd..92b80e50ab1 100644 --- a/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleRender-test.tsx +++ b/server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleRender-test.tsx @@ -37,7 +37,7 @@ it('should render correctly', () => { shallowRender({ application: mockApplication({ description: 'Foo bar', key: 'foo' }) }) - ).toMatchSnapshot('can delete and recompute'); + ).toMatchSnapshot('can recompute'); expect(shallowRender({ loading: true })).toMatchSnapshot('is loading'); }); @@ -53,7 +53,6 @@ function shallowRender(props: Partial<ApplicationConsoleAppRendererProps> = {}) application={mockApplication({ key: 'foo' })} loading={false} onAddProject={jest.fn()} - onDelete={jest.fn()} onEdit={jest.fn()} onRefresh={jest.fn()} onRemoveProject={jest.fn()} diff --git a/server/sonar-web/src/main/js/apps/application-console/__tests__/__snapshots__/ApplicationConsoleRender-test.tsx.snap b/server/sonar-web/src/main/js/apps/application-console/__tests__/__snapshots__/ApplicationConsoleRender-test.tsx.snap index a648f4c4758..0ec83aa9f89 100644 --- a/server/sonar-web/src/main/js/apps/application-console/__tests__/__snapshots__/ApplicationConsoleRender-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/application-console/__tests__/__snapshots__/ApplicationConsoleRender-test.tsx.snap @@ -31,7 +31,7 @@ exports[`should handle editing: edit form 1`] = ` /> `; -exports[`should render correctly: can delete and recompute 1`] = ` +exports[`should render correctly: can recompute 1`] = ` <div className="page page-limited" > @@ -55,15 +55,6 @@ exports[`should render correctly: can delete and recompute 1`] = ` > application_console.recompute </Button> - <ConfirmButton - confirmButtonText="delete" - isDestructive={true} - modalBody="application_console.do_you_want_to_delete.Foo" - modalHeader="application_console.delete_application" - onConfirm={[MockFunction]} - > - <Component /> - </ConfirmButton> </div> <header className="boxed-group-header" @@ -180,15 +171,6 @@ exports[`should render correctly: default 1`] = ` > application_console.recompute </Button> - <ConfirmButton - confirmButtonText="delete" - isDestructive={true} - modalBody="application_console.do_you_want_to_delete.Foo" - modalHeader="application_console.delete_application" - onConfirm={[MockFunction]} - > - <Component /> - </ConfirmButton> </div> <header className="boxed-group-header" |