-
Notifications
You must be signed in to change notification settings - Fork 193
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
Made URL of new collection page generic #4890
Conversation
Hi @shruti862! Thank you for the great work so far. @bjester provided some guidance to your question. Also, be sure to let us know incase you have any other questions. Optional, but you could mark your pr as draft if still actively working in it and open it once it's ready for a review. Or alternatively, whenever you are done, give us a head-up so we can checkout your changes. Thanks for working on this issue. |
Thanks @shruti862 for the heads-up, and no pressure at all. Best wishes in your exams. See you soon! 👋 |
@@ -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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to NEW_CHANNEL_SET
instead for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NEW_CHANNEL_SET : 'NEW_CHANNEL_SET'
return ChannelSet.createModel(channelSetData) | ||
.then(data => { | ||
if (!data || !data.id) { | ||
console.error('Error: The created channel set does not have an ID', data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
.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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can throw a less generic error here. We could reuse ReferenceError
?
return data; | ||
}) | ||
.catch(error => { | ||
console.error('Error creating channel set:', error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
return this.verifyChannelSet(this.channelSetId); | ||
if (this.channelSetId) { | ||
return this.verifyChannelSet(this.channelSetId); | ||
} else this.setup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the syntax consistent here?
if (this.channelSetId) {
return this.verifyChannelSet(this.channelSetId);
} else {
this.setup();
}
Also, is there any reason we are returning this.verifyChannelSet
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @akolson
this.verifyChannelSet
is invoked for existing collections in the edit functionality to verify the existence of the associated channelSetId
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shruti862 I see. What would be the significance in returning its value to the beforeMount()
hook?
Hey @akolson , I have done all the suggested changes :) |
@@ -199,7 +202,7 @@ | |||
computed: { | |||
...mapGetters('channelSet', ['getChannelSet']), | |||
isNew() { | |||
return Boolean(this.channelSet[NEW_OBJECT]); | |||
return !this.channelSetId || this.$route.path === '/collections/new'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there scenarios where channelSetId
is empty(not set) and we are not creating a new collection?
return newCollection; | ||
}) | ||
.catch(error => { | ||
console.error('Error while creating collection:', error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
resolve(); | ||
return; | ||
} | ||
if (!channelSetId || channelSetId === 'new') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't seem to see where channelSetId
is being set to new
for the or
part of this condition to be successful?
reject(); | ||
}) | ||
.catch(error => { | ||
console.error('Error loading collection:', error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the loadChannelSet
error being suppressed, I don't think this will be useful
studio/contentcuration/contentcuration/frontend/channelList/vuex/channelSet/actions.js
Lines 12 to 21 in dbb5a63
export function loadChannelSet(context, id) { | |
return ChannelSet.get(id) | |
.then(channelSet => { | |
context.commit('ADD_CHANNELSET', channelSet); | |
return channelSet; | |
}) | |
.catch(() => { | |
return; | |
}); | |
} |
}); | ||
}); | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is generally not clear to me why we are returning a promise in some parts of this method i.e the lines with return Promise.resolve();
. Is there a motivation behind this? It doesn't look like we need to return them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @akolson , It seems that there is no need to change verifyChannelSet method so I just replaced it with older version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shruti862 great work, we are surely getting closer! I left a few additional comments and some clarifying questions. Thanks again.
Hey @akolson, thanks for your great review! I’ve made some changes to the code to accommodate your suggestions. Could you please take a look when you have a moment? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. I also did a bit of manual testing and everything seems to work just fine, also resolves the bug reported. Thank you @shruti862!
Summary
Made the URL of new collection page more generic i.e. (/collections/new)

References
Fixes #2450
Reviewer guidance
…