Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed May 9, 2024
1 parent ededd09 commit 7cbf58d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 132 deletions.
11 changes: 3 additions & 8 deletions public/pages/workflow_detail/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,9 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
</EuiFlexGroup>
}
rightSideItems={[
// TODO: finalize if this is needed
<EuiButton
fill={false}
color="danger"
style={{ marginTop: '8px' }}
onClick={() => {}}
>
Delete
// TODO: implement export functionality
<EuiButton fill={false} style={{ marginTop: '8px' }} onClick={() => {}}>
Export
</EuiButton>,
]}
bottomBorder={true}
Expand Down
124 changes: 1 addition & 123 deletions public/pages/workflow_detail/resizable_workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import { Form, Formik, FormikProps } from 'formik';
import * as yup from 'yup';
import { cloneDeep } from 'lodash';
import {
EuiButton,
EuiCallOut,
EuiFlexGroup,
EuiFlexItem,
EuiPageHeader,
EuiResizableContainer,
} from '@elastic/eui';
import { getCore } from '../../services';
Expand All @@ -34,23 +32,11 @@ import {
componentDataToFormik,
getComponentSchema,
processNodes,
reduceToTemplate,
APP_PATH,
} from '../../utils';
import { validateWorkspaceFlow, toTemplateFlows } from './utils';
import {
AppState,
createWorkflow,
deprovisionWorkflow,
getWorkflowState,
provisionWorkflow,
removeDirty,
setDirty,
updateWorkflow,
useAppDispatch,
} from '../../store';
import { AppState, setDirty, useAppDispatch } from '../../store';
import { Workspace } from './workspace/workspace';
import { ComponentDetails } from './component_details';

// styling
import './workspace/workspace-styles.scss';
Expand Down Expand Up @@ -338,114 +324,6 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {
deprovisioned.
</EuiCallOut>
)}
<EuiPageHeader
style={{ marginBottom: '8px' }}
rightSideItems={[
<EuiButton
fill={false}
disabled={!isDeprovisionable || isLoadingGlobal}
isLoading={isDeprovisioning}
onClick={() => {
if (workflow?.id) {
setIsDeprovisioning(true);
dispatch(deprovisionWorkflow(workflow.id))
.unwrap()
.then(async (result) => {
await new Promise((f) => setTimeout(f, 3000));
dispatch(getWorkflowState(workflow.id as string));
setIsDeprovisioning(false);
})
.catch((error: any) => {
setIsDeprovisioning(false);
});
} else {
// This case should not happen
console.debug(
'Deprovisioning triggered on an invalid workflow. Ignoring.'
);
}
}}
>
Deprovision
</EuiButton>,
<EuiButton
fill={false}
disabled={!isProvisionable || isLoadingGlobal}
isLoading={isProvisioning}
onClick={() => {
if (workflow?.id) {
setIsProvisioning(true);
dispatch(provisionWorkflow(workflow.id))
.unwrap()
.then(async (result) => {
await new Promise((f) => setTimeout(f, 3000));
dispatch(getWorkflowState(workflow.id as string));
setIsProvisioning(false);
})
.catch((error: any) => {
setIsProvisioning(false);
});
} else {
// This case should not happen
console.debug(
'Provisioning triggered on an invalid workflow. Ignoring.'
);
}
}}
>
Provision
</EuiButton>,
<EuiButton
fill={false}
disabled={!isSaveable || isLoadingGlobal || isDeprovisionable}
isLoading={isSaving}
onClick={() => {
setIsSaving(true);
dispatch(removeDirty());
if (isFirstSave) {
setIsFirstSave(false);
}
validateFormAndFlow(
formikProps,
// The callback fn to run if everything is valid.
(updatedWorkflow) => {
if (updatedWorkflow.id) {
dispatch(
updateWorkflow({
workflowId: updatedWorkflow.id,
workflowTemplate: reduceToTemplate(updatedWorkflow),
})
)
.unwrap()
.then((result) => {
setIsSaving(false);
})
.catch((error: any) => {
setIsSaving(false);
});
} else {
dispatch(createWorkflow(updatedWorkflow))
.unwrap()
.then((result) => {
const { workflow } = result;
history.replace(
`${APP_PATH.WORKFLOWS}/${workflow.id}`
);
history.go(0);
})
.catch((error: any) => {
setIsSaving(false);
});
}
}
);
}}
>
{props.isNewWorkflow || isCreating ? 'Create' : 'Save'}
</EuiButton>,
]}
bottomBorder={false}
/>
<EuiResizableContainer
direction="horizontal"
className="stretch-absolute"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
<EuiFlexGroup
direction="column"
justifyContent="spaceBetween"
style={{ height: '100%', paddingBottom: '96px' }}
style={{ height: '100%', paddingBottom: '48px' }}
>
<EuiFlexItem grow={false}>
<EuiTitle size="s">
Expand Down
3 changes: 3 additions & 0 deletions public/pages/workflows/new_workflow/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import {
NormalizationTransformer,
} from '../../../component_types';

// TODO: change from producing a flow state, to producing a form state w/ some preset values.
// The form will generate the end flow state.

// Fn to produce the complete preset template with all necessary UI metadata.
// Some UI metadata we want to generate on-the-fly using our component classes we have on client-side.
// Thus, we only persist a minimal subset of a full template on server-side. We generate
Expand Down

0 comments on commit 7cbf58d

Please sign in to comment.