Skip to content

feat: assign taxonomy to organizations [FC-0036] - #760

Merged
xitij2000 merged 59 commits into
openedx:masterfrom
open-craft:rpenido/fal-3543-assign-taxonomy-to-organizations
Jan 12, 2024
Merged

feat: assign taxonomy to organizations [FC-0036]#760
xitij2000 merged 59 commits into
openedx:masterfrom
open-craft:rpenido/fal-3543-assign-taxonomy-to-organizations

Conversation

@rpenido

@rpenido rpenido commented Dec 20, 2023

Copy link
Copy Markdown
Contributor

Description

This PR adds the UI to assign organizations to a Taxonomy.

manage_orgs

Supporting Information

Testing instructions

  1. Go to the taxonomy list page (http://localhost:2001/taxonomies)
  2. Click on the Manage Organizations menu from an existing taxonomy card
  3. You will be prompted with a form to assign Organizations to the taxonomy.
  4. Assign an org to the taxonomy and click on Save
  5. Click on the Manage Organizations menu from the taxonomy and check if the org was assigned
  6. Use the checkbox to Assign to all organizations. The other fields must be disabled. Click on Save
  7. Click on the Manage Organizations menu from the taxonomy and check if the Taxonomy was assigned to all orgs
  8. Uncheck the Assign to all organizations, leave the Taxonomy without assigned orgs and click on Save
  9. A dialog will ask for confirmation if you leave a Taxonomy without associated orgs
  10. Click on the Manage Organizations menu from the taxonomy and check if the Taxonomy has no assigned orgs

The feature can also be accessed from the Actions menu on the Taxonomy Details page.

image


Private-ref:

rpenido and others added 30 commits November 9, 2023 09:34
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
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Dec 20, 2023
@openedx-webhooks

openedx-webhooks commented Dec 20, 2023

Copy link
Copy Markdown

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:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

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

codecov Bot commented Dec 21, 2023

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (138f1d2) 89.62% compared to head (aa1031e) 89.82%.
Report is 10 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@xitij2000
xitij2000 self-requested a review December 28, 2023 10:16
@rpenido

rpenido commented Jan 8, 2024

Copy link
Copy Markdown
Contributor Author

Hi @xitij2000! I rebased this PR and it is ready to review!

@xitij2000 xitij2000 left a comment

Copy link
Copy Markdown
Contributor

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}

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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) {

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed: 3cf5758

Comment on lines +131 to +143
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]);

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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 😦

Copy link
Copy Markdown
Contributor

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!

Comment thread src/taxonomy/data/apiHooks.test.jsx Outdated
Comment on lines +82 to +115
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();
});
});

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await waitFor(() => expect(getByText('Assign to organizations')).toBeInTheDocument());
expect(await findByText('Assign to organizations')).toBeInTheDocument();

Copy link
Copy Markdown
Contributor Author

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(() => getByText('Assign to organizations')).toThrow();
expect(queryByText('Assign to organizations')).not.toBeInTheDocument();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: 3cf5758

@rpenido
rpenido force-pushed the rpenido/fal-3543-assign-taxonomy-to-organizations branch from b2745e1 to aa1031e Compare January 11, 2024 23:13
@rpenido

rpenido commented Jan 11, 2024

Copy link
Copy Markdown
Contributor Author

Thank you for your review @xitij2000.

Let me know if I missed something!

@xitij2000
xitij2000 merged commit 1fef358 into openedx:master Jan 12, 2024
@openedx-webhooks

Copy link
Copy Markdown

@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.

@xitij2000
xitij2000 deleted the rpenido/fal-3543-assign-taxonomy-to-organizations branch January 12, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants