X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b6ac7fe88d347582d39fffa002e300af222c578f..d8b6d772739992431b81de993f8adc783b00feb1:/src/store/resources/resources.ts?ds=sidebyside diff --git a/src/store/resources/resources.ts b/src/store/resources/resources.ts index 6f7acadae0..3f71140497 100644 --- a/src/store/resources/resources.ts +++ b/src/store/resources/resources.ts @@ -9,26 +9,6 @@ import { GroupResource } from "models/group"; export type ResourcesState = { [key: string]: Resource }; -const getResourceWritableBy = (state: ResourcesState, id: string, userUuid: string): string[] => { - if (!id) { - return []; - } - - if (id === userUuid) { - return [userUuid]; - } - - const resource = (state[id] as ProjectResource); - - if (!resource) { - return []; - } - - const { writableBy } = resource; - - return writableBy || getResourceWritableBy(state, resource.ownerUuid, userUuid); -}; - export const getResourceWithEditableStatus = (id: string, userUuid?: string) => (state: ResourcesState): T | undefined => { if (state[id] === undefined) { return; } @@ -36,7 +16,12 @@ export const getResourceWithEditableStatus = -1 : false; + resource.isEditable = resource.canWrite; + + if (!resource.isEditable && state[resource.ownerUuid]) { + const resourceOwner = JSON.parse(JSON.stringify(state[resource.ownerUuid] as T)); + resource.isEditable = resourceOwner.canWrite; + } } return resource;