Skip to content
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: Taxonomy export menu [FC-0036] #645

Merged
merged 21 commits into from
Nov 14, 2023

Conversation

ChrisChV
Copy link
Contributor

@ChrisChV ChrisChV commented Oct 19, 2023

Changes added:

  • ExportModal.
  • Export menu added. Note: Is hidden for system-defined, because the export API doesn't allow export system-defined.
  • Functions to make a call to the export API.
  • Flow to export a taxonomy.
  • System-defined tooltip.

Screenshots

image
image

Testing instructions

  • Verify the tooltip of the badge of a System-defined taxonomy.
  • Create a new Taxonomy on the CMS python shell or use the taxonomy-sample-data.
  • Go to the Taxonomy List page, you should be able to see the new taxonomy.
  • Click on the tree dots on the new taxonomy card and on Export.
  • Check the new Export modal.
  • Click on Export on the Export modal with CSV format.
  • Verify the downloaded file.
  • Click on Export on the Export modal with JSON format.
  • Verify the downloaded file.

Other info

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 19, 2023
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 19, 2023

Thanks for the pull request, @ChrisChV! 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.

@ChrisChV ChrisChV marked this pull request as draft October 19, 2023 18:46
@ChrisChV ChrisChV force-pushed the chris/FAL-3528-taxonomy-export-menu branch from 667bf1e to 09aa8b6 Compare October 20, 2023 18:45
@ChrisChV ChrisChV marked this pull request as ready for review October 20, 2023 18:46
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (77a355e) 88.02% compared to head (16233fb) 88.40%.
Report is 14 commits behind head on master.

Files Patch % Lines
src/taxonomy/taxonomy-card/TaxonomyCardMenu.jsx 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #645      +/-   ##
==========================================
+ Coverage   88.02%   88.40%   +0.38%     
==========================================
  Files         417      424       +7     
  Lines        6598     6573      -25     
  Branches     1428     1411      -17     
==========================================
+ Hits         5808     5811       +3     
+ Misses        765      737      -28     
  Partials       25       25              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/taxonomy/api/types.mjs Outdated Show resolved Hide resolved
Copy link
Contributor

@rpenido rpenido left a comment

Choose a reason for hiding this comment

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

Hi @ChrisChV! It looks good to me.

  • I read through the code
  • I followed the test instructions and ran the code locally

About the system-defined taxonomy export that @bradenmacdonald mentioned in the other PR:
We have a restriction in the python API blocking the import/export of system-defined taxonomies. I think the main reason was to avoid importing a system-defined taxonomy (no one can change it), but currently, the same check is applied to both (import/export):

https://github.com/openedx/openedx-learning/blob/v0.2.5/openedx_tagging/core/tagging/import_export/api.py#L145-L151

I think it will not be a problem to decouple the checks.

@bradenmacdonald Do you think we should handle it in this task or another later?

@pomegranited
Copy link
Contributor

pomegranited commented Oct 25, 2023

@ChrisChV CC @rpenido This repo has good documentation in the README describing its various features and how to enable them. This isn't the first Tagging feature for this repo (#622 was first), but this is the next one likely to merge, so could you update the README to add details for these features (including the platform flags we need to set), and we'll do the same for subsequent Tagging PRs?

@bradenmacdonald
Copy link
Contributor

@bradenmacdonald Do you think we should handle it in this task or another later?

Let's make the change to allow export (not import) of system-defined taxonomies on the backend now. It should be a simple change, and you don't need to include a version bump or anything. Later we can make the corresponding UI change in a separate task.

@rpenido
Copy link
Contributor

rpenido commented Oct 26, 2023

@bradenmacdonald Do you think we should handle it in this task or another later?

Let's make the change to allow export (not import) of system-defined taxonomies on the backend now. It should be a simple change, and you don't need to include a version bump or anything. Later we can make the corresponding UI change in a separate task.

Done: openedx/openedx-learning#107
I assumed that the same principle was valid for open taxonomies (allow_free_text=True)

