Skip to content

Commit a9b39d7

Browse files
Merge branch 'feat/restrict-ml-processing-jobs' of https://github.com/RolnickLab/antenna into feat/restrict-ml-processing-jobs
2 parents f385af3 + b4e16ad commit a9b39d7

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

ui/src/data-services/models/capture-details.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { UserPermission } from 'utils/user/types'
12
import { Capture, ServerCapture } from './capture'
23
import { Job } from './job'
34

@@ -69,4 +70,8 @@ export class CaptureDetails extends Capture {
6970
get url(): string {
7071
return this._capture.url
7172
}
73+
74+
get userPermissions(): UserPermission[] {
75+
return this._capture.user_permissions
76+
}
7277
}

ui/src/data-services/models/job.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class Job {
4545

4646
get canCancel(): boolean {
4747
return (
48-
this._job.user_permissions.includes(UserPermission.Cancel) &&
48+
this._job.user_permissions.includes(UserPermission.Run) &&
4949
(this.status.code === 'STARTED' || this.status.code === 'PENDING')
5050
)
5151
}
@@ -63,7 +63,7 @@ export class Job {
6363

6464
get canRetry(): boolean {
6565
return (
66-
this._job.user_permissions.includes(UserPermission.Retry) &&
66+
this._job.user_permissions.includes(UserPermission.Run) &&
6767
this.status.code !== 'CREATED' &&
6868
this.status.code !== 'STARTED' &&
6969
this.status.code !== 'PENDING'

ui/src/pages/session-details/playback/capture-details/capture-job/process-now.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { useCreateJob } from 'data-services/hooks/jobs/useCreateJob'
2-
import { useProjectDetails } from 'data-services/hooks/projects/useProjectDetails'
32
import { CaptureDetails } from 'data-services/models/capture-details'
43
import { Tooltip } from 'design-system/components/tooltip/tooltip'
54
import { CheckIcon, Loader2Icon } from 'lucide-react'
65
import { Button } from 'nova-ui-kit'
76
import { useParams } from 'react-router-dom'
87
import { STRING, translate } from 'utils/language'
8+
import { UserPermission } from 'utils/user/types'
99

1010
export const ProcessNow = ({
1111
capture,
@@ -15,14 +15,16 @@ export const ProcessNow = ({
1515
pipelineId?: string
1616
}) => {
1717
const { projectId } = useParams()
18-
const { project } = useProjectDetails(projectId as string, true)
1918
const { createJob, isLoading, isSuccess } = useCreateJob()
19+
const canProcess = capture?.userPermissions.includes(
20+
UserPermission.RunSingleImage
21+
)
2022
const disabled =
21-
!capture || capture.hasJobInProgress || !pipelineId || !project?.canUpdate
23+
!capture || capture.hasJobInProgress || !pipelineId || !canProcess
2224

2325
// @TODO: hasJobInProgress, replace with if pipeline is healthy/available
2426

25-
const tooltipContent = project?.canUpdate
27+
const tooltipContent = canProcess
2628
? translate(STRING.MESSAGE_PROCESS_NOW_TOOLTIP)
2729
: translate(STRING.MESSAGE_PERMISSIONS_MISSING)
2830

ui/src/utils/user/types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ export type UserInfo = {
1111
}
1212

1313
export enum UserPermission {
14-
Cancel = 'cancel', // Custom job permission
1514
Create = 'create',
1615
Delete = 'delete',
1716
Populate = 'populate', // Custom collection permission
18-
Retry = 'retry', // Custom job permission
1917
Run = 'run', // Custom job permission
18+
RunSingleImage = 'run_single_image', // Custom job permission
2019
Star = 'star',
21-
Update = 'update', // Custom capture permission
20+
Update = 'update',
2221
}
2322

2423
export interface UserContextValues {

0 commit comments

Comments
 (0)