Skip to content

Commit

Permalink
Filter out pipelines not in the project
Browse files Browse the repository at this point in the history
  • Loading branch information
vanessavmac committed Jan 28, 2025
1 parent 8b3418d commit 285f8ae
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
8 changes: 7 additions & 1 deletion ami/ml/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,14 @@ class ProcessingServiceViewSet(DefaultViewSet):
def get_queryset(self) -> QuerySet:
query_set: QuerySet = super().get_queryset()
project = get_active_project(self.request)

if project:
query_set = query_set.filter(projects=project)
query_set = query_set.filter(projects=project).prefetch_related(
Prefetch(
"pipelines",
queryset=Pipeline.objects.filter(projects=project.id),
)
)
return query_set

@extend_schema(parameters=[project_id_doc_param])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const convertServerRecord = (record: ServerProcessingService) =>
new ProcessingService(record)

export const useProcessingServiceDetails = (
processingServiceId: string
processingServiceId: string,
queryParams: { projectId: string }
): {
processingService?: ProcessingService
isLoading: boolean
Expand All @@ -20,7 +21,7 @@ export const useProcessingServiceDetails = (
const { data, isLoading, isFetching, error } =
useAuthorizedQuery<ProcessingService>({
queryKey: [API_ROUTES.PROCESSING_SERVICES, processingServiceId],
url: `${API_URL}/${API_ROUTES.PROCESSING_SERVICES}/${processingServiceId}/`,
url: `${API_URL}/${API_ROUTES.PROCESSING_SERVICES}/${processingServiceId}/?project_id=${queryParams.projectId}`,
})

const processingService = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { PopulateProcessingService } from './processing-services-actions'

export const columns: (
projectId: string
) => TableColumn<ProcessingService>[] = () => [
) => TableColumn<ProcessingService>[] = (projectId: string) => [
{
id: 'id',
sortField: 'id',
Expand All @@ -24,7 +24,11 @@ export const columns: (
name: translate(STRING.FIELD_LABEL_NAME),
renderCell: (item: ProcessingService) => (
<BasicTableCell>
<ProcessingServiceDetailsDialog id={item.id} name={item.name} />
<ProcessingServiceDetailsDialog
id={item.id}
projectId={projectId}
name={item.name}
/>
</BasicTableCell>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import styles from './styles.module.scss'

export const ProcessingServiceDetailsDialog = ({
id,
projectId,
name,
}: {
id: string
projectId: string
name: string
}) => {
const [isOpen, setIsOpen] = useState(false)
Expand All @@ -40,6 +42,7 @@ export const ProcessingServiceDetailsDialog = ({
<div className={styles.content}>
<ProcessingServiceDetailsContent
id={id}
projectId={projectId}
onLoadingChange={setIsLoading}
/>
</div>
Expand All @@ -50,13 +53,17 @@ export const ProcessingServiceDetailsDialog = ({

const ProcessingServiceDetailsContent = ({
id,
projectId,
onLoadingChange,
}: {
id: string
projectId: string
onLoadingChange: (isLoading: boolean) => void
}) => {
const { processingService, isLoading, error } =
useProcessingServiceDetails(id)
const { processingService, isLoading, error } = useProcessingServiceDetails(
id,
{ projectId }
)

useEffect(() => {
onLoadingChange(isLoading)
Expand Down

0 comments on commit 285f8ae

Please sign in to comment.