Skip to content

Commit

Permalink
Adds check to the 'Imported from' link to verify source nodes exist b…
Browse files Browse the repository at this point in the history
…efore attempting a navigation
  • Loading branch information
akolson committed Dec 3, 2024
1 parent d687a5c commit bb454a2
Showing 1 changed file with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,15 @@
{{ $tr('resources') }}
</div>
<DetailsRow
v-if="isImported && importedChannelLink"
v-if="showImportedChannelLink"
:label="$tr('originalChannel')"
>
<ActionLink
:text="importedChannelName"
:href="importedChannelLink"
truncate
notranslate
target="_blank"
@click="onClickImportedFrom()"
/>
</DetailsRow>
<DetailsRow :label="$tr('totalResources')">
Expand Down Expand Up @@ -395,15 +395,15 @@
{{ $tr('source') }}
</div>
<DetailsRow
v-if="isImported && importedChannelLink"
v-if="showImportedChannelLink"
:label="$tr('originalChannel')"
>
<ActionLink
:text="importedChannelName"
:href="importedChannelLink"
truncate
notranslate
target="_blank"
@click="onClickImportedFrom()"
/>
</DetailsRow>
<DetailsRow
Expand Down Expand Up @@ -661,6 +661,9 @@
importedChannelName() {
return this.node.original_channel_name;
},
showImportedChannelLink() {
return this.isImported && this.importedChannelLink;
},
sortedTags() {
return orderBy(this.node.tags, ['count'], ['desc']);
},
Expand Down Expand Up @@ -766,7 +769,7 @@
this.tab = this.isExercise ? 'questions' : 'details';
},
methods: {
...mapActions('contentNode', ['loadRelatedResources']),
...mapActions('contentNode', ['loadContentNodes', 'loadRelatedResources']),
...mapActions('file', ['loadFiles']),
...mapActions('assessmentItem', ['loadNodeAssessmentItems']),
getText(field) {
Expand Down Expand Up @@ -849,6 +852,23 @@
}
}
},
onClickImportedFrom() {
if (this.showImportedChannelLink) {
const originalNodeId = this.node.original_source_node_id;
const originalChannelId = this.node.original_channel_id;
this.loadContentNodes({
'[node_id+channel_id]__in': [[originalNodeId, originalChannelId]],
}).then(nodes => {
if (nodes.length > 0) {
window.open(this.importedChannelLink, '_blank');
} else {
this.$store.dispatch('showSnackbar', {
text: this.$tr('sourceContentDoesntExist'),
});
}
});
}
},
},
$trs: {
questions: 'Questions',
Expand Down Expand Up @@ -892,6 +912,8 @@
noQuestionsError: 'Exercise is empty',
incompleteQuestionError:
'{count, plural, one {# incomplete question} other {# incomplete questions}}',
sourceContentDoesntExist:
'Source content no longer exists. Please contact your administrator.',
},
};
Expand Down

0 comments on commit bb454a2

Please sign in to comment.