From c34b61f2521fa778978012df101d3faf19b45028 Mon Sep 17 00:00:00 2001 From: shruti862 Date: Sat, 1 Feb 2025 15:11:47 +0530 Subject: [PATCH 01/14] new commits --- .../frontend/channelList/constants.js | 1 + .../frontend/channelList/router.js | 6 ++ .../views/ChannelSet/ChannelSetList.vue | 7 +- .../views/ChannelSet/ChannelSetModal.vue | 94 +++++++++++++------ .../channelList/vuex/channelSet/actions.js | 24 ++++- 5 files changed, 96 insertions(+), 36 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/constants.js b/contentcuration/contentcuration/frontend/channelList/constants.js index a4bb39e202..f69122fb5a 100644 --- a/contentcuration/contentcuration/frontend/channelList/constants.js +++ b/contentcuration/contentcuration/frontend/channelList/constants.js @@ -21,6 +21,7 @@ export const RouteNames = { CHANNEL_EDIT: 'CHANNEL_EDIT', CHANNEL_SETS: 'CHANNEL_SETS', CHANNEL_SET_DETAILS: 'CHANNEL_SET_DETAILS', + NEW_CHANNEL_SET_DETAILS: 'NEW_CHANNEL_SET_DETAILS', CATALOG_ITEMS: 'CATALOG_ITEMS', CATALOG_DETAILS: 'CATALOG_DETAILS', CATALOG_FAQ: 'CATALOG_FAQ', diff --git a/contentcuration/contentcuration/frontend/channelList/router.js b/contentcuration/contentcuration/frontend/channelList/router.js index 9f1c31aab4..9424ca5cfe 100644 --- a/contentcuration/contentcuration/frontend/channelList/router.js +++ b/contentcuration/contentcuration/frontend/channelList/router.js @@ -52,6 +52,12 @@ const router = new VueRouter({ component: ChannelSetModal, props: true, }, + { + name: RouteNames.NEW_CHANNEL_SET_DETAILS, + path: '/collections/new', + component: ChannelSetModal, + + }, { name: RouteNames.CATALOG_ITEMS, path: '/public', diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue index ea771b5241..a1470e8ba5 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue @@ -107,14 +107,11 @@ }); }, methods: { - ...mapActions('channelSet', ['loadChannelSetList', 'createChannelSet']), + ...mapActions('channelSet', ['loadChannelSetList',]), newChannelSet() { - this.createChannelSet().then(id => { this.$router.push({ - name: RouteNames.CHANNEL_SET_DETAILS, - params: { channelSetId: id }, + name: RouteNames.NEW_CHANNEL_SET_DETAILS, }); - }); }, }, $trs: { diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue index c5607ff011..40a5649260 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue @@ -97,7 +97,10 @@ :key="listType.id" lazy > - + @@ -158,7 +161,7 @@ import { RouteNames } from '../../constants'; import ChannelItem from './ChannelItem'; import ChannelSelectionList from './ChannelSelectionList'; - import { NEW_OBJECT, ChannelListTypes, ErrorTypes } from 'shared/constants'; + import { ChannelListTypes, ErrorTypes } from 'shared/constants'; import { constantsTranslationMixin, routerMixin } from 'shared/mixins'; import CopyToken from 'shared/views/CopyToken'; import MessageDialog from 'shared/views/MessageDialog'; @@ -181,7 +184,7 @@ props: { channelSetId: { type: String, - required: true, + default: '', }, }, data() { @@ -194,12 +197,13 @@ showUnsavedDialog: false, diffTracker: {}, saving: false, + }; }, computed: { ...mapGetters('channelSet', ['getChannelSet']), - isNew() { - return Boolean(this.channelSet[NEW_OBJECT]); + isNew() { + return !this.channelSetId || this.$route.path === '/new'; }, nameRules() { return [name => (name && name.trim().length ? true : this.$tr('titleRequiredText'))]; @@ -245,8 +249,11 @@ }, }, beforeMount() { - return this.verifyChannelSet(this.channelSetId); - }, + if (this.channelSetId) { + return this.verifyChannelSet(this.channelSetId); + } + else this.setup(); +}, mounted() { this.updateTitleForPage(); }, @@ -297,6 +304,7 @@ removeChannel(channelId) { this.channels = this.channels.filter(c => c !== channelId); }, + loadChannels() { if (this.channelSet.channels && this.channelSet.channels.length) { this.loadingChannels = true; @@ -307,6 +315,7 @@ this.loadingChannels = false; } }, + setChannelSet(data) { for (const key in data) { Vue.set(this.diffTracker, key, data[key]); @@ -318,29 +327,53 @@ this.title = this.isNew ? this.$tr('creatingChannelSet') : this.channelSet.name; }, save() { - if (this.saving) { + if (this.saving) { + return; + } + this.saving = true; + this.showUnsavedDialog = false; + + if (this.$refs.channelsetform.validate()) { + let promise; + + if (this.isNew) { + const channelSetData = { ...this.diffTracker }; + promise = this.commitChannelSet(channelSetData).then(newCollection => { + + if (!newCollection || !newCollection.id) { + console.error("Error: New collection was not created properly.", newCollection); + this.saving = false; return; } - this.saving = true; - this.showUnsavedDialog = false; - if (this.$refs.channelsetform.validate()) { - let promise; - if (this.isNew) { - promise = this.commitChannelSet({ id: this.channelSetId, ...this.diffTracker }); - } else { - promise = this.saveChannels().then(() => { - return this.updateChannelSet({ id: this.channelSetId, ...this.diffTracker }); - }); - } - promise - .then(() => { - this.close(); - }) - .finally(() => { - this.saving = false; - }); - } - }, + + const newCollectionId = newCollection.id; + + + this.$router.replace({ name: 'CHANNEL_SET_DETAILS', params: { channelSetId: newCollectionId } }); + + return newCollection; + }).catch(error => { + console.error("Error while creating collection:", error); + this.saving = false; + }); + } else { + promise = this.saveChannels().then(() => { + return this.updateChannelSet({ id: this.channelSetId, ...this.diffTracker }); + }); + } + + promise + .then(() => { + this.close(); + }) + .finally(() => { + this.saving = false; + }); + } +}, + + + cancelChanges() { if (this.changed) { this.showUnsavedDialog = true; @@ -360,6 +393,7 @@ this.diffTracker = {}; this.$router.push({ name: RouteNames.CHANNEL_SETS }); }, + verifyChannelSet(channelSetId) { return new Promise((resolve, reject) => { // Check if we already have the channel locally @@ -387,7 +421,9 @@ }); }); }, - }, +}, + + $trs: { creatingChannelSet: 'New collection', collectionErrorText: 'This collection does not exist', diff --git a/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js b/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js index 7d35025152..bad5e4a610 100644 --- a/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js +++ b/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js @@ -42,9 +42,14 @@ export function commitChannelSet( { id, name = NOVALUE, description = NOVALUE, channels = [] } = {} ) { const channelSetData = {}; + if (!id) { - throw ReferenceError('id must be defined to commit a channel'); + + channelSetData.isNew = true; + } else { + channelSetData.id = id; } + if (name !== NOVALUE) { channelSetData.name = name; } @@ -55,12 +60,27 @@ export function commitChannelSet( for (const channel of channels) { channelSetData.channels[channel] = true; } + + return ChannelSet.createModel(channelSetData).then(data => { - context.commit('SET_CHANNELSET_NOT_NEW', id); + + if (!data || !data.id) { + console.error('Error: The created channel set does not have an ID', data); + throw new Error('The created channel set does not have an ID'); + } + + context.commit('SET_CHANNELSET_NOT_NEW', data.id); context.commit('UPDATE_CHANNELSET', data); + + return data; + }).catch(error => { + console.error('Error creating channel set:', error); + throw error; }); } + + export function updateChannelSet(context, { id, name = NOVALUE, description = NOVALUE } = {}) { const channelSetData = {}; if (!id) { From 8fb902a007ff99b61c5ade996e8a09b0a978dace Mon Sep 17 00:00:00 2001 From: shruti862 Date: Sat, 1 Feb 2025 22:40:47 +0530 Subject: [PATCH 02/14] new changes --- .../frontend/channelList/router.js | 2 +- .../views/ChannelSet/ChannelSetModal.vue | 92 +++++++++++-------- 2 files changed, 55 insertions(+), 39 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/router.js b/contentcuration/contentcuration/frontend/channelList/router.js index 9424ca5cfe..dde864c217 100644 --- a/contentcuration/contentcuration/frontend/channelList/router.js +++ b/contentcuration/contentcuration/frontend/channelList/router.js @@ -56,7 +56,7 @@ const router = new VueRouter({ name: RouteNames.NEW_CHANNEL_SET_DETAILS, path: '/collections/new', component: ChannelSetModal, - + props: true, }, { name: RouteNames.CATALOG_ITEMS, diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue index 40a5649260..5d7bddb074 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue @@ -382,45 +382,61 @@ } }, confirmCancel() { - if (this.isNew) { - return this.deleteChannelSet(this.channelSet).then(this.close); - } - this.close(); - }, - close() { - this.changed = false; - this.showUnsavedDialog = false; - this.diffTracker = {}; - this.$router.push({ name: RouteNames.CHANNEL_SETS }); - }, - - verifyChannelSet(channelSetId) { - return new Promise((resolve, reject) => { - // Check if we already have the channel locally - if (this.getChannelSet(channelSetId)) { - this.setup(); - resolve(); - return; - } + if (this.isNew) { + if (this.channelSet && this.channelSet.id) { + return this.deleteChannelSet(this.channelSet).then(this.close); + } else { + this.close(); + } + } else { + this.close(); + } +}, + + + close() { + this.changed = false; + this.showUnsavedDialog = false; + this.diffTracker = {}; + this.$router.push({ name: RouteNames.CHANNEL_SETS }); +}, + + +verifyChannelSet(channelSetId) { + + if (!channelSetId || channelSetId === 'new') { + + return Promise.resolve(); + } + + + if (this.getChannelSet(channelSetId)) { + this.setup(); + return Promise.resolve(); + } + + + return this.loadChannelSet(channelSetId).then(channelSet => { + if (channelSet) { + this.setup(); + return; + } + + + this.$router.replace({ name: 'NEW_CHANNEL_SET_DETAILS' }); + + this.$store.dispatch('errors/handleGenericError', { + errorType: ErrorTypes.PAGE_NOT_FOUND, + errorText: this.$tr('collectionErrorText'), + }); + }).catch(error => { + console.error("Error loading collection:", error); + this.$router.replace({ name: 'NEW_CHANNEL_SET_DETAILS' }); + }); +} + + - // If not, try to load the channel - this.loadChannelSet(channelSetId).then(channelset => { - // Did our fetch return any channels, then we have a channel! - if (channelset) { - this.setup(); - resolve(); - return; - } - // If not, reject! - - this.$store.dispatch('errors/handleGenericError', { - errorType: ErrorTypes.PAGE_NOT_FOUND, - errorText: this.$tr('collectionErrorText'), - }); - reject(); - }); - }); - }, }, From 14dde08104e8983fc6093ca3b32c1969b7461924 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sat, 1 Feb 2025 17:16:23 +0000 Subject: [PATCH 03/14] [pre-commit.ci lite] apply automatic fixes --- .../views/ChannelSet/ChannelSetList.vue | 8 +- .../views/ChannelSet/ChannelSetModal.vue | 196 +++++++++--------- .../channelList/vuex/channelSet/actions.js | 33 ++- 3 files changed, 112 insertions(+), 125 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue index a1470e8ba5..328c339997 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue @@ -107,11 +107,11 @@ }); }, methods: { - ...mapActions('channelSet', ['loadChannelSetList',]), + ...mapActions('channelSet', ['loadChannelSetList']), newChannelSet() { - this.$router.push({ - name: RouteNames.NEW_CHANNEL_SET_DETAILS, - }); + this.$router.push({ + name: RouteNames.NEW_CHANNEL_SET_DETAILS, + }); }, }, $trs: { diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue index 5d7bddb074..deadcf505b 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue @@ -197,12 +197,11 @@ showUnsavedDialog: false, diffTracker: {}, saving: false, - }; }, computed: { ...mapGetters('channelSet', ['getChannelSet']), - isNew() { + isNew() { return !this.channelSetId || this.$route.path === '/new'; }, nameRules() { @@ -250,10 +249,9 @@ }, beforeMount() { if (this.channelSetId) { - return this.verifyChannelSet(this.channelSetId); - } - else this.setup(); -}, + return this.verifyChannelSet(this.channelSetId); + } else this.setup(); + }, mounted() { this.updateTitleForPage(); }, @@ -304,7 +302,7 @@ removeChannel(channelId) { this.channels = this.channels.filter(c => c !== channelId); }, - + loadChannels() { if (this.channelSet.channels && this.channelSet.channels.length) { this.loadingChannels = true; @@ -327,52 +325,53 @@ this.title = this.isNew ? this.$tr('creatingChannelSet') : this.channelSet.name; }, save() { - if (this.saving) { - return; - } - this.saving = true; - this.showUnsavedDialog = false; - - if (this.$refs.channelsetform.validate()) { - let promise; - - if (this.isNew) { - const channelSetData = { ...this.diffTracker }; - promise = this.commitChannelSet(channelSetData).then(newCollection => { - - if (!newCollection || !newCollection.id) { - console.error("Error: New collection was not created properly.", newCollection); - this.saving = false; + if (this.saving) { return; } + this.saving = true; + this.showUnsavedDialog = false; + + if (this.$refs.channelsetform.validate()) { + let promise; + + if (this.isNew) { + const channelSetData = { ...this.diffTracker }; + promise = this.commitChannelSet(channelSetData) + .then(newCollection => { + if (!newCollection || !newCollection.id) { + console.error('Error: New collection was not created properly.', newCollection); + this.saving = false; + return; + } + + const newCollectionId = newCollection.id; + + this.$router.replace({ + name: 'CHANNEL_SET_DETAILS', + params: { channelSetId: newCollectionId }, + }); + + return newCollection; + }) + .catch(error => { + console.error('Error while creating collection:', error); + this.saving = false; + }); + } else { + promise = this.saveChannels().then(() => { + return this.updateChannelSet({ id: this.channelSetId, ...this.diffTracker }); + }); + } - const newCollectionId = newCollection.id; - - - this.$router.replace({ name: 'CHANNEL_SET_DETAILS', params: { channelSetId: newCollectionId } }); - - return newCollection; - }).catch(error => { - console.error("Error while creating collection:", error); - this.saving = false; - }); - } else { - promise = this.saveChannels().then(() => { - return this.updateChannelSet({ id: this.channelSetId, ...this.diffTracker }); - }); - } - - promise - .then(() => { - this.close(); - }) - .finally(() => { - this.saving = false; - }); - } -}, - - + promise + .then(() => { + this.close(); + }) + .finally(() => { + this.saving = false; + }); + } + }, cancelChanges() { if (this.changed) { @@ -382,64 +381,55 @@ } }, confirmCancel() { - if (this.isNew) { - if (this.channelSet && this.channelSet.id) { - return this.deleteChannelSet(this.channelSet).then(this.close); - } else { - this.close(); - } - } else { - this.close(); - } -}, - - - close() { - this.changed = false; - this.showUnsavedDialog = false; - this.diffTracker = {}; - this.$router.push({ name: RouteNames.CHANNEL_SETS }); -}, - - -verifyChannelSet(channelSetId) { - - if (!channelSetId || channelSetId === 'new') { - - return Promise.resolve(); - } - - - if (this.getChannelSet(channelSetId)) { - this.setup(); - return Promise.resolve(); - } - - - return this.loadChannelSet(channelSetId).then(channelSet => { - if (channelSet) { - this.setup(); - return; - } - - - this.$router.replace({ name: 'NEW_CHANNEL_SET_DETAILS' }); + if (this.isNew) { + if (this.channelSet && this.channelSet.id) { + return this.deleteChannelSet(this.channelSet).then(this.close); + } else { + this.close(); + } + } else { + this.close(); + } + }, - this.$store.dispatch('errors/handleGenericError', { - errorType: ErrorTypes.PAGE_NOT_FOUND, - errorText: this.$tr('collectionErrorText'), - }); - }).catch(error => { - console.error("Error loading collection:", error); - this.$router.replace({ name: 'NEW_CHANNEL_SET_DETAILS' }); - }); -} + close() { + this.changed = false; + this.showUnsavedDialog = false; + this.diffTracker = {}; + this.$router.push({ name: RouteNames.CHANNEL_SETS }); + }, + verifyChannelSet(channelSetId) { + if (!channelSetId || channelSetId === 'new') { + return Promise.resolve(); + } + if (this.getChannelSet(channelSetId)) { + this.setup(); + return Promise.resolve(); + } -}, + return this.loadChannelSet(channelSetId) + .then(channelSet => { + if (channelSet) { + this.setup(); + return; + } + + this.$router.replace({ name: 'NEW_CHANNEL_SET_DETAILS' }); + + this.$store.dispatch('errors/handleGenericError', { + errorType: ErrorTypes.PAGE_NOT_FOUND, + errorText: this.$tr('collectionErrorText'), + }); + }) + .catch(error => { + console.error('Error loading collection:', error); + this.$router.replace({ name: 'NEW_CHANNEL_SET_DETAILS' }); + }); + }, + }, - $trs: { creatingChannelSet: 'New collection', collectionErrorText: 'This collection does not exist', diff --git a/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js b/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js index bad5e4a610..9f48ccad83 100644 --- a/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js +++ b/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js @@ -44,10 +44,9 @@ export function commitChannelSet( const channelSetData = {}; if (!id) { - channelSetData.isNew = true; } else { - channelSetData.id = id; + channelSetData.id = id; } if (name !== NOVALUE) { @@ -61,26 +60,24 @@ export function commitChannelSet( channelSetData.channels[channel] = true; } - - return ChannelSet.createModel(channelSetData).then(data => { - - if (!data || !data.id) { - console.error('Error: The created channel set does not have an ID', data); - throw new Error('The created channel set does not have an ID'); - } + return ChannelSet.createModel(channelSetData) + .then(data => { + if (!data || !data.id) { + console.error('Error: The created channel set does not have an ID', data); + throw new Error('The created channel set does not have an ID'); + } - context.commit('SET_CHANNELSET_NOT_NEW', data.id); - context.commit('UPDATE_CHANNELSET', data); + context.commit('SET_CHANNELSET_NOT_NEW', data.id); + context.commit('UPDATE_CHANNELSET', data); - return data; - }).catch(error => { - console.error('Error creating channel set:', error); - throw error; - }); + return data; + }) + .catch(error => { + console.error('Error creating channel set:', error); + throw error; + }); } - - export function updateChannelSet(context, { id, name = NOVALUE, description = NOVALUE } = {}) { const channelSetData = {}; if (!id) { From 6f10821a1616b609efa9eece0e0b0689a96fa495 Mon Sep 17 00:00:00 2001 From: shruti862 Date: Tue, 18 Feb 2025 17:13:57 +0530 Subject: [PATCH 04/14] new commits --- .../frontend/channelList/router.js | 38 ++++++++++--------- .../views/ChannelSet/ChannelSetModal.vue | 2 +- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/router.js b/contentcuration/contentcuration/frontend/channelList/router.js index 252c0f2d4f..919831b814 100644 --- a/contentcuration/contentcuration/frontend/channelList/router.js +++ b/contentcuration/contentcuration/frontend/channelList/router.js @@ -17,6 +17,24 @@ const router = new VueRouter({ component: ChannelList, props: { listType: ChannelListTypes.EDITABLE }, }, + + { + name: RouteNames.CHANNEL_SETS, + path: '/collections', + component: ChannelSetList, + }, + { + name: RouteNames.NEW_CHANNEL_SET_DETAILS, + path: '/collections/new', + component: ChannelSetModal, + props: true, + }, + { + name: RouteNames.CHANNEL_SET_DETAILS, + path: '/collections/:channelSetId', + component: ChannelSetModal, + props: true, + }, { name: RouteNames.CHANNELS_STARRED, path: '/starred', @@ -47,23 +65,9 @@ const router = new VueRouter({ component: ChannelModal, props: true, }, - { - name: RouteNames.CHANNEL_SETS, - path: '/collections', - component: ChannelSetList, - }, - { - name: RouteNames.CHANNEL_SET_DETAILS, - path: '/collections/:channelSetId', - component: ChannelSetModal, - props: true, - }, - { - name: RouteNames.NEW_CHANNEL_SET_DETAILS, - path: '/collections/new', - component: ChannelSetModal, - props: true, - }, + + + { name: RouteNames.CATALOG_ITEMS, path: '/public', diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue index deadcf505b..6b8ed64bb1 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue @@ -202,7 +202,7 @@ computed: { ...mapGetters('channelSet', ['getChannelSet']), isNew() { - return !this.channelSetId || this.$route.path === '/new'; + return !this.channelSetId || this.$route.path === '/collections/new'; }, nameRules() { return [name => (name && name.trim().length ? true : this.$tr('titleRequiredText'))]; From e29d3d3845073a8737ade53bdf05e39f423818f7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:46:02 +0000 Subject: [PATCH 05/14] [pre-commit.ci lite] apply automatic fixes --- .../contentcuration/frontend/channelList/router.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/router.js b/contentcuration/contentcuration/frontend/channelList/router.js index 919831b814..be183f5061 100644 --- a/contentcuration/contentcuration/frontend/channelList/router.js +++ b/contentcuration/contentcuration/frontend/channelList/router.js @@ -17,7 +17,7 @@ const router = new VueRouter({ component: ChannelList, props: { listType: ChannelListTypes.EDITABLE }, }, - + { name: RouteNames.CHANNEL_SETS, path: '/collections', @@ -65,9 +65,7 @@ const router = new VueRouter({ component: ChannelModal, props: true, }, - - - + { name: RouteNames.CATALOG_ITEMS, path: '/public', From cdaec533da04ab59ec29bdd64e9da7c677dc71e9 Mon Sep 17 00:00:00 2001 From: shruti862 Date: Tue, 18 Feb 2025 18:43:15 +0530 Subject: [PATCH 06/14] fixed failing frontend test channelSetList.spec.js --- .../ChannelSet/__tests__/channelSetList.spec.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js index 813c48ffa3..102d6944c5 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js @@ -24,10 +24,17 @@ describe('channelSetList', () => { const createChannelSetStub = jest.fn().mockImplementation(() => Promise.resolve(id)); beforeEach(() => { wrapper = makeWrapper(createChannelSetStub); + wrapper.setData({ loading: false }); + }); - it('should create a new channel set when new set button is clicked', () => { - wrapper.setData({ loading: false }); - wrapper.find('[data-test="add-channelset"]').trigger('click'); - expect(createChannelSetStub).toHaveBeenCalled(); - }); + it('should open a new channel set modal when new set button is clicked', async () => { + const push = jest.fn(); + wrapper.vm.$router.push = push; + await wrapper.find('[data-test="add-channelset"]').trigger('click'); + expect(push).toHaveBeenCalledWith({ + name: RouteNames.NEW_CHANNEL_SET_DETAILS, + }); + }); + + }); From 274c29693abb70ff2f1dbf26ab068c5ab605d040 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:15:44 +0000 Subject: [PATCH 07/14] [pre-commit.ci lite] apply automatic fixes --- .../ChannelSet/__tests__/channelSetList.spec.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js index 102d6944c5..87da0a9157 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js @@ -24,17 +24,14 @@ describe('channelSetList', () => { const createChannelSetStub = jest.fn().mockImplementation(() => Promise.resolve(id)); beforeEach(() => { wrapper = makeWrapper(createChannelSetStub); - wrapper.setData({ loading: false }); - + wrapper.setData({ loading: false }); }); it('should open a new channel set modal when new set button is clicked', async () => { - const push = jest.fn(); - wrapper.vm.$router.push = push; - await wrapper.find('[data-test="add-channelset"]').trigger('click'); - expect(push).toHaveBeenCalledWith({ - name: RouteNames.NEW_CHANNEL_SET_DETAILS, - }); + const push = jest.fn(); + wrapper.vm.$router.push = push; + await wrapper.find('[data-test="add-channelset"]').trigger('click'); + expect(push).toHaveBeenCalledWith({ + name: RouteNames.NEW_CHANNEL_SET_DETAILS, }); - - + }); }); From c4a84cb83f82dbbea81b2e9078afbdcc454f81a4 Mon Sep 17 00:00:00 2001 From: shruti862 Date: Tue, 18 Feb 2025 19:02:05 +0530 Subject: [PATCH 08/14] changed channelSetModal.spec.js test --- .../__tests__/channelSetModal.spec.js | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetModal.spec.js b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetModal.spec.js index 5ea74f9258..94aff8ae13 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetModal.spec.js +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetModal.spec.js @@ -10,7 +10,7 @@ import channelSet from '../../../vuex/channelSet'; import ChannelSetModal from '../ChannelSetModal'; import channel from 'shared/vuex/channel'; import storeFactory from 'shared/vuex/baseStore'; -import { NEW_OBJECT } from 'shared/constants'; + const localVue = createLocalVue(); localVue.use(Vuex); @@ -39,11 +39,6 @@ const CHANNEL_SET = { }, }; -const NEW_CHANNEL_SET = { - id: 'id-new-channel-set', - channels: [], - [NEW_OBJECT]: true, -}; const loadChannelSetMock = (cs, store) => { return jest.fn().mockImplementation(() => { @@ -238,20 +233,6 @@ describe('ChannelSetModal', () => { expect(wrapper.vm.$route.name).toBe(RouteNames.CHANNEL_SETS); }); - it('should delete a channel set if it is new', () => { - const storeConfig = cloneDeep(STORE_CONFIG); - const deleteChannelSet = jest.fn(); - storeConfig.modules.channelSet.actions.deleteChannelSet = deleteChannelSet; - const store = storeFactory(storeConfig); - store.commit('channelSet/ADD_CHANNELSET', NEW_CHANNEL_SET); - - wrapper = makeWrapper({ store, channelSetId: NEW_CHANNEL_SET.id }); - - getCloseButton(wrapper).trigger('click'); - expect(deleteChannelSet).toHaveBeenCalledTimes(1); - expect(deleteChannelSet.mock.calls[0][1]).toEqual(NEW_CHANNEL_SET); - }); - it('should prompt user if there are unsaved changes', () => { expect(getUnsavedDialog(wrapper).attributes('data-test-visible')).toBeFalsy(); From 955ce06669215180613ea5d0bb577b1ca0bbb76f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:34:08 +0000 Subject: [PATCH 09/14] [pre-commit.ci lite] apply automatic fixes --- .../views/ChannelSet/__tests__/channelSetModal.spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetModal.spec.js b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetModal.spec.js index 94aff8ae13..5c417f3fcc 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetModal.spec.js +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetModal.spec.js @@ -11,7 +11,6 @@ import ChannelSetModal from '../ChannelSetModal'; import channel from 'shared/vuex/channel'; import storeFactory from 'shared/vuex/baseStore'; - const localVue = createLocalVue(); localVue.use(Vuex); localVue.use(VueRouter); @@ -39,7 +38,6 @@ const CHANNEL_SET = { }, }; - const loadChannelSetMock = (cs, store) => { return jest.fn().mockImplementation(() => { store.commit('channelSet/ADD_CHANNELSET', cs); From 02b9e52fe32496eb1e90930a7dcdaddefa5a3661 Mon Sep 17 00:00:00 2001 From: shruti862 Date: Thu, 20 Feb 2025 00:22:50 +0530 Subject: [PATCH 10/14] done suggested changes --- .../contentcuration/frontend/channelList/constants.js | 2 +- .../contentcuration/frontend/channelList/router.js | 2 +- .../channelList/views/ChannelSet/ChannelSetList.vue | 2 +- .../channelList/views/ChannelSet/ChannelSetModal.vue | 11 ++++++----- .../frontend/channelList/vuex/channelSet/actions.js | 4 +--- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/constants.js b/contentcuration/contentcuration/frontend/channelList/constants.js index 9855c12b9b..a0d89c28da 100644 --- a/contentcuration/contentcuration/frontend/channelList/constants.js +++ b/contentcuration/contentcuration/frontend/channelList/constants.js @@ -21,7 +21,7 @@ export const RouteNames = { CHANNEL_EDIT: 'CHANNEL_EDIT', CHANNEL_SETS: 'CHANNEL_SETS', CHANNEL_SET_DETAILS: 'CHANNEL_SET_DETAILS', - NEW_CHANNEL_SET_DETAILS: 'NEW_CHANNEL_SET_DETAILS', + NEW_CHANNEL_SET : 'NEW_CHANNEL_SET', CATALOG_ITEMS: 'CATALOG_ITEMS', CATALOG_DETAILS: 'CATALOG_DETAILS', CATALOG_FAQ: 'CATALOG_FAQ', diff --git a/contentcuration/contentcuration/frontend/channelList/router.js b/contentcuration/contentcuration/frontend/channelList/router.js index be183f5061..533057ef1b 100644 --- a/contentcuration/contentcuration/frontend/channelList/router.js +++ b/contentcuration/contentcuration/frontend/channelList/router.js @@ -24,7 +24,7 @@ const router = new VueRouter({ component: ChannelSetList, }, { - name: RouteNames.NEW_CHANNEL_SET_DETAILS, + name: RouteNames.NEW_CHANNEL_SET, path: '/collections/new', component: ChannelSetModal, props: true, diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue index 328c339997..372d36ea35 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetList.vue @@ -110,7 +110,7 @@ ...mapActions('channelSet', ['loadChannelSetList']), newChannelSet() { this.$router.push({ - name: RouteNames.NEW_CHANNEL_SET_DETAILS, + name: RouteNames.NEW_CHANNEL_SET, }); }, }, diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue index 6b8ed64bb1..4af5e394c1 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue @@ -249,8 +249,10 @@ }, beforeMount() { if (this.channelSetId) { - return this.verifyChannelSet(this.channelSetId); - } else this.setup(); + return this.verifyChannelSet(this.channelSetId); + } else { + this.setup(); + } }, mounted() { this.updateTitleForPage(); @@ -339,7 +341,6 @@ promise = this.commitChannelSet(channelSetData) .then(newCollection => { if (!newCollection || !newCollection.id) { - console.error('Error: New collection was not created properly.', newCollection); this.saving = false; return; } @@ -416,7 +417,7 @@ return; } - this.$router.replace({ name: 'NEW_CHANNEL_SET_DETAILS' }); + this.$router.replace({ name: 'NEW_CHANNEL_SET' }); this.$store.dispatch('errors/handleGenericError', { errorType: ErrorTypes.PAGE_NOT_FOUND, @@ -425,7 +426,7 @@ }) .catch(error => { console.error('Error loading collection:', error); - this.$router.replace({ name: 'NEW_CHANNEL_SET_DETAILS' }); + this.$router.replace({ name: 'NEW_CHANNEL_SET' }); }); }, }, diff --git a/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js b/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js index 9f48ccad83..01832ea1e9 100644 --- a/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js +++ b/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js @@ -63,8 +63,7 @@ export function commitChannelSet( return ChannelSet.createModel(channelSetData) .then(data => { if (!data || !data.id) { - console.error('Error: The created channel set does not have an ID', data); - throw new Error('The created channel set does not have an ID'); + throw ReferenceError('id must be defined to commit a channel'); } context.commit('SET_CHANNELSET_NOT_NEW', data.id); @@ -73,7 +72,6 @@ export function commitChannelSet( return data; }) .catch(error => { - console.error('Error creating channel set:', error); throw error; }); } From db1e7071dd9c6353d00fd9141b661e4d81e1ffb3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:55:59 +0000 Subject: [PATCH 11/14] [pre-commit.ci lite] apply automatic fixes --- .../contentcuration/frontend/channelList/constants.js | 2 +- .../frontend/channelList/views/ChannelSet/ChannelSetModal.vue | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/constants.js b/contentcuration/contentcuration/frontend/channelList/constants.js index a0d89c28da..e2caafa367 100644 --- a/contentcuration/contentcuration/frontend/channelList/constants.js +++ b/contentcuration/contentcuration/frontend/channelList/constants.js @@ -21,7 +21,7 @@ export const RouteNames = { CHANNEL_EDIT: 'CHANNEL_EDIT', CHANNEL_SETS: 'CHANNEL_SETS', CHANNEL_SET_DETAILS: 'CHANNEL_SET_DETAILS', - NEW_CHANNEL_SET : 'NEW_CHANNEL_SET', + NEW_CHANNEL_SET: 'NEW_CHANNEL_SET', CATALOG_ITEMS: 'CATALOG_ITEMS', CATALOG_DETAILS: 'CATALOG_DETAILS', CATALOG_FAQ: 'CATALOG_FAQ', diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue index 4af5e394c1..aff50d5135 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue @@ -249,9 +249,9 @@ }, beforeMount() { if (this.channelSetId) { - return this.verifyChannelSet(this.channelSetId); + return this.verifyChannelSet(this.channelSetId); } else { - this.setup(); + this.setup(); } }, mounted() { From e0f4272600363806f890171f87c3bb73530b03da Mon Sep 17 00:00:00 2001 From: shruti862 Date: Thu, 20 Feb 2025 00:33:50 +0530 Subject: [PATCH 12/14] new commit --- .../views/ChannelSet/__tests__/channelSetList.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js index 87da0a9157..22eb2189e8 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSetList.spec.js @@ -31,7 +31,7 @@ describe('channelSetList', () => { wrapper.vm.$router.push = push; await wrapper.find('[data-test="add-channelset"]').trigger('click'); expect(push).toHaveBeenCalledWith({ - name: RouteNames.NEW_CHANNEL_SET_DETAILS, + name: RouteNames.NEW_CHANNEL_SET, }); }); }); From c8983fe8cebe7cf2242cba8237107d4d21f36daf Mon Sep 17 00:00:00 2001 From: shruti862 Date: Fri, 21 Feb 2025 21:32:17 +0530 Subject: [PATCH 13/14] new changes done --- .../views/ChannelSet/ChannelSetModal.vue | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue index aff50d5135..5422b4c68f 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue @@ -202,7 +202,7 @@ computed: { ...mapGetters('channelSet', ['getChannelSet']), isNew() { - return !this.channelSetId || this.$route.path === '/collections/new'; + return this.$route.path === '/collections/new'; }, nameRules() { return [name => (name && name.trim().length ? true : this.$tr('titleRequiredText'))]; @@ -354,8 +354,7 @@ return newCollection; }) - .catch(error => { - console.error('Error while creating collection:', error); + .catch(()=> { this.saving = false; }); } else { @@ -401,33 +400,29 @@ }, verifyChannelSet(channelSetId) { - if (!channelSetId || channelSetId === 'new') { - return Promise.resolve(); - } - - if (this.getChannelSet(channelSetId)) { - this.setup(); - return Promise.resolve(); - } - - return this.loadChannelSet(channelSetId) - .then(channelSet => { - if (channelSet) { + return new Promise((resolve, reject) => { + // Check if we already have the channel locally + if (this.getChannelSet(channelSetId)) { + this.setup(); + resolve(); + return; + } + // If not, try to load the channel + this.loadChannelSet(channelSetId).then(channelset => { + // Did our fetch return any channels, then we have a channel! + if (channelset) { this.setup(); + resolve(); return; } - - this.$router.replace({ name: 'NEW_CHANNEL_SET' }); - + // If not, reject! this.$store.dispatch('errors/handleGenericError', { errorType: ErrorTypes.PAGE_NOT_FOUND, errorText: this.$tr('collectionErrorText'), }); - }) - .catch(error => { - console.error('Error loading collection:', error); - this.$router.replace({ name: 'NEW_CHANNEL_SET' }); + reject(); }); + }); }, }, From c0d8164674c97d8e0b30505141d0378e438ca6fa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 16:05:12 +0000 Subject: [PATCH 14/14] [pre-commit.ci lite] apply automatic fixes --- .../frontend/channelList/views/ChannelSet/ChannelSetModal.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue index 5422b4c68f..282c34eb1a 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSetModal.vue @@ -202,7 +202,7 @@ computed: { ...mapGetters('channelSet', ['getChannelSet']), isNew() { - return this.$route.path === '/collections/new'; + return this.$route.path === '/collections/new'; }, nameRules() { return [name => (name && name.trim().length ? true : this.$tr('titleRequiredText'))]; @@ -354,7 +354,7 @@ return newCollection; }) - .catch(()=> { + .catch(() => { this.saving = false; }); } else {