Skip to content
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

Merged
merged 20 commits into from
Feb 24, 2025

Conversation

shruti862
Copy link
Contributor

@shruti862 shruti862 commented Feb 1, 2025

Summary

Made the URL of new collection page more generic i.e. (/collections/new)
Screenshot from 2025-02-01 22-44-08

References

Fixes #2450

Reviewer guidance

@akolson
Copy link
Member

akolson commented Feb 11, 2025

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.

@akolson akolson self-assigned this Feb 11, 2025
@shruti862
Copy link
Contributor Author

Hey @akolson, I’ve already gone through the guidance provided by @bjester. However, since my midsem exams are currently ongoing, I haven’t had time to work on it. I’ll get back to this issue in 2-3 days. Until then, as you suggested, I’m marking this PR as a draft.

@shruti862 shruti862 marked this pull request as draft February 11, 2025 18:43
@akolson
Copy link
Member

akolson commented Feb 11, 2025

Thanks @shruti862 for the heads-up, and no pressure at all. Best wishes in your exams. See you soon! 👋

@shruti862
Copy link
Contributor Author

Hey @akolson @bjester , The PR is ready for review :) please have a look whenever you get time .

@shruti862 shruti862 marked this pull request as ready for review February 18, 2025 11:48
@@ -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',
Copy link
Member

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.

Copy link
Member

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);
Copy link
Member

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');
Copy link
Member

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);
Copy link
Member

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();
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@akolson akolson Feb 21, 2025

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?

@shruti862
Copy link
Contributor Author

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';
Copy link
Member

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);
Copy link
Member

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') {
Copy link
Member

@akolson akolson Feb 21, 2025

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);
Copy link
Member

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

export function loadChannelSet(context, id) {
return ChannelSet.get(id)
.then(channelSet => {
context.commit('ADD_CHANNELSET', channelSet);
return channelSet;
})
.catch(() => {
return;
});
}

});
});
},
},
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@akolson akolson left a 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.

@shruti862
Copy link
Contributor Author

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?

@akolson akolson self-requested a review February 21, 2025 18:22
Copy link
Member

@akolson akolson left a 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!

@akolson akolson merged commit 184cfbf into learningequality:unstable Feb 24, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problems with page refresh on a new collection page
3 participants