@ChrisChV
Copy link
Contributor Author

@ChrisChV CC @rpenido This repo has good documentation in the README describing its various features and how to enable them. This isn't the first Tagging feature for this repo (#622 was first), but this is the next one likely to merge, so could you update the README to add details for these features (including the openedx/edx-platform#33439), and we'll do the same for subsequent Tagging PRs?

Thanks @pomegranited, I added it on 5af8d66

Comment on lines 24 to 27

export const callExportTaxonomy = (pk, format) => (
exportTaxonomy(pk, format)
);
Copy link
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 selectors is the correct place for this, although I think this might be a preexisting problem with this module.

I think it's important to keep this ADR in mind: https://github.com/openedx/frontend-template-application/blob/master/docs/decisions/0002-feature-based-application-organization.rst

None of the functions here are hooks or selectors in the commonly understood context of those terms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xitij2000 I updated the UI components to match with the ADR here: b09b86a

About the data layer, we have try to use useQuery to get data. On df8432d I tried to match with the structure on the ADR, @xitij2000 could you check it?

CC @bradenmacdonald

Copy link
Contributor

Choose a reason for hiding this comment

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

Given that this is using useQuery instead of redux I'm not sure how things would map. However, I think it's best to avoid confusion with exist terms like hooks, thunks, selectors, if you are not using those since someone else working on this might have difficulty navigating this codebase in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I understand. I deleted thunks.js and I move hooks.jsx to api/apiHooks.jsx (to avoid use hooks or any other exist term). Also I added a docstring in api/apiHooks.jsx to explain all of this.

const orgsCountEnabled = () => orgsCount !== undefined && orgsCount !== 0;

