From e7213b127d33bcde48ba5d0fe90b50f3f79b261a Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Sat, 26 Oct 2024 07:20:56 +0200 Subject: [PATCH] linting --- .../src/lib/custom-script-runner.tsx | 272 +++++++++--------- .../scriptrunner/src/lib/script-runner-ui.tsx | 6 +- libs/remix-ui/scriptrunner/src/types/index.ts | 12 +- libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 28 +- 4 files changed, 156 insertions(+), 162 deletions(-) diff --git a/libs/remix-ui/scriptrunner/src/lib/custom-script-runner.tsx b/libs/remix-ui/scriptrunner/src/lib/custom-script-runner.tsx index 8846d973f7..be0959bd5b 100644 --- a/libs/remix-ui/scriptrunner/src/lib/custom-script-runner.tsx +++ b/libs/remix-ui/scriptrunner/src/lib/custom-script-runner.tsx @@ -4,7 +4,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faToggleOff, faToggleOn, faTrash } from "@fortawesome/free-solid-svg-icons"; import { CustomTooltip } from "@remix-ui/helper"; - export interface ScriptRunnerUIProps { publishedConfigurations: ProjectConfiguration[]; openCustomConfig: () => any; @@ -14,157 +13,156 @@ export interface ScriptRunnerUIProps { } export const CustomScriptRunner = (props: ScriptRunnerUIProps) => { - const [dependencies, setDependencies] = useState([]); - const [name, setName] = useState(''); - const [alias, setAlias] = useState(''); - const [version, setVersion] = useState(''); - const [baseConfig, setBaseConfig] = useState('default'); - const [loading, setLoading] = useState(false); - const [useRequire, setUseRequire] = useState(false) - - const { customConfig } = props; + const [dependencies, setDependencies] = useState([]); + const [name, setName] = useState(''); + const [alias, setAlias] = useState(''); + const [version, setVersion] = useState(''); + const [baseConfig, setBaseConfig] = useState('default'); + const [loading, setLoading] = useState(false); + const [useRequire, setUseRequire] = useState(false) - useEffect(() => { - if(!customConfig) return; - setDependencies(customConfig.dependencies); - setBaseConfig(customConfig.baseConfiguration); - },[customConfig]) + const { customConfig } = props; - const handleAddDependency = () => { - if (name.trim() && version.trim()) { - const newDependency: Dependency = { name, version, require: useRequire, alias }; - setDependencies([...dependencies, newDependency]); - setName(''); - setVersion(''); - } else { - alert('Please fill out both name and version.'); - } - }; + useEffect(() => { + if (!customConfig) return; + setDependencies(customConfig.dependencies); + setBaseConfig(customConfig.baseConfiguration); + },[customConfig]) - const handleRemoveDependency = (index: number) => { - const updatedDependencies = dependencies.filter((_, i) => i !== index); - setDependencies(updatedDependencies); - }; + const handleAddDependency = () => { + if (name.trim() && version.trim()) { + const newDependency: Dependency = { name, version, require: useRequire, alias }; + setDependencies([...dependencies, newDependency]); + setName(''); + setVersion(''); + } else { + alert('Please fill out both name and version.'); + } + }; + const handleRemoveDependency = (index: number) => { + const updatedDependencies = dependencies.filter((_, i) => i !== index); + setDependencies(updatedDependencies); + }; - const handleSaveToFile = () => { - const fileData = JSON.stringify(dependencies, null, 2); - console.log(fileData, baseConfig); - const customConfig: customScriptRunnerConfig = { baseConfiguration: baseConfig, dependencies }; - console.log(customConfig); - props.saveCustomConfig(customConfig); - }; + const handleSaveToFile = () => { + const fileData = JSON.stringify(dependencies, null, 2); + console.log(fileData, baseConfig); + const customConfig: customScriptRunnerConfig = { baseConfiguration: baseConfig, dependencies }; + console.log(customConfig); + props.saveCustomConfig(customConfig); + }; - const openConfig = async () => { - const fileData: customScriptRunnerConfig = await props.openCustomConfig(); - } + const openConfig = async () => { + const fileData: customScriptRunnerConfig = await props.openCustomConfig(); + } - const activateCustomConfig = async () => { - const customConfig: customScriptRunnerConfig = { baseConfiguration: baseConfig, dependencies }; - setLoading(true); - try { - await props.activateCustomScriptRunner(customConfig); - } catch (e) { - console.log(e) - } finally { - setLoading(false); - } + const activateCustomConfig = async () => { + const customConfig: customScriptRunnerConfig = { baseConfiguration: baseConfig, dependencies }; + setLoading(true); + try { + await props.activateCustomScriptRunner(customConfig); + } catch (e) { + console.log(e) + } finally { + setLoading(false); } + } - const onSelectBaseConfig = (e: React.ChangeEvent) => { - setBaseConfig(e.target.value); - } + const onSelectBaseConfig = (e: React.ChangeEvent) => { + setBaseConfig(e.target.value); + } - const toggleRequire = () => { - setUseRequire((prev) => !prev) - } + const toggleRequire = () => { + setUseRequire((prev) => !prev) + } - if (loading) { - return
-
- -
-
- } + if (loading) { + return
+
+ +
+
+ } - return ( -
-
Custom configuration
- - - -
- setName(e.target.value)} - style={{ marginRight: '10px' }} - /> - setAlias(e.target.value)} /> - setVersion(e.target.value)} - /> - -
- - -
-
- + +
+
    + {dependencies.map((dependency, index) => ( +
  • +
    + {dependency.name} - {dependency.version} +
    -
      - {dependencies.map((dependency, index) => ( -
    • -
      - {dependency.name} - {dependency.version} - -
      -
    • - ))} -
    - {dependencies.length > 0 && ( -
  • + ))} +
+ {dependencies.length > 0 && ( + - )} - + )} + - {dependencies.length > 0 && ( - + {dependencies.length > 0 && ( + )} -
- ); + )} + + ); } \ No newline at end of file diff --git a/libs/remix-ui/scriptrunner/src/lib/script-runner-ui.tsx b/libs/remix-ui/scriptrunner/src/lib/script-runner-ui.tsx index 03043180ab..52692be16f 100644 --- a/libs/remix-ui/scriptrunner/src/lib/script-runner-ui.tsx +++ b/libs/remix-ui/scriptrunner/src/lib/script-runner-ui.tsx @@ -22,7 +22,7 @@ export const ScriptRunnerUI = (props: ScriptRunnerUIProps) => { const [activeKey, setActiveKey] = useState('default'); useEffect(() => { - if(activeConfig) { + if (activeConfig) { setActiveKey(activeConfig.name) } },[activeConfig]) @@ -31,8 +31,6 @@ export const ScriptRunnerUI = (props: ScriptRunnerUIProps) => { return
Loading...
; } - - return (
@@ -78,7 +76,6 @@ export const ScriptRunnerUI = (props: ScriptRunnerUIProps) => {
- <>

Description: {config.description}

@@ -104,4 +101,3 @@ export const ScriptRunnerUI = (props: ScriptRunnerUIProps) => { ); }; - diff --git a/libs/remix-ui/scriptrunner/src/types/index.ts b/libs/remix-ui/scriptrunner/src/types/index.ts index 99e453bd37..d675fa2084 100644 --- a/libs/remix-ui/scriptrunner/src/types/index.ts +++ b/libs/remix-ui/scriptrunner/src/types/index.ts @@ -8,12 +8,12 @@ export interface Dependency { require: boolean; windowImport?: boolean; } - - export interface Replacements { + +export interface Replacements { [key: string]: string; } - - export interface ProjectConfiguration { + +export interface ProjectConfiguration { name: string; publish: boolean; description: string; @@ -25,12 +25,12 @@ export interface Dependency { isLoading: boolean; } - export interface customScriptRunnerConfig { +export interface customScriptRunnerConfig { baseConfiguration: string; dependencies: Dependency[]; } - export interface ScriptRunnerConfig { +export interface ScriptRunnerConfig { defaultConfig: string, customConfig: customScriptRunnerConfig } diff --git a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx index 7572db392c..53d4b17f2e 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -51,19 +51,19 @@ const initialTabsState: ITabsState = { const tabsReducer = (state: ITabsState, action: ITabsAction) => { switch (action.type) { - case 'SELECT_INDEX': - return { - ...state, - currentExt: action.ext, - selectedIndex: action.payload - } - case 'SET_FILE_DECORATIONS': - return { - ...state, - fileDecorations: action.payload as fileDecoration[] - } - default: - return state + case 'SELECT_INDEX': + return { + ...state, + currentExt: action.ext, + selectedIndex: action.payload + } + case 'SET_FILE_DECORATIONS': + return { + ...state, + fileDecorations: action.payload as fileDecoration[] + } + default: + return state } } @@ -241,7 +241,7 @@ export const TabsUI = (props: TabsUIProps) => { onClick={async () => { props.plugin.call('menuicons', 'select', 'scriptRunnerBridge') }} - > + > }