feat(05-02): add scriptTargets filtering and Back button to ReviewStep
- Destructure dispatch from useWizard() alongside state - Derive showIntune and showRmm booleans from state.deployment.scriptTargets - Conditionally unmount Intune OutputBlocks (showIntune) and RMM OutputBlock (showRmm) - rclone.conf OutputBlock always rendered regardless of scriptTargets - handleDownloadZip builds files array dynamically — filters by showIntune/showRmm - Add Back button dispatching SET_STEP(2) following DeploymentStep pattern - All 15 ReviewStep tests green including new TECH-01 and TECH-02 cases
This commit is contained in:
@@ -15,7 +15,7 @@ import { downloadZip } from '../../utils/downloadZip';
|
|||||||
const PLACEHOLDER = '# Fill in the wizard steps to generate your rclone.conf';
|
const PLACEHOLDER = '# Fill in the wizard steps to generate your rclone.conf';
|
||||||
|
|
||||||
export function ReviewStep() {
|
export function ReviewStep() {
|
||||||
const { state } = useWizard();
|
const { state, dispatch } = useWizard();
|
||||||
const [acknowledged, setAcknowledged] = useState(false);
|
const [acknowledged, setAcknowledged] = useState(false);
|
||||||
|
|
||||||
// CONF-02: live preview — updates on every state change
|
// CONF-02: live preview — updates on every state change
|
||||||
@@ -51,17 +51,22 @@ export function ReviewStep() {
|
|||||||
}
|
}
|
||||||
}, [state]);
|
}, [state]);
|
||||||
|
|
||||||
// DOWN-05: ZIP bundle — always include all 4 files
|
const showIntune = state.deployment.scriptTargets.includes('intune');
|
||||||
|
const showRmm = state.deployment.scriptTargets.includes('rmm');
|
||||||
|
|
||||||
|
// DOWN-05: ZIP bundle — filtered by scriptTargets (TECH-01)
|
||||||
async function handleDownloadZip() {
|
async function handleDownloadZip() {
|
||||||
await downloadZip(
|
const files: { name: string; content: string }[] = [
|
||||||
[
|
|
||||||
{ name: 'rclone.conf', content: rcloneConf },
|
{ name: 'rclone.conf', content: rcloneConf },
|
||||||
{ name: 'intune-install.ps1', content: intuneInstall },
|
];
|
||||||
{ name: 'intune-detection.ps1', content: intuneDetection },
|
if (showIntune) {
|
||||||
{ name: 'rmm-script.ps1', content: rmmScript },
|
files.push({ name: 'intune-install.ps1', content: intuneInstall });
|
||||||
],
|
files.push({ name: 'intune-detection.ps1', content: intuneDetection });
|
||||||
'rclone-deployment.zip'
|
}
|
||||||
);
|
if (showRmm) {
|
||||||
|
files.push({ name: 'rmm-script.ps1', content: rmmScript });
|
||||||
|
}
|
||||||
|
await downloadZip(files, 'rclone-deployment.zip');
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -93,24 +98,41 @@ export function ReviewStep() {
|
|||||||
filename="rclone.conf"
|
filename="rclone.conf"
|
||||||
disabled={!acknowledged}
|
disabled={!acknowledged}
|
||||||
/>
|
/>
|
||||||
|
{showIntune && (
|
||||||
<OutputBlock
|
<OutputBlock
|
||||||
label="Intune Install Script"
|
label="Intune Install Script"
|
||||||
content={intuneInstall}
|
content={intuneInstall}
|
||||||
filename="intune-install.ps1"
|
filename="intune-install.ps1"
|
||||||
disabled={!acknowledged}
|
disabled={!acknowledged}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{showIntune && (
|
||||||
<OutputBlock
|
<OutputBlock
|
||||||
label="Intune Detection Script"
|
label="Intune Detection Script"
|
||||||
content={intuneDetection}
|
content={intuneDetection}
|
||||||
filename="intune-detection.ps1"
|
filename="intune-detection.ps1"
|
||||||
disabled={!acknowledged}
|
disabled={!acknowledged}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{showRmm && (
|
||||||
<OutputBlock
|
<OutputBlock
|
||||||
label="RMM Script"
|
label="RMM Script"
|
||||||
content={rmmScript}
|
content={rmmScript}
|
||||||
filename="rmm-script.ps1"
|
filename="rmm-script.ps1"
|
||||||
disabled={!acknowledged}
|
disabled={!acknowledged}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* TECH-02: Back button — dispatches SET_STEP(2) */}
|
||||||
|
<div className="flex gap-3 mt-6">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => dispatch({ type: 'SET_STEP', payload: 2 })}
|
||||||
|
className="px-4 py-2 text-sm border border-gray-300 rounded-md hover:bg-gray-50"
|
||||||
|
>
|
||||||
|
Back
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* DOWN-05: ZIP bundle */}
|
{/* DOWN-05: ZIP bundle */}
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user