-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BackupScheduleSetting: add next scheduled backup time on Latest Backu…
…p section (#95602) * Decouple convertHourToRange into an utils file convertHourToRange now receives a moment instance * Add useNextBackupSchedule hook * Add NextScheduledBackup component * Add NextScheduledBackup on backup successful view Also we are moving the actions toolbar to the bottom * Fix daily backup <p> font size * Refactor actions toolbar to allow SplitButton Migrating actions to its own components and refactor RestoreButton to allow be grouped as a SplitButton * Add useSplitButton prop to Toolbar component Refactored classNames using clsx to consider custom class names depending on the type of content * Refactor to include Toolbar using useSplitButton prop * Adjust split button styles * Fix button margin * Render NextScheduledBackup under a feature flag * Remove unnecessary optional chaining operator * Ensure next backup is not moved to the next day Ensure next backup is not moved to the next day within the backup window
- Loading branch information
Showing
14 changed files
with
408 additions
and
107 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
client/components/activity-card/toolbar/actions/credentials-prompt.tsx
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,37 @@ | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { FunctionComponent } from 'react'; | ||
import missingCredentialsIcon from 'calypso/components/jetpack/daily-backup-status/missing-credentials.svg'; | ||
import { settingsPath } from 'calypso/lib/jetpack/paths'; | ||
import { useDispatch } from 'calypso/state'; | ||
import { recordTracksEvent } from 'calypso/state/analytics/actions/record'; | ||
|
||
type CredentialsPromptProps = { | ||
siteSlug: string; | ||
}; | ||
|
||
const CredentialsPrompt: FunctionComponent< CredentialsPromptProps > = ( { siteSlug } ) => { | ||
const dispatch = useDispatch(); | ||
const translate = useTranslate(); | ||
|
||
const onClick = () => { | ||
dispatch( recordTracksEvent( 'calypso_jetpack_backup_actions_credentials_click' ) ); | ||
}; | ||
|
||
return ( | ||
<div className="toolbar__credentials-warning"> | ||
<img src={ missingCredentialsIcon } alt="" role="presentation" /> | ||
<div className="toolbar__credentials-warning-text"> | ||
{ translate( | ||
'{{a}}Enter your server credentials{{/a}} to enable one-click restores from your backups.', | ||
{ | ||
components: { | ||
a: <a href={ settingsPath( siteSlug ) } onClick={ onClick } />, | ||
}, | ||
} | ||
) } | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CredentialsPrompt; |
46 changes: 46 additions & 0 deletions
46
client/components/activity-card/toolbar/actions/download-button.tsx
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,46 @@ | ||
import { download as downloadIcon, Icon } from '@wordpress/icons'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { FunctionComponent } from 'react'; | ||
import Button from 'calypso/components/forms/form-button'; | ||
import { backupDownloadPath } from 'calypso/my-sites/backup/paths'; | ||
import { useDispatch } from 'calypso/state'; | ||
import { rewindRequestBackup } from 'calypso/state/activity-log/actions'; | ||
import { recordTracksEvent } from 'calypso/state/analytics/actions/record'; | ||
|
||
type DownloadButtonProps = { | ||
siteId: number; | ||
siteSlug: string; | ||
rewindId: string; | ||
}; | ||
|
||
const DownloadButton: FunctionComponent< DownloadButtonProps > = ( { | ||
siteId, | ||
siteSlug, | ||
rewindId, | ||
} ) => { | ||
const translate = useTranslate(); | ||
const dispatch = useDispatch(); | ||
const onDownloadClick = () => { | ||
dispatch( | ||
recordTracksEvent( 'calypso_jetpack_backup_actions_download_click', { | ||
rewind_id: rewindId, | ||
} ) | ||
); | ||
dispatch( rewindRequestBackup( siteId, rewindId ) ); | ||
}; | ||
return ( | ||
<Button | ||
borderless | ||
compact | ||
isPrimary={ false } | ||
onClick={ onDownloadClick } | ||
href={ backupDownloadPath( siteSlug, rewindId ) } | ||
className="toolbar__download-button" | ||
> | ||
<Icon icon={ downloadIcon } className="toolbar__download-button-icon" size={ 18 } /> | ||
{ translate( 'Download backup' ) } | ||
</Button> | ||
); | ||
}; | ||
|
||
export default DownloadButton; |
61 changes: 61 additions & 0 deletions
61
client/components/activity-card/toolbar/actions/restore-button.tsx
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,61 @@ | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { FunctionComponent, ReactNode } from 'react'; | ||
import Button from 'calypso/components/forms/form-button'; | ||
import SplitButton from 'calypso/components/split-button'; | ||
import { backupRestorePath } from 'calypso/my-sites/backup/paths'; | ||
import { useDispatch, useSelector } from 'calypso/state'; | ||
import { recordTracksEvent } from 'calypso/state/analytics/actions/record'; | ||
import canRestoreSite from 'calypso/state/rewind/selectors/can-restore-site'; | ||
|
||
type RestoreButtonProps = { | ||
siteId: number; | ||
siteSlug: string; | ||
rewindId: string; | ||
secondaryActions?: ReactNode[]; | ||
}; | ||
|
||
const RestoreButton: FunctionComponent< RestoreButtonProps > = ( { | ||
siteId, | ||
siteSlug, | ||
rewindId, | ||
secondaryActions = [], | ||
} ) => { | ||
const translate = useTranslate(); | ||
const dispatch = useDispatch(); | ||
const isRestoreDisabled = useSelector( ( state ) => ! canRestoreSite( state, siteId ) ); | ||
const onRestoreClick = () => { | ||
dispatch( recordTracksEvent( 'calypso_jetpack_backup_actions_restore_click' ) ); | ||
}; | ||
|
||
const buttonLabel = translate( 'Restore to this point' ); | ||
|
||
// Conditionally render as a SplitButton if there are secondary actions | ||
if ( secondaryActions.length > 0 ) { | ||
return ( | ||
<SplitButton | ||
className="toolbar__restore-button" | ||
disableMain={ isRestoreDisabled } | ||
href={ ! isRestoreDisabled && backupRestorePath( siteSlug, rewindId ) } | ||
label={ buttonLabel } | ||
onClick={ onRestoreClick } | ||
primary | ||
whiteSeparator | ||
> | ||
{ secondaryActions } | ||
</SplitButton> | ||
); | ||
} | ||
|
||
return ( | ||
<Button | ||
href={ ! isRestoreDisabled && backupRestorePath( siteSlug, rewindId ) } | ||
className="toolbar__restore-button" | ||
disabled={ isRestoreDisabled } | ||
onClick={ onRestoreClick } | ||
> | ||
{ buttonLabel } | ||
</Button> | ||
); | ||
}; | ||
|
||
export default RestoreButton; |
File renamed without changes.
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.