Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: hide Automations tab and stop jobs polling without jobs:manage (#3963)
Kyle Mendell94d6d79d533c
diff --git a/frontend/src/lib/services/job-schedule-service.ts b/frontend/src/lib/services/job-schedule-service.tsindex 18663602e..5aa3c8512 100644--- a/frontend/src/lib/services/job-schedule-service.ts+++ b/frontend/src/lib/services/job-schedule-service.ts@@ -1,5 +1,5 @@import type { JobRun, JobRunList } from '#lib/types/job.js';-import BaseAPIService from './api-service';+import BaseAPIService, { type APIRequestConfig } from './api-service';import type { JobSchedules, JobSchedulesUpdate, JobListResponse, JobRunResponse } from '#lib/types/settings.js';class JobScheduleService extends BaseAPIService {@@ -11,8 +11,8 @@ class JobScheduleService extends BaseAPIService {return this.handleResponse(this.api.put(`/environments/${environmentId}/job-schedules`, update));}- async listJobs(environmentId: string = '0'): Promise<JobListResponse> {- return this.handleResponse(this.api.get(`/environments/${environmentId}/jobs`));+ async listJobs(environmentId: string = '0', config?: APIRequestConfig): Promise<JobListResponse> {+ return this.handleResponse(this.api.get(`/environments/${environmentId}/jobs`, config));}async runJob(jobId: string, environmentId: string = '0', requestId: string = crypto.randomUUID()): Promise<JobRunResponse> {diff --git a/frontend/src/routes/(app)/environments/[id]/+page.svelte b/frontend/src/routes/(app)/environments/[id]/+page.svelteindex 2aa155aa4..9a0c2d15f 100644--- a/frontend/src/routes/(app)/environments/[id]/+page.svelte+++ b/frontend/src/routes/(app)/environments/[id]/+page.svelte@@ -103,6 +103,7 @@let showSettingsTabs = $derived(runtimeEnvironment.enabled && isCurrentlyOnline && settings !== null && hasPermission('settings:read', environment.id));+ let showJobsTab = $derived(showSettingsTabs && hasPermission('jobs:manage', environment.id));let hasMTLSAssets = $derived(Boolean(runtimeEnvironment.edgeMTLSCertificate));let canPairEnvironments = $derived(hasPermission('environments:pair'));let showMTLSDownloads = $derived(@@ -225,15 +226,18 @@value: 'security',label: m.security(),icon: SecurityIcon- },- {- value: 'jobs',- label: m.automations(),- icon: JobsIcon});}+ if (showJobsTab) {+ items.push({+ value: 'jobs',+ label: m.automations(),+ icon: JobsIcon+ });+ }+items.push({value: 'gitops',label: m.git_syncs_title(),@@ -889,7 +893,9 @@</Tabs.Content></Tabs.Root></Tabs.Content>+ {/if}+ {#if showJobsTab}<Tabs.Content value="jobs"><JobsTab bind:formInputs environmentId={environment.id} /></Tabs.Content>diff --git a/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte b/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelteindex fcf3d2acb..1193c9c06 100644--- a/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte+++ b/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte@@ -6,6 +6,7 @@import { jobScheduleService } from '#lib/services/job-schedule-service.js';import { containerService } from '#lib/services/container-service.js';import { tryCatch } from '#lib/utils/try-catch.js';+ import { hasPermission } from '#lib/utils/auth.js';import JobCard from '#lib/components/job-card/job-card.svelte';import { Spinner } from '#lib/components/ui/spinner/index.js';import { m } from '#lib/paraglide/messages.js';@@ -28,10 +29,11 @@let { formInputs = $bindable(), environmentId }: JobsTabProps = $props();const vulnerabilityManagementEnabled = $derived(featureStore.isEnabled('vulnerabilityManagement', environmentId));+ const canManageJobs = $derived(hasPermission('jobs:manage', environmentId));const jobsQuery = createQuery(() => ({queryKey: queryKeys.jobs.list(environmentId),- queryFn: async () => {- const response = await jobScheduleService.listJobs(environmentId);+ queryFn: async ({ signal }) => {+ const response = await jobScheduleService.listJobs(environmentId, { signal, suppressAccessDeniedToast: true });return {...response,jobs: response.jobs.map((job) => ({@@ -40,7 +42,7 @@}))};},- enabled: !!environmentId,+ enabled: !!environmentId && canManageJobs,refetchInterval: 5000}));const jobsResponse = $derived(jobsQuery.data);@@ -98,6 +100,7 @@}function loadJobs() {+ if (!canManageJobs) return;void jobsQuery.refetch();}