Repository navigation
feat: add files and uploads page #541
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
68560f1
feat: show files and uploads page
KristinAoki 2a83d6e
feat: update packages
KristinAoki cfdb63a
feat: add file and uploads components
KristinAoki 8a482ee
feat: add api functions
KristinAoki dda21fe
Merge branch 'master' into KristinAoki/add-files-and-uploads
KristinAoki bfcca7a
fix: lint errors
KristinAoki f29d433
Merge branch 'master' into KristinAoki/add-files-and-uploads
KristinAoki cf6d2e8
chore: rename file
KristinAoki f7ce7c2
fix: console errors
KristinAoki 06bf73b
fix: pagination page count error
KristinAoki 97639d5
chore: add files and uploads tests
KristinAoki f5769b6
fix: lint warning count error
KristinAoki 232f267
fix: api fetch for all assets
KristinAoki 7e2f0e4
chore: remove focus on file upload test
KristinAoki 4b89b70
chore: add file menu tests
KristinAoki a4c0844
fix: move duplicate code into shared function
KristinAoki b1be395
fix: broken mock api response
KristinAoki 4a1e517
fix: heap memory error
KristinAoki 3dbdced
fix: error alerts
KristinAoki 08e73cb
fix: remove console logs
KristinAoki 5c827b7
fix: fetch all variables from redux in one call
KristinAoki fca7a25
fix: js errors
KristinAoki 921e7d4
fix: broken test
KristinAoki 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,36 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { injectIntl } from '@edx/frontend-platform/i18n'; | ||
| import { Toast } from '@edx/paragon'; | ||
|
|
||
| const ApiStatusToast = ({ | ||
| actionType, | ||
| selectedRowCount, | ||
| isOpen, | ||
| setClose, | ||
| setSelectedRowCount, | ||
| }) => { | ||
| const handleClose = () => { | ||
| setSelectedRowCount(0); | ||
| setClose(); | ||
| }; | ||
|
|
||
| return ( | ||
| <Toast | ||
| show={isOpen} | ||
| onClose={handleClose} | ||
| > | ||
| {`You have ${actionType} ${selectedRowCount} files`} | ||
| </Toast> | ||
| ); | ||
| }; | ||
|
|
||
| ApiStatusToast.propTypes = { | ||
| actionType: PropTypes.string.isRequired, | ||
| selectedRowCount: PropTypes.number.isRequired, | ||
| isOpen: PropTypes.bool.isRequired, | ||
| setClose: PropTypes.func.isRequired, | ||
| setSelectedRowCount: PropTypes.func.isRequired, | ||
| }; | ||
|
|
||
| export default injectIntl(ApiStatusToast); | ||
This file contains hidden or 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,148 @@ | ||
| import React, { useState } from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { injectIntl, FormattedMessage, intlShape } from '@edx/frontend-platform/i18n'; | ||
|
|
||
| import { | ||
| ModalDialog, | ||
| Stack, | ||
| IconButton, | ||
| ActionRow, | ||
| Icon, | ||
| Truncate, | ||
| IconButtonWithTooltip, | ||
| CheckboxControl, | ||
| } from '@edx/paragon'; | ||
| import { ContentCopy, InfoOutline } from '@edx/paragon/icons'; | ||
| import AssetThumbnail from './FileThumbnail'; | ||
|
|
||
| import messages from './messages'; | ||
|
|
||
| const FileInfo = ({ | ||
| asset, | ||
| isOpen, | ||
| onClose, | ||
| handleLockedAsset, | ||
| // injected | ||
| intl, | ||
| }) => { | ||
| const [lockedState, setLockedState] = useState(asset.locked); | ||
| const handleLock = (e) => { | ||
| const locked = e.target.checked; | ||
| setLockedState(locked); | ||
| handleLockedAsset(asset.id, locked); | ||
| }; | ||
|
|
||
| return ( | ||
| <ModalDialog | ||
| title={asset.displayName} | ||
| isOpen={isOpen} | ||
| onClose={onClose} | ||
| size="lg" | ||
| hasCloseButton | ||
| > | ||
| <ModalDialog.Header> | ||
| <ModalDialog.Title> | ||
| {asset.displayName} | ||
| </ModalDialog.Title> | ||
| </ModalDialog.Header> | ||
| <ModalDialog.Body className="pt-0 x-small"> | ||
| <hr /> | ||
| <div className="row flex-nowrap m-0 mt-4"> | ||
| <div className="col-7 mr-3"> | ||
| <AssetThumbnail | ||
| thumbnail={asset.thumbnail} | ||
| externalUrl={asset.externalUrl} | ||
| displayName={asset.displayName} | ||
| wrapperType={asset.wrapperType} | ||
| /> | ||
| </div> | ||
| <Stack> | ||
| <div className="font-weight-bold"> | ||
| <FormattedMessage {...messages.dateAddedTitle} /> | ||
| </div> | ||
| {asset.dateAdded} | ||
| <div className="font-weight-bold mt-3"> | ||
| <FormattedMessage {...messages.fileSizeTitle} /> | ||
| </div> | ||
| {/* {asset.fileSize} */} | ||
| <hr /> | ||
| <div className="font-weight-bold mt-3"> | ||
| <FormattedMessage {...messages.studioUrlTitle} /> | ||
| </div> | ||
| <ActionRow> | ||
| <Truncate lines={1}> | ||
| {asset.portableUrl} | ||
| </Truncate> | ||
| <ActionRow.Spacer /> | ||
| <IconButton | ||
| src={ContentCopy} | ||
| iconAs={Icon} | ||
| alt={messages.copyStudioUrlTitle.defaultMessage} | ||
| onClick={() => navigator.clipboard.writeText(asset.portableUrl)} | ||
| /> | ||
| </ActionRow> | ||
| <div className="font-weight-bold mt-3"> | ||
| <FormattedMessage {...messages.webUrlTitle} /> | ||
| </div> | ||
| <ActionRow> | ||
| <Truncate lines={1}> | ||
| {asset.externalUrl} | ||
| </Truncate> | ||
| <ActionRow.Spacer /> | ||
| <IconButton | ||
| src={ContentCopy} | ||
| iconAs={Icon} | ||
| alt={messages.copyWebUrlTitle.defaultMessage} | ||
| onClick={() => navigator.clipboard.writeText(asset.externalUrl)} | ||
| /> | ||
| </ActionRow> | ||
| <hr /> | ||
| <ActionRow> | ||
| <div className="font-weight-bold"> | ||
| <FormattedMessage {...messages.lockFileTitle} /> | ||
| </div> | ||
| <IconButtonWithTooltip | ||
| key="lock-file-info" | ||
| tooltipPlacement="top" | ||
| tooltipContent={intl.formatMessage(messages.lockFileTooltipContent)} | ||
| src={InfoOutline} | ||
| iconAs={Icon} | ||
| alt="Info" | ||
| size="inline" | ||
| /> | ||
| <ActionRow.Spacer /> | ||
| <CheckboxControl | ||
| checked={lockedState} | ||
| onChange={handleLock} | ||
| aria-label="Checkbox" | ||
| /> | ||
| </ActionRow> | ||
| </Stack> | ||
| </div> | ||
| <div className="row m-0 pt-3 font-weight-bold"> | ||
| <FormattedMessage {...messages.usageTitle} /> | ||
| </div> | ||
| </ModalDialog.Body> | ||
| </ModalDialog> | ||
| ); | ||
| }; | ||
|
|
||
| FileInfo.propTypes = { | ||
| asset: PropTypes.shape({ | ||
| displayName: PropTypes.string.isRequired, | ||
| wrapperType: PropTypes.string.isRequired, | ||
| locked: PropTypes.bool.isRequired, | ||
| externalUrl: PropTypes.string.isRequired, | ||
| thumbnail: PropTypes.string, | ||
| id: PropTypes.string.isRequired, | ||
| portableUrl: PropTypes.string.isRequired, | ||
| dateAdded: PropTypes.string.isRequired, | ||
| }).isRequired, | ||
| onClose: PropTypes.func.isRequired, | ||
| isOpen: PropTypes.bool.isRequired, | ||
| handleLockedAsset: PropTypes.func.isRequired, | ||
| // injected | ||
| intl: intlShape.isRequired, | ||
| }; | ||
|
|
||
| export default injectIntl(FileInfo); |
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.
Uh oh!
There was an error while loading. Please reload this page.