-
Notifications
You must be signed in to change notification settings - Fork 2
Fixed Upload Data Modal and Download Data Modal #331
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
base: main
Are you sure you want to change the base?
Changes from all commits
2aa3976
cdb8d75
1778cc5
c4680bd
ac59c7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,11 +14,41 @@ | |
| } | ||
|
|
||
| .tableWrapper { | ||
| height: 35rem; | ||
| height: 30rem; | ||
| @include mixins.scrollbar-dark; | ||
| } | ||
| } | ||
|
|
||
| .submitButton { | ||
| margin-top: 1.25rem; | ||
| /* Responsive styles for smaller desktop windows */ | ||
| @media screen and (max-width: 1400px) { | ||
| .downloadModal { | ||
| width: 60rem; | ||
|
|
||
| .tableWrapper { | ||
| height: 30rem; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @media screen and (max-width: 1024px) { | ||
|
Collaborator
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. Use your mixin |
||
| .downloadModal { | ||
|
Collaborator
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. This sorta stuff could also be done in baseModal maybe so itll affect this, the upload and the preset and every other modal down the line |
||
| width: 50rem; | ||
| padding: 0 1.5rem; | ||
|
|
||
| .tableWrapper { | ||
| height: 30rem; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @media screen and (max-width: 768px) { | ||
|
Collaborator
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. Use your mixin |
||
| .downloadModal { | ||
| width: 90vw; | ||
| max-width: 35rem; | ||
| padding: 0 1rem; | ||
|
|
||
| .tableWrapper { | ||
| height: 20rem; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import styles from './PresetFilesModal.module.scss'; | ||
| import baseModalStyles from '@components/ui/baseModal/BaseModal.module.scss'; | ||
| import { BaseModal } from '@components/ui/baseModal/BaseModal'; | ||
| import { FileTable } from '@components/ui/fileTable/FileTable'; | ||
| import { UploadForm } from '@components/ui/uploadForm/UploadForm'; | ||
| import { Button } from '@components/ui/button/Button'; | ||
| import { useState, useEffect } from 'react'; | ||
| import { rightArrowIcon } from '@assets/icons'; | ||
|
|
@@ -22,8 +22,7 @@ interface PresetFilesModalProps { | |
| export const PresetFilesModal = ({ onClose, isOpen, onSubmit, currentSources }: PresetFilesModalProps) => { | ||
| // TODO: Adjust based on preset | ||
| const [selectedFiles, setSelectedFiles] = useState<FileInformation[]>([]); | ||
| const [uploadedFiles, setUploadedFiles] = useState<File[]>([]); | ||
| const { data: files, refetch } = useFiles(); | ||
| const { data: files } = useFiles(); | ||
|
|
||
| // Pre-select files based on currentSources prop | ||
| useEffect(() => { | ||
|
|
@@ -37,53 +36,32 @@ export const PresetFilesModal = ({ onClose, isOpen, onSubmit, currentSources }: | |
| }, [currentSources, files]); | ||
|
|
||
| const handleSubmit = async () => { | ||
| if (selectedFiles.length === 0 && uploadedFiles.length === 0) { | ||
| showWarningToast('Oops!', 'Please select or upload at least one file'); | ||
| if (selectedFiles.length === 0) { | ||
| showWarningToast('Oops!', 'Please select at least one file'); | ||
| return; | ||
| } | ||
|
|
||
| const uploadPromises = uploadedFiles.map((file) => ApiUtil.uploadFile(file)); | ||
| await Promise.all(uploadPromises); | ||
|
|
||
| const fileKeys = selectedFiles.map((file) => file.key); | ||
|
|
||
| const uploadedFolderNames = uploadedFiles.map((file) => { | ||
| return file.name.substring(0, file.name.lastIndexOf('.')); | ||
| }); | ||
|
|
||
| fileKeys.push(...uploadedFolderNames); | ||
|
|
||
| onSubmit(fileKeys); | ||
| onClose(); | ||
| refetch(); // Refetch files after upload | ||
| }; | ||
|
|
||
| return ( | ||
| <BaseModal isOpen={isOpen} onClose={onClose}> | ||
| <div className={styles.presetFilesModal}> | ||
|
|
||
| <div className={styles.formWrapper}> | ||
| <div className={styles.uploadForm}> | ||
| <h2 className={styles.title}>Upload your files</h2> | ||
| <UploadForm files={uploadedFiles} setFiles={setUploadedFiles} accept={'.bin'}/> | ||
| </div> | ||
|
|
||
| <div className={styles.selectFiles}> | ||
| <h2 className={styles.title}>...Or select existing ones</h2> | ||
| <div className={styles.tableWrapper}> | ||
| <FileTable | ||
| files={getFolders(files || [])} | ||
| selectedFiles={selectedFiles} | ||
| setSelectedFiles={setSelectedFiles} | ||
| /> | ||
| </div> | ||
| </div> | ||
| <h2 className={styles.title}>Select a file</h2> | ||
| <div className={styles.tableWrapper}> | ||
| <FileTable | ||
| files={getFolders(files || [])} | ||
| selectedFiles={selectedFiles} | ||
| setSelectedFiles={setSelectedFiles} | ||
|
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. Looks like even on normal screen sizes these changes eliminate the upload functionality entirely from the preset files modal
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. IIRC, I thought we agreed that the upload functionality wasnt necessary when clicking on the preset files in general?
Collaborator
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. No, only on mobile sizes. Neccesary on desktop |
||
| /> | ||
| </div> | ||
|
|
||
| <Button | ||
| onClick={handleSubmit} | ||
| textSize={'2rem'} | ||
| className={styles.submitButton} | ||
| className={baseModalStyles.submitButton} | ||
| > | ||
| <span>Submit</span> | ||
| <img src={rightArrowIcon} alt="right arrow"/> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,5 +26,4 @@ export const PresetCard = ({ image, name, description, fileCount, onClick }: Pre | |
| </div> | ||
| </button> | ||
| ); | ||
| }; | ||
|
|
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,30 @@ | ||
| @use '@styles/_fonts'; | ||
|
|
||
|
|
||
| .uploadModal { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| width: 40rem; | ||
| height: 34rem; | ||
| padding: 0 2rem; | ||
|
|
||
| .title { | ||
| all: unset; | ||
| @include fonts.title-large; | ||
| } | ||
| } | ||
|
|
||
| @media screen and (max-width: 1024px) { | ||
| .uploadModal { | ||
| width: 35rem; | ||
| padding: 0 1.5rem; | ||
| } | ||
| } | ||
|
|
||
| .submitButton { | ||
| margin-top: 1.25rem; | ||
| @media screen and (max-width: 768px) { | ||
| .uploadModal { | ||
| width: 90vw; | ||
| max-width: 26rem; | ||
| padding: 0 1rem; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { useFiles } from '@lib/files/useFiles'; | |
| import { showErrorToast, showSuccessToast } from '@components/ui/toastNotification/ToastNotification'; | ||
| import { rightArrowIcon } from '@assets/icons'; | ||
| import styles from './uploadModal.module.scss'; | ||
| import baseModalStyles from '@components/ui/baseModal/BaseModal.module.scss'; | ||
|
Collaborator
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. Don't do this! Styles are all co-located. If you have styles in baseModalStyles, they are meant to apply to parts in the baseModal. When I suggested doing styles in baseModal this was because you could just apply the styles to the root directly. You should never import a different style file |
||
|
|
||
| interface UploadModalProps { | ||
| isOpen: boolean; | ||
|
|
@@ -80,7 +81,7 @@ export const UploadModal = ({ isOpen, onClose }: UploadModalProps) => { | |
| <Button | ||
| onClick={submitFiles} | ||
| textSize={'2rem'} | ||
| className={styles.submitButton} | ||
| className={baseModalStyles.submitButton} | ||
| disabled={files.length === 0} | ||
| > | ||
| <span>Submit</span> | ||
|
|
||
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.
Use your mixin