-
Notifications
You must be signed in to change notification settings - Fork 75
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: assign taxonomy to organizations [FC-0036] #760
feat: assign taxonomy to organizations [FC-0036] #760
Conversation
Co-authored-by: Jillian <[email protected]>
* 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 <[email protected]> --------- Co-authored-by: Jillian <[email protected]>
* 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! |
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.
Looks good! Just a few minor comments.
isOpen={isOpen} | ||
onClose={onClose} | ||
size="lg" | ||
disabled={isDialogDisabled} |
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 don't think disabled is a valid property on ModalDialog.
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.
Removed: 3cf5758
if (setToastMessage) { | ||
setToastMessage(intl.formatMessage(messages.assignOrgsSuccess)); | ||
} | ||
} catch (/** @type {any} */ error) { |
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 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.
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.
Removed: 3cf5758
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know there some work towards a better alternative on the Paragon front!
src/taxonomy/data/apiHooks.test.jsx
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are not testing anything, please remove them in favour of testing the component directly.
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.
Done: aa1031e
fireEvent.click(getByTestId('taxonomy-menu-manageOrgs')); | ||
|
||
// Modal opened | ||
await waitFor(() => expect(getByText('Assign to organizations')).toBeInTheDocument()); |
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.
await waitFor(() => expect(getByText('Assign to organizations')).toBeInTheDocument()); | |
expect(await findByText('Assign to organizations')).toBeInTheDocument(); |
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.
Done: 3cf5758
fireEvent.click(getByText('Cancel')); | ||
|
||
// Modal closed | ||
expect(() => getByText('Assign to organizations')).toThrow(); |
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.
expect(() => getByText('Assign to organizations')).toThrow(); | |
expect(queryByText('Assign to organizations')).not.toBeInTheDocument(); |
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.
Done: 3cf5758
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 Organizations
menu from an existing taxonomy cardSave
Manage Organizations
menu from the taxonomy and check if the org was assignedAssign to all organizations
. The other fields must be disabled. Click onSave
Manage Organizations
menu from the taxonomy and check if the Taxonomy was assigned to all orgsAssign to all organizations
, leave the Taxonomy without assigned orgs and click onSave
Manage Organizations
menu from the taxonomy and check if the Taxonomy has no assigned orgsThe feature can also be accessed from the
Actions
menu on the Taxonomy Details page.Private-ref: