From d270c1a2c9553654df5a32cca1705f503b3f5910 Mon Sep 17 00:00:00 2001 From: "Shaun A. Noordin" Date: Fri, 17 May 2024 23:31:29 +0100 Subject: [PATCH] Pages Editor: add "Choose Starting Page" dropdown (#7088) * pages-editor-pt21: reorganise WorkflowHeader, now has preview link * WorkflowHeader: minor restyle * WorkflowHeader: minor restyle * TasksPage: replace preview link with 'choose starting page' dropdown * TasksPage: update list of starting pages * TasksPage: implement choose starting page * TasksPage: setting Starting Page will now just rearrange Steps * TasksPage: restyle starting page dropdown * TasksPage: hide 'choose starting page' dropdown if 0 steps --- .../TasksPage/ExperimentalPanel.jsx | 2 + .../components/TasksPage/TasksPage.jsx | 45 ++++++++++------ .../components/WorkflowHeader.jsx | 31 ++++++++--- .../WorkflowSettingsPage.jsx | 7 +-- css/lab-pages-editor.styl | 54 ++++++++++++------- 5 files changed, 94 insertions(+), 45 deletions(-) diff --git a/app/pages/lab-pages-editor/components/TasksPage/ExperimentalPanel.jsx b/app/pages/lab-pages-editor/components/TasksPage/ExperimentalPanel.jsx index 636f3bc773..6d18b28da5 100644 --- a/app/pages/lab-pages-editor/components/TasksPage/ExperimentalPanel.jsx +++ b/app/pages/lab-pages-editor/components/TasksPage/ExperimentalPanel.jsx @@ -5,6 +5,7 @@ export default function ExperimentalPanel({ }) { function experimentalReset() { update({ + first_task: '', tasks: {}, steps: [] }); @@ -12,6 +13,7 @@ export default function ExperimentalPanel({ function experimentalQuickSetup() { update({ + first_task: '', tasks: { 'T0': { answers: [ diff --git a/app/pages/lab-pages-editor/components/TasksPage/TasksPage.jsx b/app/pages/lab-pages-editor/components/TasksPage/TasksPage.jsx index 8d1e1b60a0..d040477d0a 100644 --- a/app/pages/lab-pages-editor/components/TasksPage/TasksPage.jsx +++ b/app/pages/lab-pages-editor/components/TasksPage/TasksPage.jsx @@ -7,21 +7,20 @@ import getNewStepKey from '../../helpers/getNewStepKey.js'; import getNewTaskKey from '../../helpers/getNewTaskKey.js'; import moveItemInArray from '../../helpers/moveItemInArray.js'; import cleanupTasksAndSteps from '../../helpers/cleanupTasksAndSteps.js'; -import getPreviewEnv from '../../helpers/getPreviewEnv.js'; // import strings from '../../strings.json'; // TODO: move all text into strings import ExperimentalPanel from './ExperimentalPanel.jsx'; import EditStepDialog from './components/EditStepDialog'; import NewTaskDialog from './components/NewTaskDialog.jsx'; import StepItem from './components/StepItem'; -import ExternalLinkIcon from '../../icons/ExternalLinkIcon.jsx'; export default function TasksPage() { - const { project, workflow, update } = useWorkflowContext(); + const { workflow, update } = useWorkflowContext(); const editStepDialog = useRef(null); const newTaskDialog = useRef(null); const [ activeStepIndex, setActiveStepIndex ] = useState(-1); // Tracks which Step is being edited. const [ activeDragItem, setActiveDragItem ] = useState(-1); // Keeps track of active item being dragged (StepItem). This is because "dragOver" CAN'T read the data from dragEnter.dataTransfer.getData(). + const firstStepKey = workflow?.steps?.[0]?.[0] || ''; const isActive = true; // TODO /* @@ -156,6 +155,13 @@ export default function TasksPage() { setActiveStepIndex(-1); } + function handleChangeStartingPage(e) { + const targetStepKey = e?.target?.value || ''; + const targetStepIndex = workflow?.steps?.findIndex(([stepKey]) => stepKey === targetStepKey) || -1; + if (targetStepIndex < 0) return; + moveStep(targetStepIndex, 0); + } + // Changes the optional "next page" of a step/page function updateNextStepForStep(stepKey, next = undefined) { if (!workflow || !workflow.steps) return; @@ -201,15 +207,14 @@ export default function TasksPage() { stepHasOneTask: activeStep?.[1]?.taskKeys?.length > 0, stepHasManyTasks: activeStep?.[1]?.taskKeys?.length > 1 } - const previewEnv = getPreviewEnv(); - const previewUrl = `https://frontend.preview.zooniverse.org/projects/${project?.slug}/classify/workflow/${workflow?.id}${previewEnv}`; + if (!workflow) return null; return (
-

{workflow?.display_name}

- {`#${workflow?.id}`} +

{workflow.display_name}

+ {`#${workflow.id}`} {(isActive) ? Active : Inactive}
@@ -222,17 +227,27 @@ export default function TasksPage() { > Add a new Task - - Preview Workflow - + + {workflow.steps?.map(([stepKey, stepBody]) => ( + + ))} +