mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
Suggest change - update status and get per project (#2266)
Set change status
This commit is contained in:
parent
09bf93f9dd
commit
3daef1d00c
@ -7,6 +7,7 @@ import {
|
|||||||
ISuggestChange,
|
ISuggestChange,
|
||||||
ISuggestChangeset,
|
ISuggestChangeset,
|
||||||
SuggestChangeAction,
|
SuggestChangeAction,
|
||||||
|
SuggestChangesetState,
|
||||||
} from '../types/model';
|
} from '../types/model';
|
||||||
|
|
||||||
const T = {
|
const T = {
|
||||||
@ -151,9 +152,11 @@ export class SuggestChangeStore implements ISuggestChangeStore {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getForProject = async (project: string): Promise<ISuggestChangeset[]> => {
|
getForProject = async (project: string): Promise<ISuggestChangeset[]> => {
|
||||||
const rows = await this.buildSuggestChangeSetChangesQuery().where({
|
const rows = await this.buildSuggestChangeSetChangesQuery()
|
||||||
project,
|
.where({
|
||||||
});
|
project,
|
||||||
|
})
|
||||||
|
.whereNot('state', SuggestChangesetState.DRAFT);
|
||||||
return this.mapRows(rows);
|
return this.mapRows(rows);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -163,7 +166,7 @@ export class SuggestChangeStore implements ISuggestChangeStore {
|
|||||||
): Promise<ISuggestChangeset[]> => {
|
): Promise<ISuggestChangeset[]> => {
|
||||||
const rows = await this.buildSuggestChangeSetChangesQuery().where({
|
const rows = await this.buildSuggestChangeSetChangesQuery().where({
|
||||||
'changeSet.created_by': userId,
|
'changeSet.created_by': userId,
|
||||||
state: 'Draft',
|
state: SuggestChangesetState.DRAFT,
|
||||||
project: project,
|
project: project,
|
||||||
});
|
});
|
||||||
const changesets = this.mapRows(rows);
|
const changesets = this.mapRows(rows);
|
||||||
@ -250,4 +253,14 @@ export class SuggestChangeStore implements ISuggestChangeStore {
|
|||||||
};
|
};
|
||||||
|
|
||||||
destroy(): void {}
|
destroy(): void {}
|
||||||
|
|
||||||
|
async updateState(
|
||||||
|
id: number,
|
||||||
|
state: SuggestChangesetState,
|
||||||
|
): Promise<ISuggestChangeset> {
|
||||||
|
await this.db(T.SUGGEST_CHANGE_SET)
|
||||||
|
.update('state', state)
|
||||||
|
.where({ id });
|
||||||
|
return this.get(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,13 +385,12 @@ export interface ISuggestChange {
|
|||||||
createdAt?: Date;
|
createdAt?: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SuggestChangesetEvent {
|
export enum SuggestChangesetState {
|
||||||
CREATED = 'CREATED',
|
DRAFT = 'Draft',
|
||||||
UPDATED = 'UPDATED',
|
APPROVED = 'Approved',
|
||||||
SUBMITTED = 'SUBMITTED',
|
IN_REVIEW = 'In review',
|
||||||
APPROVED = 'APPROVED',
|
APPLIED = 'Applied',
|
||||||
REJECTED = 'REJECTED',
|
CANCELLED = 'Cancelled',
|
||||||
CLOSED = 'CLOSED',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SuggestChangeAction {
|
export enum SuggestChangeAction {
|
||||||
@ -401,12 +400,6 @@ export enum SuggestChangeAction {
|
|||||||
DELETE_STRATEGY = 'strategyDelete',
|
DELETE_STRATEGY = 'strategyDelete',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SuggestChangeEvent {
|
|
||||||
UPDATE_ENABLED = 'updateFeatureEnabledEvent',
|
|
||||||
ADD_STRATEGY = 'addStrategyEvent',
|
|
||||||
UPDATE_STRATEGY = 'updateStrategyEvent',
|
|
||||||
DELETE_STRATEGY = 'deleteStrategyEvent',
|
|
||||||
}
|
|
||||||
export interface ISuggestChangeEventData {
|
export interface ISuggestChangeEventData {
|
||||||
feature: string;
|
feature: string;
|
||||||
data: unknown;
|
data: unknown;
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
import { Store } from './store';
|
import { Store } from './store';
|
||||||
import { ISuggestChange, ISuggestChangeset } from '../model';
|
import {
|
||||||
|
ISuggestChange,
|
||||||
|
ISuggestChangeset,
|
||||||
|
SuggestChangesetState,
|
||||||
|
} from '../model';
|
||||||
import { PartialSome } from '../partial';
|
import { PartialSome } from '../partial';
|
||||||
|
|
||||||
export interface ISuggestChangeStore extends Store<ISuggestChangeset, number> {
|
export interface ISuggestChangeStore extends Store<ISuggestChangeset, number> {
|
||||||
@ -19,6 +23,11 @@ export interface ISuggestChangeStore extends Store<ISuggestChangeset, number> {
|
|||||||
|
|
||||||
get(id: number): Promise<ISuggestChangeset>;
|
get(id: number): Promise<ISuggestChangeset>;
|
||||||
|
|
||||||
|
updateState(
|
||||||
|
id: number,
|
||||||
|
state: SuggestChangesetState,
|
||||||
|
): Promise<ISuggestChangeset>;
|
||||||
|
|
||||||
getAll(): Promise<ISuggestChangeset[]>;
|
getAll(): Promise<ISuggestChangeset[]>;
|
||||||
|
|
||||||
getForProject(project: string): Promise<ISuggestChangeset[]>;
|
getForProject(project: string): Promise<ISuggestChangeset[]>;
|
||||||
|
15
src/test/fixtures/fake-suggest-change-store.ts
vendored
15
src/test/fixtures/fake-suggest-change-store.ts
vendored
@ -1,5 +1,9 @@
|
|||||||
import { ISuggestChangeStore } from '../../lib/types/stores/suggest-change-store';
|
import { ISuggestChangeStore } from '../../lib/types/stores/suggest-change-store';
|
||||||
import { ISuggestChange, ISuggestChangeset } from '../../lib/types/model';
|
import {
|
||||||
|
ISuggestChange,
|
||||||
|
ISuggestChangeset,
|
||||||
|
SuggestChangesetState,
|
||||||
|
} from '../../lib/types/model';
|
||||||
import { PartialSome } from '../../lib/types/partial';
|
import { PartialSome } from '../../lib/types/partial';
|
||||||
|
|
||||||
export default class FakeSuggestChangeStore implements ISuggestChangeStore {
|
export default class FakeSuggestChangeStore implements ISuggestChangeStore {
|
||||||
@ -86,4 +90,13 @@ export default class FakeSuggestChangeStore implements ISuggestChangeStore {
|
|||||||
exists(key: number): Promise<boolean> {
|
exists(key: number): Promise<boolean> {
|
||||||
return Promise.resolve(Boolean(key));
|
return Promise.resolve(Boolean(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateState(
|
||||||
|
id: number,
|
||||||
|
state: SuggestChangesetState,
|
||||||
|
): Promise<ISuggestChangeset> {
|
||||||
|
const changeSet = this.suggestChanges.find((s) => s.id === id);
|
||||||
|
changeSet.state = state;
|
||||||
|
return Promise.resolve(undefined);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user