-
Notifications
You must be signed in to change notification settings - Fork 124
feat: add slot to extend the profile fields #1211
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, @bra-i-am! 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. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1211 +/- ##
==========================================
+ Coverage 72.89% 72.97% +0.07%
==========================================
Files 49 50 +1
Lines 797 803 +6
Branches 219 219
==========================================
+ Hits 581 586 +5
- Misses 205 206 +1
Partials 11 11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 was testing this PluginSlot, thanks to README It was easy. I like this kind of contributions.We need to expand our range of plugin slots and it is good to have this example base
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.
Everything in the PR looks good to me overall. One suggestion: it might be better to update the plugin so that it only installs the form for the profile/account MFE. This would help keep things more scoped and prevent unnecessary installations. couldn't replicate the changes locally due to some environment configs not loading, but the logic looks solid.
I tested with this plugin and I could build the MFE images with no problems:
from tutormfe.hooks import PLUGIN_SLOTS
from tutor import hooks
hooks.Filters.ENV_PATCHES.add_item(
(
"mfe-dockerfile-post-npm-install-profile",
"""
# npm package
RUN npm install '@edunext/frontend-component-extended-fields@latest' --force
""",
)
)
hooks.Filters.ENV_PATCHES.add_item(
(
"mfe-dockerfile-post-npm-install-account",
"""
# npm package
RUN npm install '@edunext/frontend-component-extended-fields@latest' --force
""",
)
)
hooks.Filters.ENV_PATCHES.add_item(
(
"mfe-env-config-buildtime-imports-profile",
"""
import { ExtendedProfileFields } from '@edunext/frontend-component-extended-fields';
""",
)
)
hooks.Filters.ENV_PATCHES.add_item(
(
"mfe-env-config-buildtime-imports-account",
"""
import { ExtendedProfileFields } from '@edunext/frontend-component-extended-fields';
""",
)
)
PLUGIN_SLOTS.add_items(
[
(
"profile",
"extended_profile_fields_slot",
"""
{
op: PLUGIN_OPERATIONS.Insert,
widget: {
id: 'extended_profile_fields',
type: DIRECT_PLUGIN,
RenderWidget: ExtendedProfileFields,
},
}""",
),
]
)
I want to take this opportunity to mention a few things in the steps to test this development: There is no mention of the use of this branch in our Local TutorAdd the next script to tutor plugin to override the branch of Profle MFE from tutormfe.hooks import MFE_APPS
@MFE_APPS.add()
def _add_my_mfe(mfes):
mfes["profile"] = {
"repository": "https://github.com/edunext/frontend-app-profile.git",
"port": 1995,
"version": "bc/add-extra-fields-slot",
} Another way we can do this in the queue is by using
import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework';
import { ExtendedProfileFields } from '@edunext/frontend-component-extended-fields';
// Load environment variables from .env file
const config = {
...process.env,
pluginSlots: {
extended_profile_fields_slot: {
plugins: [
{
op: PLUGIN_OPERATIONS.Insert,
widget: {
id: 'extended_profile_fields',
type: DIRECT_PLUGIN,
RenderWidget: ExtendedProfileFields,
},
},
],
},
},
};
export default config; Problem with backend to update valuesI think this problem is not associate with this PR, but maybe we have to mention this in troubleshooting section Install dependency only in Profile and Account MFEWhat Andres mentions is important, we don't have to install Finally @bra-i-am I don't see anything about the PR of |
@Asespinel, thank you for your review. I'll be working on the change of the plugin you mentioned! I hope the issue is gone, and you can test it properly. Please let me know any other comments/questions you have ✨ |
@jignaciopm, thank you again for your review 🙏✨
You're right, I forgot to mention that really important thing... with your permission, I'll paste the steps you give in the cover letter of this PR 😅
I already reviewed this: it was an error with the handling I was doing in the
Yees, you are right... I'll be checking this out
Honestly, I didn't create any PR for those things... but the repositories are not too big, so if you take a look at them, it would be great! |
4900dd4
to
7d59b6c
Compare
7d59b6c
to
a622578
Compare
Hello @arbrandes or @brian-smith-tcril, this PR has been waiting for quite a while for a review from infinity. I'm escalating this to the people I know. The PR is basic in essence. We are adding a UISlot so that it is possible to extend the profile page by adding new fields in this space. This app has not received many UI slots yet, we believe this is the next most necessary one. Also the NAU project is very keen on using this for their install. |
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.
Overall I'm in favor of adding this functionality via a slot.
I left a few comments with specific questions/suggestions.
Thanks for this PR! Let me know if you have any questions/need anything from me!
src/profile/ProfilePage.jsx
Outdated
@@ -362,6 +365,9 @@ const ProfilePage = ({ params }) => { | |||
{...commonFormProps} | |||
/> | |||
)} | |||
|
|||
<ExtendedProfileFieldsSlot /> |
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 curious about the choice to put this above the SocialLinks
block. I'd think having all the "out of the box" fields come before any additional ones would make more sense, but if there's specific reasoning for not putting this at the end I'm all ears!
src/profile/ProfilePage.jsx
Outdated
@@ -15,6 +15,9 @@ import { | |||
import { InfoOutline } from '@openedx/paragon/icons'; | |||
import classNames from 'classnames'; | |||
|
|||
import ExtendedProfileFieldsSlot from '../plugin-slots/ExtendedProfileFieldsSlot'; |
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.
Bit of a naming nitpick here, how would you feel about this being AdditionalProfileFieldsSlot
instead of extended? My thought process here is that "additional" more clearly implies "you can use this to add more fields to the proflie" where "extended" may send the impression that existing fields could be modified into "extended" versions.
const pluginProps = { | ||
refreshUserProfile: useCallback((username) => dispatch(fetchProfile(username)), [dispatch]), | ||
updateUserProfile: patchProfile, | ||
profileFieldValues: extendedProfileValues, | ||
formComponents: { | ||
SwitchContent, | ||
EmptyContent, | ||
EditableItemHeader, | ||
}, | ||
}; |
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.
Overall I think these make sense to have as pluginProps
, but it'd be helpful to have some documentation for them. I noticed they are missing from the README
for the slot, so adding them there with some descriptive info would be perfect!
```jsx | ||
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
||
import { ExtendedProfileFields } from '@organization/frontend-component-extended-fields'; |
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 example doesn't quite fit with my goal of "you can copy the example env.config.jsx
code from a plugin slot's README
into your env.config.jsx
file and see it work." The main problem is that @organization/frontend-component-extended-fields
isn't an actual npm package, but even if it were that would mean people using this example code to test out the slot would need to install a package.
I think this example code would be wonderful to have in https://github.com/eduneXT/frontend-component-extended-fields so anyone using that package can get up and running easily.
For the slot documentation, something super simple (without any extra npm dependencies) should do the trick.
return ( | ||
<PluginSlot | ||
id="org.openedx.frontend.profile.extended_profile_fields.v1" | ||
idAliases={['extended_profile_fields_slot']} |
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.
Since this is a new slot we don't need an alias.
### Slot ID Aliases | ||
* `extended_profile_fields_slot` |
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.
Since this is a new slot we don't need an alias.
|
||
const config = { | ||
pluginSlots: { | ||
extended_profile_fields_slot: { |
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 should use the id that follows the slot naming format from the ADR.
extended_profile_fields_slot: { | |
'org.openedx.frontend.profile.extended_profile_fields.v1': { |
…and documentation
dd11ffd
to
40f3dc4
Compare
Description
This PR creates a slot
ExtendedProfileFieldsSlot
and inserts it intoProfilePage.jsx
. The main goal of this change is to allow the extension of the profile fields.This use case is required by NAU and can be validated by @igobranco
Screenshots
How Has This Been Tested?
In case you want to test my implementation, I'll leave you a little guide down below:
Have a tutor environment (I used
Tutor Main
)You have to mount this MFE on the branch of this PR so you can use the slot:
a. Add this script to the following tutor plugin to override the branch of
Profle MFE
b. Another way we can do this in the queue is by
tutor mounts add
the MFE in our Tutor local env. To do this, we must:Install the
@edunext/frontend-component-extended-fields@latest
package in our MFE Profile.Create an
env.config.jsx
file in the root of the MFE with the following configuration:Create a tutor plugin and enable it:
Run
tutor images build mfe --no-cache
Add this in the
config.yml
to add the custom form:Add the following env variables
Run
tutor images build openedx --no-cache
Run
tutor local start
Add the following settings to the
Site Configurations > local.openedx.io
:Run
tutor local restart
to update the settings