diff --git a/webview/src/experiments/components/table/Row.tsx b/webview/src/experiments/components/table/Row.tsx index 9ffdbae6b5..573109f52c 100644 --- a/webview/src/experiments/components/table/Row.tsx +++ b/webview/src/experiments/components/table/Row.tsx @@ -120,17 +120,21 @@ const getRunResumeOptions = ( ) => { const isNotCheckpoint = depth <= 1 || isWorkspace + const resetNeedsSeparator = !hideVaryAndRun && projectHasCheckpoints + const runNeedsSeparator = !hideVaryAndRun && !projectHasCheckpoints + return [ withId( 'Modify, Reset and Run', MessageFromWebviewType.VARY_EXPERIMENT_PARAMS_RESET_AND_RUN, - !isNotCheckpoint || !projectHasCheckpoints + !isNotCheckpoint || !projectHasCheckpoints, + resetNeedsSeparator ), withId( projectHasCheckpoints ? 'Modify and Resume' : 'Modify and Run', MessageFromWebviewType.VARY_EXPERIMENT_PARAMS_AND_RUN, !isNotCheckpoint, - !hideVaryAndRun + runNeedsSeparator ), withId( 'Modify and Queue', diff --git a/webview/src/stories/Table.stories.tsx b/webview/src/stories/Table.stories.tsx index 55f186f6bd..61aee5aa03 100644 --- a/webview/src/stories/Table.stories.tsx +++ b/webview/src/stories/Table.stories.tsx @@ -53,6 +53,37 @@ const tableData: TableData = { ] } +const noRunningExperiments = { + ...tableData, + hasRunningExperiment: false, + rows: rowsFixture.map(row => ({ + ...row, + running: false, + subRows: row.subRows?.map(experiment => ({ + ...experiment, + running: false, + subRows: experiment.subRows?.map(checkpoint => ({ + ...checkpoint, + running: false + })) + })) + })) +} + +const noRunningExperimentsNoCheckpoints = { + ...noRunningExperiments, + hasCheckpoints: false, + rows: rowsFixture.map(row => ({ + ...row, + running: false, + subRows: row.subRows?.map(experiment => ({ + ...experiment, + running: false, + subRows: [] + })) + })) +} + export default { args: { tableData @@ -101,23 +132,32 @@ WithMiddleStates.play = async ({ canvasElement }) => { export const WithNoRunningExperiments = Template.bind({}) WithNoRunningExperiments.args = { - tableData: { - ...tableData, - hasRunningExperiment: false, - rows: rowsFixture.map(row => ({ - ...row, - running: false, - subRows: row.subRows?.map(experiment => ({ - ...experiment, - running: false, - subRows: experiment.subRows?.map(checkpoint => ({ - ...checkpoint, - running: false - })) - })) - })) - } + tableData: noRunningExperiments +} + +const contextMenuPlay = async ({ + canvasElement +}: { + canvasElement: HTMLElement +}) => { + const experiment = await within(canvasElement).findByText('[exp-e7a67]') + userEvent.click(experiment, { + bubbles: true, + button: 2 + }) +} + +export const WithContextMenu = Template.bind({}) +WithContextMenu.args = { + tableData: noRunningExperiments +} +WithContextMenu.play = contextMenuPlay + +export const WithContextMenuNoCheckpoints = Template.bind({}) +WithContextMenuNoCheckpoints.args = { + tableData: noRunningExperimentsNoCheckpoints } +WithContextMenuNoCheckpoints.play = contextMenuPlay export const WithAllDataTypes = Template.bind({}) WithAllDataTypes.args = { tableData: dataTypesTableData }