From c0584b3479a335c0dda8fa255226f1213ed9aafe Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Thu, 10 Nov 2022 06:38:04 -0800 Subject: [PATCH 1/9] Prevent empty strings and nulls from populating detail lists --- contentcuration/contentcuration/models.py | 11 ++++++----- .../contentcuration/tests/test_contentnodes.py | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/contentcuration/contentcuration/models.py b/contentcuration/contentcuration/models.py index f7bfe2fdc6..5be2b29155 100644 --- a/contentcuration/contentcuration/models.py +++ b/contentcuration/contentcuration/models.py @@ -1705,13 +1705,14 @@ def get_details(self, channel_id=None): "accessible_languages": node.get("accessible_languages", ""), "licenses": node.get("licenses", ""), "tags": node.get("tags_list", []), - "copyright_holders": node["copyright_holders"], - "authors": node["authors"], - "aggregators": node["aggregators"], - "providers": node["providers"], - "sample_pathway": pathway, "original_channels": original_channels, + "sample_pathway": pathway, "sample_nodes": sample_nodes, + # source model fields for the below default to an empty string, but can also be null + "authors": list(filter(bool, node["authors"])), + "aggregators": list(filter(bool, node["aggregators"])), + "providers": list(filter(bool, node["providers"])), + "copyright_holders": list(filter(bool, node["copyright_holders"])), } # Set cache with latest data diff --git a/contentcuration/contentcuration/tests/test_contentnodes.py b/contentcuration/contentcuration/tests/test_contentnodes.py index 03b70cff50..25569f8988 100644 --- a/contentcuration/contentcuration/tests/test_contentnodes.py +++ b/contentcuration/contentcuration/tests/test_contentnodes.py @@ -184,6 +184,10 @@ def test_get_node_details(self): assert details["resource_count"] > 0 assert details["resource_size"] > 0 assert len(details["kind_count"]) > 0 + assert len(details["authors"]) == len([author for author in details["authors"] if author]) + assert len(details["aggregators"]) == len([aggregator for aggregator in details["aggregators"] if aggregator]) + assert len(details["providers"]) == len([provider for provider in details["providers"] if provider]) + assert len(details["copyright_holders"]) == len([holder for holder in details["copyright_holders"] if holder]) class NodeOperationsTestCase(StudioTestCase): From b59d0d5283ecefcbde766a599fbd224876ca102c Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Thu, 10 Nov 2022 06:39:22 -0800 Subject: [PATCH 2/9] Require a defined array of items --- .../contentcuration/frontend/shared/views/ExpandableList.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/contentcuration/contentcuration/frontend/shared/views/ExpandableList.vue b/contentcuration/contentcuration/frontend/shared/views/ExpandableList.vue index 66b03d6e12..2bb20e3a2e 100644 --- a/contentcuration/contentcuration/frontend/shared/views/ExpandableList.vue +++ b/contentcuration/contentcuration/frontend/shared/views/ExpandableList.vue @@ -78,6 +78,7 @@ props: { items: { type: Array, + required: true, default: () => [], }, max: { From 08c987d9e5b8309f244790d5b367c7713bbd7837 Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Thu, 10 Nov 2022 06:41:38 -0800 Subject: [PATCH 3/9] Check that channel_id exists before calling method --- .../contentcuration/frontend/channelEdit/vuex/task/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/vuex/task/index.js b/contentcuration/contentcuration/frontend/channelEdit/vuex/task/index.js index 657757e9af..17d049cad9 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/vuex/task/index.js +++ b/contentcuration/contentcuration/frontend/channelEdit/vuex/task/index.js @@ -28,7 +28,10 @@ export default { getPublishTaskForChannel(state) { return function(channelId) { return Object.values(state.asyncTasksMap).find( - t => t.channel_id.replace('-', '') === channelId && t.task_name === 'export-channel' + t => + t.task_name === 'export-channel' && + t.channel_id && + t.channel_id.replace('-', '') === channelId ); }; }, From c686fff5d715720e5f9efd1c5de64dc5a46fa732 Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Thu, 10 Nov 2022 06:49:58 -0800 Subject: [PATCH 4/9] Check map exists before delete --- .../frontend/channelEdit/vuex/assessmentItem/mutations.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/vuex/assessmentItem/mutations.js b/contentcuration/contentcuration/frontend/channelEdit/vuex/assessmentItem/mutations.js index 943fa59de0..c743ee25b9 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/vuex/assessmentItem/mutations.js +++ b/contentcuration/contentcuration/frontend/channelEdit/vuex/assessmentItem/mutations.js @@ -59,5 +59,7 @@ export function UPDATE_ASSESSMENTITEM_FROM_INDEXEDDB(state, { id, ...mods }) { } export function DELETE_ASSESSMENTITEM(state, assessmentItem) { - Vue.delete(state.assessmentItemsMap[assessmentItem.contentnode], assessmentItem.assessment_id); + if (state.assessmentItemsMap[assessmentItem.contentnode]) { + Vue.delete(state.assessmentItemsMap[assessmentItem.contentnode], assessmentItem.assessment_id); + } } From 6594f3020e442ce2837096a04fd4d099ab85cc79 Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Thu, 10 Nov 2022 07:14:03 -0800 Subject: [PATCH 5/9] Prevent rendering until loaded --- .../channelEdit/views/CurrentTopicView.vue | 2 +- .../channelEdit/views/TreeView/TreeViewBase.vue | 14 +++++++++++--- .../frontend/channelEdit/views/TreeView/index.vue | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue b/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue index 3ab612faca..644ccd629d 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue @@ -93,7 +93,7 @@ - + @@ -279,6 +279,12 @@ MessageDialog, }, mixins: [titleMixin], + props: { + loading: { + type: Boolean, + default: false, + }, + }, data() { return { drawer: false, @@ -331,7 +337,9 @@ } }, showChannelMenu() { - return this.$vuetify.breakpoint.xsOnly || this.canManage || this.isPublished; + return ( + !this.loading && (this.$vuetify.breakpoint.xsOnly || this.canManage || this.isPublished) + ); }, viewChannelDetailsLink() { return { diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/index.vue b/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/index.vue index c9f522e478..0a310e354c 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/index.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/index.vue @@ -1,6 +1,6 @@