const onClickMenuItem = (menuName) => {
switch (menuName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If there is only one option, wouldn't this be clearer as a simple if condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In future tasks more menu items will be added. I have added a comment for it

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, that makes sense. Would it be cleaner in this case to have a dict based approach?
i.e. something like this:

const menuItemActions = {
  'export': setIsExportModalOpen,
  'import': setIsImportModalOpen,
...
}

menuItemActions[menuName]?.(true)

This might end up being less clear depending on the usage though since I don't know the whole context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. I like it. I added it on this commit: 080b03e

src/taxonomy/taxonomy-card/TaxonomyCard.jsx Outdated Show resolved Hide resolved
src/taxonomy/taxonomy-card/TaxonomyCard.jsx Outdated Show resolved Hide resolved
src/taxonomy/taxonomy-card/TaxonomyCard.jsx Outdated Show resolved Hide resolved
src/taxonomy/modals/ExportModal.test.jsx Outdated Show resolved Hide resolved
@bradenmacdonald
Copy link
Contributor

@ChrisChV Is this ready for another look from @xitij2000 ? Or are you still working on refactoring the tests?

@ChrisChV
Copy link
Contributor Author

ChrisChV commented Nov 3, 2023

@bradenmacdonald Yes, I will check this way. @xitij2000 do you have any comments about the changes here? or recommendations? So I can do changes in one batch :)

@ChrisChV
Copy link
Contributor Author

ChrisChV commented Nov 6, 2023

@xitij2000 I updated the tests. It's full ready for another review

/* istanbul ignore next */
const exportTaxonomy = (pk, format) => (
getTaxonomyExportFile(pk, format)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

@ChrisChV IIRR, thunk.js is for redux operations (ref). And since exportTaxonomy is just wrapping an API function, can't we just call getTaxonomyExportFile directly where it's needed?

Is that right @xitij2000 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, thunks are where you can connect the API to the redux store. Since this is using a different approach with useQuery, I think there might not be any thunks here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Ok, I agree. I deleted thunks.js 080b03e

Copy link
Contributor

@xitij2000 xitij2000 left a comment

Choose a reason for hiding this comment

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

I'm currently not able to test this in running since my devstack is set up for something else I don't want to delay this.

Has it been manually tested?

const orgsCountEnabled = () => orgsCount !== undefined && orgsCount !== 0;

const onClickMenuItem = (menuName) => {
switch (menuName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, that makes sense. Would it be cleaner in this case to have a dict based approach?
i.e. something like this:

const menuItemActions = {
  'export': setIsExportModalOpen,
  'import': setIsImportModalOpen,
...
}

menuItemActions[menuName]?.(true)

This might end up being less clear depending on the usage though since I don't know the whole context.

/* istanbul ignore next */
const exportTaxonomy = (pk, format) => (
getTaxonomyExportFile(pk, format)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, thunks are where you can connect the API to the redux store. Since this is using a different approach with useQuery, I think there might not be any thunks here.

Comment on lines 24 to 27

export const callExportTaxonomy = (pk, format) => (
exportTaxonomy(pk, format)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that this is using useQuery instead of redux I'm not sure how things would map. However, I think it's best to avoid confusion with exist terms like hooks, thunks, selectors, if you are not using those since someone else working on this might have difficulty navigating this codebase in that case.

@rpenido
Copy link
Contributor

rpenido commented Nov 8, 2023

I'm currently not able to test this in running since my devstack is set up for something else I don't want to delay this.

Has it been manually tested?

Hi @xitij2000 ! Yes!
I just tested it.

@ChrisChV
Copy link
Contributor Author

ChrisChV commented Nov 8, 2023

@xitij2000 I addressed your comments. It's ready for another review


* ``edx-platform`` Waffle flags:

* ``contentstore.new_studio_mfe.use_tagging_taxonomy_list_page``: this feature flag must be enabled.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
* ``contentstore.new_studio_mfe.use_tagging_taxonomy_list_page``: this feature flag must be enabled.
* ``new_studio_mfe.use_tagging_taxonomy_list_page``: this feature flag must be enabled.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct, but all the other feature flags use contentstore.new_studio_mfe... so that was a small mistake on our part. Doesn't really matter though.

@ChrisChV
Copy link
Contributor Author

Hi @xitij2000, kindly reminder to do another round of review here. We need to unblock and merge this. I suggest that if there is another recommendation on the architecture and structure of the taxonomy module, we could chek it and reach a consensus in another ticket/PR 😄

Copy link
Contributor

@xitij2000 xitij2000 left a comment

Choose a reason for hiding this comment

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

Looks good! Just one small nit.

src/taxonomy/taxonomy-card/index.jsx Outdated Show resolved Hide resolved
@ChrisChV
Copy link
Contributor Author

@bradenmacdonald @xitij2000 It's ready to merge. I don't have permission to do it

@ormsbee ormsbee merged commit 1ee80b6 into openedx:master Nov 14, 2023
6 checks passed
@openedx-webhooks
Copy link

@ChrisChV 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

Ian2012 pushed a commit to eduNEXT/frontend-app-course-authoring that referenced this pull request Nov 15, 2023
* feat: System-defined tooltip added
* feat: Taxonomy card menu added. Export menu item added
* feat: Modal for export taxonomy
* feat: Connect with export API
* test: Tests for API and selectors
* feat: Use windows.location.href to call the export endpoint
* test: ExportModal.test added
* style: Delete unnecessary code
* docs: README updated with taxonomy feature
* style: TaxonomyCard updated to a better code style
* style: injectIntl replaced by useIntl on taxonomy pages and components
* refactor: Move and rename taxonomy UI components to match 0002 ADR
* refactor: Move api to data to match with 0002 ADR
* test: Refactor ExportModal tests
* chore: Fix validations
* chore: Lint
* refactor: Moving hooks to apiHooks
* style: Nit on return null

---------

Co-authored-by: Rômulo Penido <[email protected]>
Co-authored-by: Christofer Chavez <[email protected]>
@bradenmacdonald bradenmacdonald deleted the chris/FAL-3528-taxonomy-export-menu branch July 12, 2024 08:25
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.

[Tagging] Per-taxonomy menu on Taxonomy List Page
7 participants