Skip to content

Commit

Permalink
Merge pull request #4846 from akolson/import-from-link-ui-fix
Browse files Browse the repository at this point in the history
Adds check to the "Imported from" link to verify source nodes exist before attempting a navigation
  • Loading branch information
bjester authored Dec 12, 2024
2 parents 8d32100 + f210078 commit a81876e
Showing 1 changed file with 27 additions and 7 deletions.
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

0 comments on commit a81876e

Please sign in to comment.