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'] }),
|
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() {
|
export function useUpdateApplicationConfig() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
return useMutation({
|
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(
|
const res = await authFetch(
|
||||||
`/environments/${encodeURIComponent(environment)}/apps/${encodeURIComponent(config.application)}/config`, {
|
`/environments/${encodeURIComponent(environment)}/apps/${encodeURIComponent(config.application)}/config?apply=${apply}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(config),
|
body: JSON.stringify(config),
|
||||||
|
|||||||
Reference in New Issue
Block a user