Files
ServerKit/frontend/src/services/api/projects.js
T
Juan DenisandClaude Opus 4.8 e2438db9d1 feat: UX hardening for the new organization/proxy/snapshot surfaces
Tightens the seams the recent features introduced:

- Secret precedence/conflict: the embedded shared-variables panel now resolves
  via the hierarchical endpoint, shows a per-variable source-scope badge +
  precedence legend, and flags keys that are also set locally with a
  "Set locally — local value applies" badge (shared groups are a facade and are
  not injected into the container; the app's own env var is authoritative).
- Split inventory: apps now expose project_name/environment_name; the Services
  list shows a project/environment badge (or "Unassigned") and a "Move to
  project" bulk action (POST /apps/move-to-project, workspace-validated,
  null-unassigns).
- Fleet proxy actionability: fleet_overview rows carry a {level,text}
  recommendation (mismatch warning / idle stack / empty host / aligned),
  rendered as a per-row pill.
- Onboarding wizard: "Step X of 5" + progress bar + rough ETA, and a
  collapsible step-history trail so returning users get a clean summary.
- Config diff: a plain-language summary ("3 environment variables and the image
  tag (app:1.2.1 -> app:1.1.9) changed") above the technical diff and echoed in
  the restore confirmation.
- Container status: an always-visible "N issues" / "healthy/total" badge so a
  degraded sub-container isn't hidden behind hover.
- Sidebar: Projects, Shared Variables and Workspaces collapse under a single
  "Organization" group.

No schema change (project/environment names are derived). Backend suite: 935
passed, 14 skipped; frontend builds clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 21:15:16 -04:00

82 lines
2.2 KiB
JavaScript

// Projects & Environments (Workspace -> Project -> Environment -> Applications)
//
// Project endpoints are workspace-scoped; the active workspace is derived from
// the X-Workspace-Id header the client already sends, so these methods don't
// need to pass it explicitly.
// --- Projects ---
export async function getProjects() {
return this.request('/projects');
}
export async function getProject(id) {
return this.request(`/projects/${id}`);
}
export async function createProject(data) {
return this.request('/projects', {
method: 'POST',
body: data,
});
}
export async function updateProject(id, data) {
return this.request(`/projects/${id}`, {
method: 'PUT',
body: data,
});
}
export async function deleteProject(id) {
return this.request(`/projects/${id}`, {
method: 'DELETE',
});
}
// --- Environments ---
export async function createEnvironment(projectId, data) {
return this.request('/environments', {
method: 'POST',
body: { project_id: projectId, ...data },
});
}
export async function updateEnvironment(environmentId, data) {
return this.request(`/environments/${environmentId}`, {
method: 'PUT',
body: data,
});
}
export async function deleteEnvironment(environmentId) {
return this.request(`/environments/${environmentId}`, {
method: 'DELETE',
});
}
export async function reorderEnvironments(projectId, orderedIds) {
return this.request('/environments/reorder', {
method: 'POST',
body: { project_id: projectId, ordered_ids: orderedIds },
});
}
// --- Apps <-> Project assignment ---
// Bulk-assign applications to a project (and optionally an environment), or
// unassign them by passing projectId = null. The backend validates the
// project/environment against each app's workspace and silently drops invalid
// pairings, so a mixed selection is safe. Returns { apps, skipped }.
export async function moveAppsToProject(appIds, projectId, environmentId) {
return this.request('/apps/move-to-project', {
method: 'POST',
body: {
app_ids: appIds,
project_id: projectId ?? null,
environment_id: environmentId ?? null,
},
});
}