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';
|
||||
|
||||
export function ReviewStep() {
|
||||
const { state } = useWizard();
|
||||
const { state, dispatch } = useWizard();
|
||||
const [acknowledged, setAcknowledged] = useState(false);
|
||||
|
||||
// CONF-02: live preview — updates on every state change
|
||||
@@ -51,17 +51,22 @@ export function ReviewStep() {
|
||||
}
|
||||
}, [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() {
|
||||
await downloadZip(
|
||||
[
|
||||
{ name: 'rclone.conf', content: rcloneConf },
|
||||
{ name: 'intune-install.ps1', content: intuneInstall },
|
||||
{ name: 'intune-detection.ps1', content: intuneDetection },
|
||||
{ name: 'rmm-script.ps1', content: rmmScript },
|
||||
],
|
||||
'rclone-deployment.zip'
|
||||
);
|
||||
const files: { name: string; content: string }[] = [
|
||||
{ name: 'rclone.conf', content: rcloneConf },
|
||||
];
|
||||
if (showIntune) {
|
||||
files.push({ name: 'intune-install.ps1', content: intuneInstall });
|
||||
files.push({ name: 'intune-detection.ps1', content: intuneDetection });
|
||||
}
|
||||
if (showRmm) {
|
||||
files.push({ name: 'rmm-script.ps1', content: rmmScript });
|
||||
}
|
||||
await downloadZip(files, 'rclone-deployment.zip');
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -93,24 +98,41 @@ export function ReviewStep() {
|
||||
filename="rclone.conf"
|
||||
disabled={!acknowledged}
|
||||
/>
|
||||
<OutputBlock
|
||||
label="Intune Install Script"
|
||||
content={intuneInstall}
|
||||
filename="intune-install.ps1"
|
||||
disabled={!acknowledged}
|
||||
/>
|
||||
<OutputBlock
|
||||
label="Intune Detection Script"
|
||||
content={intuneDetection}
|
||||
filename="intune-detection.ps1"
|
||||
disabled={!acknowledged}
|
||||
/>
|
||||
<OutputBlock
|
||||
label="RMM Script"
|
||||
content={rmmScript}
|
||||
filename="rmm-script.ps1"
|
||||
disabled={!acknowledged}
|
||||
/>
|
||||
{showIntune && (
|
||||
<OutputBlock
|
||||
label="Intune Install Script"
|
||||
content={intuneInstall}
|
||||
filename="intune-install.ps1"
|
||||
disabled={!acknowledged}
|
||||
/>
|
||||
)}
|
||||
{showIntune && (
|
||||
<OutputBlock
|
||||
label="Intune Detection Script"
|
||||
content={intuneDetection}
|
||||
filename="intune-detection.ps1"
|
||||
disabled={!acknowledged}
|
||||
/>
|
||||
)}
|
||||
{showRmm && (
|
||||
<OutputBlock
|
||||
label="RMM Script"
|
||||
content={rmmScript}
|
||||
filename="rmm-script.ps1"
|
||||
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 */}
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user