From d0bad11661cb93756891e7fafe729b7f4e415fb1 Mon Sep 17 00:00:00 2001 From: Vijay Raghavan Aravamudhan Date: Wed, 1 Sep 2021 09:29:49 +0530 Subject: Fix issue with workspace feature - fixes #1682 (#1854) * fix issue with workspace feature not being turned on, and then randomly turning on somehow. * when deleting the active workspace, auto-select the default workspace. * consolidated the toggling of features into a single place in the config file. Co-authored-by: Sadetdin EYILI Signed-off-by: Vijay A --- CHANGELOG.md | 6 ++++ src/config.ts | 5 +-- .../workspaces/components/EditWorkspaceForm.js | 1 + src/features/workspaces/store.js | 38 ++++++++-------------- .../app/Controllers/Http/StaticController.js | 16 +++------ 5 files changed, 28 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 342c21c63..3cb1970ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# [v5.6.1-nightly.46](https://github.com/getferdi/ferdi/compare/v5.6.1-nightly.45...v5.6.1-nightly.46) (2021-09-01) + +### Bug Fixes + +- Workspaces are now working. When the active workspace gets deleted, the default workspace gets auto-selected. 💖 @sad270, @vraravam + # [v5.6.1-nightly.45](https://github.com/getferdi/ferdi/compare/v5.6.1-nightly.43...v5.6.1-nightly.45) (2021-09-01) - Upgrade to [electron 13.3.0](https://github.com/electron/electron/releases/tag/v13.3.0) 💖 @vraravam diff --git a/src/config.ts b/src/config.ts index 0647b8f52..835d130da 100644 --- a/src/config.ts +++ b/src/config.ts @@ -134,10 +134,11 @@ export const ICON_SIZES = { export const iconSizeBias = 20; export const DEFAULT_FEATURES_CONFIG = { - isServiceProxyEnabled: false, + isServiceProxyEnabled: true, isAnnouncementsEnabled: true, - isWorkspaceEnabled: false, + isWorkspaceEnabled: true, isTodosEnabled: true, + isSettingsWSEnabled: false, }; export const DEFAULT_WINDOW_OPTIONS = { diff --git a/src/features/workspaces/components/EditWorkspaceForm.js b/src/features/workspaces/components/EditWorkspaceForm.js index 0ff836cba..c97d4bd9c 100644 --- a/src/features/workspaces/components/EditWorkspaceForm.js +++ b/src/features/workspaces/components/EditWorkspaceForm.js @@ -224,6 +224,7 @@ class EditWorkspaceForm extends Component { busy={isSaving} buttonType={isSaving ? 'secondary' : 'primary'} onClick={this.save.bind(this, form)} + // TODO: Need to disable if no services have been added to this workspace disabled={isSaving} /> diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js index 8c73516bc..ec9d7ee7f 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js @@ -155,38 +155,26 @@ export default class WorkspacesStore extends FeatureStore { }; @action _create = async ({ name }) => { - // eslint-disable-next-line no-useless-catch - try { - const workspace = await createWorkspaceRequest.execute(name); - await getUserWorkspacesRequest.result.push(workspace); - this._edit({ workspace }); - } catch (error) { - throw error; - } + const workspace = await createWorkspaceRequest.execute(name); + await getUserWorkspacesRequest.result.push(workspace); + this._edit({ workspace }); }; @action _delete = async ({ workspace }) => { - // eslint-disable-next-line no-useless-catch - try { - await deleteWorkspaceRequest.execute(workspace); - await getUserWorkspacesRequest.result.remove(workspace); - this.stores.router.push('/settings/workspaces'); - } catch (error) { - throw error; + await deleteWorkspaceRequest.execute(workspace); + await getUserWorkspacesRequest.result.remove(workspace); + this.stores.router.push('/settings/workspaces'); + if (this.activeWorkspace === workspace) { + this._deactivateActiveWorkspace(); } }; @action _update = async ({ workspace }) => { - // eslint-disable-next-line no-useless-catch - try { - await updateWorkspaceRequest.execute(workspace); - // Path local result optimistically - const localWorkspace = this._getWorkspaceById(workspace.id); - Object.assign(localWorkspace, workspace); - this.stores.router.push('/settings/workspaces'); - } catch (error) { - throw error; - } + await updateWorkspaceRequest.execute(workspace); + // Path local result optimistically + const localWorkspace = this._getWorkspaceById(workspace.id); + Object.assign(localWorkspace, workspace); + this.stores.router.push('/settings/workspaces'); }; @action _setActiveWorkspace = ({ workspace }) => { diff --git a/src/internal-server/app/Controllers/Http/StaticController.js b/src/internal-server/app/Controllers/Http/StaticController.js index b9a145061..28c5389a9 100644 --- a/src/internal-server/app/Controllers/Http/StaticController.js +++ b/src/internal-server/app/Controllers/Http/StaticController.js @@ -2,21 +2,15 @@ * Controller for routes with static responses */ +import { DEFAULT_FEATURES_CONFIG } from '../../../../config'; + +// TODO: This endpoint and associated code needs to be remoeved as cleanup class StaticController { // Enable all features features({ response, }) { - return response.send({ - isServiceProxyEnabled: true, - isWorkspaceEnabled: true, - isAnnouncementsEnabled: true, - isSettingsWSEnabled: false, - isMagicBarEnabled: true, - isTodosEnabled: true, - subscribeURL: 'https://getferdi.com', - hasInlineCheckout: true, - }); + return response.send(DEFAULT_FEATURES_CONFIG); } // Return an empty array @@ -34,4 +28,4 @@ class StaticController { } } -module.exports = StaticController; +export default StaticController; -- cgit v1.2.3-70-g09d2