diff --git a/telemetry/ui/src/components/routes/app/DataView.tsx b/telemetry/ui/src/components/routes/app/DataView.tsx index f94fb094..e56a1fff 100644 --- a/telemetry/ui/src/components/routes/app/DataView.tsx +++ b/telemetry/ui/src/components/routes/app/DataView.tsx @@ -5,7 +5,7 @@ import { Button } from '../../common/button'; import { Switch, SwitchField } from '../../common/switch'; import { Label } from '../../common/fieldset'; import { classNames } from '../../../utils/tailwind'; -import { ChevronDownIcon, ChevronUpIcon, QuestionMarkCircleIcon } from '@heroicons/react/20/solid'; +import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/20/solid'; import { getUniqueAttributeID } from '../../../utils'; import { AppViewHighlightContext } from './AppView'; import { MinusIcon } from '@heroicons/react/24/outline'; @@ -140,27 +140,6 @@ const SectionHeaderWithExpand = (props: { ); }; -const FlashMessage = ({ - message, - duration, - onClose -}: { - message: string; - duration: number; - onClose: () => void; -}) => { - useEffect(() => { - const timer = setTimeout(onClose, duration); - return () => clearTimeout(timer); - }, [duration, onClose]); - - return ( -
- {message} -
- ); -}; - export const DataView = (props: { currentStep: Step | undefined; priorStep: Step | undefined }) => { const [whichState, setWhichState] = useState<'after' | 'before' | 'compare'>('after'); const stepToExamine = whichState !== 'before' ? props.currentStep : props.priorStep; @@ -179,18 +158,7 @@ export const DataView = (props: { currentStep: Step | undefined; priorStep: Step useState('default_expanded'); const attributes = stepToExamine?.attributes || []; - const step = props.currentStep || props.priorStep; - const [isFlashVisible, setIsFlashVisible] = useState(false); - const url = window.location.href; - const parts = url.split('/'); - const [projectName, partitionKey, appID] = parts.slice(-3); - const cmd = - 'burr-test-case create \\\n' + - ` --project-name "${projectName}" \\\n` + - ` --partition-key "${partitionKey}" \\\n` + - ` --app-id "${appID}" \\\n` + - ` --sequence-id ${step ? step.step_start_log.sequence_id : '?'} \\\n` + - ' --target-file-name YOUR_FIXTURE_FILE.json \n'; + return (
@@ -200,32 +168,6 @@ export const DataView = (props: { currentStep: Step | undefined; priorStep: Step setDefaultExpanded={setAllStateExpanded} dualToggle={viewRawData === 'raw'} /> -
- {' '} - { - navigator.clipboard.writeText(cmd); - setIsFlashVisible(true); - // alert(`Copied ${cmd} to clipboard`); - }} - > - Step {step ? step.step_start_log.sequence_id : '?'} Test Case 📋 - - - window.open('https://burr.dagworks.io/examples/creating_tests/', '_blank') - } - /> - {isFlashVisible && ( - setIsFlashVisible(false)} - /> - )} -
void; +}) => { + useEffect(() => { + const timer = setTimeout(onClose, duration); + return () => clearTimeout(timer); + }, [duration, onClose]); + + return ( +
+ {message} +
+ ); +}; + +export const ReproduceView = (props: { + step: Step | undefined; + appId: string; + partitionKey: string; + projectID: string; +}) => { + const cmd = + 'burr-test-case create \\\n' + + ` --project-name "${props.projectID}" \\\n` + + ` --partition-key "${props.partitionKey}" \\\n` + + ` --app-id "${props.appId}" \\\n` + + ` --sequence-id ${props.step ? props.step.step_start_log.sequence_id : '?'} \\\n` + + ' --target-file-name YOUR_FIXTURE_FILE.json \n'; + + const [isFlashVisible, setIsFlashVisible] = useState(false); + + return ( +
+ {isFlashVisible && ( + setIsFlashVisible(false)} + /> + )} +
+

+ To generate a test case for this step, run the following command. + + {' '} + Further reading + + . +

{' '} + { + navigator.clipboard.writeText(cmd); + setIsFlashVisible(true); + }} + /> +
+
{cmd}
; +
+ ); + // { + // navigator.clipboard.writeText(cmd); + // setIsFlashVisible(true); + // // alert(`Copied ${cmd} to clipboard`); + // }}> + // Step {step ? step.step_start_log.sequence_id : '?'} Test Case 📋 + // ; +}; diff --git a/telemetry/ui/src/components/routes/app/StateMachine.tsx b/telemetry/ui/src/components/routes/app/StateMachine.tsx index a1b38131..a8fe897c 100644 --- a/telemetry/ui/src/components/routes/app/StateMachine.tsx +++ b/telemetry/ui/src/components/routes/app/StateMachine.tsx @@ -4,6 +4,16 @@ import { DataView } from './DataView'; import { ActionView } from './ActionView'; import { GraphView } from './GraphView'; import { InsightsView } from './InsightsView'; +import { ReproduceView } from './ReproduceView'; +import { useParams } from 'react-router-dom'; + +const NoStepSelected = () => { + return ( +
+

Please select a step from the table on the left

+
+ ); +}; export const AppStateView = (props: { steps: Step[]; @@ -26,9 +36,11 @@ export const AppStateView = (props: { const actionModel = props.stateMachine.actions.find( (action) => action.name === currentStep?.step_start_log.action ); + const { projectId, appId, partitionKey } = useParams(); const tabs = [ { id: 'data', displayName: 'Data' }, - { id: 'action', displayName: 'Action' }, + { id: 'code', displayName: 'Code' }, + { id: 'reproduce', displayName: 'Reproduce' }, { id: 'insights', displayName: 'Insights' } ]; if (props.displayGraphAsTab) { @@ -38,10 +50,14 @@ export const AppStateView = (props: { <>
- {currentTab === 'data' && currentStep && ( - - )} - {currentTab === 'action' && currentStep && } + {currentTab === 'data' && + (currentStep ? ( + + ) : ( + + ))} + {currentTab === 'code' && + (currentStep ? : )} {currentTab === 'graph' && ( )} {currentTab === 'insights' && } + {currentTab === 'reproduce' && + (currentStep ? ( + + ) : ( + + ))}
);