-
Notifications
You must be signed in to change notification settings - Fork 52
Studio: Show sync selection size (e.g. 1.2 GB / 2 GB) in site push dialog #2125
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 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
408ea8d
Add basic implementation
147cad6
Account for footer sizing
faa7520
Add custom progress bar
55a14f2
Minor styling
fae101c
Final adjustments for the style
5e2d435
Component refactor
1ac4d9d
Ensure we use color variables
4c446f8
Rename bytes
928a8a0
Add total limit on the right
06532ae
Merge branch 'trunk' of github.com:Automattic/studio into add/site-si…
sejas 0ee447e
Make the file size calculation recursive
sejas 9c2db09
Add special condition for mu-plugins
sejas 0f68de1
For mu-plugins calculate it only for selected nodes because we have s…
sejas d1766cd
Reuse SYNC_PUSH_SIZE_LIMIT_BYTES constant
sejas a5dcbf2
Fix tests by making wpContentIndeterminate more real
sejas 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
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 |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import { ArrowIcon } from 'src/components/arrow-icon'; | |
| import Button from 'src/components/button'; | ||
| import { RightArrowIcon } from 'src/components/icons/right-arrow'; | ||
| import Modal from 'src/components/modal'; | ||
| import { TwoColorProgressBar } from 'src/components/progress-bar'; | ||
| import { Tooltip } from 'src/components/tooltip'; | ||
| import { TreeView, TreeNode, updateNodeById } from 'src/components/tree-view'; | ||
| import { SYNC_PUSH_SIZE_LIMIT_GB } from 'src/constants'; | ||
|
|
@@ -140,11 +141,15 @@ export function SyncDialog( { | |
| const [ showAllFiles, setShowAllFiles ] = useState( false ); | ||
| const [ treeState, setTreeState ] = useState< TreeNode[] >( defaultTree ); | ||
| const isSubmitDisabled = treeState.every( ( node ) => ! node.checked && ! node.indeterminate ); | ||
| const { isPushSelectionOverLimit, isLoading: isSizeCheckLoading } = useSelectedItemsPushSize( | ||
| localSite.id, | ||
| treeState, | ||
| type | ||
| ); | ||
| const { | ||
| isPushSelectionOverLimit, | ||
| isLoading: isSizeCheckLoading, | ||
| totalSize, | ||
| limitBytes, | ||
| formattedSize, | ||
| formattedLimit, | ||
| formattedOverAmount, | ||
| } = useSelectedItemsPushSize( localSite.id, treeState, type ); | ||
|
|
||
| const { fetchChildren, rewindId, isLoadingRewindId, isErrorRewindId, isLoadingLocalFileTree } = | ||
| useDynamicTreeState( type, localSite.id, remoteSite.id, setTreeState ); | ||
|
|
@@ -218,13 +223,23 @@ export function SyncDialog( { | |
| onRequestClose(); | ||
| }; | ||
|
|
||
| const getBottomPadding = () => { | ||
| if ( type === 'pull' ) { | ||
| return 'pb-[70px]'; // Original padding for pull | ||
|
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. I left these comments for the ease of reading the function. They could be removed if they seem self-explanatory |
||
| } | ||
| if ( isPushSelectionOverLimit ) { | ||
| return 'pb-[200px]'; // Progress bar + warning notice | ||
| } | ||
| return 'pb-[110px]'; // Just progress bar | ||
| }; | ||
|
|
||
| return ( | ||
| <Modal | ||
| className="w-3/5 min-w-[550px] max-h-[84vh] [&>div]:!p-0" | ||
| onRequestClose={ onRequestClose } | ||
| title={ syncTexts.title } | ||
| > | ||
| <div className={ isPushSelectionOverLimit ? 'pb-[140px]' : 'pb-[70px]' }> | ||
| <div className={ getBottomPadding() }> | ||
| <div className="px-8 pb-6 pt-1">{ syncTexts.description }</div> | ||
| <div className="px-8"> | ||
| <span className="sr-only"> | ||
|
|
@@ -321,7 +336,19 @@ export function SyncDialog( { | |
| </div> | ||
| </Tooltip> | ||
|
|
||
| <div className="px-8 py-4 absolute left-0 right-0 bottom-0 bg-white z-10"> | ||
| <div className="px-8 py-4 absolute left-0 right-0 bottom-0 bg-white z-10 border-t border-a8c-gray-5"> | ||
| { type === 'push' && ( | ||
| <div className="mb-4"> | ||
| <TwoColorProgressBar | ||
| value={ totalSize } | ||
| maxValue={ limitBytes } | ||
| showLabels | ||
| valueLabel={ formattedSize } | ||
| limitLabel={ formattedLimit } | ||
| overLimitLabel={ sprintf( __( '%s over' ), formattedOverAmount ) } | ||
| /> | ||
| </div> | ||
| ) } | ||
| { type === 'push' && isPushSelectionOverLimit && ( | ||
| <Notice status="warning" isDismissible={ false } className="mb-4"> | ||
|
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. |
||
| <p data-testid="push-selection-over-limit-notice"> | ||
|
|
||
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
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.
I tried to achieve this with
ProgressBarbut that component is too simple so I opted for this custom simple implementation.