Repository navigation
feat: Taxonomy export menu [FC-0036] #645
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
Changes from 11 commits
4963124
4077397
e87c545
4922420
5e12a8f
09aa8b6
1925fae
0be804c
da0156f
0cc473c
5af8d66
a21fac2
61864d3
b09b86a
df8432d
1abf034
1d6f9a5
5c4c87a
7e514b6
080b03e
16233fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // @ts-check | ||
| import useTaxonomyListData from './api'; | ||
| import { | ||
| useTaxonomyListData, | ||
| exportTaxonomy, | ||
| } from './api'; | ||
|
|
||
| /** | ||
| * @returns {import("../types.mjs").TaxonomyListData | undefined} | ||
|
|
@@ -18,3 +21,7 @@ export const useTaxonomyListDataResponse = () => { | |
| export const useIsTaxonomyListDataLoaded = () => ( | ||
| useTaxonomyListData().status === 'success' | ||
| ); | ||
|
|
||
| export const callExportTaxonomy = (pk, format) => ( | ||
| exportTaxonomy(pk, format) | ||
| ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I understand. I deleted |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import React, { useState } from 'react'; | ||
| import { | ||
| ActionRow, | ||
| Button, | ||
| Form, | ||
| ModalDialog, | ||
| } from '@edx/paragon'; | ||
| import PropTypes from 'prop-types'; | ||
| import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; | ||
| import messages from '../messages'; | ||
| import { callExportTaxonomy } from '../api/hooks/selectors'; | ||
|
|
||
| const ExportModal = ({ | ||
| taxonomyId, | ||
| isOpen, | ||
| onClose, | ||
| intl, | ||
| }) => { | ||
| const [outputFormat, setOutputFormat] = useState('csv'); | ||
|
|
||
| const onClickExport = () => { | ||
| onClose(); | ||
| callExportTaxonomy(taxonomyId, outputFormat); | ||
| }; | ||
|
|
||
| return ( | ||
| <ModalDialog | ||
| title={intl.formatMessage(messages.exportModalTitle)} | ||
| isOpen={isOpen} | ||
| onClose={onClose} | ||
| size="lg" | ||
| hasCloseButton | ||
| isFullscreenOnMobile | ||
| > | ||
| <ModalDialog.Header> | ||
| <ModalDialog.Title> | ||
| {intl.formatMessage(messages.exportModalTitle)} | ||
| </ModalDialog.Title> | ||
| </ModalDialog.Header> | ||
| <ModalDialog.Body className="pb-5 mt-2"> | ||
| <Form.Group> | ||
| <Form.Label> | ||
| {intl.formatMessage(messages.exportModalBodyDescription)} | ||
| </Form.Label> | ||
| <Form.RadioSet | ||
| name="export-format" | ||
| value={outputFormat} | ||
| onChange={(e) => setOutputFormat(e.target.value)} | ||
| > | ||
| <Form.Radio | ||
| key={`export-csv-format-${taxonomyId}`} | ||
| value="csv" | ||
| > | ||
| {intl.formatMessage(messages.taxonomyCSVFormat)} | ||
| </Form.Radio> | ||
| <Form.Radio | ||
| key={`export-json-format-${taxonomyId}`} | ||
| value="json" | ||
| > | ||
| {intl.formatMessage(messages.taxonomyJSONFormat)} | ||
| </Form.Radio> | ||
| </Form.RadioSet> | ||
| </Form.Group> | ||
| </ModalDialog.Body> | ||
| <ModalDialog.Footer> | ||
| <ActionRow> | ||
| <ModalDialog.CloseButton variant="tertiary"> | ||
| {intl.formatMessage(messages.taxonomyModalsCancelLabel)} | ||
| </ModalDialog.CloseButton> | ||
| <Button variant="primary" onClick={onClickExport}> | ||
| {intl.formatMessage(messages.exportModalSubmitButtonLabel)} | ||
| </Button> | ||
| </ActionRow> | ||
| </ModalDialog.Footer> | ||
| </ModalDialog> | ||
| ); | ||
| }; | ||
|
|
||
| ExportModal.propTypes = { | ||
| taxonomyId: PropTypes.number.isRequired, | ||
| isOpen: PropTypes.bool.isRequired, | ||
| onClose: PropTypes.func.isRequired, | ||
| intl: intlShape.isRequired, | ||
| }; | ||
|
|
||
| export default injectIntl(ExportModal); |
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.
nit:
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 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.