}
export function deleteQualityGate(data: {
- id: number;
+ id: string;
organization?: string;
}): Promise<void | Response> {
return post('/api/qualitygates/destroy', data).catch(throwGlobalError);
}
export function renameQualityGate(data: {
- id: number;
+ id: string;
name: string;
organization?: string;
}): Promise<void | Response> {
}
export function copyQualityGate(data: {
- id: number;
+ id: string;
name: string;
organization?: string;
}): Promise<T.QualityGate> {
}
export function setQualityGateAsDefault(data: {
- id: number;
+ id: string;
organization?: string;
}): Promise<void | Response> {
return post('/api/qualitygates/set_as_default', data).catch(throwGlobalError);
export function createCondition(
data: {
- gateId: number;
+ gateId: string;
organization?: string;
} & T.Omit<T.Condition, 'id'>
): Promise<T.Condition> {
}
export function searchProjects(data: {
- gateId: number;
+ gateId: string;
organization?: string;
page?: number;
pageSize?: number;
}
export function associateGateWithProject(data: {
- gateId: number;
+ gateId: string;
organization?: string;
projectKey: string;
}): Promise<void | Response> {
}
export function dissociateGateWithProject(data: {
- gateId: number;
+ gateId: string;
organization?: string;
projectKey: string;
}): Promise<void | Response> {
);
}
- handleChangeGate = (oldId?: number, newId?: number) => {
+ handleChangeGate = (oldId?: string, newId?: string) => {
const { allGates } = this.state;
if ((!oldId && !newId) || !allGates) {
return Promise.resolve();
interface Props {
allGates: T.QualityGate[];
gate?: T.QualityGate;
- onChange: (oldGate?: number, newGate?: number) => Promise<void>;
+ onChange: (oldGate?: string, newGate?: string) => Promise<void>;
}
interface State {
const isSet = gate == null && option.value != null;
const isUnset = gate != null && option.value == null;
- const isChanged = gate != null && gate.id !== Number(option.value);
+ const isChanged = gate != null && gate.id !== option.value;
const hasChanged = isSet || isUnset || isChanged;
if (hasChanged) {
this.setState({ loading: true });
- this.props
- .onChange(gate && gate.id, Number(option.value))
- .then(this.stopLoading, this.stopLoading);
+ this.props.onChange(gate && gate.id, option.value).then(this.stopLoading, this.stopLoading);
}
};
import Form from '../Form';
it('renders', () => {
- const foo = randomGate(1);
- const allGates = [foo, randomGate(2)];
+ const foo = randomGate('1');
+ const allGates = [foo, randomGate('2')];
expect(shallow(<Form allGates={allGates} gate={foo} onChange={jest.fn()} />)).toMatchSnapshot();
});
it('changes quality gate', () => {
- const allGates = [randomGate(1), randomGate(2)];
+ const allGates = [randomGate('1'), randomGate('2')];
const onChange = jest.fn(() => Promise.resolve());
const wrapper = shallow(<Form allGates={allGates} onChange={onChange} />);
- wrapper.find('Select').prop<Function>('onChange')({ value: 2 });
- expect(onChange).lastCalledWith(undefined, 2);
+ wrapper.find('Select').prop<Function>('onChange')({ value: '2' });
+ expect(onChange).lastCalledWith(undefined, '2');
- wrapper.setProps({ gate: randomGate(1) });
- wrapper.find('Select').prop<Function>('onChange')({ value: 2 });
- expect(onChange).lastCalledWith(1, 2);
+ wrapper.setProps({ gate: randomGate('1') });
+ wrapper.find('Select').prop<Function>('onChange')({ value: '2' });
+ expect(onChange).lastCalledWith('1', '2');
});
-function randomGate(id: number) {
+function randomGate(id: string) {
return {
id,
name: `name-${id}`
const refreshItem = jest.fn();
const refreshList = jest.fn();
- const qualityGate = mockQualityGate({ id: 1, actions: { setAsDefault: true } });
+ const qualityGate = mockQualityGate({ id: 'one', actions: { setAsDefault: true } });
const wrapper = shallowRender({ onSetDefault, qualityGate, refreshItem, refreshList });
click(wrapper.find('Button#quality-gate-toggle-default'));
- expect(setQualityGateAsDefault).toBeCalledWith({ id: 1 });
+ expect(setQualityGateAsDefault).toBeCalledWith({ id: 'one' });
expect(onSetDefault).toBeCalled();
await waitAndUpdate(wrapper);
expect(refreshItem).toBeCalled();
onClose={[Function]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onCopy={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSetDefault={[Function]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[Function]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
key="1"
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
"rename": true,
"setAsDefault": true,
},
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
<Link
activeClassName="active"
className="list-group-item display-flex-center"
- data-id={1}
+ data-id="1"
key="1"
onlyActiveOnIndex={false}
style={Object {}}
<Link
activeClassName="active"
className="list-group-item display-flex-center"
- data-id={1}
+ data-id="1"
key="1"
onlyActiveOnIndex={false}
style={Object {}}
<Link
activeClassName="active"
className="list-group-item display-flex-center"
- data-id={1}
+ data-id="1"
key="1"
onlyActiveOnIndex={false}
style={Object {}}
export function mockQualityGate(overrides: Partial<T.QualityGate> = {}): T.QualityGate {
return {
- id: 1,
+ id: '1',
name: 'qualitygate',
...overrides
};
setAsDefault?: boolean;
};
conditions?: Condition[];
- id: number;
+ id: string;
isBuiltIn?: boolean;
isDefault?: boolean;
name: string;