From a482d45b5a46c897ff2da9808e01317831559a00 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Thu, 14 Oct 2021 15:28:40 -0300 Subject: [PATCH] 18128: Exports a common type for panel implementors to receive MPV props. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- .../multi-panel-view/multi-panel-view.tsx | 14 ++++++++------ .../process-panel/process-information-card.tsx | 5 ++--- .../subprocess-panel/subprocess-panel-root.tsx | 5 ++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/multi-panel-view/multi-panel-view.tsx b/src/components/multi-panel-view/multi-panel-view.tsx index 8b38e6c6..5c16096b 100644 --- a/src/components/multi-panel-view/multi-panel-view.tsx +++ b/src/components/multi-panel-view/multi-panel-view.tsx @@ -35,25 +35,27 @@ interface MPVHideablePanelActionProps { doHidePanel: () => void; } -type MPVPanelProps = MPVHideablePanelDataProps & MPVHideablePanelActionProps; +type MPVHideablePanelProps = MPVHideablePanelDataProps & MPVHideablePanelActionProps; -const MPVHideablePanel = ({doHidePanel, name, visible, ...props}: MPVPanelProps) => +const MPVHideablePanel = ({doHidePanel, name, visible, ...props}: MPVHideablePanelProps) => visible ? <> {React.cloneElement((props.children as ReactElement), { doHidePanel, panelName: name })} : null; -interface MPVPanelContentDataProps { +interface MPVPanelDataProps { panelName?: string; - children: ReactElement; } -interface MPVPanelContentActionProps { +interface MPVPanelActionProps { doHidePanel?: () => void; } -type MPVPanelContentProps = MPVPanelContentDataProps & MPVPanelContentActionProps & GridProps; +// Props received by panel implementors +export type MPVPanelProps = MPVPanelDataProps & MPVPanelActionProps; + +type MPVPanelContentProps = {children: ReactElement} & MPVPanelProps & GridProps; // Grid item compatible component for layout and MPV props passing export const MPVPanelContent = ({doHidePanel, panelName, ...props}: MPVPanelContentProps) => diff --git a/src/views/process-panel/process-information-card.tsx b/src/views/process-panel/process-information-card.tsx index ad7673af..8be7d1cc 100644 --- a/src/views/process-panel/process-information-card.tsx +++ b/src/views/process-panel/process-information-card.tsx @@ -15,6 +15,7 @@ import { getProcessStatus, getProcessStatusColor } from 'store/processes/process import { formatDate } from 'common/formatters'; import classNames from 'classnames'; import { ContainerState } from 'models/container'; +import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view'; type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'link' | 'content' | 'title' | 'avatar' | 'cancelButton'; @@ -81,11 +82,9 @@ export interface ProcessInformationCardDataProps { navigateToOutput: (uuid: string) => void; openWorkflow: (uuid: string) => void; cancelProcess: (uuid: string) => void; - doHidePanel?: () => void; - panelName?: string; } -type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles; +type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles & MPVPanelProps; export const ProcessInformationCard = withStyles(styles, { withTheme: true })( ({ classes, process, onContextMenu, theme, openProcessInputDialog, navigateToOutput, openWorkflow, cancelProcess, doHidePanel, panelName }: ProcessInformationCardProps) => { diff --git a/src/views/subprocess-panel/subprocess-panel-root.tsx b/src/views/subprocess-panel/subprocess-panel-root.tsx index e35a5712..49354671 100644 --- a/src/views/subprocess-panel/subprocess-panel-root.tsx +++ b/src/views/subprocess-panel/subprocess-panel-root.tsx @@ -17,6 +17,7 @@ import { DataTableDefaultView } from 'components/data-table-default-view/data-ta import { createTree } from 'models/tree'; import { getInitialProcessStatusFilters } from 'store/resource-type-filters/resource-type-filters'; import { ResourcesState } from 'store/resources/resources'; +import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view'; export enum SubprocessPanelColumnNames { NAME = "Name", @@ -65,14 +66,12 @@ export const subprocessPanelColumns: DataColumns = [ export interface SubprocessPanelDataProps { resources: ResourcesState; - panelName?: string; } export interface SubprocessPanelActionProps { onItemClick: (item: string) => void; onContextMenu: (event: React.MouseEvent, item: string, resources: ResourcesState) => void; onItemDoubleClick: (item: string) => void; - doHidePanel?: () => void; } type SubprocessPanelProps = SubprocessPanelActionProps & SubprocessPanelDataProps; @@ -82,7 +81,7 @@ const DEFAULT_VIEW_MESSAGES = [ 'The current process may not have any or none matches current filtering.' ]; -export const SubprocessPanelRoot = (props: SubprocessPanelProps) => { +export const SubprocessPanelRoot = (props: SubprocessPanelProps & MPVPanelProps) => { return