forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
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: refined ux update a taxonomy by downloading and uploading (TEMP) #19
Closed
rpenido
wants to merge
52
commits into
rpenido/fal-3532-import-taxonomy
from
rpenido/fal-3539-refined-ux-update-a-taxonomy-by-downloading-and-uploading
Closed
Changes from 39 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
4c22a0a
feat: refined ux update a taxonomy by downloading and uploading
rpenido 63a1487
fix: eslint
rpenido 1110979
fix: design adjustments
rpenido 8eac9cb
fix: more design adjustments
rpenido 830c991
test: fix tests
rpenido 7a0a44c
test: fix api test
rpenido 6a55c6f
refactor: move getFileSizeToClosestByte to root utils
rpenido 1119041
fix: invalidate taxonomyDetail query
rpenido f56a05d
test: add testing-library/react-hooks and fix testing
rpenido cb52fd7
fix: rename files
rpenido 94f1bf7
test: fix api test
rpenido b63147a
test: check invalidateQueries
rpenido 3613f22
test: improve LoadingButton tests
rpenido 2b8d534
test: fix LoadingButton test
rpenido 895bbc4
test: add ImportTagsWizard tests
rpenido 538d003
test: more ImportTagsWizard tests
rpenido 1eea5d2
fix: types
rpenido d91716b
feat: add typings from code review
rpenido 244b83b
refactor: typings and return of taxonomy import api
rpenido c85ebdc
fix: type import
rpenido 707b1bd
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido aa5fc4f
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido 9fce34b
fix: TaxonomyContext types
rpenido 89f8116
feat: add toast and error message
rpenido 5dd25a2
fix: layout alert message
rpenido 676a636
fix: types and lint
rpenido 23c28af
fix: lint
rpenido ad69e11
fix: error message
rpenido f6cfcf3
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido 2d3abe8
fix: use scss utility
rpenido cfa01b6
style: add PR in comment
rpenido e0f1a40
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido 8bcbb64
fix: missing }
rpenido a33aa8a
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido 7900876
fix: import taxonomy type
rpenido 46b7b3e
revert: changes in package-lock.json
rpenido e54fd45
refactor: rename close -> onClose
rpenido a51bb40
test: change to getByText
rpenido 9a35f1a
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido 4ffebda
fix(deps): update dependency @edx/frontend-lib-content-components to …
renovate[bot] ef20d55
fix: add a div over the dialog to prevent the user to interact while …
rpenido 65ca5a9
fix: add title to dialog to remove console warning
rpenido ff234b4
fix: add title property to Stepper.Step to fix warning
rpenido 72d82d6
fix: remove warning when toastMessage = null
rpenido 2788621
feat: Add filter taxonomies by org (#755)
yusuf-musleh 52b75e0
fix: uploading progress percentage (#763)
KristinAoki 2e070c9
feat: error page on invalid course key (#761)
ArturGaspar 2205506
chore: removed reported_content_email_notifications_flag dependency (…
ayesha-waris 6c0fc09
feat: add import taxonomy feature [FC-0036] (#675)
rpenido 138f1d2
feat: Add v2 lib components content tags support (#771)
yusuf-musleh 3e5931d
Merge branch 'master' into rpenido/fal-3539-refined-ux-update-a-taxon…
rpenido 67e0f7b
fix: merging errors
rpenido File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ | |
color: $black; | ||
} | ||
|
||
.h-200px { | ||
height: 200px; | ||
} | ||
|
||
.mw-300px { | ||
max-width: 300px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import LoadingButton from '.'; | ||
|
||
const buttonTitle = 'Button Title'; | ||
|
||
const RootWrapper = (onClick) => ( | ||
<LoadingButton onClick={onClick}> | ||
{buttonTitle} | ||
</LoadingButton> | ||
); | ||
|
||
describe('<LoadingButton />', () => { | ||
it('renders the title and doesnt handle the spinner initially', () => { | ||
const { getByText, getByTestId } = render(RootWrapper(() => { })); | ||
const titleElement = getByText(buttonTitle); | ||
expect(titleElement).toBeInTheDocument(); | ||
expect(() => getByTestId('button-loading-spinner')).toThrow('Unable to find an element'); | ||
}); | ||
|
||
it('doesnt render the spinner initially without onClick function', () => { | ||
const { getByRole, getByText, getByTestId } = render(RootWrapper()); | ||
const titleElement = getByText(buttonTitle); | ||
expect(titleElement).toBeInTheDocument(); | ||
expect(() => getByTestId('button-loading-spinner')).toThrow('Unable to find an element'); | ||
const buttonElement = getByRole('button'); | ||
buttonElement.click(); | ||
expect(() => getByTestId('button-loading-spinner')).toThrow('Unable to find an element'); | ||
}); | ||
|
||
it('renders the spinner correctly', () => { | ||
const longFunction = () => new Promise((resolve) => { | ||
setTimeout(resolve, 1000); | ||
}); | ||
const { getByRole, getByText, getByTestId } = render(RootWrapper(longFunction)); | ||
const buttonElement = getByRole('button'); | ||
buttonElement.click(); | ||
const spinnerElement = getByTestId('button-loading-spinner'); | ||
expect(spinnerElement).toBeInTheDocument(); | ||
const titleElement = getByText(buttonTitle); | ||
expect(titleElement).toBeInTheDocument(); | ||
expect(buttonElement).toBeDisabled(); | ||
setTimeout(() => { | ||
expect(buttonElement).toBeEnabled(); | ||
expect(spinnerElement).not.toBeInTheDocument(); | ||
}, 2000); | ||
}); | ||
|
||
it('renders the spinner correctly even with error', () => { | ||
const longFunction = () => new Promise((_resolve, reject) => { | ||
setTimeout(reject, 1000); | ||
}); | ||
const { getByRole, getByText, getByTestId } = render(RootWrapper(longFunction)); | ||
const buttonElement = getByRole('button'); | ||
buttonElement.click(); | ||
const spinnerElement = getByTestId('button-loading-spinner'); | ||
expect(spinnerElement).toBeInTheDocument(); | ||
const titleElement = getByText(buttonTitle); | ||
expect(titleElement).toBeInTheDocument(); | ||
expect(buttonElement).toBeDisabled(); | ||
setTimeout(() => { | ||
expect(buttonElement).toBeEnabled(); | ||
expect(spinnerElement).not.toBeInTheDocument(); | ||
}, 2000); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// @ts-check | ||
import React, { useState } from 'react'; | ||
|
||
import { | ||
Button, | ||
Spinner, | ||
Stack, | ||
} from '@edx/paragon'; | ||
|
||
/** | ||
* A button that shows a loading spinner when clicked. | ||
* @param {object} props | ||
* @param {React.ReactNode=} props.children | ||
* @param {boolean=} props.disabled | ||
* @param {function=} props.onClick | ||
* @returns {JSX.Element} | ||
*/ | ||
const LoadingButton = ({ | ||
onClick, | ||
children, | ||
disabled, | ||
...props | ||
}) => { | ||
const [isLoading, setIsLoading] = useState(false); | ||
|
||
const loadingOnClick = async (e) => { | ||
if (!onClick) { | ||
return; | ||
} | ||
|
||
setIsLoading(true); | ||
try { | ||
await onClick(e); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<Button | ||
{...props} | ||
disabled={!!isLoading || disabled} | ||
onClick={loadingOnClick} | ||
> | ||
<Stack gap={2} direction="horizontal"> | ||
{children} | ||
{isLoading && <Spinner size="sm" animation="border" data-testid="button-loading-spinner" />} | ||
</Stack> | ||
</Button> | ||
); | ||
}; | ||
|
||
LoadingButton.propTypes = { | ||
...Button.propTypes, | ||
}; | ||
|
||
LoadingButton.defaultProps = { | ||
...Button.defaultProps, | ||
}; | ||
|
||
export default LoadingButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 function was moved to /src/utils.js