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
feat: Pages and Resources components [BD-38] [TNL-8101] [BB-3972] #63
feat: Pages and Resources components [BD-38] [TNL-8101] [BB-3972] #63
Conversation
Thanks for the pull request, @xitij2000! I've created BLENDED-810 to keep track of it in Jira. When this pull request is ready, tag your edX technical lead. |
src/pages-and-resources/app-settings-modal/AppSettingsModal.jsx
Outdated
Show resolved
Hide resolved
(tweaked the PR title to use conventional commits, as per the new OEP: https://github.com/edx/open-edx-proposals/blob/master/oeps/oep-0051-bp-conventional-commits.rst) |
@davidjoy This is stil WIP, and I plan to squash the commits with a proper message before this is ready. |
e1bb64f
to
42e637b
Compare
42e637b
to
0518865
Compare
@xitij2000 Can you also add screenshots of how the pages look like? |
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.
Some Logical and Console Errors are there which may be because this work is in progress. other things we have reviewed and have listed our findings for your reference.
src/pages-and-resources/app-settings-modal/AppSettingsModal.jsx
Outdated
Show resolved
Hide resolved
> | ||
<h3>{title}</h3> | ||
<AppConfigFormDivider /> | ||
<Form onSubmit={onApply}> |
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.
why are not we using the Formik library for form management? by convention we are using Formik forms in codebase.
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 PR started before that became convention :-)
I'll update this code to use that.
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.
Actually I think in this case Formik might not work as well since the the base form doesn't know about the form elements injected in the child component.
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.
We can use Formik
in AppSettingsModal I see no reason why we can’t.
The structure of form does not look good to me and the modal is not closing on submit.
The type=submit
will also work if you place this button inside form closing tag. I think this needs to be revisited.
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.
We can use Formik in AppSettingsModal I see no reason why we can’t.
The reason using Formik here is harder is that the form is crated in AppSettingsModal, but the contents of the form will be created elsewhere. So Formik here will not know what all form elements the child components have added.
The fact that we can't use it here, doesn't mean we can't use it at all. We can use it in individual components, so I'll update those and share.
The structure of form does not look good to me and the modal is not closing on submit.
Could you highlight what doesn't look about the structure of the form?
The modal is not closing on submit on purpose for a couple of reasons:
- The apply operation is a remote operation, so we'd want to convey the saving state, possibly via a stateful apply button, or some other UI element. So the form shouldn't close till the data is saved and we've confirmed to the use that the data is saved.
- If the saving fails, and the form closes, it could be irritating for users so have to reopen the page, apply all the changes again (it could be a lot of teamsets) and then try saving again.
- A user might want to make a couple of changes, apply them, and continue editing.
The type=submit will also work if you place this button inside form closing tag. I think this needs to be revisited.
I'll see if I can do something to restructure this to allow that to work.
{isDeleting | ||
? ( | ||
<div className="d-flex flex-column m-4" key="isDeleting"> | ||
<h3>{intl.formatMessage(messages.team_set_delete_heading)}</h3> | ||
<p>{intl.formatMessage(messages.team_set_delete_body)}</p> | ||
<div className="d-flex flex-row justify-content-end"> | ||
<Button variant="muted" size="sm" onClick={() => onDelete(teamSet)}> | ||
{intl.formatMessage(messages.delete)} | ||
</Button> | ||
<Button variant="muted" size="sm" onClick={cancelDeletion}> | ||
{intl.formatMessage(messages.cancel)} | ||
</Button> | ||
</div> | ||
</div> | ||
) |
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.
Suggestion: this should be in generics to be used in other components as well. this is already in use at other places in the application.
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 not sure what exactly you're referring to here?
91106ba
to
3832f35
Compare
Codecov Report
@@ Coverage Diff @@
## master #63 +/- ##
==========================================
- Coverage 73.31% 68.56% -4.76%
==========================================
Files 67 75 +8
Lines 1023 1091 +68
Branches 192 211 +19
==========================================
- Hits 750 748 -2
- Misses 268 338 +70
Partials 5 5
Continue to review full report at Codecov.
|
Done. |
return useFormik({ | ||
initialValues: { | ||
enabled: !!appInfo?.enabled, | ||
...initialValues, | ||
}, | ||
validationSchema: Yup.object() | ||
.shape({ | ||
enabled: Yup.boolean(), | ||
...validationSchema, | ||
}), | ||
onSubmit: handleSubmit, | ||
}); |
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.
useFormik limits us sometimes we are restricted in many features e.g
Field, FastField, ErrorMessage, connect(), and FieldArray will NOT work with useFormik() as they all require React Context you can learn more here
Considering future perspective its best to use <Formik />
component instead which is more powerful.
As you can see in figma when you will need to work on team settings you will need to work with <FieldArray>
then useFormik will not work. for help you can take help from this already implemented example
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.
any thought on this one?
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 will investigate this and update the PR accordingly.
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've updated the code to use Formik as you suggested.
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.
there are two pending things on this PR, I think if we can agree on some point on this we will be able to close it soon.
<div> | ||
{page.showStatus && <span>{intl.formatMessage(messages[pageStatusMsgId])}</span>} | ||
<div className="my-1"> | ||
<StatusBadge status={page.enabled} /> |
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 the padding of the status badge is also needed to be fixed. The dividers used not part of the Figma design and are going out from both sides of the modal. you can see that in the attached video as well. if that is needed to be fixed in this PR. then you might need to look at it again.
return useFormik({ | ||
initialValues: { | ||
enabled: !!appInfo?.enabled, | ||
...initialValues, | ||
}, | ||
validationSchema: Yup.object() | ||
.shape({ | ||
enabled: Yup.boolean(), | ||
...validationSchema, | ||
}), | ||
onSubmit: handleSubmit, | ||
}); |
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.
any thought on this one?
22fe883
to
ddc937f
Compare
src/pages-and-resources/app-settings-modal/AppSettingsModal.jsx
Outdated
Show resolved
Hide resolved
src/pages-and-resources/app-settings-modal/AppSettingsModal.jsx
Outdated
Show resolved
Hide resolved
|
||
export function enableDisableApp(courseId, appId, state, syncChange = false) { | ||
return async (dispatch) => { | ||
if (!syncChange) { |
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.
Why this piece of if
condition needed here? When we only need to update store and not make an API call? Can you elaborate?
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.
Yes, it's used to persist state to the store without changing the state on the server.
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.
Whats' the use case for this?
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.
Hmm, I think it was used in a previous version of the code that got refactored out.
But generally the idea was, that if a user is applying complex changes to something like teams, you keep all those changes in the store, and save then so if the page accidentally closes, you don't lose those changes. You can then pick up where you left off and sync.
showStatus: PropTypes.bool.isRequired, | ||
showEnable: PropTypes.bool.isRequired, | ||
enabled: PropTypes.bool.isRequired, | ||
allowed_operations: PropTypes.shape({ |
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 should be =>allowedOperations
<h3>{title}</h3> | ||
<AppConfigFormDivider /> | ||
<FormSwitchGroup | ||
id={`enable-${appId}-toggle`} |
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.
Just checking why this ID is needed? The general perception for addingid
s is to things if we need to use the ID somewhere e.g. tests or referencing. I can't see any usage of this.
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 required by the FormSwitchGroup so I added it. I will update the component to make it optional.
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 see, thank you.
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.
Actually, reading through the comments in FormSwitchGroup it seems that currently you need to attach a label to the switch component.
16e22a5
to
b8da9e9
Compare
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 changes looks good now, thanks for addressing them @xitij2000 :)
This PR looks good to me. can you please rebase your commits in 1 commit and insert a commit message following commit conventions. Also, Let me know when you need to merge it. I will do that. |
…ration Hooks up the course apps API so that the data returned by the server is being used. Adds the base components and infrastructure to enable adding pages for configuring each app.
b8da9e9
to
5ad7f43
Compare
I've squashed down to a single commit. |
Pr merged. |
@awaisdar001 Thanks! |
TNL-8101 / TNL-8450
Hooks up the course apps API so that the data returned by the server is being used.
Adds the base components and infrastructure to enable adding pages for configuring each app.
This PR adds the foundation to the UI for adding settings components for individual pages in future PRs.
course-apps-calculator.mp4