ui(api): add useDirtyState + apply=staged|live on useUpdateApplicationConfig
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -203,3 +203,27 @@ export function usePromoteDeployment() {
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['apps'] }),
|
||||
});
|
||||
}
|
||||
|
||||
// --- Dirty State ---
|
||||
|
||||
export interface DirtyStateDifference {
|
||||
field: string;
|
||||
staged: string;
|
||||
deployed: string;
|
||||
}
|
||||
|
||||
export interface DirtyState {
|
||||
dirty: boolean;
|
||||
lastSuccessfulDeploymentId: string | null;
|
||||
differences: DirtyStateDifference[];
|
||||
}
|
||||
|
||||
export function useDirtyState(envSlug: string | undefined, appSlug: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['apps', envSlug, appSlug, 'dirty-state'],
|
||||
queryFn: () => apiFetch<DirtyState>(
|
||||
`${envBase(envSlug!)}/${encodeURIComponent(appSlug!)}/dirty-state`,
|
||||
),
|
||||
enabled: !!envSlug && !!appSlug,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,9 +83,13 @@ export interface ConfigUpdateResponse {
|
||||
export function useUpdateApplicationConfig() {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: async ({ config, environment }: { config: ApplicationConfig; environment: string }) => {
|
||||
mutationFn: async ({ config, environment, apply = 'live' }: {
|
||||
config: ApplicationConfig;
|
||||
environment: string;
|
||||
apply?: 'staged' | 'live';
|
||||
}) => {
|
||||
const res = await authFetch(
|
||||
`/environments/${encodeURIComponent(environment)}/apps/${encodeURIComponent(config.application)}/config`, {
|
||||
`/environments/${encodeURIComponent(environment)}/apps/${encodeURIComponent(config.application)}/config?apply=${apply}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(config),
|
||||
|
||||
Reference in New Issue
Block a user