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 {
loading: boolean;
}
-export const BRANCH_PULL_REQUEST_LIFETIME_SETTING =
- 'sonar.dbcleaner.daysBeforeDeletingInactiveShortLivingBranches';
-
export class LifetimeInformation extends React.PureComponent<Props, State> {
mounted = false;
state: State = { loading: true };
}
fetchBranchAndPullRequestLifetimeSetting() {
- getValues({ keys: BRANCH_PULL_REQUEST_LIFETIME_SETTING }).then(
+ getValues({ keys: SettingsKey.DaysBeforeDeletingInactiveBranchesAndPRs }).then(
settings => {
if (this.mounted) {
this.setState({
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' }])
await waitAndUpdate(wrapper);
- expect(getValues).toHaveBeenCalledWith({ keys: BRANCH_PULL_REQUEST_LIFETIME_SETTING });
+ expect(getValues).toHaveBeenCalledWith({
+ keys: SettingsKey.DaysBeforeDeletingInactiveBranchesAndPRs
+ });
expect(wrapper).toMatchSnapshot('after_fetching_data');
});
--- /dev/null
+/*
+ * 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'
+}