diff --git a/web/src/components/PluginsPanel/PluginsPanel.tsx b/web/src/components/PluginsPanel/PluginsPanel.tsx index 31701f7d9..58c7cb99a 100644 --- a/web/src/components/PluginsPanel/PluginsPanel.tsx +++ b/web/src/components/PluginsPanel/PluginsPanel.tsx @@ -39,7 +39,7 @@ const PluginCategories: PluginInterface[] = [ { category: PluginCategory.Drone, name: 'Drone', description: 'Run Drone plugins', icon: 'ci-infra' } ] -const pluginSpecMock = { +const dronePluginSpecMock = { inputs: { channel: { type: 'string' @@ -61,6 +61,14 @@ const pluginSpecMock = { ] } +const runStepSpec = { + inputs: { + script: { + type: 'string' + } + } +} + export interface PluginsPanelInterface { onPluginAddUpdate?: (isUpdate: boolean, pluginFormData: Record) => void } @@ -101,6 +109,9 @@ export const PluginsPanel = ({ onPluginAddUpdate }: PluginsPanelInterface): JSX. setCategory(category) if (category === PluginCategory.Drone) { setPanelView(PluginPanelView.Listing) + } else if (category === PluginCategory.Harness) { + setPlugin({ uid: getString('run') }) + setPanelView(PluginPanelView.Configuration) } }} key={category} @@ -187,58 +198,57 @@ export const PluginsPanel = ({ onPluginAddUpdate }: PluginsPanelInterface): JSX. } const renderPluginConfigForm = useCallback((): JSX.Element => { - const { uid, spec } = plugin || {} - if (spec) { - // let specAsObj = {} - // try { - // specAsObj = parse(spec) - // } catch (e) { - // // ignore error - // } - const inputs = get(pluginSpecMock, 'inputs', {}) - return ( - - - { - setPlugin(undefined) + // TODO obtain plugin input spec by parsing YAML + const inputs = get(category === PluginCategory.Drone ? dronePluginSpecMock : runStepSpec, 'inputs', {}) + return ( + + + { + setPlugin(undefined) + if (category === PluginCategory.Drone) { setPanelView(PluginPanelView.Listing) - }} - className={css.arrow} - /> + } else if (category === PluginCategory.Harness) { + setPanelView(PluginPanelView.Category) + } + }} + className={css.arrow} + /> + {plugin?.uid ? ( - {getString('addLabel')} {uid} + {getString('addLabel')} {plugin.uid} {getString('plugins.stepLabel')} - - - { - onPluginAddUpdate?.(false, formData) - }}> - - - - {Object.keys(inputs).map((field: string) => { - const fieldType = get(inputs, `${field}.type`, '') as 'string' - return renderPluginFormField({ name: field, type: fieldType }) - })} - -