-
Notifications
You must be signed in to change notification settings - Fork 90
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
refactor: block creation in libraries v2 #1574
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, @dcoa! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.
|
94b0493
to
6af6ee7
Compare
f70d770
to
b8ecbe2
Compare
Hey @dcoa , I'm interested in making sure this gets across the line. Is there anything blocking you or anything that you'd like a second set of eyes on? |
It just occurred to me that if we need a place to store uploaded static assets when they're uploaded before saving, we could potentially use StagedContent to hold the draft version of the new component. Not sure if it's a good idea or if we should just save things locally in the browser, which is another alternative. |
Sorry, I have had some issues with the pc and additional tasks that slow my progress, but I will continue working on it tomorrow, most of the code is already functional but I need to change the reset logic a little bit. Thanks @bradenmacdonald for your help giving me options for the images issue, I will start testing that. |
e995900
to
8c23e0d
Compare
8c23e0d
to
e677ed0
Compare
871b242
to
4832895
Compare
4832895
to
3dd53d4
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1574 +/- ##
==========================================
- Coverage 93.23% 93.20% -0.04%
==========================================
Files 1098 1100 +2
Lines 21709 21887 +178
Branches 4593 4744 +151
==========================================
+ Hits 20240 20399 +159
- Misses 1404 1414 +10
- Partials 65 74 +9 ☔ View full report in Codecov by Sentry. |
1773448
to
a8f286c
Compare
fc1b4cf
to
82e5d80
Compare
@kdmccormick @bradenmacdonald hi, I think the PR is good to start the review process (I just need to fix some test coverage - but the functionality is already implemented and working) |
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.
Very nice work @dcoa ! This is exciting to see and will be a really big improvement.
app: app.reducer, | ||
requests: requests.reducer, | ||
video: video.reducer, | ||
problem: problem.reducer, | ||
game: game.reducer, | ||
}); | ||
|
||
const rootReducer = (state: any, action: any) => { | ||
if (action.type === 'resetEditor') { |
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'm kind of surprised we didn't have this resetEditor
before.
const problemTitles = new Set([...Object.values(ProblemTypes).map((problem) => problem.title), | ||
...Object.values(AdvanceProblems).map((problem) => problem.title)]); | ||
|
||
definitionId = problemTitles.has(blockTitle) ? `${uuid4()}` : definitionId; |
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 you please add a comment to explain what this code is doing? It's not clear to me what it's for, and why it sometimes needs a UUID as the definition 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.
The problem editor has 2 steps, fist you need to select the type of problem and secondly edit/add the content. When the problem type is selected that becomes the block title, if the user don't change it will create the UUID to avoid create blocks with the default title and eventually avoid the definitionId
is already taken problem.
promise: createLibraryBlock({ | ||
libraryId: selectors.app.learningContextId(getState()), | ||
blockType: selectors.app.blockType(getState()), | ||
definitionId, | ||
}), |
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.
Should we throw an error if the learning context is not a library, but we get to this function? Or is that definitely impossible?
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.
At the moment only libraries launch the creation action (I didn't modify courses workflow so it could be manage in a different PR and avoid make something too large and hard for reviewing)
const blockTitle = selectors.app.blockTitle(getState()); | ||
let definitionId = blockTitle | ||
? blockTitle.toLowerCase().replaceAll(' ', '-') | ||
: `${uuid4()}`; |
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.
This can happen in a follow-up PR, but I think we need a better way to handle what happens when this definitionId
is already taken. It should automatically generate a unique ID by appending a number to the definitionId, but instead it just throws an error:
This error could be confusing for users since it's based on the title, but titles aren't required to be unique.
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 used the title based on my understanding of #1384 (comment), a possible fix could be add a shorten hash after the title part.
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.
a possible fix could be add a shorten hash after the title part.
That makes sense to me, yep.
3ac5427
to
f350757
Compare
f350757
to
9a547a6
Compare
Thanks for those changes! I'll test this again tomorrow :) I've also asked if anyone else wants to review it. |
f4d678b
to
c67b88d
Compare
5f19a99
to
bb57bd4
Compare
bb57bd4
to
2a96990
Compare
Description
This PR changes the way components are creating in libraries V2 with the purpose to avoid the creation of a blank component as fist step, behavior that have the following problems:
Supporting information
This PR is liked to #1482 (comment) issue.
Testing instructions
[text, video, problem]
usage_key
block.Other information
Include anything else that will help reviewers and consumers understand the change.