-
Notifications
You must be signed in to change notification settings - Fork 1
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
feature/toggle-modal #311
Merged
BrianWhitneyAI
merged 13 commits into
feature/local_cloud_toggle
from
feature/toggle-modal
Nov 4, 2024
Merged
feature/toggle-modal #311
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f2a0559
feature/toggle-modal
BrianWhitneyAI f52d31c
add conditional show move menu item
BrianWhitneyAI 77a52bd
modal list to table
BrianWhitneyAI 1201a84
reorder imports
BrianWhitneyAI ae06c75
use existing filesize method
BrianWhitneyAI e159438
add placeholder action
BrianWhitneyAI 8c810a6
add placeholder logic
BrianWhitneyAI 1e3c38b
remove duplicate reducer
BrianWhitneyAI 588447d
update styling for move modal
BrianWhitneyAI 741d415
remove off nas
BrianWhitneyAI 1bc859f
update move only structure
BrianWhitneyAI 034549d
remove loc target
BrianWhitneyAI a450c41
add gradient
BrianWhitneyAI 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
31 changes: 31 additions & 0 deletions
31
packages/core/components/Modal/MoveFileManifest/MoveFileManifest.module.css
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,31 @@ | ||
.file-table-container { | ||
max-height: 300px; | ||
overflow-y: auto; | ||
border: 1px solid var(--border-color); | ||
margin-bottom: var(--margin); | ||
} | ||
|
||
.file-table { | ||
width: 100%; | ||
border-collapse: collapse; | ||
} | ||
|
||
.file-table th, | ||
.file-table td { | ||
padding: 8px; | ||
text-align: left; | ||
border-bottom: 1px solid var(--border-color); | ||
white-space: nowrap; | ||
color: var(--primary-text-color); | ||
} | ||
|
||
.file-table th { | ||
background-color: var(--secondary-background-color); | ||
position: sticky; | ||
top: 0; | ||
z-index: 1; | ||
} | ||
|
||
.file-table td:first-child { | ||
border-right: 1px solid var(--border-color); | ||
} |
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,99 @@ | ||
import filesize from "filesize"; | ||
import * as React from "react"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
|
||
import { ModalProps } from ".."; | ||
import BaseModal from "../BaseModal"; | ||
import { PrimaryButton } from "../../Buttons"; | ||
import FileDetail from "../../../entity/FileDetail"; | ||
import FileSelection from "../../../entity/FileSelection"; | ||
import { interaction, selection } from "../../../state"; | ||
|
||
import styles from "./MoveFileManifest.module.css"; | ||
|
||
/** | ||
* Modal overlay for displaying details of selected files for NAS cache operations. | ||
*/ | ||
export default function MoveFileManifest({ onDismiss }: ModalProps) { | ||
const dispatch = useDispatch(); | ||
const fileService = useSelector(interaction.selectors.getFileService); | ||
const fileSelection = useSelector( | ||
selection.selectors.getFileSelection, | ||
FileSelection.selectionsAreEqual | ||
); | ||
const moveFileTarget = useSelector(interaction.selectors.getMoveFileTarget); | ||
|
||
const [fileDetails, setFileDetails] = React.useState<FileDetail[]>([]); | ||
const [totalSize, setTotalSize] = React.useState<string | undefined>(); | ||
const [isLoading, setLoading] = React.useState(false); | ||
|
||
React.useEffect(() => { | ||
async function fetchDetails() { | ||
setLoading(true); | ||
const details = await fileSelection.fetchAllDetails(); | ||
setFileDetails(details); | ||
|
||
const aggregateInfo = await fileService.getAggregateInformation(fileSelection); | ||
const formattedSize = aggregateInfo.size ? filesize(aggregateInfo.size) : undefined; | ||
setTotalSize(formattedSize); | ||
setLoading(false); | ||
} | ||
|
||
fetchDetails(); | ||
}, [fileSelection, fileService]); | ||
|
||
const onMove = () => { | ||
if (moveFileTarget) { | ||
dispatch(interaction.actions.moveFiles(fileDetails, moveFileTarget)); | ||
onDismiss(); | ||
} else { | ||
console.warn( | ||
"Move file target location is undefined. Cannot proceed with moving files." | ||
BrianWhitneyAI marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
} | ||
}; | ||
|
||
const body = ( | ||
<div> | ||
<p>Selected Files:</p> | ||
<div className={styles.fileTableContainer}> | ||
<table className={styles.fileTable}> | ||
<thead> | ||
<tr> | ||
<th>File Name</th> | ||
<th>File Size</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{fileDetails.map((file) => ( | ||
<tr key={file.id}> | ||
<td>{file.name}</td> | ||
<td>{filesize(file.size || 0)}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
<p>Total Files: {fileDetails.length}</p> | ||
<p>Total Size: {isLoading ? "Loading..." : totalSize}</p> | ||
</div> | ||
); | ||
|
||
return ( | ||
<BaseModal | ||
body={body} | ||
footer={ | ||
<PrimaryButton | ||
className={styles.confirmButton} | ||
disabled={!fileDetails.length} | ||
iconName="Accept" | ||
onClick={onMove} | ||
text="CONFIRM" | ||
title="Confirm" | ||
/> | ||
} | ||
onDismiss={onDismiss} | ||
title={`Move Files to ${moveFileTarget}`} | ||
/> | ||
); | ||
} |
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 |
---|---|---|
|
@@ -147,37 +147,20 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => { | |
dispatch(interaction.actions.downloadFiles()); | ||
}, | ||
}, | ||
{ | ||
key: "move-files", | ||
text: "Move Files", | ||
title: "Move files between NAS Cache", | ||
disabled: !filters && fileSelection.count() === 0, | ||
iconProps: { | ||
iconName: "MoveToFolder", | ||
}, | ||
subMenuProps: { | ||
items: [ | ||
{ | ||
key: "off-nas", | ||
text: "Off NAS Cache", | ||
title: "Move files off the NAS cache", | ||
onClick() { | ||
// Placeholder for moving files off NAS Cache | ||
console.log("Move files off NAS Cache"); | ||
}, | ||
}, | ||
{ | ||
key: "onto-nas", | ||
text: "Onto NAS Cache", | ||
title: "Move files onto the NAS cache", | ||
onClick() { | ||
// Placeholder for moving files onto NAS Cache | ||
console.log("Move files onto NAS Cache"); | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
...(isQueryingAicsFms | ||
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. Lets move this option above "Download" 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. resolved in 034549d |
||
? [ | ||
{ | ||
key: "move-to-cache", | ||
text: "Move to Cache", | ||
title: "Move selected files to NAS Cache", | ||
disabled: !filters && fileSelection.count() === 0, | ||
iconProps: { iconName: "MoveToFolder" }, | ||
onClick() { | ||
dispatch(interaction.actions.showMoveFileManifest("NAS")); | ||
}, | ||
}, | ||
] | ||
: []), | ||
]; | ||
|
||
dispatch( | ||
|
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
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.
Now that we don't have a notion of moving on/off the cache it seems we can remove the idea of having a target. IMO this is likely a YAGNI since other than FMS we won't have control over moving files.
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.
resolved in 034549d