Type flag endpoints
This commit is contained in:
parent
417286b16d
commit
1b6e6ed7db
|
@ -10,14 +10,11 @@ export function createFlagsStore() {
|
|||
set(flags)
|
||||
},
|
||||
updateFlag: async (flag, value) => {
|
||||
await API.updateFlag({
|
||||
flag,
|
||||
value,
|
||||
})
|
||||
await API.updateFlag(flag, value)
|
||||
await actions.fetch()
|
||||
},
|
||||
toggleUiFeature: async feature => {
|
||||
await API.toggleUiFeature({ value: feature })
|
||||
await API.toggleUiFeature(feature)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
export const buildFlagEndpoints = API => ({
|
||||
import { Flags, SetFlagRequest } from "@budibase/types"
|
||||
import { BaseAPIClient } from "./types"
|
||||
|
||||
export interface FlagEndpoints {
|
||||
getFlags: () => Promise<Flags>
|
||||
updateFlag: (flag: string, value: any) => Promise<{ message: string }>
|
||||
toggleUiFeature: (value: string) => Promise<{ message: string }>
|
||||
}
|
||||
|
||||
export const buildFlagEndpoints = (API: BaseAPIClient): FlagEndpoints => ({
|
||||
/**
|
||||
* Gets the current user flags object.
|
||||
*/
|
||||
|
@ -13,8 +22,8 @@ export const buildFlagEndpoints = API => ({
|
|||
* @param flag the flag to update
|
||||
* @param value the value to set the flag to
|
||||
*/
|
||||
updateFlag: async ({ flag, value }) => {
|
||||
return await API.post({
|
||||
updateFlag: async (flag, value) => {
|
||||
return await API.post<SetFlagRequest, { message: string }>({
|
||||
url: "/api/users/flags",
|
||||
body: {
|
||||
flag,
|
||||
|
@ -26,7 +35,7 @@ export const buildFlagEndpoints = API => ({
|
|||
* Allows us to experimentally toggle a beta UI feature through a cookie.
|
||||
* @param value the feature to toggle
|
||||
*/
|
||||
toggleUiFeature: async ({ value }) => {
|
||||
toggleUiFeature: async value => {
|
||||
return await API.post({
|
||||
url: `/api/beta/${value}`,
|
||||
})
|
|
@ -10,6 +10,7 @@ import { ConfigEndpoints } from "./configs"
|
|||
import { DatasourceEndpoints } from "./datasources"
|
||||
import { EnvironmentVariableEndpoints } from "./environmentVariables"
|
||||
import { EventEndpoints } from "./events"
|
||||
import { FlagEndpoints } from "./flags"
|
||||
|
||||
export enum HTTPMethod {
|
||||
POST = "POST",
|
||||
|
@ -81,4 +82,5 @@ export type APIClient = BaseAPIClient &
|
|||
ConfigEndpoints &
|
||||
DatasourceEndpoints &
|
||||
EnvironmentVariableEndpoints &
|
||||
EventEndpoints
|
||||
EventEndpoints &
|
||||
FlagEndpoints
|
||||
|
|
Loading…
Reference in New Issue