mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix default workspace remove (#242)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
f12b2b6a99
commit
298636b8f1
@ -18,6 +18,7 @@ export class Workspace implements WorkspaceData {
|
||||
}
|
||||
|
||||
export class WorkspaceStore {
|
||||
public static defaultId = "default"
|
||||
private static instance: WorkspaceStore;
|
||||
public store: ElectronStore;
|
||||
|
||||
@ -39,6 +40,9 @@ export class WorkspaceStore {
|
||||
}
|
||||
|
||||
public removeWorkspace(workspace: Workspace) {
|
||||
if (workspace.id === WorkspaceStore.defaultId) {
|
||||
throw new Error("Cannot remove default workspace")
|
||||
}
|
||||
const workspaces = this.getAllWorkspaces()
|
||||
const index = workspaces.findIndex((w) => w.id === workspace.id)
|
||||
if (index !== -1) {
|
||||
@ -64,9 +68,9 @@ export class WorkspaceStore {
|
||||
|
||||
const workspaceStore: WorkspaceStore = WorkspaceStore.getInstance()
|
||||
|
||||
if (workspaceStore.getAllWorkspaces().length === 0) {
|
||||
if (!workspaceStore.getAllWorkspaces().find( ws => ws.id === WorkspaceStore.defaultId)) {
|
||||
workspaceStore.storeWorkspace({
|
||||
id: "default",
|
||||
id: WorkspaceStore.defaultId,
|
||||
name: "default"
|
||||
})
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
<b-button variant="primary" type="submit">
|
||||
Save
|
||||
</b-button>
|
||||
<b-button v-b-modal.bv-modal-confirm>
|
||||
<b-button v-if="workspace.id !== 'default'" v-b-modal.bv-modal-confirm>
|
||||
Delete
|
||||
</b-button>
|
||||
<b-modal id="bv-modal-confirm" @ok="deleteWorkspace" ok-title="Delete" ok-variant="danger" title-class="confirm-header" hide-backdrop title="Confirm workspace delete">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user