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: refined ux update a taxonomy by downloading and uploading (TEMP) #19

Closed
Show file tree
Hide file tree
Changes from 6 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 Dec 7, 2023
63a1487
fix: eslint
rpenido Dec 7, 2023
1110979
fix: design adjustments
rpenido Dec 7, 2023
8eac9cb
fix: more design adjustments
rpenido Dec 7, 2023
830c991
test: fix tests
rpenido Dec 7, 2023
7a0a44c
test: fix api test
rpenido Dec 7, 2023
6a55c6f
refactor: move getFileSizeToClosestByte to root utils
rpenido Dec 8, 2023
1119041
fix: invalidate taxonomyDetail query
rpenido Dec 8, 2023
f56a05d
test: add testing-library/react-hooks and fix testing
rpenido Dec 8, 2023
cb52fd7
fix: rename files
rpenido Dec 8, 2023
94f1bf7
test: fix api test
rpenido Dec 8, 2023
b63147a
test: check invalidateQueries
rpenido Dec 8, 2023
3613f22
test: improve LoadingButton tests
rpenido Dec 8, 2023
2b8d534
test: fix LoadingButton test
rpenido Dec 8, 2023
895bbc4
test: add ImportTagsWizard tests
rpenido Dec 8, 2023
538d003
test: more ImportTagsWizard tests
rpenido Dec 8, 2023
1eea5d2
fix: types
rpenido Dec 8, 2023
d91716b
feat: add typings from code review
rpenido Dec 9, 2023
244b83b
refactor: typings and return of taxonomy import api
rpenido Dec 9, 2023
c85ebdc
fix: type import
rpenido Dec 9, 2023
707b1bd
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido Dec 9, 2023
aa5fc4f
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido Dec 15, 2023
9fce34b
fix: TaxonomyContext types
rpenido Dec 15, 2023
89f8116
feat: add toast and error message
rpenido Dec 15, 2023
5dd25a2
fix: layout alert message
rpenido Dec 15, 2023
676a636
fix: types and lint
rpenido Dec 15, 2023
23c28af
fix: lint
rpenido Dec 15, 2023
ad69e11
fix: error message
rpenido Dec 18, 2023
f6cfcf3
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido Dec 18, 2023
2d3abe8
fix: use scss utility
rpenido Dec 18, 2023
cfa01b6
style: add PR in comment
rpenido Dec 18, 2023
e0f1a40
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido Dec 19, 2023
8bcbb64
fix: missing }
rpenido Dec 19, 2023
a33aa8a
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido Dec 19, 2023
7900876
fix: import taxonomy type
rpenido Dec 19, 2023
46b7b3e
revert: changes in package-lock.json
rpenido Dec 20, 2023
e54fd45
refactor: rename close -> onClose
rpenido Dec 20, 2023
a51bb40
test: change to getByText
rpenido Dec 20, 2023
9a35f1a
Merge branch 'rpenido/fal-3532-import-taxonomy' into rpenido/fal-3539…
rpenido Dec 21, 2023
4ffebda
fix(deps): update dependency @edx/frontend-lib-content-components to …
renovate[bot] Dec 21, 2023
ef20d55
fix: add a div over the dialog to prevent the user to interact while …
rpenido Dec 21, 2023
65ca5a9
fix: add title to dialog to remove console warning
rpenido Dec 26, 2023
ff234b4
fix: add title property to Stepper.Step to fix warning
rpenido Dec 26, 2023
72d82d6
fix: remove warning when toastMessage = null
rpenido Dec 26, 2023
2788621
feat: Add filter taxonomies by org (#755)
yusuf-musleh Jan 4, 2024
52b75e0
fix: uploading progress percentage (#763)
KristinAoki Jan 4, 2024
2e070c9
feat: error page on invalid course key (#761)
ArturGaspar Jan 4, 2024
2205506
chore: removed reported_content_email_notifications_flag dependency (…
ayesha-waris Jan 5, 2024
6c0fc09
feat: add import taxonomy feature [FC-0036] (#675)
rpenido Jan 8, 2024
138f1d2
feat: Add v2 lib components content tags support (#771)
yusuf-musleh Jan 8, 2024
3e5931d
Merge branch 'master' into rpenido/fal-3539-refined-ux-update-a-taxon…
rpenido Jan 8, 2024
67e0f7b
fix: merging errors
rpenido Jan 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/generic/loading-button/LoadingButton.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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 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 { getByText, getByTestId } = render(RootWrapper());
const titleElement = getByText(buttonTitle);
expect(titleElement).toBeInTheDocument();
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);
});
});
52 changes: 52 additions & 0 deletions src/generic/loading-button/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useState } from 'react';

import {
Button,
Spinner,
Stack,
} from '@edx/paragon';

const LoadingButton = ({
onClick,
children,
disabled,
...props
}) => {
const [isLoading, setIsLoading] = useState(false);

const loadingOnClick = async (e) => {
if (onClick === undefined) {
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;
Loading
Loading