From f912f003853b42c745041796220e28536629a548 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Mon, 23 May 2022 12:01:07 -0400 Subject: [PATCH] 19143: Picker opens, needs to be hooked in Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- src/store/processes/processes-actions.ts | 2 +- .../inputs/project-input.tsx | 125 ++++++++++++++++++ .../run-process-basic-form.tsx | 8 ++ .../workflow-description-card.tsx | 4 - 4 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 src/views/run-process-panel/inputs/project-input.tsx diff --git a/src/store/processes/processes-actions.ts b/src/store/processes/processes-actions.ts index 6bd2976c..11106e49 100644 --- a/src/store/processes/processes-actions.ts +++ b/src/store/processes/processes-actions.ts @@ -60,7 +60,7 @@ export const reRunProcess = (processUuid: string, workflowUuid: string) => const stringifiedDefinition = JSON.stringify(process.mounts[MOUNT_PATH_CWL_WORKFLOW].content); const newWorkflow = { ...workflow, definition: stringifiedDefinition }; - const basicInitialData: RunProcessBasicFormData = { name: `Copy of: ${process.name}`, description: process.description }; + const basicInitialData: RunProcessBasicFormData = { name: `Copy of: ${process.name}`, description: process.description, ownerUuid: workflow.ownerUuid }; dispatch(initialize(RUN_PROCESS_BASIC_FORM, basicInitialData)); const advancedInitialData: RunProcessAdvancedFormData = { diff --git a/src/views/run-process-panel/inputs/project-input.tsx b/src/views/run-process-panel/inputs/project-input.tsx new file mode 100644 index 00000000..03e02920 --- /dev/null +++ b/src/views/run-process-panel/inputs/project-input.tsx @@ -0,0 +1,125 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import React from 'react'; +import { connect, DispatchProp } from 'react-redux'; +import { Field } from 'redux-form'; +import { Input, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@material-ui/core'; +import { + GenericCommandInputParameter +} from 'models/workflow'; +import { GenericInputProps, GenericInput } from './generic-input'; +import { ProjectsTreePicker } from 'views-components/projects-tree-picker/projects-tree-picker'; +import { initProjectsTreePicker } from 'store/tree-picker/tree-picker-actions'; +import { TreeItem } from 'components/tree/tree'; +import { ProjectsTreePickerItem } from 'views-components/projects-tree-picker/generic-projects-tree-picker'; +import { ProjectResource } from 'models/project'; +import { ResourceKind } from 'models/resource'; + +const WORKFLOW_OWNER_PROJECT = "WORKFLOW_OWNER_PROJECT"; + +export interface ProjectInputProps { + options?: { showOnlyOwned: boolean, showOnlyWritable: boolean }; +} +export const ProjectInput = ({ options }: ProjectInputProps) => + ; + +const format = (value?: ProjectResource) => value ? value.name : ''; + +interface ProjectInputComponentState { + open: boolean; + project?: ProjectResource; +} + +const ProjectInputComponent = connect()( + class ProjectInputComponent extends React.Component { + state: ProjectInputComponentState = { + open: false, + }; + + componentDidMount() { + this.props.dispatch( + initProjectsTreePicker(WORKFLOW_OWNER_PROJECT)); + } + + render() { + return <> + {this.renderInput()} + {this.renderDialog()} + ; + } + + openDialog = () => { + this.setState({ open: true }); + } + + closeDialog = () => { + this.setState({ open: false }); + } + + submit = () => { + this.closeDialog(); + this.props.input.onChange(this.state.project); + } + + setProject = (_: {}, { data }: TreeItem) => { + if ('kind' in data && data.kind === ResourceKind.PROJECT) { + this.setState({ project: data }); + } else { + this.setState({ project: undefined }); + } + } + + renderInput() { + return + } + {...this.props} />; + } + + renderDialog() { + return + Choose a project + + + + + + + + ; + } + + }); diff --git a/src/views/run-process-panel/run-process-basic-form.tsx b/src/views/run-process-panel/run-process-basic-form.tsx index 13d882ba..1417c074 100644 --- a/src/views/run-process-panel/run-process-basic-form.tsx +++ b/src/views/run-process-panel/run-process-basic-form.tsx @@ -6,6 +6,7 @@ import React from 'react'; import { reduxForm, Field } from 'redux-form'; import { Grid } from '@material-ui/core'; import { TextField } from 'components/text-field/text-field'; +import { ProjectInput } from 'views/run-process-panel/inputs/project-input'; import { PROCESS_NAME_VALIDATION } from 'validators/validators'; export const RUN_PROCESS_BASIC_FORM = 'runProcessBasicForm'; @@ -13,6 +14,7 @@ export const RUN_PROCESS_BASIC_FORM = 'runProcessBasicForm'; export interface RunProcessBasicFormData { name: string; description: string; + ownerUuid?: string; } export const RunProcessBasicForm = reduxForm({ @@ -34,5 +36,11 @@ export const RunProcessBasicForm = component={TextField as any} label="Enter a description for run process" /> + + + ); diff --git a/src/views/workflow-panel/workflow-description-card.tsx b/src/views/workflow-panel/workflow-description-card.tsx index f25a8e64..df1b2811 100644 --- a/src/views/workflow-panel/workflow-description-card.tsx +++ b/src/views/workflow-panel/workflow-description-card.tsx @@ -21,10 +21,6 @@ import { WorkflowIcon } from 'components/icon/icon'; import { DataTableDefaultView } from 'components/data-table-default-view/data-table-default-view'; import { parseWorkflowDefinition, getWorkflowInputs, getInputLabel, stringifyInputType } from 'models/workflow'; import { WorkflowDetailsCardDataProps, WorkflowDetailsAttributes } from 'views-components/details-panel/workflow-details'; -import { WorkflowResource, parseWorkflowDefinition, getWorkflowInputs, getInputLabel, stringifyInputType } from 'models/workflow'; -import { DetailsAttribute } from 'components/details-attribute/details-attribute'; -import { ResourceOwnerWithName } from 'views-components/data-explorer/renderers'; -import { formatDate } from "common/formatters"; export type CssRules = 'root' | 'tab' | 'inputTab' | 'graphTab' | 'graphTabWithChosenWorkflow' | 'descriptionTab' | 'inputsTable'; -- 2.30.2