Skip to content

Commit

Permalink
Fix item permissions not respected in drawer-item (#24045)
Browse files Browse the repository at this point in the history
  • Loading branch information
ComfortablyCoding authored Dec 2, 2024
1 parent 0bb3351 commit fb41400
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-ladybugs-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@directus/app': patch
---

Fixed item permissions not respected in `drawer-item`
18 changes: 13 additions & 5 deletions app/src/views/private/components/drawer-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ const title = computed(() => {
: t('editing_in', { collection: collection.name });
});
const { fields: fieldsWithPermissions } = useItemPermissions(
const { fields: fieldsWithPermissions, updateAllowed } = useItemPermissions(
collection,
primaryKey,
computed(() => props.primaryKey === '+'),
);
const { fields: relatedCollectionFields } = useItemPermissions(
const { fields: relatedCollectionFields, updateAllowed: updateRelatedCollectionAllowed } = useItemPermissions(
relatedCollection as Ref<string>,
relatedPrimaryKey,
computed(() => props.primaryKey === '+'),
Expand Down Expand Up @@ -152,6 +152,14 @@ const templatePrimaryKey = computed(() =>
const templateCollection = computed(() => relatedCollectionInfo.value || collectionInfo.value);
const isSavable = computed(() => {
if (props.disabled) return false;
if (isNew.value) return true;
if (updateAllowed.value && !props.junctionField) return true;
if (updateAllowed.value && props.junctionField && updateRelatedCollectionAllowed.value) return true;
return false;
});
const {
template,
templateData,
Expand Down Expand Up @@ -391,7 +399,7 @@ function useActions() {

<template #actions>
<slot name="actions" />
<v-button v-tooltip.bottom="t('save')" icon rounded @click="save">
<v-button v-tooltip.bottom="t('save')" icon rounded :disabled="!isSavable" @click="save">
<v-icon name="check" />
</v-button>
</template>
Expand All @@ -406,7 +414,7 @@ function useActions() {
<div v-else class="drawer-item-order" :class="{ swap: swapFormOrder }">
<v-form
v-if="junctionField"
:disabled="disabled"
:disabled="disabled || (!updateRelatedCollectionAllowed && !isNew)"
:loading="loading"
:show-no-visible-fields="false"
:initial-values="initialValues?.[junctionField]"
Expand All @@ -421,7 +429,7 @@ function useActions() {

<v-form
v-model="internalEdits"
:disabled="disabled"
:disabled="disabled || (!updateAllowed && !isNew)"
:loading="loading"
:show-no-visible-fields="false"
:initial-values="initialValues"
Expand Down

0 comments on commit fb41400

Please sign in to comment.