@@ -15,17 +15,17 @@ import { storeToRefs } from "pinia";
1515import { computed , ref } from " vue" ;
1616import Multiselect from " vue-multiselect" ;
1717
18+ import type { AnyShareableItemWithStatus , ShareOption } from " @/api" ;
19+ import { isShareableHistoryWithStatus } from " @/api" ;
1820import { useConfig } from " @/composables/config" ;
1921import { getAppRoot } from " @/onload" ;
2022import { useUserStore } from " @/stores/userStore" ;
2123import { assertArray } from " @/utils/assertions" ;
2224
23- import type { Item , ShareOption } from " ./item" ;
24-
2525import Heading from " ../Common/Heading.vue" ;
2626
2727const props = defineProps <{
28- item: Item ;
28+ item: AnyShareableItemWithStatus ;
2929 modelClass: string ;
3030}>();
3131
@@ -39,7 +39,7 @@ const { currentUser } = storeToRefs(useUserStore());
3939const { config, isConfigLoaded } = useConfig (false );
4040
4141const permissionsChangeRequired = computed (() => {
42- if (props .item . extra ) {
42+ if (isShareableHistoryWithStatus ( props .item ) ) {
4343 return props .item .extra .can_change .length > 0 || props .item .extra .cannot_change .length > 0 ;
4444 } else {
4545 return false ;
@@ -123,8 +123,21 @@ const noChanges = computed(() => {
123123 return ! (newCandidates .length !== 0 || removedShared .length !== 0 );
124124});
125125
126- const canChangeCount = computed (() => props .item .extra ?.can_change .length ?? 0 );
127- const cannotChangeCount = computed (() => props .item .extra ?.cannot_change .length ?? 0 );
126+ const canChangeCount = computed (() => {
127+ return isShareableHistoryWithStatus (props .item ) ? props .item .extra .can_change .length : 0 ;
128+ });
129+
130+ const cannotChangeCount = computed (() => {
131+ return isShareableHistoryWithStatus (props .item ) ? props .item .extra .cannot_change .length : 0 ;
132+ });
133+
134+ const canChangeDatasets = computed (() => {
135+ return isShareableHistoryWithStatus (props .item ) ? props .item .extra .can_change : [];
136+ });
137+
138+ const cannotChangeDatasets = computed (() => {
139+ return isShareableHistoryWithStatus (props .item ) ? props .item .extra .cannot_change : [];
140+ });
128141
129142const selectedSharingOption = ref <ShareOption >(" make_public" );
130143
@@ -251,7 +264,7 @@ defineExpose({
251264 v-if =" canChangeCount > 0"
252265 header =" The following datasets can be shared by updating their permissions" >
253266 <BListGroup >
254- <BListGroupItem v-for =" dataset in props.item.extra?.can_change ?? [] " :key =" dataset.id" >
267+ <BListGroupItem v-for =" dataset in canChangeDatasets " :key =" dataset.id" >
255268 {{ dataset.name }}
256269 </BListGroupItem >
257270 </BListGroup >
@@ -261,7 +274,7 @@ defineExpose({
261274 v-if =" cannotChangeCount > 0"
262275 header =" The following datasets cannot be shared, you are not authorized to change their permissions" >
263276 <BListGroup >
264- <BListGroupItem v-for =" dataset in props.item.extra?.cannot_change ?? [] " :key =" dataset.id" >
277+ <BListGroupItem v-for =" dataset in cannotChangeDatasets " :key =" dataset.id" >
265278 {{ dataset.name }}
266279 </BListGroupItem >
267280 </BListGroup >
0 commit comments