From 406c4b872da3115b87e287a0dcc58c3bfd046918 Mon Sep 17 00:00:00 2001 From: Garrett Date: Mon, 18 Sep 2023 11:27:46 -0700 Subject: [PATCH 01/10] Allow direct updates to deep results when no nested forms exist --- src/renderer/src/stories/JSONSchemaForm.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index e1902a2a3..3a209ed3d 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -252,12 +252,17 @@ export class JSONSchemaForm extends LitElement { const resolvedParent = path.reduce(reducer, this.resolved); const hasUpdate = resolvedParent[name] !== value; + const isTop = fullPath.length === 1 + const hasNested = Object.keys(this.#nestedForms).length + const willUpdateResult = !hasNested || isTop + // NOTE: Forms with nested forms will handle their own state updates + console.log('Updating', fullPath, this.#nestedForms) if (!value) { - if (fullPath.length === 1) delete resultParent[name]; + if (willUpdateResult) delete resultParent[name]; delete resolvedParent[name]; } else { - if (fullPath.length === 1) resultParent[name] = value; + if (willUpdateResult) resultParent[name] = value; resolvedParent[name] = value; } From ef80863f0ac709cfd25f04ce93facb6dfb645cae Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:30:17 +0000 Subject: [PATCH 02/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/JSONSchemaForm.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index 3a209ed3d..59c72b2cc 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -252,12 +252,12 @@ export class JSONSchemaForm extends LitElement { const resolvedParent = path.reduce(reducer, this.resolved); const hasUpdate = resolvedParent[name] !== value; - const isTop = fullPath.length === 1 - const hasNested = Object.keys(this.#nestedForms).length - const willUpdateResult = !hasNested || isTop + const isTop = fullPath.length === 1; + const hasNested = Object.keys(this.#nestedForms).length; + const willUpdateResult = !hasNested || isTop; // NOTE: Forms with nested forms will handle their own state updates - console.log('Updating', fullPath, this.#nestedForms) + console.log("Updating", fullPath, this.#nestedForms); if (!value) { if (willUpdateResult) delete resultParent[name]; delete resolvedParent[name]; From 726869bf3251c5274129aa07a424e706e09d6454 Mon Sep 17 00:00:00 2001 From: Garrett Date: Mon, 18 Sep 2023 11:42:26 -0700 Subject: [PATCH 03/10] Add test --- src/renderer/src/stories/JSONSchemaForm.js | 8 ++++---- tests/metadata.test.ts | 18 +++++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index 3a209ed3d..e7fa53aee 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -302,9 +302,9 @@ export class JSONSchemaForm extends LitElement { throw new Error(message); }; - validate = async () => { + validate = async (resolved) => { // Check if any required inputs are missing - const invalidInputs = await this.#validateRequirements(); // get missing required paths + const invalidInputs = await this.#validateRequirements(resolved); // get missing required paths const isValid = !invalidInputs.length; // Print out a detailed error message if any inputs are missing @@ -321,9 +321,9 @@ export class JSONSchemaForm extends LitElement { if (message) this.throw(message); - for (let key in this.#nestedForms) await this.#nestedForms[key].validate(); // Validate nested forms too + for (let key in this.#nestedForms) await this.#nestedForms[key].validate(resolved ? resolved[key] : undefined); // Validate nested forms too try { - for (let key in this.tables) await this.tables[key].validate(); // Validate nested tables too + for (let key in this.tables) await this.tables[key].validate(resolved ? resolved[key] : undefined); // Validate nested tables too } catch (e) { this.throw(e.message); } diff --git a/tests/metadata.test.ts b/tests/metadata.test.ts index 2d1292778..5932395d9 100644 --- a/tests/metadata.test.ts +++ b/tests/metadata.test.ts @@ -136,7 +136,6 @@ test('inter-table updates are triggered', async () => { test('changes are resolved correctly', async () => { const results = {} - const schema = { properties: { v0: { @@ -148,11 +147,16 @@ test('changes are resolved correctly', async () => { l2: { type: "object", properties: { - v2: { - type: 'string' - } + l3: { + type: "object", + properties: { + v2: { + type: 'string' + } + }, + required: ['v2'] + }, }, - required: ['v2'] }, v1: { type: 'string' @@ -181,13 +185,13 @@ test('changes are resolved correctly', async () => { const input1 = form.getInput(['v0']) const input2 = form.getInput(['l1', 'v1']) - const input3 = form.getInput(['l1', 'l2', 'v2']) + const input3 = form.getInput(['l1', 'l2', 'l3', 'v2']) input1.updateData('test') input2.updateData('test') input3.updateData('test') // Validate that the new structure is correct - await form.validate().then(res => errors = false).catch(e => errors = true) + await form.validate(form.results).then(res => errors = false).catch(e => errors = true) expect(errors).toBe(false) // Is valid }) From d6b922ce6f4c7354aa0eb7ae125afbcbaac37bc2 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn <46533749+GarrettMFlynn@users.noreply.github.com> Date: Wed, 20 Sep 2023 11:52:42 -0700 Subject: [PATCH 04/10] Fix filesystem update issue + annoying save progression issue --- src/renderer/src/stories/FileSystemSelector.js | 6 +----- src/renderer/src/stories/JSONSchemaForm.js | 11 +++-------- src/renderer/src/stories/pages/Page.js | 8 +++++++- .../pages/guided-mode/data/GuidedSourceData.js | 1 - 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/renderer/src/stories/FileSystemSelector.js b/src/renderer/src/stories/FileSystemSelector.js index df79bc57f..b6b85e650 100644 --- a/src/renderer/src/stories/FileSystemSelector.js +++ b/src/renderer/src/stories/FileSystemSelector.js @@ -188,11 +188,7 @@ export class FilesystemSelector extends LitElement { isUpdated = resolved !== this.value; } - if (isUpdated) { - this.value = resolved; - this.#handleFiles(this.value); // Notify of the change to the separators - return; - } + if (isUpdated) this.#handleFiles(resolved); // Notify of the change to the separators const resolvedValueDisplay = isArray ? len > 1 diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index 9d0728fc2..f8c82241a 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -178,7 +178,7 @@ export class JSONSchemaForm extends LitElement { this.identifier = props.identifier; this.mode = props.mode ?? "default"; this.schema = props.schema ?? {}; - this.results = props.results ?? {}; + this.results = (props.base ? structuredClone(props.results) : props.results) ?? {}; // Deep clone results in nested forms this.globals = props.globals ?? {}; this.ignore = props.ignore ?? []; @@ -252,17 +252,12 @@ export class JSONSchemaForm extends LitElement { const resolvedParent = path.reduce(reducer, this.resolved); const hasUpdate = resolvedParent[name] !== value; - const isTop = fullPath.length === 1; - const hasNested = Object.keys(this.#nestedForms).length; - const willUpdateResult = !hasNested || isTop; - // NOTE: Forms with nested forms will handle their own state updates - console.log("Updating", fullPath, this.#nestedForms); if (!value) { - if (willUpdateResult) delete resultParent[name]; + delete resultParent[name]; delete resolvedParent[name]; } else { - if (willUpdateResult) resultParent[name] = value; + resultParent[name] = value; resolvedParent[name] = value; } diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index 49b22071b..9e5d4ee1c 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -64,7 +64,13 @@ export class Page extends LitElement { this.beforeTransition(); // Otherwise note unsaved updates if present - if (this.unsavedUpdates || ("states" in this.info && !this.info.states.saved)) { + if ( + this.unsavedUpdates + || ( + "states" in this.info + && transition === 1 // Only ensure save for standard forward progression + && !this.info.states.saved + )) { if (transition === 1) await this.save(); // Save before a single forward transition else { Swal.fire({ diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js index eacd86b3a..599866717 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js @@ -1,4 +1,3 @@ -import { html } from "lit"; import Swal from "sweetalert2"; import { isStorybook } from "../../../../dependencies/globals.js"; From dfc07a7fffdb61755727ef9c5b93ef97e0834faa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 18:53:52 +0000 Subject: [PATCH 05/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/FileSystemSelector.js | 2 +- src/renderer/src/stories/pages/Page.js | 11 +++++------ .../pages/guided-mode/data/GuidedSourceData.js | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/stories/FileSystemSelector.js b/src/renderer/src/stories/FileSystemSelector.js index b6b85e650..fc21050a9 100644 --- a/src/renderer/src/stories/FileSystemSelector.js +++ b/src/renderer/src/stories/FileSystemSelector.js @@ -188,7 +188,7 @@ export class FilesystemSelector extends LitElement { isUpdated = resolved !== this.value; } - if (isUpdated) this.#handleFiles(resolved); // Notify of the change to the separators + if (isUpdated) this.#handleFiles(resolved); // Notify of the change to the separators const resolvedValueDisplay = isArray ? len > 1 diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index 9e5d4ee1c..1e0fffcef 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -65,12 +65,11 @@ export class Page extends LitElement { // Otherwise note unsaved updates if present if ( - this.unsavedUpdates - || ( - "states" in this.info - && transition === 1 // Only ensure save for standard forward progression - && !this.info.states.saved - )) { + this.unsavedUpdates || + ("states" in this.info && + transition === 1 && // Only ensure save for standard forward progression + !this.info.states.saved) + ) { if (transition === 1) await this.save(); // Save before a single forward transition else { Swal.fire({ diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js index 599866717..dd9c9f872 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js @@ -1,4 +1,3 @@ - import Swal from "sweetalert2"; import { isStorybook } from "../../../../dependencies/globals.js"; import { JSONSchemaForm } from "../../../JSONSchemaForm.js"; From c4564840b8cf37842f821f78cf4dbffd972c74ab Mon Sep 17 00:00:00 2001 From: rly Date: Wed, 20 Sep 2023 15:44:28 -0700 Subject: [PATCH 06/10] Fix error in updating project name, edit error msg --- src/renderer/src/progress/update.js | 12 +++++------- .../pages/guided-mode/setup/GuidedNewDatasetInfo.js | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/progress/update.js b/src/renderer/src/progress/update.js index 8756db83a..4983aef65 100644 --- a/src/renderer/src/progress/update.js +++ b/src/renderer/src/progress/update.js @@ -2,15 +2,15 @@ import { updateURLParams } from "../../utils/url.js"; import { guidedProgressFilePath } from "../dependencies/simple.js"; import { fs } from "../electron/index.js"; import { joinPath } from "../globals.js"; -import { get } from "./index.js"; +import { get, hasEntry } from "./index.js"; export const update = (newDatasetName, previousDatasetName) => { - //If updataing the dataset, update the old banner image path with a new one + //If updating the dataset, update the old banner image path with a new one if (previousDatasetName) { - if (previousDatasetName === newDatasetName) return "No changes made to dataset name"; + if (previousDatasetName === newDatasetName) return; if (hasEntry(newDatasetName)) - throw new Error("An existing progress file already exists with that name. Please choose a different name."); + throw new Error("An existing project already exists with that name. Please choose a different name."); // update old progress file with new dataset name const oldProgressFilePath = `${guidedProgressFilePath}/${previousDatasetName}.json`; @@ -20,9 +20,7 @@ export const update = (newDatasetName, previousDatasetName) => { localStorage.setItem(newProgressFilePath, localStorage.getItem(oldProgressFilePath)); localStorage.removeItem(oldProgressFilePath); } - - return "Dataset name updated"; - } else throw new Error("No previous dataset name provided"); + } else throw new Error("No previous project name provided"); }; export const updateAppProgress = ( pageId, diff --git a/src/renderer/src/stories/pages/guided-mode/setup/GuidedNewDatasetInfo.js b/src/renderer/src/stories/pages/guided-mode/setup/GuidedNewDatasetInfo.js index e39b8fe4e..cdb2c6f62 100644 --- a/src/renderer/src/stories/pages/guided-mode/setup/GuidedNewDatasetInfo.js +++ b/src/renderer/src/stories/pages/guided-mode/setup/GuidedNewDatasetInfo.js @@ -61,7 +61,7 @@ export class GuidedNewDatasetPage extends Page { const has = await hasEntry(name); if (has) { this.notify( - "An existing progress file already exists with that name. Please choose a different name.", + "An existing project already exists with that name. Please choose a different name.", "error" ); return; From f643c12d0ebb4c5e2b8fb7bf1fd97f0467a0ea75 Mon Sep 17 00:00:00 2001 From: Garrett Date: Thu, 21 Sep 2023 10:37:54 -0700 Subject: [PATCH 07/10] Change update to rename --- src/renderer/src/progress/update.js | 5 +++-- .../stories/pages/guided-mode/setup/GuidedNewDatasetInfo.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/progress/update.js b/src/renderer/src/progress/update.js index 8756db83a..8c5fc7e30 100644 --- a/src/renderer/src/progress/update.js +++ b/src/renderer/src/progress/update.js @@ -4,8 +4,8 @@ import { fs } from "../electron/index.js"; import { joinPath } from "../globals.js"; import { get } from "./index.js"; -export const update = (newDatasetName, previousDatasetName) => { - //If updataing the dataset, update the old banner image path with a new one +export const rename = (newDatasetName, previousDatasetName) => { + //If updating the dataset, update the old banner image path with a new one if (previousDatasetName) { if (previousDatasetName === newDatasetName) return "No changes made to dataset name"; @@ -24,6 +24,7 @@ export const update = (newDatasetName, previousDatasetName) => { return "Dataset name updated"; } else throw new Error("No previous dataset name provided"); }; + export const updateAppProgress = ( pageId, dataOrProjectName = {}, diff --git a/src/renderer/src/stories/pages/guided-mode/setup/GuidedNewDatasetInfo.js b/src/renderer/src/stories/pages/guided-mode/setup/GuidedNewDatasetInfo.js index e39b8fe4e..7b081e41c 100644 --- a/src/renderer/src/stories/pages/guided-mode/setup/GuidedNewDatasetInfo.js +++ b/src/renderer/src/stories/pages/guided-mode/setup/GuidedNewDatasetInfo.js @@ -1,5 +1,5 @@ import { html } from "lit"; -import { global, hasEntry, update } from "../../../../progress/index.js"; +import { global, hasEntry, rename } from "../../../../progress/index.js"; import { JSONSchemaForm } from "../../../JSONSchemaForm.js"; import { Page } from "../../Page.js"; import { validateOnChange } from "../../../../validation/index.js"; @@ -50,7 +50,7 @@ export class GuidedNewDatasetPage extends Page { // Update existing progress file if (globalState.initialized) { try { - const res = update(name, globalState.name); + const res = rename(name, globalState.name); if (typeof res === "string") this.notify(res); if (res === false) return; } catch (e) { From b9e67f1a8c76c8bb6293603e6ef6ebbd28b25255 Mon Sep 17 00:00:00 2001 From: Garrett Date: Thu, 21 Sep 2023 10:38:22 -0700 Subject: [PATCH 08/10] Add test --- src/renderer/src/progress/index.js | 23 +++++--------------- src/renderer/src/progress/operations.js | 23 ++++++++++++++++++++ tests/progress.test.ts | 29 +++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 src/renderer/src/progress/operations.js diff --git a/src/renderer/src/progress/index.js b/src/renderer/src/progress/index.js index 8e39c7e97..7de0bb38e 100644 --- a/src/renderer/src/progress/index.js +++ b/src/renderer/src/progress/index.js @@ -14,6 +14,8 @@ import { merge } from "../stories/pages/utils.js"; import { updateAppProgress, updateFile } from "./update.js"; import { updateURLParams } from "../../utils/url.js"; +import * as operations from './operations' + export * from "./update"; class GlobalAppConfig { @@ -56,6 +58,8 @@ export const save = (page, overrides = {}) => { export const getEntries = () => { if (fs && !fs.existsSync(guidedProgressFilePath)) fs.mkdirSync(guidedProgressFilePath, { recursive: true }); //Check if progress folder exists. If not, create it. const progressFiles = fs ? fs.readdirSync(guidedProgressFilePath) : Object.keys(localStorage); + console.log(progressFiles) + return progressFiles.filter((path) => path.slice(-5) === ".json"); }; @@ -122,24 +126,7 @@ export const remove = async (name) => { focusCancel: true, }); - if (result.isConfirmed) { - //Get the path of the progress file to delete - const progressFilePathToDelete = joinPath(guidedProgressFilePath, name + ".json"); - - //delete the progress file - if (fs) fs.unlinkSync(progressFilePathToDelete); - else localStorage.removeItem(progressFilePathToDelete); - - if (fs) { - // delete default stub location - fs.rmSync(joinPath(stubSaveFolderPath, name), { recursive: true, force: true }); - - // delete default conversion location - fs.rmSync(joinPath(conversionSaveFolderPath, name), { recursive: true, force: true }); - } - - return true; - } + if (result.isConfirmed) return operations.remove(name) return false; }; diff --git a/src/renderer/src/progress/operations.js b/src/renderer/src/progress/operations.js new file mode 100644 index 000000000..7cd8df54d --- /dev/null +++ b/src/renderer/src/progress/operations.js @@ -0,0 +1,23 @@ +import { joinPath } from "../globals"; +import { conversionSaveFolderPath, guidedProgressFilePath, stubSaveFolderPath } from "../dependencies/simple"; +import { fs } from "../electron"; + + +export const remove = (name) => { + //Get the path of the progress file to delete + const progressFilePathToDelete = joinPath(guidedProgressFilePath, name + ".json"); + + //delete the progress file + if (fs) fs.unlinkSync(progressFilePathToDelete); + else localStorage.removeItem(progressFilePathToDelete); + + if (fs) { + // delete default stub location + fs.rmSync(joinPath(stubSaveFolderPath, name), { recursive: true, force: true }); + + // delete default conversion location + fs.rmSync(joinPath(conversionSaveFolderPath, name), { recursive: true, force: true }); + } + + return true; +} \ No newline at end of file diff --git a/tests/progress.test.ts b/tests/progress.test.ts index 52f68b634..4e8e9da72 100644 --- a/tests/progress.test.ts +++ b/tests/progress.test.ts @@ -1,4 +1,29 @@ -import { test } from 'vitest' -import { updateAppProgress } from '../src/renderer/src/progress/update' +import { expect, test } from 'vitest' +import { updateAppProgress, updateFile, rename } from '../src/renderer/src/progress/update' +import { get } from '../src/renderer/src/progress' +import { remove } from '../src/renderer/src/progress/operations' test('updates to app progress do not fail', () => updateAppProgress('/', {})) + +const initialName = '.progressTestPipelineName' +const renameName = initialName + 2 +const info = { random: Math.random() } + +// Remove before tests +remove(initialName) +remove(renameName) + +// create pipeline +test('pipeline creation works', () => { + updateFile(initialName, () => info) + const result = get(initialName) + expect(result.random).toEqual(info.random) // NOTE: Result has an extra lastModified field +}) + +// rename pipeline +test('pipeline renaming works', () => rename(renameName, initialName)) + +// delete pipeline +test('pipeline deletion works', () => remove(renameName)) + + From 98b2077126f933cd9aa905c3606150939476fa4e Mon Sep 17 00:00:00 2001 From: Garrett Date: Thu, 21 Sep 2023 10:38:48 -0700 Subject: [PATCH 09/10] Update index.js --- src/renderer/src/progress/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/renderer/src/progress/index.js b/src/renderer/src/progress/index.js index 7de0bb38e..f303dabd2 100644 --- a/src/renderer/src/progress/index.js +++ b/src/renderer/src/progress/index.js @@ -58,8 +58,6 @@ export const save = (page, overrides = {}) => { export const getEntries = () => { if (fs && !fs.existsSync(guidedProgressFilePath)) fs.mkdirSync(guidedProgressFilePath, { recursive: true }); //Check if progress folder exists. If not, create it. const progressFiles = fs ? fs.readdirSync(guidedProgressFilePath) : Object.keys(localStorage); - console.log(progressFiles) - return progressFiles.filter((path) => path.slice(-5) === ".json"); }; From e7af457fa38b356c23bada5e15f42a9a533e6c6d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 21 Sep 2023 17:39:19 +0000 Subject: [PATCH 10/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/progress/index.js | 4 ++-- src/renderer/src/progress/operations.js | 27 ++++++++++++------------- tests/progress.test.ts | 2 -- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/renderer/src/progress/index.js b/src/renderer/src/progress/index.js index f303dabd2..212954f47 100644 --- a/src/renderer/src/progress/index.js +++ b/src/renderer/src/progress/index.js @@ -14,7 +14,7 @@ import { merge } from "../stories/pages/utils.js"; import { updateAppProgress, updateFile } from "./update.js"; import { updateURLParams } from "../../utils/url.js"; -import * as operations from './operations' +import * as operations from "./operations"; export * from "./update"; @@ -124,7 +124,7 @@ export const remove = async (name) => { focusCancel: true, }); - if (result.isConfirmed) return operations.remove(name) + if (result.isConfirmed) return operations.remove(name); return false; }; diff --git a/src/renderer/src/progress/operations.js b/src/renderer/src/progress/operations.js index 7cd8df54d..20ec92b2c 100644 --- a/src/renderer/src/progress/operations.js +++ b/src/renderer/src/progress/operations.js @@ -2,22 +2,21 @@ import { joinPath } from "../globals"; import { conversionSaveFolderPath, guidedProgressFilePath, stubSaveFolderPath } from "../dependencies/simple"; import { fs } from "../electron"; - export const remove = (name) => { - //Get the path of the progress file to delete - const progressFilePathToDelete = joinPath(guidedProgressFilePath, name + ".json"); + //Get the path of the progress file to delete + const progressFilePathToDelete = joinPath(guidedProgressFilePath, name + ".json"); - //delete the progress file - if (fs) fs.unlinkSync(progressFilePathToDelete); - else localStorage.removeItem(progressFilePathToDelete); + //delete the progress file + if (fs) fs.unlinkSync(progressFilePathToDelete); + else localStorage.removeItem(progressFilePathToDelete); - if (fs) { - // delete default stub location - fs.rmSync(joinPath(stubSaveFolderPath, name), { recursive: true, force: true }); + if (fs) { + // delete default stub location + fs.rmSync(joinPath(stubSaveFolderPath, name), { recursive: true, force: true }); - // delete default conversion location - fs.rmSync(joinPath(conversionSaveFolderPath, name), { recursive: true, force: true }); - } + // delete default conversion location + fs.rmSync(joinPath(conversionSaveFolderPath, name), { recursive: true, force: true }); + } - return true; -} \ No newline at end of file + return true; +}; diff --git a/tests/progress.test.ts b/tests/progress.test.ts index 4e8e9da72..f00782f73 100644 --- a/tests/progress.test.ts +++ b/tests/progress.test.ts @@ -25,5 +25,3 @@ test('pipeline renaming works', () => rename(renameName, initialName)) // delete pipeline test('pipeline deletion works', () => remove(renameName)) - -