Merge branch 'main' from workbench2.git
[arvados.git] / services / workbench2 / src / common / frozen-resources.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ProjectResource } from "models/project";
6 import { getResource } from "store/resources/resources";
7
8 export const resourceIsFrozen = (resource: any, resources): boolean => {
9     let isFrozen: boolean = !!resource.frozenByUuid;
10     let ownerUuid: string | undefined = resource?.ownerUuid;
11
12     while(!isFrozen && !!ownerUuid && ownerUuid.indexOf('000000000000000') === -1) {
13         const parentResource: ProjectResource | undefined = getResource<ProjectResource>(ownerUuid)(resources);
14         isFrozen = !!parentResource?.frozenByUuid;
15         ownerUuid = parentResource?.ownerUuid;
16     }
17
18     return isFrozen;
19 }