From ab801b91e6f61f587a3e8f059b7c0953814617fa Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 13 Feb 2018 09:19:41 +0100 Subject: [PATCH] rewrite custom measures app in react (#3052) --- server/sonar-web/src/main/js/api/measures.ts | 37 ++- server/sonar-web/src/main/js/app/types.ts | 22 ++ .../apps/custom-measures/components/App.tsx | 159 ++++++++++ .../components/CreateButton.tsx | 73 +++++ .../components/DeleteButton.tsx | 53 ++++ .../custom-measures/components/EditButton.tsx | 79 +++++ .../apps/custom-measures/components/Form.tsx | 209 ++++++++++++++ ...stomMeasuresAppContainer.js => Header.tsx} | 32 ++- .../apps/custom-measures/components/List.tsx | 125 ++++++++ .../components/__tests__/App-test.tsx | 90 ++++++ .../__tests__/CreateButton-test.tsx} | 48 ++-- .../__tests__/DeleteButton-test.tsx} | 38 ++- .../components/__tests__/EditButton-test.tsx | 50 ++++ .../components/__tests__/Form-test.tsx | 68 +++++ .../__tests__/Header-test.tsx} | 22 +- .../components/__tests__/List-test.tsx | 51 ++++ .../__tests__/__snapshots__/App-test.tsx.snap | 173 +++++++++++ .../__snapshots__/CreateButton-test.tsx.snap | 32 +++ .../__snapshots__/DeleteButton-test.tsx.snap | 12 + .../__snapshots__/EditButton-test.tsx.snap | 48 ++++ .../__snapshots__/Form-test.tsx.snap | 219 ++++++++++++++ .../__snapshots__/Header-test.tsx.snap | 31 ++ .../__snapshots__/List-test.tsx.snap | 272 ++++++++++++++++++ .../js/apps/custom-measures/create-view.js | 49 ---- .../js/apps/custom-measures/custom-measure.js | 55 ---- .../apps/custom-measures/custom-measures.js | 66 ----- .../js/apps/custom-measures/delete-view.js | 50 ---- .../main/js/apps/custom-measures/form-view.js | 66 ----- .../src/main/js/apps/custom-measures/init.js | 67 ----- .../js/apps/custom-measures/list-item-view.js | 63 ---- .../main/js/apps/custom-measures/list-view.js | 28 -- .../main/js/apps/custom-measures/metric.js | 55 ---- .../main/js/apps/custom-measures/metrics.js | 56 ---- .../main/js/apps/custom-measures/routes.ts | 4 +- .../templates/custom-measures-delete.hbs | 13 - .../templates/custom-measures-form.hbs | 39 --- .../templates/custom-measures-header.hbs | 7 - .../templates/custom-measures-layout.hbs | 5 - .../templates/custom-measures-list-footer.hbs | 6 - .../templates/custom-measures-list-item.hbs | 49 ---- .../templates/custom-measures-list.hbs | 14 - .../js/apps/custom-measures/update-view.js | 46 --- .../js/apps/custom-metrics/components/App.tsx | 2 +- 43 files changed, 1872 insertions(+), 811 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/App.tsx create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/CreateButton.tsx create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/DeleteButton.tsx create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/EditButton.tsx create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/Form.tsx rename server/sonar-web/src/main/js/apps/custom-measures/components/{CustomMeasuresAppContainer.js => Header.tsx} (52%) create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/List.tsx create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/App-test.tsx rename server/sonar-web/src/main/js/apps/custom-measures/{list-footer-view.js => components/__tests__/CreateButton-test.tsx} (53%) rename server/sonar-web/src/main/js/apps/custom-measures/{header-view.js => components/__tests__/DeleteButton-test.tsx} (55%) create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/EditButton-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/Form-test.tsx rename server/sonar-web/src/main/js/apps/custom-measures/{layout.js => components/__tests__/Header-test.tsx} (60%) create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/List-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/__snapshots__/App-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/__snapshots__/CreateButton-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/__snapshots__/DeleteButton-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/__snapshots__/EditButton-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/__snapshots__/Form-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/__snapshots__/Header-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/custom-measures/components/__tests__/__snapshots__/List-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/create-view.js delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/delete-view.js delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/form-view.js delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/init.js delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/list-item-view.js delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/list-view.js delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/metric.js delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/metrics.js delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-delete.hbs delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-form.hbs delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-header.hbs delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-layout.hbs delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list-footer.hbs delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list-item.hbs delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list.hbs delete mode 100644 server/sonar-web/src/main/js/apps/custom-measures/update-view.js diff --git a/server/sonar-web/src/main/js/api/measures.ts b/server/sonar-web/src/main/js/api/measures.ts index 2f5ae506503..bf6f8712090 100644 --- a/server/sonar-web/src/main/js/api/measures.ts +++ b/server/sonar-web/src/main/js/api/measures.ts @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { getJSON, RequestData } from '../helpers/request'; +import { getJSON, RequestData, postJSON, post } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; import { Measure, MeasurePeriod } from '../helpers/measures'; -import { Metric } from '../app/types'; +import { Metric, CustomMeasure, Paging } from '../app/types'; import { Period } from '../helpers/periods'; export function getMeasures( @@ -66,3 +66,36 @@ export function getMeasuresForProjects( metricKeys: metricKeys.join() }).then(r => r.measures); } + +export function getCustomMeasures(data: { + f?: string; + p?: number; + projectKey: string; + ps?: number; +}): Promise<{ customMeasures: CustomMeasure[]; paging: Paging }> { + return getJSON('/api/custom_measures/search', data).then( + r => + ({ + customMeasures: r.customMeasures, + paging: { pageIndex: r.p, pageSize: r.ps, total: r.total } + } as any), + throwGlobalError + ); +} + +export function createCustomMeasure(data: { + description?: string; + metricKey: string; + projectKey: string; + value: string; +}): Promise { + return postJSON('/api/custom_measures/create', data).catch(throwGlobalError); +} + +export function updateCustomMeasure(data: { description?: string; id: string; value?: string }) { + return post('/api/custom_measures/update', data).catch(throwGlobalError); +} + +export function deleteCustomMeasure(data: { id: string }) { + return post('/api/custom_measures/delete', data).catch(throwGlobalError); +} diff --git a/server/sonar-web/src/main/js/app/types.ts b/server/sonar-web/src/main/js/app/types.ts index 1eb6b2b5350..504e86547be 100644 --- a/server/sonar-web/src/main/js/app/types.ts +++ b/server/sonar-web/src/main/js/app/types.ts @@ -292,3 +292,25 @@ export interface User { scmAccounts?: string[]; tokensCount?: number; } + +export interface CustomMeasure { + createdAt?: string; + description?: string; + id: string; + metric: { + key: string; + name: string; + domain?: string; + type: string; + }; + projectKey: string; + pending?: boolean; + user: { + active?: boolean; + email?: string; + login: string; + name: string; + }; + value: string; + updatedAt?: string; +} diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/App.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/App.tsx new file mode 100644 index 00000000000..10ad59e53d8 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/App.tsx @@ -0,0 +1,159 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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 Helmet from 'react-helmet'; +import Header from './Header'; +import List from './List'; +import { + getCustomMeasures, + createCustomMeasure, + updateCustomMeasure, + deleteCustomMeasure +} from '../../../api/measures'; +import { Paging, CustomMeasure } from '../../../app/types'; +import ListFooter from '../../../components/controls/ListFooter'; +import { translate } from '../../../helpers/l10n'; + +interface Props { + component: { key: string }; +} + +interface State { + loading: boolean; + measures?: CustomMeasure[]; + paging?: Paging; +} + +const PAGE_SIZE = 50; + +export default class App extends React.PureComponent { + mounted: boolean; + state: State = { loading: true }; + + componentDidMount() { + this.mounted = true; + this.fetchMeasures(); + } + + componentWillUnmount() { + this.mounted = false; + } + + fetchMeasures = () => { + this.setState({ loading: true }); + getCustomMeasures({ projectKey: this.props.component.key, ps: PAGE_SIZE }).then( + ({ customMeasures, paging }) => { + if (this.mounted) { + this.setState({ loading: false, measures: customMeasures, paging }); + } + }, + this.stopLoading + ); + }; + + fetchMore = () => { + const { paging } = this.state; + if (paging) { + this.setState({ loading: true }); + getCustomMeasures({ + projectKey: this.props.component.key, + p: paging.pageIndex + 1, + ps: PAGE_SIZE + }).then(({ customMeasures, paging }) => { + if (this.mounted) { + this.setState(({ measures = [] }: State) => ({ + loading: false, + measures: [...measures, ...customMeasures], + paging + })); + } + }, this.stopLoading); + } + }; + + stopLoading = () => { + if (this.mounted) { + this.setState({ loading: false }); + } + }; + + handleCreate = (data: { description: string; metricKey: string; value: string }) => { + return createCustomMeasure({ ...data, projectKey: this.props.component.key }).then(measure => { + if (this.mounted) { + this.setState(({ measures = [], paging }: State) => ({ + measures: [...measures, measure], + paging: paging && { ...paging, total: paging.total + 1 } + })); + } + }); + }; + + handleEdit = (data: { description: string; id: string; value: string }) => { + return updateCustomMeasure(data).then(() => { + if (this.mounted) { + this.setState(({ measures = [] }: State) => ({ + measures: measures.map( + measure => (measure.id === data.id ? { ...measure, ...data } : measure) + ) + })); + } + }); + }; + + handleDelete = (measureId: string) => { + return deleteCustomMeasure({ id: measureId }).then(() => { + if (this.mounted) { + this.setState(({ measures = [], paging }: State) => ({ + measures: measures.filter(measure => measure.id !== measureId), + paging: paging && { ...paging, total: paging.total - 1 } + })); + } + }); + }; + + render() { + const { loading, measures, paging } = this.state; + + return ( + <> + +
+
measure.metric.key)} + /> + {measures && ( + + )} + {measures && + paging && ( + + )} +
+ + ); + } +} diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/CreateButton.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/CreateButton.tsx new file mode 100644 index 00000000000..ed9e536e3f1 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/CreateButton.tsx @@ -0,0 +1,73 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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 Form from './Form'; +import { translate } from '../../../helpers/l10n'; + +interface Props { + onCreate: (data: { description: string; metricKey: string; value: string }) => Promise; + skipMetrics: string[] | undefined; +} + +interface State { + modal: boolean; +} + +export default class CreateButton extends React.PureComponent { + mounted: boolean; + state: State = { modal: false }; + + componentDidMount() { + this.mounted = true; + } + + componentWillUnmount() { + this.mounted = false; + } + + handleClick = () => { + this.setState({ modal: true }); + }; + + handleClose = () => { + if (this.mounted) { + this.setState({ modal: false }); + } + }; + + render() { + return ( + <> + + {this.state.modal && ( +
+ )} + + ); + } +} diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/DeleteButton.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/DeleteButton.tsx new file mode 100644 index 00000000000..f4f2ff15d24 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/DeleteButton.tsx @@ -0,0 +1,53 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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 { CustomMeasure } from '../../../app/types'; +import ConfirmButton from '../../../components/controls/ConfirmButton'; +import { ActionsDropdownItem } from '../../../components/controls/ActionsDropdown'; +import { translate, translateWithParameters } from '../../../helpers/l10n'; + +interface Props { + measure: CustomMeasure; + onDelete: (measureId: string) => Promise; +} + +export default function DeleteButton({ measure, onDelete }: Props) { + return ( + + {({ onClick }) => ( + + {translate('delete')} + + )} + + ); +} diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/EditButton.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/EditButton.tsx new file mode 100644 index 00000000000..ac0bef49808 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/EditButton.tsx @@ -0,0 +1,79 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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 Form from './Form'; +import { CustomMeasure } from '../../../app/types'; +import { translate } from '../../../helpers/l10n'; +import { ActionsDropdownItem } from '../../../components/controls/ActionsDropdown'; + +interface Props { + measure: CustomMeasure; + onEdit: (data: { description: string; id: string; value: string }) => Promise; +} + +interface State { + modal: boolean; +} + +export default class EditButton extends React.PureComponent { + mounted: boolean; + state: State = { modal: false }; + + componentDidMount() { + this.mounted = true; + } + + componentWillUnmount() { + this.mounted = false; + } + + handleClick = () => { + this.setState({ modal: true }); + }; + + handleClose = () => { + if (this.mounted) { + this.setState({ modal: false }); + } + }; + + handleSubmit = (data: { description: string; value: string }) => { + return this.props.onEdit({ id: this.props.measure.id, ...data }); + }; + + render() { + return ( + <> + + {translate('update_verb')} + + {this.state.modal && ( + + )} + + ); + } +} diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/Form.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/Form.tsx new file mode 100644 index 00000000000..97aceef43da --- /dev/null +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/Form.tsx @@ -0,0 +1,209 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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 { getAllMetrics } from '../../../api/metrics'; +import { CustomMeasure, Metric } from '../../../app/types'; +import DeferredSpinner from '../../../components/common/DeferredSpinner'; +import Select from '../../../components/controls/Select'; +import SimpleModal from '../../../components/controls/SimpleModal'; +import { translate } from '../../../helpers/l10n'; + +interface Props { + confirmButtonText: string; + header: string; + measure?: CustomMeasure; + onClose: () => void; + onSubmit: (data: { description: string; metricKey: string; value: string }) => Promise; + skipMetrics?: string[]; +} + +interface State { + description: string; + loading: boolean; + metricKey?: string; + metrics?: Metric[]; + value: string; +} + +export default class Form extends React.PureComponent { + mounted: boolean; + + constructor(props: Props) { + super(props); + this.state = { + description: (props.measure && props.measure.description) || '', + loading: false, + metricKey: props.measure && props.measure.metric.key, + value: (props.measure && props.measure.value) || '' + }; + } + + componentDidMount() { + this.mounted = true; + if (!this.props.measure) { + this.fetchCustomMetrics(); + } + } + + componentWillUnmount() { + this.mounted = false; + } + + handleSubmit = () => { + return this.state.metricKey + ? this.props + .onSubmit({ + description: this.state.description, + metricKey: this.state.metricKey, + value: this.state.value + }) + .then(this.props.onClose) + : Promise.reject(undefined); + }; + + fetchCustomMetrics = () => { + this.setState({ loading: true }); + getAllMetrics({ isCustom: true }).then( + metrics => { + if (this.mounted) { + this.setState({ loading: false, metrics }); + } + }, + () => { + if (this.mounted) { + this.setState({ loading: false }); + } + } + ); + }; + + handleMetricSelect = ({ value }: { value: string }) => { + this.setState({ metricKey: value }); + }; + + handleDescriptionChange = (event: React.ChangeEvent) => { + this.setState({ description: event.currentTarget.value }); + }; + + handleValueChange = (event: React.ChangeEvent) => { + this.setState({ value: event.currentTarget.value }); + }; + + renderMetricSelect = (options: { label: string; value: string }[]) => { + if (!options.length && !this.state.loading) { + return ( +
{translate('custom_measures.all_metrics_taken')}
+ ); + } + return ( +
+ + {this.state.loading ? ( + + ) : ( + +
+
+ + -
- - - diff --git a/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-header.hbs b/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-header.hbs deleted file mode 100644 index 840706f77e2..00000000000 --- a/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-header.hbs +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-layout.hbs b/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-layout.hbs deleted file mode 100644 index 14efdfad1f4..00000000000 --- a/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-layout.hbs +++ /dev/null @@ -1,5 +0,0 @@ -
-
-
- -
diff --git a/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list-footer.hbs b/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list-footer.hbs deleted file mode 100644 index 91d1dbcfee5..00000000000 --- a/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list-footer.hbs +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list-item.hbs b/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list-item.hbs deleted file mode 100644 index 0d40e51c4db..00000000000 --- a/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list-item.hbs +++ /dev/null @@ -1,49 +0,0 @@ - -
- {{metric.name}} - {{#if pending}} - {{t 'custom_measures.pending'}} - {{/if}} -
- {{metric.domain}} - - - - {{formatMeasure value metric.type}} - - - - {{description}} - - - - {{#if updatedAt }} - {{t 'updated_on'}} {{d updatedAt}} - {{else}} - {{#if createdAt }} - {{t 'created_on'}} {{d createdAt}} - {{else}} - {{t 'created'}} - {{/if}} - {{/if}} - {{t 'by_'}} {{user.name}} - - - - - diff --git a/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list.hbs b/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list.hbs deleted file mode 100644 index 97c513248eb..00000000000 --- a/server/sonar-web/src/main/js/apps/custom-measures/templates/custom-measures-list.hbs +++ /dev/null @@ -1,14 +0,0 @@ -
- - - - - - - - - - - -
{{t 'custom_measures.metric'}}{{t 'value'}}{{t 'description'}}{{t 'date'}} 
-
diff --git a/server/sonar-web/src/main/js/apps/custom-measures/update-view.js b/server/sonar-web/src/main/js/apps/custom-measures/update-view.js deleted file mode 100644 index 26716f5d25e..00000000000 --- a/server/sonar-web/src/main/js/apps/custom-measures/update-view.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 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 FormView from './form-view'; - -export default FormView.extend({ - sendRequest() { - const that = this; - this.model.set({ - value: this.$('#create-custom-measure-value').val(), - description: this.$('#create-custom-measure-description').val() - }); - this.disableForm(); - return this.model - .save(null, { - statusCode: { - // do not show global error - 400: null - } - }) - .done(() => { - that.collection.refresh(); - that.destroy(); - }) - .fail(jqXHR => { - that.enableForm(); - that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); - }); - } -}); diff --git a/server/sonar-web/src/main/js/apps/custom-metrics/components/App.tsx b/server/sonar-web/src/main/js/apps/custom-metrics/components/App.tsx index 09dffecab93..a616a996a85 100644 --- a/server/sonar-web/src/main/js/apps/custom-metrics/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/custom-metrics/components/App.tsx @@ -45,7 +45,7 @@ interface State { types?: string[]; } -const PAGE_SIZE = 500; +const PAGE_SIZE = 50; export default class App extends React.PureComponent { mounted: boolean; -- 2.39.5