Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds check to the "Imported from" link to verify source nodes exist before attempting a navigation #4846

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,14 @@
{{ $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 +394,14 @@
{{ $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 +659,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 +767,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 +850,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 +910,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
Loading