-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Import export environment flags (#3161)
Co-authored-by: Matthew Elwell <[email protected]>
- Loading branch information
1 parent
d516b4d
commit 7b8c8dc
Showing
44 changed files
with
1,936 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,4 +494,5 @@ export default { | |
'#AAC200', | ||
'#DE3163', | ||
], | ||
untaggedTag: { color: '#dedede', label: 'Untagged' }, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { Res } from 'common/types/responses' | ||
import { Req } from 'common/types/requests' | ||
import { service } from 'common/service' | ||
|
||
export const featureExportService = service | ||
.enhanceEndpoints({ addTagTypes: ['FeatureExport'] }) | ||
.injectEndpoints({ | ||
endpoints: (builder) => ({ | ||
createFeatureExport: builder.mutation< | ||
Res['featureExport'], | ||
Req['createFeatureExport'] | ||
>({ | ||
invalidatesTags: [{ id: 'LIST', type: 'FeatureExport' }], | ||
query: (query: Req['createFeatureExport']) => ({ | ||
body: query, | ||
method: 'POST', | ||
url: `features/create-feature-export/`, | ||
}), | ||
}), | ||
getFeatureExport: builder.query< | ||
Res['featureExport'], | ||
Req['getFeatureExport'] | ||
>({ | ||
providesTags: (res) => [{ id: res?.id, type: 'FeatureExport' }], | ||
query: (query: Req['getFeatureExport']) => ({ | ||
url: `features/download-feature-export/${query.id}/`, | ||
}), | ||
}), | ||
getFeatureExports: builder.query< | ||
Res['featureExports'], | ||
Req['getFeatureExports'] | ||
>({ | ||
providesTags: [{ id: 'LIST', type: 'FeatureExport' }], | ||
query: (query) => ({ | ||
url: `projects/${query.projectId}/feature-exports/`, | ||
}), | ||
}), | ||
// END OF ENDPOINTS | ||
}), | ||
}) | ||
|
||
export async function createFeatureExport( | ||
store: any, | ||
data: Req['createFeatureExport'], | ||
options?: Parameters< | ||
typeof featureExportService.endpoints.createFeatureExport.initiate | ||
>[1], | ||
) { | ||
return store.dispatch( | ||
featureExportService.endpoints.createFeatureExport.initiate(data, options), | ||
) | ||
} | ||
export async function getFeatureExport( | ||
store: any, | ||
data: Req['getFeatureExport'], | ||
options?: Parameters< | ||
typeof featureExportService.endpoints.getFeatureExport.initiate | ||
>[1], | ||
) { | ||
return store.dispatch( | ||
featureExportService.endpoints.getFeatureExport.initiate(data, options), | ||
) | ||
} | ||
export async function getFeatureExports( | ||
store: any, | ||
data: Req['getFeatureExports'], | ||
options?: Parameters< | ||
typeof featureExportService.endpoints.getFeatureExports.initiate | ||
>[1], | ||
) { | ||
return store.dispatch( | ||
featureExportService.endpoints.getFeatureExports.initiate(data, options), | ||
) | ||
} | ||
// END OF FUNCTION_EXPORTS | ||
|
||
export const { | ||
useCreateFeatureExportMutation, | ||
useGetFeatureExportQuery, | ||
useGetFeatureExportsQuery, | ||
// END OF EXPORTS | ||
} = featureExportService | ||
|
||
/* Usage examples: | ||
const { data, isLoading } = useGetFeatureExportQuery({ id: 2 }, {}) //get hook | ||
const [createFeatureExport, { isLoading, data, isSuccess }] = useCreateFeatureExportMutation() //create hook | ||
featureExportService.endpoints.getFeatureExport.select({id: 2})(store.getState()) //access data from any function | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Res } from 'common/types/responses' | ||
import { Req } from 'common/types/requests' | ||
import { service } from 'common/service' | ||
|
||
export const featureImportService = service | ||
.enhanceEndpoints({ addTagTypes: ['FeatureImport'] }) | ||
.injectEndpoints({ | ||
endpoints: (builder) => ({ | ||
getFeatureImports: builder.query< | ||
Res['featureImports'], | ||
Req['getFeatureImports'] | ||
>({ | ||
providesTags: [{ id: 'LIST', type: 'FeatureImport' }], | ||
query: (query) => ({ | ||
url: `projects/${query.projectId}/feature-imports/`, | ||
}), | ||
}), | ||
// END OF ENDPOINTS | ||
}), | ||
}) | ||
|
||
export async function getFeatureImports( | ||
store: any, | ||
data: Req['getFeatureImports'], | ||
options?: Parameters< | ||
typeof featureImportService.endpoints.getFeatureImports.initiate | ||
>[1], | ||
) { | ||
return Promise.all( | ||
store.dispatch(featureImportService.util.getRunningQueriesThunk()), | ||
) | ||
} | ||
// END OF FUNCTION_EXPORTS | ||
|
||
export const { | ||
useGetFeatureImportsQuery, | ||
// END OF EXPORTS | ||
} = featureImportService | ||
|
||
/* Usage examples: | ||
const { data, isLoading } = useGetFeatureImportsQuery({ id: 2 }, {}) //get hook | ||
const [createFeatureImports, { isLoading, data, isSuccess }] = useCreateFeatureImportsMutation() //create hook | ||
featureImportService.endpoints.getFeatureImports.select({id: 2})(store.getState()) //access data from any function | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Res } from 'common/types/responses' | ||
import { Req } from 'common/types/requests' | ||
import { service } from 'common/service' | ||
import toFormData from 'common/utils/toFormData' | ||
|
||
export const flagsmithProjectImportService = service | ||
.enhanceEndpoints({ addTagTypes: ['FlagsmithProjectImport'] }) | ||
.injectEndpoints({ | ||
endpoints: (builder) => ({ | ||
createFlagsmithProjectImport: builder.mutation< | ||
Res['flagsmithProjectImport'], | ||
Req['createFlagsmithProjectImport'] | ||
>({ | ||
invalidatesTags: [{ id: 'LIST', type: 'FlagsmithProjectImport' }], | ||
queryFn: async (query, baseQueryApi, extraOptions, baseQuery) => { | ||
const { environment_id, ...rest } = query | ||
const formData = toFormData({ ...rest }) | ||
|
||
const { data, error } = await baseQuery({ | ||
body: formData, | ||
method: 'POST', | ||
url: `features/feature-import/${environment_id}`, | ||
}) | ||
return { data, error } | ||
}, | ||
}), | ||
// END OF ENDPOINTS | ||
}), | ||
}) | ||
|
||
export async function createFlagsmithProjectImport( | ||
store: any, | ||
data: Req['createFlagsmithProjectImport'], | ||
options?: Parameters< | ||
typeof flagsmithProjectImportService.endpoints.createFlagsmithProjectImport.initiate | ||
>[1], | ||
) { | ||
store.dispatch( | ||
flagsmithProjectImportService.endpoints.createFlagsmithProjectImport.initiate( | ||
data, | ||
options, | ||
), | ||
) | ||
return Promise.all( | ||
store.dispatch(flagsmithProjectImportService.util.getRunningQueriesThunk()), | ||
) | ||
} | ||
// END OF FUNCTION_EXPORTS | ||
|
||
export const { | ||
useCreateFlagsmithProjectImportMutation, | ||
// END OF EXPORTS | ||
} = flagsmithProjectImportService | ||
|
||
/* Usage examples: | ||
const { data, isLoading } = useGetFlagsmithProjectImportQuery({ id: 2 }, {}) //get hook | ||
const [createFlagsmithProjectImport, { isLoading, data, isSuccess }] = useCreateFlagsmithProjectImportMutation() //create hook | ||
flagsmithProjectImportService.endpoints.getFlagsmithProjectImport.select({id: 2})(store.getState()) //access data from any function | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.