Skip to content

Commit a81876e

Browse files
authored
Merge pull request #4846 from akolson/import-from-link-ui-fix
Adds check to the "Imported from" link to verify source nodes exist before attempting a navigation
2 parents 8d32100 + f210078 commit a81876e

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

contentcuration/contentcuration/frontend/channelEdit/components/ResourcePanel.vue

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,14 @@
354354
{{ $tr('resources') }}
355355
</div>
356356
<DetailsRow
357-
v-if="isImported && importedChannelLink"
357+
v-if="showImportedChannelLink"
358358
:label="$tr('originalChannel')"
359359
>
360360
<ActionLink
361361
:text="importedChannelName"
362-
:href="importedChannelLink"
363362
truncate
364363
notranslate
365-
target="_blank"
364+
@click="onClickImportedFrom()"
366365
/>
367366
</DetailsRow>
368367
<DetailsRow :label="$tr('totalResources')">
@@ -395,15 +394,14 @@
395394
{{ $tr('source') }}
396395
</div>
397396
<DetailsRow
398-
v-if="isImported && importedChannelLink"
397+
v-if="showImportedChannelLink"
399398
:label="$tr('originalChannel')"
400399
>
401400
<ActionLink
402401
:text="importedChannelName"
403-
:href="importedChannelLink"
404402
truncate
405403
notranslate
406-
target="_blank"
404+
@click="onClickImportedFrom()"
407405
/>
408406
</DetailsRow>
409407
<DetailsRow
@@ -661,6 +659,9 @@
661659
importedChannelName() {
662660
return this.node.original_channel_name;
663661
},
662+
showImportedChannelLink() {
663+
return this.isImported && this.importedChannelLink;
664+
},
664665
sortedTags() {
665666
return orderBy(this.node.tags, ['count'], ['desc']);
666667
},
@@ -766,7 +767,7 @@
766767
this.tab = this.isExercise ? 'questions' : 'details';
767768
},
768769
methods: {
769-
...mapActions('contentNode', ['loadRelatedResources']),
770+
...mapActions('contentNode', ['loadContentNodes', 'loadRelatedResources']),
770771
...mapActions('file', ['loadFiles']),
771772
...mapActions('assessmentItem', ['loadNodeAssessmentItems']),
772773
getText(field) {
@@ -849,6 +850,23 @@
849850
}
850851
}
851852
},
853+
onClickImportedFrom() {
854+
if (this.showImportedChannelLink) {
855+
const originalNodeId = this.node.original_source_node_id;
856+
const originalChannelId = this.node.original_channel_id;
857+
this.loadContentNodes({
858+
'[node_id+channel_id]__in': [[originalNodeId, originalChannelId]],
859+
}).then(nodes => {
860+
if (nodes.length > 0) {
861+
window.open(this.importedChannelLink, '_blank');
862+
} else {
863+
this.$store.dispatch('showSnackbar', {
864+
text: this.$tr('sourceContentDoesntExist'),
865+
});
866+
}
867+
});
868+
}
869+
},
852870
},
853871
$trs: {
854872
questions: 'Questions',
@@ -892,6 +910,8 @@
892910
noQuestionsError: 'Exercise is empty',
893911
incompleteQuestionError:
894912
'{count, plural, one {# incomplete question} other {# incomplete questions}}',
913+
sourceContentDoesntExist:
914+
'Source content no longer exists. Please contact your administrator.',
895915
},
896916
};
897917

0 commit comments

Comments
 (0)