import { getJSON, RequestData, post, postJSON } from '../helpers/request';
import { TYPE_PROPERTY_SET } from '../apps/settings/constants';
-export function getDefinitions(componentKey: string): Promise<any> {
- const data: RequestData = {};
- if (componentKey) {
- data.component = componentKey;
- }
- return getJSON('/api/settings/list_definitions', data).then(r => r.definitions);
+export function getDefinitions(component: string | null, branch?: string): Promise<any> {
+ return getJSON('/api/settings/list_definitions', { branch, component }).then(r => r.definitions);
}
-export function getValues(keys: string, componentKey: string): Promise<any> {
- const data: RequestData = { keys };
- if (componentKey) {
- data.component = componentKey;
- }
- return getJSON('/api/settings/values', data).then(r => r.settings);
+export function getValues(keys: string, component?: string, branch?: string): Promise<any> {
+ return getJSON('/api/settings/values', { keys, component, branch }).then(r => r.settings);
}
-export function setSettingValue(definition: any, value: any, componentKey: string): Promise<void> {
+export function setSettingValue(
+ definition: any,
+ value: any,
+ component?: string,
+ branch?: string
+): Promise<void> {
const { key } = definition;
- const data: RequestData = { key };
+ const data: RequestData = { key, component, branch };
if (definition.multiValues) {
data.values = value;
data.value = value;
}
- if (componentKey) {
- data.component = componentKey;
- }
-
return post('/api/settings/set', data);
}
-export function resetSettingValue(key: string, componentKey: string): Promise<void> {
- const data: RequestData = { keys: key };
- if (componentKey) {
- data.component = componentKey;
- }
- return post('/api/settings/reset', data);
+export function resetSettingValue(key: string, component?: string, branch?: string): Promise<void> {
+ return post('/api/settings/reset', { keys: key, component, branch });
}
export function sendTestEmail(to: string, subject: string, message: string): Promise<void> {
import * as PropTypes from 'prop-types';
import { Branch, Component, ComponentExtension, ComponentConfiguration } from '../../../types';
import NavBarTabs from '../../../../components/nav/NavBarTabs';
-import { isShortLivingBranch, getBranchName } from '../../../../helpers/branches';
+import {
+ isShortLivingBranch,
+ getBranchName,
+ isLongLivingBranch
+} from '../../../../helpers/branches';
import { translate } from '../../../../helpers/l10n';
const SETTINGS_URLS = [
}
renderAdministration() {
- if (!this.props.branch.isMain) {
+ if (isShortLivingBranch(this.props.branch)) {
return null;
}
}
renderAdministrationLinks() {
- return [
- this.renderSettingsLink(),
- this.renderBranchesLink(),
- this.renderProfilesLink(),
- this.renderQualityGateLink(),
- this.renderCustomMeasuresLink(),
- this.renderLinksLink(),
- this.renderPermissionsLink(),
- this.renderBackgroundTasksLink(),
- this.renderUpdateKeyLink(),
- ...this.renderAdminExtensions(),
- this.renderDeletionLink()
- ];
+ return isLongLivingBranch(this.props.branch)
+ ? [this.renderSettingsLink()]
+ : [
+ this.renderSettingsLink(),
+ this.renderBranchesLink(),
+ this.renderProfilesLink(),
+ this.renderQualityGateLink(),
+ this.renderCustomMeasuresLink(),
+ this.renderLinksLink(),
+ this.renderPermissionsLink(),
+ this.renderBackgroundTasksLink(),
+ this.renderUpdateKeyLink(),
+ ...this.renderAdminExtensions(),
+ this.renderDeletionLink()
+ ];
}
renderSettingsLink() {
return (
<li key="settings">
<Link
- to={{ pathname: '/project/settings', query: { id: this.props.component.key } }}
+ to={{
+ pathname: '/project/settings',
+ query: { branch: getBranchName(this.props.branch), id: this.props.component.key }
+ }}
activeClassName="active">
{translate('project_settings.page')}
</Link>
isMain: false,
mergeBranch: 'master',
name: 'feature',
- status: { bugs: 0, codeSmells: 2, vulnerabilities: 3 },
type: BranchType.SHORT
};
const component = { key: 'foo', qualifier: 'TRK' } as Component;
project_activity.page
</Link>
</li>
+ <li
+ className="dropdown"
+ >
+ <a
+ className="dropdown-toggle is-admin"
+ data-toggle="dropdown"
+ href="#"
+ id="component-navigation-admin"
+ >
+ layout.settings
+
+ <i
+ className="icon-dropdown"
+ />
+ </a>
+ <ul
+ className="dropdown-menu"
+ >
+ <li>
+ <Link
+ activeClassName="active"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/project/settings",
+ "query": Object {
+ "branch": "release",
+ "id": "foo",
+ },
+ }
+ }
+ >
+ project_settings.page
+ </Link>
+ </li>
+ </ul>
+ </li>
</NavBarTabs>
`;
Object {
"pathname": "/project/settings",
"query": Object {
+ "branch": undefined,
"id": "foo",
},
}
Object {
"pathname": "/project/settings",
"query": Object {
+ "branch": undefined,
"id": "foo",
},
}
import CategoryDefinitionsList from './CategoryDefinitionsList';
import AllCategoriesList from './AllCategoriesList';
import WildcardsHelp from './WildcardsHelp';
+import { getBranchName } from '../../../helpers/branches';
import { translate } from '../../../helpers/l10n';
import '../styles.css';
/*::
type Props = {
+ branch?: {},
component?: { key: string },
defaultCategory: ?string,
- fetchSettings(componentKey: ?string): Promise<*>,
+ fetchSettings(componentKey: ?string, branch?: string): Promise<*>,
location: { query: {} }
};
*/
html.classList.add('dashboard-page');
}
const componentKey = this.props.component ? this.props.component.key : null;
- this.props.fetchSettings(componentKey).then(() => this.setState({ loaded: true }));
+ const branch = this.props.branch && getBranchName(this.props.branch);
+ this.props.fetchSettings(componentKey, branch).then(() => this.setState({ loaded: true }));
}
componentDidUpdate(prevProps /*: Props*/) {
if (prevProps.component !== this.props.component) {
const componentKey = this.props.component ? this.props.component.key : null;
- this.props.fetchSettings(componentKey);
+ const branch = this.props.branch && getBranchName(this.props.branch);
+ this.props.fetchSettings(componentKey, branch);
}
}
const { query } = this.props.location;
const selectedCategory = query.category || this.props.defaultCategory;
+ const branchName = this.props.branch && getBranchName(this.props.branch);
+
return (
<div id="settings-page" className="page page-limited">
<Helmet title={translate('settings.page')} />
- <PageHeader component={this.props.component} />
+ <PageHeader branch={branchName} component={this.props.component} />
<div className="side-tabs-layout settings-layout">
<div className="side-tabs-side">
<AllCategoriesList
+ branch={branchName}
component={this.props.component}
selectedCategory={selectedCategory}
defaultCategory={this.props.defaultCategory}
/>
</div>
<div className="side-tabs-main">
- <CategoryDefinitionsList component={this.props.component} category={selectedCategory} />
+ <CategoryDefinitionsList
+ branch={branchName}
+ component={this.props.component}
+ category={selectedCategory}
+ />
{selectedCategory === 'exclusions' && <WildcardsHelp />}
</div>
/*::
type Props = {
+ branch?: string,
categories: Category[],
component?: { key: string },
defaultCategory: string,
/*:: rops: Props; */
renderLink(category /*: Category */) {
- const query = {};
+ const query /*: Object */ = { branch: this.props.branch };
if (category.key !== this.props.defaultCategory) {
query.category = category.key.toLowerCase();
/*:: timeout: number; */
static propTypes = {
+ branch: PropTypes.string,
component: PropTypes.object,
setting: PropTypes.object.isRequired,
changedValue: PropTypes.any,
const componentKey = this.props.component ? this.props.component.key : null;
const { definition } = this.props.setting;
return this.props
- .resetValue(definition.key, componentKey)
+ .resetValue(definition.key, componentKey, this.props.branch)
.then(() => {
this.safeSetState({ success: true });
this.timeout = setTimeout(() => this.safeSetState({ success: false }), 3000);
this.safeSetState({ success: false });
const componentKey = this.props.component ? this.props.component.key : null;
this.props
- .saveValue(this.props.setting.definition.key, componentKey)
+ .saveValue(this.props.setting.definition.key, componentKey, this.props.branch)
.then(() => {
this.safeSetState({ success: true });
this.timeout = setTimeout(() => this.safeSetState({ success: false }), 3000);
export default class DefinitionsList extends React.PureComponent {
static propTypes = {
+ branch: PropTypes.object,
component: PropTypes.object,
settings: PropTypes.array.isRequired
};
<ul className="settings-definitions-list">
{this.props.settings.map(setting =>
<li key={setting.definition.key}>
- <Definition component={this.props.component} setting={setting} />
+ <Definition
+ branch={this.props.branch}
+ component={this.props.component}
+ setting={setting}
+ />
</li>
)}
</ul>
export default class PageHeader extends React.PureComponent {
static propTypes = {
+ branch: PropTypes.string,
component: PropTypes.object
};
const description =
this.props.component != null
- ? translate('project_settings.page.description')
+ ? this.props.branch
+ ? translate('branch_settings.page.description')
+ : translate('project_settings.page.')
: translate('settings.page.description');
return (
export default class SubCategoryDefinitionsList extends React.PureComponent {
static propTypes = {
+ branch: PropTypes.string,
component: PropTypes.object,
settings: PropTypes.array.isRequired
};
dangerouslySetInnerHTML={{ __html: subCategory.description }}
/>}
<DefinitionsList
- settings={bySubCategory[subCategory.key]}
+ branch={this.props.branch}
component={this.props.component}
+ settings={bySubCategory[subCategory.key]}
/>
{this.renderEmailForm(subCategory.key)}
</li>
import { translate } from '../../../helpers/l10n';
import { getSettingsAppDefinition, getSettingsAppChangedValue } from '../../../store/rootReducer';
-export const fetchSettings = componentKey => dispatch => {
- return getDefinitions(componentKey)
+export const fetchSettings = (componentKey, branch) => dispatch => {
+ return getDefinitions(componentKey, branch)
.then(definitions => {
const withoutLicenses = definitions.filter(definition => definition.type !== 'LICENSE');
dispatch(receiveDefinitions(withoutLicenses));
const keys = withoutLicenses.map(definition => definition.key).join();
- return getValues(keys, componentKey);
+ return getValues(keys, componentKey, branch);
})
.then(settings => {
dispatch(receiveValues(settings, componentKey));
.catch(e => parseError(e).then(message => dispatch(addGlobalErrorMessage(message))));
};
-export const saveValue = (key, componentKey) => (dispatch, getState) => {
+export const saveValue = (key, componentKey, branch) => (dispatch, getState) => {
dispatch(startLoading(key));
const state = getState();
return Promise.reject();
}
- return setSettingValue(definition, value, componentKey)
- .then(() => getValues(key, componentKey))
+ return setSettingValue(definition, value, componentKey, branch)
+ .then(() => getValues(key, componentKey, branch))
.then(values => {
dispatch(receiveValues(values, componentKey));
dispatch(cancelChange(key));
});
};
-export const resetValue = (key, componentKey) => dispatch => {
+export const resetValue = (key, componentKey, branch) => dispatch => {
dispatch(startLoading(key));
- return resetSettingValue(key, componentKey)
- .then(() => getValues(key, componentKey))
+ return resetSettingValue(key, componentKey, branch)
+ .then(() => getValues(key, componentKey, branch))
.then(values => {
if (values.length > 0) {
dispatch(receiveValues(values, componentKey));
roles.page.description_portfolio=Grant and revoke portfolio-level permissions. Permissions can be granted to groups or individual users.
project_settings.page=General Settings
project_settings.page.description=Edit project settings.
+branch_settings.page.description=Edit branch settings.
project_links.page=Links
project_links.page.description=Edit some links associated with this project.
project_history.page=History