});
};
- showHandler = ({ id }: { id: string }) => {
+ showHandler = ({ name }: { name: string }) => {
const qualityGate = omit(
- this.list.find((q) => q.id === id),
+ this.list.find((q) => q.name === name),
'isDefault'
);
return this.reply({ ...qualityGate, actions: this.computeActions(qualityGate) });
return getJSON('/api/qualitygates/list').catch(throwGlobalError);
}
-export function fetchQualityGate(data: { id: number | string }): Promise<QualityGate> {
+export function fetchQualityGate(data: { name: string }): Promise<QualityGate> {
return getJSON('/api/qualitygates/show', data).catch(throwGlobalError);
}
import { getQualityGateUrl } from '../../../../../../helpers/urls';
interface Props {
- qualityGate: { isDefault?: boolean; key: string; name: string };
+ qualityGate: { isDefault?: boolean; name: string };
}
export default function MetaQualityGate({ qualityGate }: Props) {
{qualityGate.isDefault && (
<span className="note spacer-right">({translate('default')})</span>
)}
- <Link to={getQualityGateUrl(qualityGate.key)}>{qualityGate.name}</Link>
+ <Link to={getQualityGateUrl(qualityGate.name)}>{qualityGate.name}</Link>
</li>
</ul>
</>
{component.qualityGate && (
<div className="big-spacer-bottom">
- <Link className="button" to={getQualityGateUrl(component.qualityGate.key)}>
+ <Link className="button" to={getQualityGateUrl(component.qualityGate.name)}>
{translate('overview.quality_gate.conditions.cayc.review')}
</Link>
</div>
const path =
component.qualityGate === undefined
? getQualityGatesUrl()
- : getQualityGateUrl(component.qualityGate.key);
+ : getQualityGateUrl(component.qualityGate.name);
return (
<div
"link": <ForwardRef(Link)
to={
{
- "pathname": "/quality_gates/show/30",
+ "pathname": "/quality_gates/show/Sonar%20way",
}
}
>
"link": <ForwardRef(Link)
to={
{
- "pathname": "/quality_gates/show/30",
+ "pathname": "/quality_gates/show/Sonar%20way",
}
}
>
const { qualitygates } = await fetchQualityGates();
return Promise.all(
qualitygates.map(async (qg) => {
- const detailedQp = await fetchQualityGate({ id: qg.id }).catch(() => qg);
+ const detailedQp = await fetchQualityGate({ name: qg.name }).catch(() => qg);
return { ...detailedQp, ...qg };
})
);
import { Alert } from '../../components/ui/Alert';
import { translate } from '../../helpers/l10n';
import { isDiffMetric } from '../../helpers/measures';
+import { getQualityGateUrl } from '../../helpers/urls';
import { QualityGate } from '../../types/types';
import BuiltInQualityGateBadge from '../quality-gates/components/BuiltInQualityGateBadge';
import { USE_SYSTEM_DEFAULT } from './constants';
defaultMessage={translate('project_quality_gate.no_condition')}
values={{
link: (
- <Link to={{ pathname: `/quality_gates/show/${props.data.value}` }}>
+ <Link to={getQualityGateUrl(props.data.label)}>
{translate('project_quality_gate.no_condition.link')}
</Link>
),
defaultMessage={translate('project_quality_gate.no_condition_on_new_code')}
values={{
link: (
- <Link to={{ pathname: `/quality_gates/show/${selectedQualityGate.id}` }}>
+ <Link to={getQualityGateUrl(selectedQualityGate.name)}>
{translate('project_quality_gate.no_condition.link')}
</Link>
),
"name": "qualitygate",
},
{
+ "conditions": [
+ {
+ "error": "10",
+ "id": "1",
+ "metric": "coverage",
+ "op": "LT",
+ },
+ {
+ "error": "10",
+ "id": "1",
+ "metric": "new_bugs",
+ "op": "LT",
+ },
+ ],
"id": "gate4",
"name": "qualitygate",
},
"link": <ForwardRef(Link)
to={
{
- "pathname": "/quality_gates/show/3",
+ "pathname": "/quality_gates/show/qualitygate",
}
}
>
import ListHeader from './ListHeader';
interface Props {
- id?: string;
+ name?: string;
navigate: NavigateFunction;
}
}
componentDidUpdate(prevProps: Props) {
- if (prevProps.id !== undefined && this.props.id === undefined) {
+ if (prevProps.name !== undefined && this.props.name === undefined) {
this.openDefault(this.state.qualityGates);
}
}
if (this.mounted) {
this.setState({ canCreate: actions.create, loading: false, qualityGates });
- if (!this.props.id) {
+ if (!this.props.name) {
this.openDefault(qualityGates);
}
}
openDefault(qualityGates: QualityGate[]) {
const defaultQualityGate = qualityGates.find((gate) => Boolean(gate.isDefault))!;
- this.props.navigate(getQualityGateUrl(String(defaultQualityGate.id)), { replace: true });
+ this.props.navigate(getQualityGateUrl(defaultQualityGate.name), { replace: true });
}
handleSetDefault = (qualityGate: QualityGate) => {
};
render() {
- const { id } = this.props;
+ const { name } = this.props;
const { canCreate, qualityGates } = this.state;
const defaultTitle = translate('quality_gates.page');
refreshQualityGates={this.fetchQualityGates}
/>
<DeferredSpinner loading={this.state.loading}>
- <List qualityGates={qualityGates} currentQualityGate={id} />
+ <List qualityGates={qualityGates} currentQualityGate={name} />
</DeferredSpinner>
</div>
</div>
)}
</ScreenPositionHelper>
- {id !== undefined && (
+ {name !== undefined && (
<Details
- id={id}
+ qualityGateName={name}
onSetDefault={this.handleSetDefault}
qualityGates={this.state.qualityGates}
refreshQualityGates={this.fetchQualityGates}
const params = useParams();
const navigate = useNavigate();
- return <App id={params['id']} navigate={navigate} />;
+ return <App name={params['name']} navigate={navigate} />;
}
return copyQualityGate({ sourceName: qualityGate.name, name }).then((newQualityGate) => {
this.props.onCopy();
- this.props.router.push(getQualityGateUrl(String(newQualityGate.id)));
+ this.props.router.push(getQualityGateUrl(newQualityGate.name));
});
};
await this.props.onCreate();
- this.props.router.push(getQualityGateUrl(String(qualityGate.id)));
+ this.props.router.push(getQualityGateUrl(qualityGate.name));
}
};
import DetailsHeader from './DetailsHeader';
interface Props {
- id: string;
+ qualityGateName: string;
onSetDefault: (qualityGate: QualityGate) => void;
qualityGates: QualityGate[];
refreshQualityGates: () => Promise<void>;
}
componentDidUpdate(prevProps: Props) {
- if (prevProps.id !== this.props.id) {
+ if (prevProps.qualityGateName !== this.props.qualityGateName) {
this.fetchDetails();
}
}
}
fetchDetails = () => {
- const { id } = this.props;
+ const { qualityGateName } = this.props;
this.setState({ loading: true });
- return fetchQualityGate({ id }).then(
+ return fetchQualityGate({ name: qualityGateName }).then(
(qualityGate) => {
if (this.mounted) {
this.setState({ loading: false, qualityGate, updatedConditionId: undefined });
modal={({ onClose }) => (
<RenameQualityGateForm
onClose={onClose}
- onRename={this.handleActionRefresh}
+ onRename={this.props.refreshList}
qualityGate={qualityGate}
/>
)}
{qualityGates.map((qualityGate) => (
<NavLink
className="list-group-item display-flex-center"
- aria-current={currentQualityGate === qualityGate.id && 'page'}
+ aria-current={currentQualityGate === qualityGate.name && 'page'}
data-id={qualityGate.id}
key={qualityGate.id}
- to={getQualityGateUrl(String(qualityGate.id))}
+ to={getQualityGateUrl(qualityGate.name)}
>
<span className="flex-1 text-ellipsis" title={qualityGate.name}>
{qualityGate.name}
import * as React from 'react';
import { renameQualityGate } from '../../../api/quality-gates';
import ConfirmModal from '../../../components/controls/ConfirmModal';
+import { withRouter, WithRouterProps } from '../../../components/hoc/withRouter';
import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker';
import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation';
import { translate } from '../../../helpers/l10n';
+import { getQualityGateUrl } from '../../../helpers/urls';
import { QualityGate } from '../../../types/types';
-interface Props {
+interface Props extends WithRouterProps {
onClose: () => void;
onRename: () => Promise<void>;
qualityGate: QualityGate;
name: string;
}
-export default class RenameQualityGateForm extends React.PureComponent<Props, State> {
+class RenameQualityGateForm extends React.PureComponent<Props, State> {
constructor(props: Props) {
super(props);
this.state = { name: props.qualityGate.name };
};
handleRename = () => {
- const { qualityGate } = this.props;
+ const { qualityGate, router } = this.props;
const { name } = this.state;
- return renameQualityGate({ currentName: qualityGate.name, name }).then(() =>
- this.props.onRename()
- );
+ return renameQualityGate({ currentName: qualityGate.name, name }).then(() => {
+ this.props.onRename();
+ router.push(getQualityGateUrl(name));
+ });
};
render() {
);
}
}
+
+export default withRouter(RenameQualityGateForm);
const routes = () => (
<Route path="quality_gates">
<Route index={true} element={<App />} />
- <Route path="show/:id" element={<App />} />
+ <Route path="show/:name" element={<App />} />
</Route>
);
return getProfilePath(name, language);
}
-export function getQualityGateUrl(key: string): To {
+export function getQualityGateUrl(name: string): To {
return {
- pathname: '/quality_gates/show/' + encodeURIComponent(key),
+ pathname: '/quality_gates/show/' + encodeURIComponent(name),
};
}