From f13b0df538063f349e4fd50009cc826cda276252 Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Mon, 18 Nov 2019 16:01:07 +0100 Subject: [PATCH] SONAR-12661 Rename configuration setting "sonar.dbcleaner.daysBeforeDeletingInactiveShortLivingBranches" --- .../components/LifetimeInformation.tsx | 6 ++--- .../__tests__/LifetimeInformation-test.tsx | 7 ++++-- .../sonar-web/src/main/js/types/settings.ts | 23 +++++++++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 server/sonar-web/src/main/js/types/settings.ts diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformation.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformation.tsx index c9b7890f323..8274ae39961 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformation.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformation.tsx @@ -22,6 +22,7 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { getValues } from '../../../api/settings'; import { getAppState, Store } from '../../../store/rootReducer'; +import { SettingsKey } from '../../../types/settings'; import LifetimeInformationRenderer from './LifetimeInformationRenderer'; interface Props { @@ -33,9 +34,6 @@ interface State { loading: boolean; } -export const BRANCH_PULL_REQUEST_LIFETIME_SETTING = - 'sonar.dbcleaner.daysBeforeDeletingInactiveShortLivingBranches'; - export class LifetimeInformation extends React.PureComponent { mounted = false; state: State = { loading: true }; @@ -50,7 +48,7 @@ export class LifetimeInformation extends React.PureComponent { } fetchBranchAndPullRequestLifetimeSetting() { - getValues({ keys: BRANCH_PULL_REQUEST_LIFETIME_SETTING }).then( + getValues({ keys: SettingsKey.DaysBeforeDeletingInactiveBranchesAndPRs }).then( settings => { if (this.mounted) { this.setState({ diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformation-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformation-test.tsx index ffc75629492..5072571c5b5 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformation-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformation-test.tsx @@ -22,7 +22,8 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; import { getValues } from '../../../../api/settings'; -import { BRANCH_PULL_REQUEST_LIFETIME_SETTING, LifetimeInformation } from '../LifetimeInformation'; +import { SettingsKey } from '../../../../types/settings'; +import { LifetimeInformation } from '../LifetimeInformation'; jest.mock('../../../../api/settings', () => ({ getValues: jest.fn().mockResolvedValue([{ value: '45' }]) @@ -34,7 +35,9 @@ it('should render correctly', async () => { await waitAndUpdate(wrapper); - expect(getValues).toHaveBeenCalledWith({ keys: BRANCH_PULL_REQUEST_LIFETIME_SETTING }); + expect(getValues).toHaveBeenCalledWith({ + keys: SettingsKey.DaysBeforeDeletingInactiveBranchesAndPRs + }); expect(wrapper).toMatchSnapshot('after_fetching_data'); }); diff --git a/server/sonar-web/src/main/js/types/settings.ts b/server/sonar-web/src/main/js/types/settings.ts new file mode 100644 index 00000000000..61344d4bfa5 --- /dev/null +++ b/server/sonar-web/src/main/js/types/settings.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export const enum SettingsKey { + DaysBeforeDeletingInactiveBranchesAndPRs = 'sonar.dbcleaner.daysBeforeDeletingInactiveBranchesAndPRs' +} -- 2.39.5