feat: assign taxonomy to organizations [FC-0036] - #760
Conversation
Co-authored-by: Jillian <jill@opencraft.com>
* feat: import tags to existing taxonomy * feat: add re-import menu to taxonomy detail * test: add tests * fix: clean debug code Co-authored-by: Jillian <jill@opencraft.com> --------- Co-authored-by: Jillian <jill@opencraft.com>
* refactor: merges TaxonomyCardMenu and TaxonomyDetailMenu * refactor: change menu item list
…-assign-taxonomy-to-organizations
|
Thanks for the pull request, @rpenido! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #760 +/- ##
==========================================
+ Coverage 89.62% 89.82% +0.19%
==========================================
Files 499 504 +5
Lines 8089 8276 +187
Branches 1708 1745 +37
==========================================
+ Hits 7250 7434 +184
- Misses 812 815 +3
Partials 27 27 ☔ View full report in Codecov by Sentry. |
|
Hi @xitij2000! I rebased this PR and it is ready to review! |
xitij2000
left a comment
There was a problem hiding this comment.
Looks good! Just a few minor comments.
| isOpen={isOpen} | ||
| onClose={onClose} | ||
| size="lg" | ||
| disabled={isDialogDisabled} |
There was a problem hiding this comment.
I don't think disabled is a valid property on ModalDialog.
| if (setToastMessage) { | ||
| setToastMessage(intl.formatMessage(messages.assignOrgsSuccess)); | ||
| } | ||
| } catch (/** @type {any} */ error) { |
There was a problem hiding this comment.
I don't think this type annotation is helpful, unless it's needed to make some tool happy it's better to remove it or enhance it to provide better insight.
| useEffect(() => { | ||
| if (selectedOrgs) { | ||
| // This is a hack to force the Form.Autosuggest to clear its value after a selection is made. | ||
| const inputRef = /** @type {null|HTMLInputElement} */ (document.querySelector('.pgn__form-group input')); | ||
| if (inputRef) { | ||
| // @ts-ignore | ||
| inputRef.value = null; | ||
| const event = new Event('change', { bubbles: true }); | ||
| inputRef.dispatchEvent(event); | ||
| } | ||
| } | ||
| }, [selectedOrgs]); | ||
|
|
There was a problem hiding this comment.
This seems quite hacky, but I'm not sure what alternative there is.
That said, I think the selector here is a bit broad, I think you should scope this to .manage_orgs.
There was a problem hiding this comment.
Added .manage-orgs: 3cf5758
There is some effort to refactor the Autosuggest component here: openedx/paragon#2899
But for now, this is what we have 😦
There was a problem hiding this comment.
Good to know there some work towards a better alternative on the Paragon front!
| describe('useTaxonomyDetailDataStatus', () => { | ||
| it('should return status values', () => { | ||
| const status = { | ||
| isError: false, | ||
| error: undefined, | ||
| isFetched: true, | ||
| isSuccess: true, | ||
| }; | ||
|
|
||
| useQuery.mockReturnValueOnce(status); | ||
|
|
||
| const result = useTaxonomyDetailDataStatus(0); | ||
|
|
||
| expect(result).toEqual(status); | ||
| }); | ||
| }); | ||
|
|
||
| describe('useTaxonomyDetailDataResponse', () => { | ||
| it('should return data when status is success', () => { | ||
| useQuery.mockReturnValueOnce({ isSuccess: true, data: 'data' }); | ||
|
|
||
| const result = useTaxonomyDetailDataResponse(); | ||
|
|
||
| expect(result).toEqual('data'); | ||
| }); | ||
|
|
||
| it('should return undefined when status is not success', () => { | ||
| useQuery.mockReturnValueOnce({ isSuccess: false }); | ||
|
|
||
| const result = useTaxonomyDetailDataResponse(); | ||
|
|
||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
These tests are not testing anything, please remove them in favour of testing the component directly.
| fireEvent.click(getByTestId('taxonomy-menu-manageOrgs')); | ||
|
|
||
| // Modal opened | ||
| await waitFor(() => expect(getByText('Assign to organizations')).toBeInTheDocument()); |
There was a problem hiding this comment.
| await waitFor(() => expect(getByText('Assign to organizations')).toBeInTheDocument()); | |
| expect(await findByText('Assign to organizations')).toBeInTheDocument(); |
| fireEvent.click(getByText('Cancel')); | ||
|
|
||
| // Modal closed | ||
| expect(() => getByText('Assign to organizations')).toThrow(); |
There was a problem hiding this comment.
| expect(() => getByText('Assign to organizations')).toThrow(); | |
| expect(queryByText('Assign to organizations')).not.toBeInTheDocument(); |
b2745e1 to
aa1031e
Compare
|
Thank you for your review @xitij2000. Let me know if I missed something! |
|
@rpenido 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
Description
This PR adds the UI to assign organizations to a Taxonomy.
Supporting Information
Testing instructions
Manage Organizationsmenu from an existing taxonomy cardSaveManage Organizationsmenu from the taxonomy and check if the org was assignedAssign to all organizations. The other fields must be disabled. Click onSaveManage Organizationsmenu from the taxonomy and check if the Taxonomy was assigned to all orgsAssign to all organizations, leave the Taxonomy without assigned orgs and click onSaveManage Organizationsmenu from the taxonomy and check if the Taxonomy has no assigned orgsThe feature can also be accessed from the
Actionsmenu on the Taxonomy Details page.Private-ref: