ui(api): add useDirtyState + apply=staged|live on useUpdateApplicationConfig

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-22 22:45:42 +02:00
parent 6052975750
commit 52ff385b04
2 changed files with 30 additions and 2 deletions

View File

@@ -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,
});
}

View File

@@ -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),