Skip to content

Commit

Permalink
Integrate selector to retrieve message and entry in restore progress
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieur-z committed Nov 5, 2020
1 parent 80e1af5 commit bbf96a8
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions client/my-sites/backup/rewind-flow/restore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Gridicon from 'calypso/components/gridicon';
import Loading from './loading';
import ProgressBar from './progress-bar';
import QueryRewindState from 'calypso/components/data/query-rewind-state';
import QueryRewindRestoreStatus from 'calypso/components/data/query-rewind-restore-status';
import RewindConfigEditor from './rewind-config-editor';
import RewindFlowNotice, { RewindFlowNoticeLevel } from './rewind-flow-notice';

Expand Down Expand Up @@ -50,26 +49,16 @@ const BackupRestoreFlow: FunctionComponent< Props > = ( {
const [ userHasRequestedRestore, setUserHasRequestedRestore ] = useState< boolean >( false );

const rewindState = useSelector( ( state ) => getRewindState( state, siteId ) ) as RewindState;

const loading = rewindState.state === 'uninitialized';
const restoreId = rewindState.rewind?.restoreId;

// TODO: use selectors
const currentEntry = 'wp_options'; // useSelector( ( state ) => ( restoreId ? ... : undefined ) );
const message = 'Importing database'; // useSelector( ( state ) => ( restoreId ? ... : undefined ) );
const inProgressRewindStatus = useSelector( ( state ) =>
getInProgressRewindStatus( state, siteId, rewindId )
);
const inProgressRewindPercentComplete = useSelector( ( state ) =>
getInProgressRewindPercentComplete( state, siteId, rewindId )
);

const inProgressRewindEntryDetails = useSelector( ( state ) =>
getInProgressRewindEntryDetails( state, siteId, rewindId )
);

console.log( inProgressRewindEntryDetails );

const requestRestore = useCallback(
() => dispatch( rewindRestore( siteId, rewindId, rewindConfig ) ),
[ dispatch, rewindConfig, rewindId, siteId ]
Expand All @@ -79,6 +68,9 @@ const BackupRestoreFlow: FunctionComponent< Props > = ( {
requestRestore();
}, [ setUserHasRequestedRestore, requestRestore ] );

const loading = rewindState.state === 'uninitialized';
const { message, entry } = inProgressRewindEntryDetails;

const renderConfirm = () => (
<>
<div className="rewind-flow__header">
Expand Down Expand Up @@ -124,7 +116,7 @@ const BackupRestoreFlow: FunctionComponent< Props > = ( {
<h3 className="rewind-flow__title">{ translate( 'Currently restoring your site' ) }</h3>
<ProgressBar
message={ message }
entry={ currentEntry }
entry={ entry }
percent={ inProgressRewindPercentComplete }
/>
<p className="rewind-flow__info">
Expand Down Expand Up @@ -218,7 +210,6 @@ const BackupRestoreFlow: FunctionComponent< Props > = ( {
return (
<>
<QueryRewindState siteId={ siteId } />
{ restoreId && <QueryRewindRestoreStatus siteId={ siteId } restoreId={ restoreId } /> }
{ render() }
</>
);
Expand Down

0 comments on commit bbf96a8

Please sign in to comment.