feat(ui): change flag activity method
This commit is contained in:
parent
037366e9e7
commit
2e363da443
3 changed files with 16 additions and 1 deletions
|
|
@ -12,7 +12,7 @@ function FFlagItem({ flag }: { flag: FeatureFlag }) {
|
|||
const toggleActivity = () => {
|
||||
const newValue = !flag.isActive
|
||||
flag.setIsEnabled(newValue);
|
||||
featureFlagsStore.updateFlag(flag, true).then(() => {
|
||||
featureFlagsStore.updateFlagStatus(flag.featureFlagId, newValue).then(() => {
|
||||
toast.success('Feature flag updated.');
|
||||
})
|
||||
.catch(() => {
|
||||
|
|
|
|||
|
|
@ -125,6 +125,14 @@ export default class FeatureFlagsStore {
|
|||
}
|
||||
};
|
||||
|
||||
updateFlagStatus = async (flagId: number, isActive: boolean) => {
|
||||
try {
|
||||
await this.client.updateStatus(flagId, isActive);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
updateFlag = async (flag?: FeatureFlag, skipLoader?: boolean) => {
|
||||
const usedFlag = flag || this.currentFflag;
|
||||
if (usedFlag) {
|
||||
|
|
|
|||
|
|
@ -68,6 +68,13 @@ export default class FFlagsService extends BaseService {
|
|||
.then((j) => j.data || {});
|
||||
}
|
||||
|
||||
updateStatus(flagId: number, isActive: boolean): Promise<void> {
|
||||
return this.client
|
||||
.post(`/feature-flags/${flagId}/status`, { isActive })
|
||||
.then((r) => r.json())
|
||||
.then((j) => j.data || {});
|
||||
}
|
||||
|
||||
deleteFlag(id: number): Promise<void> {
|
||||
return this.client
|
||||
.delete(`/feature-flags/${id}`)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue