Browse Source

SONAR-14047 Remove delete button on app console.

tags/8.6.0.39681
Mathieu Suen 3 years ago
parent
commit
412aeb529f

+ 1
- 17
server/sonar-web/src/main/js/apps/application-console/ApplicationConsoleApp.tsx View File

@@ -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}

+ 1
- 19
server/sonar-web/src/main/js/apps/application-console/ApplicationConsoleAppRenderer.tsx View File

@@ -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">

+ 0
- 12
server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleApp-test.tsx View File

@@ -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>(

+ 1
- 2
server/sonar-web/src/main/js/apps/application-console/__tests__/ApplicationConsoleRender-test.tsx View File

@@ -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()}

+ 1
- 19
server/sonar-web/src/main/js/apps/application-console/__tests__/__snapshots__/ApplicationConsoleRender-test.tsx.snap View File

@@ -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"

Loading…
Cancel
Save