From 5bde4ecdfb51fb24ce08e44868c64d786d4249b9 Mon Sep 17 00:00:00 2001 From: Gauthier Pogam--Le Montagner Date: Wed, 11 Apr 2018 04:33:59 +0900 Subject: [PATCH] Move stager (#329) * Delete empty file * Remove stager from config panel * Move stager as runTask parameter and set default to "local" * Fix Style * Improve types --- .../Presenters/ControlPanel.js | 8 +- .../Epics/Tasks.js | 21 ++--- .../ManualTests/execJest.js | 0 .../Types/stagers.js | 2 +- .../Actions/AddPlanConfig.js | 5 +- .../Containers/DevToolPlans.js | 2 +- .../Containers/PinnedPlans.js | 2 +- .../Containers/PlanConfigurer.js | 4 +- .../Presenters/PlanConfigurer.js | 16 ---- .../Presenters/StagerConfig.js | 90 ------------------- .../Reducers/PlanConfigs.test.js | 7 -- .../__snapshots__/PlanConfigs.test.js.snap | 18 ---- .../Types/types.js.flow | 56 ------------ .../TaskExecutionFeature/Actions/RunTask.js | 5 +- 14 files changed, 21 insertions(+), 215 deletions(-) delete mode 100644 lib/ExecutionControlEpic/LanguageServerProtocolFeature/ManualTests/execJest.js delete mode 100644 lib/ExecutionControlEpic/PlanConfigurationFeature/Presenters/StagerConfig.js diff --git a/lib/ExecutionControlEpic/ControlPanelFeature/Presenters/ControlPanel.js b/lib/ExecutionControlEpic/ControlPanelFeature/Presenters/ControlPanel.js index b39593e8..de2fd3bb 100644 --- a/lib/ExecutionControlEpic/ControlPanelFeature/Presenters/ControlPanel.js +++ b/lib/ExecutionControlEpic/ControlPanelFeature/Presenters/ControlPanel.js @@ -5,7 +5,7 @@ import React from "react"; import styled from "styled-components"; import Section from "./Section"; import { List } from "immutable"; -import type { PackagePanel } from "../Types/types"; +import type { PackagePanel, PlanPanel, ToolPanel } from "../Types/types"; import PinButton from "./PinButton"; import RunningStateIndicator from "./RunningStateIndicator"; import SplitButton from "./SplitButton"; @@ -108,13 +108,13 @@ export default function ControlPanel({ }) { return ( - {packagePanels.map(packagePanel => ( + {packagePanels.map((packagePanel: PackagePanel) => (
- {packagePanel.tools.toArray().map(toolPanel => ( + {packagePanel.tools.toArray().map((toolPanel: ToolPanel) => (
} color={toolPanel.tool.dominantColor} > - {toolPanel.plans.toArray().map(planPanel => ( + {toolPanel.plans.toArray().map((planPanel: PlanPanel) => (
void) => void; - -export type RunTaskAction = { - type: typeof RUN_TASK, - payload: { plan: PlanConfig }, -}; - function convertSetDiagnosticsForPathToSetDiagnosticsForTasks( actions: Array, ) { @@ -63,12 +58,12 @@ function convertSetDiagnosticsForPathToSetDiagnosticsForTasks( export default (context: ExecutionContext) => (action$, store) => { const rootObs = action$ - .ofType(RUN_TASK) + .ofType("RUN_TASK") .mergeMap((action: RunTaskAction) => { return Rx.Observable.create(observer => { const languageClientConfig = runLanguageClient({ plan: action.payload.plan, - stagerConfig: action.payload.plan.stager, + stagerConfig: action.payload.stager, }); let execution = null; diff --git a/lib/ExecutionControlEpic/LanguageServerProtocolFeature/ManualTests/execJest.js b/lib/ExecutionControlEpic/LanguageServerProtocolFeature/ManualTests/execJest.js deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/ExecutionControlEpic/LanguageServerProtocolFeature/Types/stagers.js b/lib/ExecutionControlEpic/LanguageServerProtocolFeature/Types/stagers.js index cb26c897..7ba0f2a1 100644 --- a/lib/ExecutionControlEpic/LanguageServerProtocolFeature/Types/stagers.js +++ b/lib/ExecutionControlEpic/LanguageServerProtocolFeature/Types/stagers.js @@ -2,5 +2,5 @@ // @flow export type StagerConfig = { - type: "local", + type: "local" | "integrated" | "remote", }; diff --git a/lib/ExecutionControlEpic/PlanConfigurationFeature/Actions/AddPlanConfig.js b/lib/ExecutionControlEpic/PlanConfigurationFeature/Actions/AddPlanConfig.js index adb53141..1ba1b2ba 100644 --- a/lib/ExecutionControlEpic/PlanConfigurationFeature/Actions/AddPlanConfig.js +++ b/lib/ExecutionControlEpic/PlanConfigurationFeature/Actions/AddPlanConfig.js @@ -1,7 +1,7 @@ "use babel"; // @flow -import type { DevToolInfo, Stager } from "../Types/types"; +import type { DevToolInfo } from "../Types/types"; import type { PackageInfo } from "../../../ProjectSystemEpic/PackageFeature/Types/types"; export type AddPlanConfigAction = { @@ -11,7 +11,6 @@ export type AddPlanConfigAction = { name: string, tool: DevToolInfo, config: mixed, - stager: Stager, packageInfo: PackageInfo, }, }; @@ -21,7 +20,6 @@ export function addPlanConfig( name: string, toolInfo: DevToolInfo, config: mixed, - stager: Stager, packageInfo: PackageInfo, ): AddPlanConfigAction { return { @@ -31,7 +29,6 @@ export function addPlanConfig( name, tool: toolInfo, config, - stager, packageInfo, }, }; diff --git a/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/DevToolPlans.js b/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/DevToolPlans.js index 7f830ee2..2705e38a 100644 --- a/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/DevToolPlans.js +++ b/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/DevToolPlans.js @@ -57,7 +57,7 @@ export function mapDispatchToProps( if (plan.state == "running") { dispatch(killTask(plan)); } else { - dispatch(runTask(plan)); + dispatch(runTask(plan, { type: "local" })); } }, }; diff --git a/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/PinnedPlans.js b/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/PinnedPlans.js index 56c2d531..9736792d 100644 --- a/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/PinnedPlans.js +++ b/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/PinnedPlans.js @@ -53,7 +53,7 @@ export function mapDispatchToProps( if (plan.state == "running") { dispatch(killTask(plan)); } else { - dispatch(runTask(plan)); + dispatch(runTask(plan, { type: "local" })); } }, }; diff --git a/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/PlanConfigurer.js b/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/PlanConfigurer.js index 1f1d9628..8c4bb562 100644 --- a/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/PlanConfigurer.js +++ b/lib/ExecutionControlEpic/PlanConfigurationFeature/Containers/PlanConfigurer.js @@ -62,7 +62,7 @@ export function mapDispatchToProps( onAddPlan: (plan: { name: string, config: mixed, - stager: Stager, + stager: StagerConfig, packageInfo: PackageInfo, }) => void, } { @@ -70,7 +70,6 @@ export function mapDispatchToProps( onAddPlan: (plan: { name: string, config: mixed, - stager: Stager, packageInfo: PackageInfo, }) => { dispatch( @@ -85,7 +84,6 @@ export function mapDispatchToProps( uri: ownProps.toolUri, }, plan.config, - plan.stager, plan.packageInfo, ), ); diff --git a/lib/ExecutionControlEpic/PlanConfigurationFeature/Presenters/PlanConfigurer.js b/lib/ExecutionControlEpic/PlanConfigurationFeature/Presenters/PlanConfigurer.js index 32ecba07..4eb2f5e7 100644 --- a/lib/ExecutionControlEpic/PlanConfigurationFeature/Presenters/PlanConfigurer.js +++ b/lib/ExecutionControlEpic/PlanConfigurationFeature/Presenters/PlanConfigurer.js @@ -5,7 +5,6 @@ import * as React from "react"; import PlanConfigPart from "./PlanConfigPart"; import AddButton from "./AddButton"; import type { ConfigSchemaPart } from "../Types/types"; -import StagerConfig from "./StagerConfig"; import PlanConfigTextInputField from "./PlanConfigTextInputField"; import PackageConfig from "./PackageConfig"; import type { Package } from "../../../ProjectSystemEpic/PackageFeature/Types/types"; @@ -62,21 +61,6 @@ export default function PlanConfigurer( marker. - Stager - - A stager is a way for controlling how your plan will be executed by - Molecule. -
j RECOMMENDED: By default, integrated, means it will be executed - in Atom. -
- EXPERIMENTAL: The local one adds an intermediary process to bufferise - the output, can be a performant gain in some cases, but we don t - recommand using it for now. -
- HIGHLY EXPERIMENTAL: The remote stager is for executing your plan on a - remote machine. -
- Create diff --git a/lib/ExecutionControlEpic/PlanConfigurationFeature/Presenters/StagerConfig.js b/lib/ExecutionControlEpic/PlanConfigurationFeature/Presenters/StagerConfig.js deleted file mode 100644 index dce46be3..00000000 --- a/lib/ExecutionControlEpic/PlanConfigurationFeature/Presenters/StagerConfig.js +++ /dev/null @@ -1,90 +0,0 @@ -"use babel"; -// @flow - -import * as React from "react"; -import PlanConfigPart from "./PlanConfigPart"; -import { SSHConfigSchema } from "../Model/StagerConfigs"; - -export default class StagerConfig extends React.Component { - state: State; - props: Props; - static defaultProps: DefaultProps; - - constructor(props: Props) { - super(props); - } - - render() { - let config = { - type: "conditional", - expression: { - label: "stager", - type: "enum", - default: "integrated", - enum: [ - { value: "integrated", description: "integrated" }, - { value: "local", description: "local" }, - { value: "remote", description: "remote" }, - ], - }, - cases: { - integrated: null, - local: null, - remote: { - type: "object", - label: "connection", - schemas: { - host: { - type: "object", - label: "host", - schemas: { - host: { - type: "string", - default: "127.0.0.1", - label: "host", - }, - port: { - type: "number", - default: 22, - label: "port", - }, - }, - }, - method: { - type: "conditional", - expression: { - type: "enum", - default: "ssh", - enum: [{ value: "ssh", description: "ssh" }], - }, - cases: { - ssh: SSHConfigSchema, - }, - }, - }, - }, - }, - }; - - return ( - - ); - } -} - -StagerConfig.defaultProps = {}; - -type DefaultProps = {}; - -type Props = { - value: any, - onChange(v: any): void, - elementName: string, -}; - -type State = {}; diff --git a/lib/ExecutionControlEpic/PlanConfigurationFeature/Reducers/PlanConfigs.test.js b/lib/ExecutionControlEpic/PlanConfigurationFeature/Reducers/PlanConfigs.test.js index 07d5a27b..f5adf754 100644 --- a/lib/ExecutionControlEpic/PlanConfigurationFeature/Reducers/PlanConfigs.test.js +++ b/lib/ExecutionControlEpic/PlanConfigurationFeature/Reducers/PlanConfigs.test.js @@ -27,7 +27,6 @@ describe("PlanConfigs", () => { uri: "file:///file", }, "ls -l", - { type: "integrated" }, { name: "", path: "/", @@ -52,7 +51,6 @@ describe("PlanConfigs", () => { uri: "file:///file", }, config: "ls -l", - stager: { type: "integrated" }, packageInfo: { name: "", path: "/", @@ -70,7 +68,6 @@ describe("PlanConfigs", () => { uri: "file:///file", }, config: "Invoke-Mimikatz", - stager: { type: "integrated" }, packageInfo: { name: "", path: "/", @@ -102,7 +99,6 @@ describe("PlanConfigs", () => { uri: "file:///file", }, config: "ls -l", - stager: { type: "integrated" }, packageInfo: { name: "", path: "/", @@ -120,7 +116,6 @@ describe("PlanConfigs", () => { uri: "file:///file", }, config: "Invoke-Mimikatz", - stager: { type: "integrated" }, packageInfo: { name: "", path: "/", @@ -152,7 +147,6 @@ describe("PlanConfigs", () => { uri: "file:///file", }, config: "ls -l", - stager: { type: "integrated" }, packageInfo: { name: "", path: "/", @@ -170,7 +164,6 @@ describe("PlanConfigs", () => { uri: "file:///file", }, config: "Invoke-Mimikatz", - stager: { type: "integrated" }, packageInfo: { name: "", path: "/", diff --git a/lib/ExecutionControlEpic/PlanConfigurationFeature/Reducers/__snapshots__/PlanConfigs.test.js.snap b/lib/ExecutionControlEpic/PlanConfigurationFeature/Reducers/__snapshots__/PlanConfigs.test.js.snap index 54bbc1fa..2dd168d8 100644 --- a/lib/ExecutionControlEpic/PlanConfigurationFeature/Reducers/__snapshots__/PlanConfigs.test.js.snap +++ b/lib/ExecutionControlEpic/PlanConfigurationFeature/Reducers/__snapshots__/PlanConfigs.test.js.snap @@ -13,9 +13,6 @@ Immutable.Map { "type": "directory", }, "pinned": false, - "stager": Object { - "type": "integrated", - }, "tool": Object { "iconUri": "atom://myplugin/icon.png", "id": "toolid", @@ -40,9 +37,6 @@ Immutable.Map { "type": "directory", }, "pinned": true, - "stager": Object { - "type": "integrated", - }, "tool": Object { "iconUri": "atom://myplugin/icon.png", "id": "toolid", @@ -60,9 +54,6 @@ Immutable.Map { "type": "directory", }, "pinned": false, - "stager": Object { - "type": "integrated", - }, "tool": Object { "iconUri": "atom://myplugin/icon.png", "id": "toolid", @@ -87,9 +78,6 @@ Immutable.Map { "type": "directory", }, "pinned": false, - "stager": Object { - "type": "integrated", - }, "tool": Object { "iconUri": "atom://myplugin/icon.png", "id": "toolid", @@ -114,9 +102,6 @@ Immutable.Map { "type": "directory", }, "pinned": false, - "stager": Object { - "type": "integrated", - }, "tool": Object { "iconUri": "atom://myplugin/icon.png", "id": "toolid", @@ -134,9 +119,6 @@ Immutable.Map { "type": "directory", }, "pinned": false, - "stager": Object { - "type": "integrated", - }, "tool": Object { "iconUri": "atom://myplugin/icon.png", "id": "toolid", diff --git a/lib/ExecutionControlEpic/PlanConfigurationFeature/Types/types.js.flow b/lib/ExecutionControlEpic/PlanConfigurationFeature/Types/types.js.flow index 37fed6c8..46f1a151 100644 --- a/lib/ExecutionControlEpic/PlanConfigurationFeature/Types/types.js.flow +++ b/lib/ExecutionControlEpic/PlanConfigurationFeature/Types/types.js.flow @@ -82,61 +82,6 @@ export type DevToolInfo = { uri: string, }; -export type SSHConfigSchema = { - type: "object", - schemas: { - username: { - type: "string", - default: "", - label: "username", - }, - privateKeyPath: { - type: "string", - default: "", - label: "key path", - }, - }, -}; - -export type SSHConfig = { - username: string, - privateKeyPath: string, -}; - -export type HostConfigSchema = { - type: "object", - schemas: { - host: { - type: "string", - default: "", - label: "host", - }, - port: { - type: "number", - default: 22, - label: "port", - }, - }, -}; - -export type HostConfig = { - host: string, - port: number, - transport: SSHConfig, -}; - -export type Stager = - | { - type: "integrated", - } - | { - type: "local", - } - | { - type: "remote", - host: HostConfig, - }; - export type DevToolPlanConfigSchema = ConfigSchemaPart & { tool: DevToolInfo }; export type PlanConfig = { @@ -144,7 +89,6 @@ export type PlanConfig = { config: any, pinned?: boolean, name: string, - stager: Stager, packageInfo: PackageInfo, id: string, }; diff --git a/lib/ExecutionControlEpic/TaskExecutionFeature/Actions/RunTask.js b/lib/ExecutionControlEpic/TaskExecutionFeature/Actions/RunTask.js index 1d941f29..a0b2812e 100644 --- a/lib/ExecutionControlEpic/TaskExecutionFeature/Actions/RunTask.js +++ b/lib/ExecutionControlEpic/TaskExecutionFeature/Actions/RunTask.js @@ -2,19 +2,22 @@ // @flow import type { PlanConfig } from "../../PlanConfigurationFeature/Types/types"; +import type { StagerConfig } from "../../LanguageServerProtocolFeature/Types/stagers"; export type RunTaskAction = { type: "RUN_TASK", payload: { plan: PlanConfig, + stager: StagerConfig, }, }; -export function runTask(plan: PlanConfig): RunTaskAction { +export function runTask(plan: PlanConfig, stager: StagerConfig): RunTaskAction { return { type: "RUN_TASK", payload: { plan, + stager, }, }; }