app.js
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* global blockLabMigration */
// @ts-check
/**
* External dependencies
*/
import * as React from 'react';
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import { Intro } from './';
import { BackUpSite, GetGenesisPro, InstallActivateGcb, MigrateBlocks, UpdateHooks } from './steps';
import { FIRST_STEP_NUMBER } from '../constants';
/**
* The migration admin page.
*
* @return {React.ReactElement} The component for the admin page.
*/
const App = () => {
const [ currentStepIndex, setStepIndex ] = useState( FIRST_STEP_NUMBER );
/**
* Sets the step index to the previous step.
*/
const goToPrevious = () => {
setStepIndex( currentStepIndex - 1 );
};
/**
* Sets the step index to the next step.
*/
const goToNext = () => {
setStepIndex( currentStepIndex + 1 );
};
const steps = [
BackUpSite,
UpdateHooks,
InstallActivateGcb,
MigrateBlocks,
];
// Conditionally add the step to get Genesis Pro.
// @ts-ignore
if ( blockLabMigration.isPro ) {
steps.unshift( GetGenesisPro );
}
return (
<div className="bl-migration__content-wrapper">
<div className="container bl-migration__content-container">
<Intro />
{
steps.map( ( MigrationStep, index ) => {
const stepIndex = FIRST_STEP_NUMBER + index;
const isStepActive = currentStepIndex === stepIndex;
const isStepComplete = currentStepIndex > stepIndex;
return (
<MigrationStep
key={ `bl-migration-step-${ stepIndex }` }
{ ...{ currentStepIndex, goToNext, goToPrevious, isStepActive, isStepComplete, stepIndex } }
/>
);
} )
}
</div>
</div>
);
};
export default App;