-
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.
Add details to restore progress screen (#47153)
* Move RewindState type in dedicated file * Add useCallback hook * Add details to restore progress - WIP * Add new rewind API fields, "message" & "current_entry" * Add selector getInProgressRewindEntryDetails. * Implement selector inProgressRewindEntryDetails for test. * Remove schema validation for message & current_entry for now.. * Integrate selector to retrieve message and entry in restore progress * Fix restore progress screen not showing proper details Co-authored-by: elliottprogrammer <bryan@elliottprogrammer.com>
- Loading branch information
1 parent
054d9d1
commit cf42ff9
Showing
7 changed files
with
114 additions
and
19 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
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
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,7 @@ | ||
export interface RewindState { | ||
state: string; | ||
rewind?: { | ||
status: 'queued' | 'running' | 'finished' | 'fail'; | ||
restoreId?: number; | ||
}; | ||
} |
33 changes: 33 additions & 0 deletions
33
client/state/selectors/get-in-progress-rewind-entry-details.js
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,33 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { pick } from 'lodash'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import getRewindState from './get-rewind-state'; | ||
|
||
/** | ||
* @typedef {Object} EntryDetails | ||
* @property {string} message - The description of current action taking place | ||
* @property {string} currentEntry - The value (filename/tablename) being processed | ||
*/ | ||
|
||
/** | ||
* Returns object containing rewind status current entry and message | ||
* | ||
* @param {object} globalState Global state tree | ||
* @param {?number|string} siteId the site ID | ||
* @param {string} rewindId the id of the rewind to get the rewind status entry and message | ||
* @returns {EntryDetails} Details of the current rewind action | ||
*/ | ||
export default function getInProgressRewindEntryDetails( globalState, siteId, rewindId ) { | ||
const { state, rewind } = getRewindState( globalState, siteId ); | ||
|
||
if ( 'active' === state && rewind?.rewindId === rewindId ) { | ||
return pick( rewind, [ 'message', 'currentEntry' ] ); | ||
} | ||
|
||
return {}; | ||
} |