diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-09-18 11:15:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-18 11:15:25 +0200 |
commit | d4101a48b3eee8b1fb177831aa02a4b4fbec2588 (patch) | |
tree | c92f2fbe91197fde8589207463d0d6526b4ff76b /src | |
parent | 5.6.3-nightly.6 [skip ci] (diff) | |
download | ferdium-app-d4101a48b3eee8b1fb177831aa02a4b4fbec2588.tar.gz ferdium-app-d4101a48b3eee8b1fb177831aa02a4b4fbec2588.tar.zst ferdium-app-d4101a48b3eee8b1fb177831aa02a4b4fbec2588.zip |
chore: convert various files from JS to TS (#1959)
Diffstat (limited to 'src')
-rw-r--r-- | src/assets/themeInfo.json | 1 | ||||
-rw-r--r-- | src/electron/ipc-api/localServer.ts | 4 | ||||
-rw-r--r-- | src/electron/macOSPermissions.ts | 2 | ||||
-rw-r--r-- | src/environment.ts (renamed from src/environment.js) | 59 | ||||
-rw-r--r-- | src/features/appearance/index.ts (renamed from src/features/appearance/index.js) | 9 | ||||
-rw-r--r-- | src/features/basicAuth/Form.ts (renamed from src/features/basicAuth/Form.js) | 0 | ||||
-rw-r--r-- | src/features/basicAuth/mainIpcHandler.ts (renamed from src/features/basicAuth/mainIpcHandler.js) | 4 | ||||
-rw-r--r-- | src/features/basicAuth/store.ts (renamed from src/features/basicAuth/store.js) | 0 | ||||
-rw-r--r-- | src/features/basicAuth/styles.ts (renamed from src/features/basicAuth/styles.js) | 0 | ||||
-rw-r--r-- | src/features/communityRecipes/index.ts (renamed from src/features/communityRecipes/index.js) | 0 | ||||
-rw-r--r-- | src/features/utils/ActionBinding.ts (renamed from src/features/utils/ActionBinding.js) | 0 | ||||
-rw-r--r-- | src/features/workspaces/actions.js | 27 | ||||
-rw-r--r-- | src/features/workspaces/actions.ts | 30 | ||||
-rw-r--r-- | src/features/workspaces/api.ts (renamed from src/features/workspaces/api.js) | 44 | ||||
-rw-r--r-- | src/features/workspaces/constants.ts (renamed from src/features/workspaces/constants.js) | 0 | ||||
-rw-r--r-- | src/features/workspaces/index.ts (renamed from src/features/workspaces/index.js) | 6 | ||||
-rw-r--r-- | src/features/workspaces/models/Workspace.ts (renamed from src/features/workspaces/models/Workspace.js) | 4 | ||||
-rw-r--r-- | src/i18n/apply-branding.ts (renamed from src/i18n/apply-branding.js) | 4 | ||||
-rw-r--r-- | src/i18n/globalMessages.ts (renamed from src/i18n/globalMessages.js) | 0 | ||||
-rw-r--r-- | src/i18n/languages.ts (renamed from src/i18n/languages.js) | 0 | ||||
-rw-r--r-- | src/i18n/translations.ts (renamed from src/i18n/translations.js) | 0 | ||||
-rw-r--r-- | src/internal-server/start.ts (renamed from src/internal-server/start.js) | 18 | ||||
-rw-r--r-- | src/internal-server/test.ts (renamed from src/internal-server/test.js) | 6 |
23 files changed, 124 insertions, 94 deletions
diff --git a/src/assets/themeInfo.json b/src/assets/themeInfo.json deleted file mode 100644 index 54e833789..000000000 --- a/src/assets/themeInfo.json +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | {"color":".theme__dark .app .sidebar .sidebar__button.is-muted, .theme__dark .app .sidebar .sidebar__button.is-active, .sidebar .sidebar__button.is-muted, .sidebar .sidebar__button.is-active, .tab-item.is-active, .settings .account .invoices .invoices__action button, .settings-navigation .settings-navigation__link.is-active .badge, a.link, button.link, .auth .welcome .button:hover, .auth .welcome .button__inverted, .franz-form .franz-form__radio.is-selected, .theme__dark .franz-form__button.franz-form__button--inverted, .franz-form__button.franz-form__button--inverted","border-color":".theme__dark .settings, .franz-form .franz-form__radio.is-selected","background":".settings .settings__header, .settings .settings__close, .settings-navigation .settings-navigation__link.is-active, a.button, button.button, .auth, .info-bar, .info-bar.info-bar--primary, .infobox.infobox--primary, .theme__dark .badge.badge--primary, .theme__dark, .badge.badge--primary, .content-tabs .content-tabs__tabs .content-tabs__item.is-active, #electron-app-title-bar .toolbar-dropdown:not(.open) > .toolbar-button > button:hover, #electron-app-title-bar .list-item.selected .menu-item, #electron-app-title-bar .list-item.selected:focus .menu-item, .theme__dark .quick-switch .active, .franz-form .franz-form__toggle-wrapper .franz-form__toggle.is-active .franz-form__toggle-button, .theme__dark .franz-form__button, .franz-form__button, .ferdi__fab, .franz-form .franz-form__slider-wrapper .slider::-webkit-slider-thumb","border-right-color":".settings .settings__header .separator"} | ||
diff --git a/src/electron/ipc-api/localServer.ts b/src/electron/ipc-api/localServer.ts index d318b93a5..61e56c777 100644 --- a/src/electron/ipc-api/localServer.ts +++ b/src/electron/ipc-api/localServer.ts | |||
@@ -2,7 +2,7 @@ import { ipcMain, BrowserWindow } from 'electron'; | |||
2 | import net from 'net'; | 2 | import net from 'net'; |
3 | import { LOCAL_HOSTNAME, LOCAL_PORT } from '../../config'; | 3 | import { LOCAL_HOSTNAME, LOCAL_PORT } from '../../config'; |
4 | import { userDataPath } from '../../environment'; | 4 | import { userDataPath } from '../../environment'; |
5 | import startServer from '../../internal-server/start'; | 5 | import { server } from '../../internal-server/start'; |
6 | 6 | ||
7 | const portInUse = (port: number): Promise<boolean> => | 7 | const portInUse = (port: number): Promise<boolean> => |
8 | new Promise(resolve => { | 8 | new Promise(resolve => { |
@@ -35,7 +35,7 @@ export default (params: { mainWindow: BrowserWindow }) => { | |||
35 | } | 35 | } |
36 | console.log('Starting local server on port', port); | 36 | console.log('Starting local server on port', port); |
37 | 37 | ||
38 | startServer(userDataPath(), port); | 38 | server(userDataPath(), port); |
39 | 39 | ||
40 | params.mainWindow.webContents.send('localServerPort', { | 40 | params.mainWindow.webContents.send('localServerPort', { |
41 | port, | 41 | port, |
diff --git a/src/electron/macOSPermissions.ts b/src/electron/macOSPermissions.ts index f5a8c7cc4..aef3ac30b 100644 --- a/src/electron/macOSPermissions.ts +++ b/src/electron/macOSPermissions.ts | |||
@@ -15,7 +15,7 @@ debug( | |||
15 | 15 | ||
16 | const filePath = userDataPath('.has-app-requested-screen-capture-permissions'); | 16 | const filePath = userDataPath('.has-app-requested-screen-capture-permissions'); |
17 | 17 | ||
18 | function hasPromptedForScreenCapturePermission(): boolean { | 18 | function hasPromptedForScreenCapturePermission(): string | boolean { |
19 | if (!isExplicitScreenCapturePermissionReqd) { | 19 | if (!isExplicitScreenCapturePermissionReqd) { |
20 | return false; | 20 | return false; |
21 | } | 21 | } |
diff --git a/src/environment.js b/src/environment.ts index b315466fc..ca1380199 100644 --- a/src/environment.js +++ b/src/environment.ts | |||
@@ -24,7 +24,9 @@ import { | |||
24 | } from './config'; | 24 | } from './config'; |
25 | 25 | ||
26 | import { asarPath } from './helpers/asar-helpers'; | 26 | import { asarPath } from './helpers/asar-helpers'; |
27 | import * as buildInfo from './buildInfo.json'; // eslint-disable-line import/no-unresolved | 27 | |
28 | // @ts-expect-error Cannot find module './buildInfo.json' or its corresponding type declarations. | ||
29 | import * as buildInfo from './buildInfo.json'; | ||
28 | 30 | ||
29 | export const { app } = electronApi; | 31 | export const { app } = electronApi; |
30 | export const ferdiVersion = app.getVersion(); | 32 | export const ferdiVersion = app.getVersion(); |
@@ -38,7 +40,11 @@ if (process.env.FERDI_APPDATA_DIR != null) { | |||
38 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); | 40 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); |
39 | app.setPath('userData', join(app.getPath('appData'))); | 41 | app.setPath('userData', join(app.getPath('appData'))); |
40 | } else if (process.env.PORTABLE_EXECUTABLE_DIR != null) { | 42 | } else if (process.env.PORTABLE_EXECUTABLE_DIR != null) { |
41 | app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.name}AppData`); | 43 | app.setPath( |
44 | 'appData', | ||
45 | process.env.PORTABLE_EXECUTABLE_DIR, | ||
46 | `${app.name}AppData`, | ||
47 | ); | ||
42 | app.setPath('userData', join(app.getPath('appData'), `${app.name}AppData`)); | 48 | app.setPath('userData', join(app.getPath('appData'), `${app.name}AppData`)); |
43 | } else if (is.windows) { | 49 | } else if (is.windows) { |
44 | app.setPath('appData', process.env.APPDATA); | 50 | app.setPath('appData', process.env.APPDATA); |
@@ -50,17 +56,17 @@ if (isDevMode) { | |||
50 | app.setPath('userData', join(app.getPath('appData'), `${app.name}Dev`)); | 56 | app.setPath('userData', join(app.getPath('appData'), `${app.name}Dev`)); |
51 | } | 57 | } |
52 | 58 | ||
53 | export function userDataPath(...segments) { | 59 | export function userDataPath(...segments: string[]) { |
54 | return join(app.getPath('userData'), ...([segments].flat())); | 60 | return join(app.getPath('userData'), ...[segments].flat()); |
55 | } | 61 | } |
56 | 62 | ||
57 | export function userDataRecipesPath(...segments) { | 63 | export function userDataRecipesPath(...segments: any[]) { |
58 | return userDataPath('recipes', ...([segments].flat())); | 64 | return userDataPath('recipes', ...[segments].flat()); |
59 | } | 65 | } |
60 | 66 | ||
61 | // Replacing app.asar is not beautiful but unfortunately necessary | 67 | // Replacing app.asar is not beautiful but unfortunately necessary |
62 | export function asarRecipesPath(...segments) { | 68 | export function asarRecipesPath(...segments: any[]) { |
63 | return join(asarPath(join(__dirname, 'recipes')), ...([segments].flat())); | 69 | return join(asarPath(join(__dirname, 'recipes')), ...[segments].flat()); |
64 | } | 70 | } |
65 | 71 | ||
66 | export const useLiveAPI = process.env.USE_LIVE_API; | 72 | export const useLiveAPI = process.env.USE_LIVE_API; |
@@ -79,22 +85,31 @@ export const is64Bit = osArch.match(/64/); | |||
79 | const ctrlKey = isMac ? '⌘' : 'Ctrl'; | 85 | const ctrlKey = isMac ? '⌘' : 'Ctrl'; |
80 | const cmdKey = isMac ? 'Cmd' : 'Ctrl'; | 86 | const cmdKey = isMac ? 'Cmd' : 'Ctrl'; |
81 | 87 | ||
82 | export const altKey = (isAccelerator = true) => (!isAccelerator && isMac ? '⌥' : 'Alt'); | 88 | export const altKey = (isAccelerator = true) => |
83 | export const shiftKey = (isAccelerator = true) => (!isAccelerator && isMac ? '⇧' : 'Shift'); | 89 | !isAccelerator && isMac ? '⌥' : 'Alt'; |
90 | export const shiftKey = (isAccelerator = true) => | ||
91 | !isAccelerator && isMac ? '⇧' : 'Shift'; | ||
84 | 92 | ||
85 | // Platform specific shortcut keys | 93 | // Platform specific shortcut keys |
86 | export const cmdOrCtrlShortcutKey = (isAccelerator = true) => (isAccelerator ? cmdKey : ctrlKey); | 94 | export const cmdOrCtrlShortcutKey = (isAccelerator = true) => |
87 | export const lockFerdiShortcutKey = (isAccelerator = true) => `${cmdOrCtrlShortcutKey(isAccelerator)}+${shiftKey(isAccelerator)}+L`; | 95 | isAccelerator ? cmdKey : ctrlKey; |
88 | export const todosToggleShortcutKey = (isAccelerator = true) => `${cmdOrCtrlShortcutKey(isAccelerator)}+T`; | 96 | export const lockFerdiShortcutKey = (isAccelerator = true) => |
89 | export const workspaceToggleShortcutKey = (isAccelerator = true) => `${cmdOrCtrlShortcutKey(isAccelerator)}+D`; | 97 | `${cmdOrCtrlShortcutKey(isAccelerator)}+${shiftKey(isAccelerator)}+L`; |
90 | export const muteFerdiShortcutKey = (isAccelerator = true) => `${cmdOrCtrlShortcutKey(isAccelerator)}+${shiftKey(isAccelerator)}+M`; | 98 | export const todosToggleShortcutKey = (isAccelerator = true) => |
91 | export const addNewServiceShortcutKey = (isAccelerator = true) => `${cmdOrCtrlShortcutKey(isAccelerator)}+N`; | 99 | `${cmdOrCtrlShortcutKey(isAccelerator)}+T`; |
92 | export const settingsShortcutKey = (isAccelerator = true) => `${cmdOrCtrlShortcutKey(isAccelerator)}+${isMac ? ',' : 'P'}`; | 100 | export const workspaceToggleShortcutKey = (isAccelerator = true) => |
93 | 101 | `${cmdOrCtrlShortcutKey(isAccelerator)}+D`; | |
94 | let api; | 102 | export const muteFerdiShortcutKey = (isAccelerator = true) => |
95 | let wsApi; | 103 | `${cmdOrCtrlShortcutKey(isAccelerator)}+${shiftKey(isAccelerator)}+M`; |
96 | let web; | 104 | export const addNewServiceShortcutKey = (isAccelerator = true) => |
97 | let todos; | 105 | `${cmdOrCtrlShortcutKey(isAccelerator)}+N`; |
106 | export const settingsShortcutKey = (isAccelerator = true) => | ||
107 | `${cmdOrCtrlShortcutKey(isAccelerator)}+${isMac ? ',' : 'P'}`; | ||
108 | |||
109 | let api: string; | ||
110 | let wsApi: string; | ||
111 | let web: string; | ||
112 | let todos: string; | ||
98 | if (!isDevMode || (isDevMode && useLiveAPI)) { | 113 | if (!isDevMode || (isDevMode && useLiveAPI)) { |
99 | api = LIVE_FERDI_API; | 114 | api = LIVE_FERDI_API; |
100 | wsApi = LIVE_WS_API; | 115 | wsApi = LIVE_WS_API; |
diff --git a/src/features/appearance/index.js b/src/features/appearance/index.ts index 0c935be32..b00b9df3d 100644 --- a/src/features/appearance/index.js +++ b/src/features/appearance/index.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import color from 'color'; | 1 | import color from 'color'; |
2 | import { reaction } from 'mobx'; | 2 | import { reaction } from 'mobx'; |
3 | import themeInfo from '../../assets/themeInfo.json'; | ||
4 | import { iconSizeBias } from '../../config'; | 3 | import { iconSizeBias } from '../../config'; |
5 | import { DEFAULT_APP_SETTINGS } from '../../environment'; | 4 | import { DEFAULT_APP_SETTINGS } from '../../environment'; |
6 | 5 | ||
@@ -30,14 +29,6 @@ function darkenAbsolute(originalColor, absoluteChange) { | |||
30 | function generateAccentStyle(accentColorStr) { | 29 | function generateAccentStyle(accentColorStr) { |
31 | let style = ''; | 30 | let style = ''; |
32 | 31 | ||
33 | for (const property of Object.keys(themeInfo)) { | ||
34 | style += ` | ||
35 | ${themeInfo[property]} { | ||
36 | ${property}: ${accentColorStr}; | ||
37 | } | ||
38 | `; | ||
39 | } | ||
40 | |||
41 | let accentColor = color(DEFAULT_APP_SETTINGS.accentColor); | 32 | let accentColor = color(DEFAULT_APP_SETTINGS.accentColor); |
42 | try { | 33 | try { |
43 | accentColor = color(accentColorStr); | 34 | accentColor = color(accentColorStr); |
diff --git a/src/features/basicAuth/Form.js b/src/features/basicAuth/Form.ts index 95721d0e9..95721d0e9 100644 --- a/src/features/basicAuth/Form.js +++ b/src/features/basicAuth/Form.ts | |||
diff --git a/src/features/basicAuth/mainIpcHandler.js b/src/features/basicAuth/mainIpcHandler.ts index ae4e7cf93..4ec3848e8 100644 --- a/src/features/basicAuth/mainIpcHandler.js +++ b/src/features/basicAuth/mainIpcHandler.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | import { BrowserWindow } from 'electron'; | ||
2 | |||
1 | const debug = require('debug')('Ferdi:feature:basicAuth:main'); | 3 | const debug = require('debug')('Ferdi:feature:basicAuth:main'); |
2 | 4 | ||
3 | export default function mainIpcHandler(mainWindow, authInfo) { | 5 | export default function mainIpcHandler(mainWindow: BrowserWindow, authInfo) { |
4 | debug('Sending basic auth call', authInfo); | 6 | debug('Sending basic auth call', authInfo); |
5 | 7 | ||
6 | mainWindow.webContents.send('feature:basic-auth', { | 8 | mainWindow.webContents.send('feature:basic-auth', { |
diff --git a/src/features/basicAuth/store.js b/src/features/basicAuth/store.ts index 0713ff572..0713ff572 100644 --- a/src/features/basicAuth/store.js +++ b/src/features/basicAuth/store.ts | |||
diff --git a/src/features/basicAuth/styles.js b/src/features/basicAuth/styles.ts index 6bdaf9a6e..6bdaf9a6e 100644 --- a/src/features/basicAuth/styles.js +++ b/src/features/basicAuth/styles.ts | |||
diff --git a/src/features/communityRecipes/index.js b/src/features/communityRecipes/index.ts index 828c6d867..828c6d867 100644 --- a/src/features/communityRecipes/index.js +++ b/src/features/communityRecipes/index.ts | |||
diff --git a/src/features/utils/ActionBinding.js b/src/features/utils/ActionBinding.ts index 787166d44..787166d44 100644 --- a/src/features/utils/ActionBinding.js +++ b/src/features/utils/ActionBinding.ts | |||
diff --git a/src/features/workspaces/actions.js b/src/features/workspaces/actions.js deleted file mode 100644 index 5b5db422e..000000000 --- a/src/features/workspaces/actions.js +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | import Workspace from './models/Workspace'; | ||
3 | import { createActionsFromDefinitions } from '../../actions/lib/actions'; | ||
4 | |||
5 | export const workspaceActions = createActionsFromDefinitions({ | ||
6 | edit: { | ||
7 | workspace: PropTypes.instanceOf(Workspace).isRequired, | ||
8 | }, | ||
9 | create: { | ||
10 | name: PropTypes.string.isRequired, | ||
11 | }, | ||
12 | delete: { | ||
13 | workspace: PropTypes.instanceOf(Workspace).isRequired, | ||
14 | }, | ||
15 | update: { | ||
16 | workspace: PropTypes.instanceOf(Workspace).isRequired, | ||
17 | }, | ||
18 | activate: { | ||
19 | workspace: PropTypes.instanceOf(Workspace).isRequired, | ||
20 | }, | ||
21 | deactivate: {}, | ||
22 | toggleWorkspaceDrawer: {}, | ||
23 | openWorkspaceSettings: {}, | ||
24 | toggleKeepAllWorkspacesLoadedSetting: {}, | ||
25 | }, PropTypes.checkPropTypes); | ||
26 | |||
27 | export default workspaceActions; | ||
diff --git a/src/features/workspaces/actions.ts b/src/features/workspaces/actions.ts new file mode 100644 index 000000000..5e7e6e721 --- /dev/null +++ b/src/features/workspaces/actions.ts | |||
@@ -0,0 +1,30 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | import Workspace from './models/Workspace'; | ||
3 | import { createActionsFromDefinitions } from '../../actions/lib/actions'; | ||
4 | |||
5 | export const workspaceActions = createActionsFromDefinitions( | ||
6 | { | ||
7 | edit: { | ||
8 | workspace: PropTypes.instanceOf(Workspace).isRequired, | ||
9 | }, | ||
10 | create: { | ||
11 | name: PropTypes.string.isRequired, | ||
12 | }, | ||
13 | delete: { | ||
14 | workspace: PropTypes.instanceOf(Workspace).isRequired, | ||
15 | }, | ||
16 | update: { | ||
17 | workspace: PropTypes.instanceOf(Workspace).isRequired, | ||
18 | }, | ||
19 | activate: { | ||
20 | workspace: PropTypes.instanceOf(Workspace).isRequired, | ||
21 | }, | ||
22 | deactivate: {}, | ||
23 | toggleWorkspaceDrawer: {}, | ||
24 | openWorkspaceSettings: {}, | ||
25 | toggleKeepAllWorkspacesLoadedSetting: {}, | ||
26 | }, | ||
27 | PropTypes.checkPropTypes, | ||
28 | ); | ||
29 | |||
30 | export default workspaceActions; | ||
diff --git a/src/features/workspaces/api.js b/src/features/workspaces/api.ts index 322695ed2..8447fc247 100644 --- a/src/features/workspaces/api.js +++ b/src/features/workspaces/api.ts | |||
@@ -12,12 +12,14 @@ export const workspaceApi = { | |||
12 | debug('getUserWorkspaces GET', url); | 12 | debug('getUserWorkspaces GET', url); |
13 | const result = await sendAuthRequest(url, { method: 'GET' }); | 13 | const result = await sendAuthRequest(url, { method: 'GET' }); |
14 | debug('getUserWorkspaces RESULT', result); | 14 | debug('getUserWorkspaces RESULT', result); |
15 | if (!result.ok) throw result; | 15 | if (!result.ok) { |
16 | throw new Error("Couldn't getUserWorkspaces"); | ||
17 | } | ||
16 | const workspaces = await result.json(); | 18 | const workspaces = await result.json(); |
17 | return workspaces.map((data) => new Workspace(data)); | 19 | return workspaces.map(data => new Workspace(data)); |
18 | }, | 20 | }, |
19 | 21 | ||
20 | createWorkspace: async (name) => { | 22 | createWorkspace: async name => { |
21 | const url = `${apiBase()}/workspace`; | 23 | const url = `${apiBase()}/workspace`; |
22 | const options = { | 24 | const options = { |
23 | method: 'POST', | 25 | method: 'POST', |
@@ -26,20 +28,24 @@ export const workspaceApi = { | |||
26 | debug('createWorkspace POST', url, options); | 28 | debug('createWorkspace POST', url, options); |
27 | const result = await sendAuthRequest(url, options); | 29 | const result = await sendAuthRequest(url, options); |
28 | debug('createWorkspace RESULT', result); | 30 | debug('createWorkspace RESULT', result); |
29 | if (!result.ok) throw result; | 31 | if (!result.ok) { |
32 | throw new Error("Couldn't createWorkspace"); | ||
33 | } | ||
30 | return new Workspace(await result.json()); | 34 | return new Workspace(await result.json()); |
31 | }, | 35 | }, |
32 | 36 | ||
33 | deleteWorkspace: async (workspace) => { | 37 | deleteWorkspace: async workspace => { |
34 | const url = `${apiBase()}/workspace/${workspace.id}`; | 38 | const url = `${apiBase()}/workspace/${workspace.id}`; |
35 | debug('deleteWorkspace DELETE', url); | 39 | debug('deleteWorkspace DELETE', url); |
36 | const result = await sendAuthRequest(url, { method: 'DELETE' }); | 40 | const result = await sendAuthRequest(url, { method: 'DELETE' }); |
37 | debug('deleteWorkspace RESULT', result); | 41 | debug('deleteWorkspace RESULT', result); |
38 | if (!result.ok) throw result; | 42 | if (!result.ok) { |
43 | throw new Error("Couldn't deleteWorkspace"); | ||
44 | } | ||
39 | return true; | 45 | return true; |
40 | }, | 46 | }, |
41 | 47 | ||
42 | updateWorkspace: async (workspace) => { | 48 | updateWorkspace: async workspace => { |
43 | const url = `${apiBase()}/workspace/${workspace.id}`; | 49 | const url = `${apiBase()}/workspace/${workspace.id}`; |
44 | const options = { | 50 | const options = { |
45 | method: 'PUT', | 51 | method: 'PUT', |
@@ -48,15 +54,29 @@ export const workspaceApi = { | |||
48 | debug('updateWorkspace UPDATE', url, options); | 54 | debug('updateWorkspace UPDATE', url, options); |
49 | const result = await sendAuthRequest(url, options); | 55 | const result = await sendAuthRequest(url, options); |
50 | debug('updateWorkspace RESULT', result); | 56 | debug('updateWorkspace RESULT', result); |
51 | if (!result.ok) throw result; | 57 | if (!result.ok) { |
58 | throw new Error("Couldn't updateWorkspace"); | ||
59 | } | ||
52 | return new Workspace(await result.json()); | 60 | return new Workspace(await result.json()); |
53 | }, | 61 | }, |
54 | }; | 62 | }; |
55 | 63 | ||
56 | export const getUserWorkspacesRequest = new Request(workspaceApi, 'getUserWorkspaces'); | 64 | export const getUserWorkspacesRequest = new Request( |
57 | export const createWorkspaceRequest = new Request(workspaceApi, 'createWorkspace'); | 65 | workspaceApi, |
58 | export const deleteWorkspaceRequest = new Request(workspaceApi, 'deleteWorkspace'); | 66 | 'getUserWorkspaces', |
59 | export const updateWorkspaceRequest = new Request(workspaceApi, 'updateWorkspace'); | 67 | ); |
68 | export const createWorkspaceRequest = new Request( | ||
69 | workspaceApi, | ||
70 | 'createWorkspace', | ||
71 | ); | ||
72 | export const deleteWorkspaceRequest = new Request( | ||
73 | workspaceApi, | ||
74 | 'deleteWorkspace', | ||
75 | ); | ||
76 | export const updateWorkspaceRequest = new Request( | ||
77 | workspaceApi, | ||
78 | 'updateWorkspace', | ||
79 | ); | ||
60 | 80 | ||
61 | export const resetApiRequests = () => { | 81 | export const resetApiRequests = () => { |
62 | getUserWorkspacesRequest.reset(); | 82 | getUserWorkspacesRequest.reset(); |
diff --git a/src/features/workspaces/constants.js b/src/features/workspaces/constants.ts index 2d1416ee0..2d1416ee0 100644 --- a/src/features/workspaces/constants.js +++ b/src/features/workspaces/constants.ts | |||
diff --git a/src/features/workspaces/index.js b/src/features/workspaces/index.ts index 83e4d9049..ecca64b41 100644 --- a/src/features/workspaces/index.js +++ b/src/features/workspaces/index.ts | |||
@@ -12,10 +12,8 @@ export default function initWorkspaces(stores, actions) { | |||
12 | 12 | ||
13 | // Toggle workspace feature | 13 | // Toggle workspace feature |
14 | reaction( | 14 | reaction( |
15 | () => ( | 15 | () => features.features.isWorkspaceEnabled, |
16 | features.features.isWorkspaceEnabled | 16 | isEnabled => { |
17 | ), | ||
18 | (isEnabled) => { | ||
19 | if (isEnabled && !workspaceStore.isFeatureActive) { | 17 | if (isEnabled && !workspaceStore.isFeatureActive) { |
20 | debug('Initializing `workspaces` feature'); | 18 | debug('Initializing `workspaces` feature'); |
21 | workspaceStore.start(stores, actions); | 19 | workspaceStore.start(stores, actions); |
diff --git a/src/features/workspaces/models/Workspace.js b/src/features/workspaces/models/Workspace.ts index 14add9437..cd3918fba 100644 --- a/src/features/workspaces/models/Workspace.js +++ b/src/features/workspaces/models/Workspace.ts | |||
@@ -28,8 +28,10 @@ export default class Workspace { | |||
28 | services.push(KEEP_WS_LOADED_USID); | 28 | services.push(KEEP_WS_LOADED_USID); |
29 | } else if (data.saving && data.services.includes(KEEP_WS_LOADED_USID)) { | 29 | } else if (data.saving && data.services.includes(KEEP_WS_LOADED_USID)) { |
30 | // Don't keep loaded | 30 | // Don't keep loaded |
31 | services = services.filter((e) => e !== KEEP_WS_LOADED_USID); | 31 | services = services.filter(e => e !== KEEP_WS_LOADED_USID); |
32 | } | 32 | } |
33 | |||
34 | // @ts-expect-error Property 'replace' does not exist on type 'never[]'. | ||
33 | this.services.replace(services); | 35 | this.services.replace(services); |
34 | 36 | ||
35 | this.userId = data.userId; | 37 | this.userId = data.userId; |
diff --git a/src/i18n/apply-branding.js b/src/i18n/apply-branding.ts index 8ec573919..801a4a525 100644 --- a/src/i18n/apply-branding.js +++ b/src/i18n/apply-branding.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | /** | 1 | /** |
2 | * Apply Ferdi branding to i18n translations | 2 | * Apply Ferdi branding to i18n translations |
3 | */ | 3 | */ |
4 | const fs = require('fs-extra'); | 4 | import fs from 'fs-extra'; |
5 | const path = require('path'); | 5 | import path from 'path'; |
6 | 6 | ||
7 | console.log('Applying Ferdi branding to translations...'); | 7 | console.log('Applying Ferdi branding to translations...'); |
8 | 8 | ||
diff --git a/src/i18n/globalMessages.js b/src/i18n/globalMessages.ts index 8e1df10f7..8e1df10f7 100644 --- a/src/i18n/globalMessages.js +++ b/src/i18n/globalMessages.ts | |||
diff --git a/src/i18n/languages.js b/src/i18n/languages.ts index e7713b42b..e7713b42b 100644 --- a/src/i18n/languages.js +++ b/src/i18n/languages.ts | |||
diff --git a/src/i18n/translations.js b/src/i18n/translations.ts index 9a7dc7453..9a7dc7453 100644 --- a/src/i18n/translations.js +++ b/src/i18n/translations.ts | |||
diff --git a/src/internal-server/start.js b/src/internal-server/start.ts index 5ccc1330e..392f7cf41 100644 --- a/src/internal-server/start.js +++ b/src/internal-server/start.ts | |||
@@ -15,16 +15,16 @@ | |||
15 | | Make sure to pass a relative path from the project root. | 15 | | Make sure to pass a relative path from the project root. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | const fold = require('@adonisjs/fold'); | 18 | import fold from '@adonisjs/fold'; |
19 | const { Ignitor } = require('@adonisjs/ignitor'); | 19 | import { Ignitor } from '@adonisjs/ignitor'; |
20 | const fs = require('fs-extra'); | 20 | import fs from 'fs-extra'; |
21 | const path = require('path'); | 21 | import path from 'path'; |
22 | const { LOCAL_HOSTNAME } = require('../config'); | 22 | import { LOCAL_HOSTNAME } from '../config'; |
23 | const { isWindows } = require('../environment'); | 23 | import { isWindows } from '../environment'; |
24 | 24 | ||
25 | process.env.ENV_PATH = path.join(__dirname, 'env.ini'); | 25 | process.env.ENV_PATH = path.join(__dirname, 'env.ini'); |
26 | 26 | ||
27 | module.exports = async (userPath, port) => { | 27 | export const server = async (userPath: string, port: number) => { |
28 | const dbPath = path.join(userPath, 'server.sqlite'); | 28 | const dbPath = path.join(userPath, 'server.sqlite'); |
29 | const dbTemplatePath = path.join(__dirname, 'database', 'template.sqlite'); | 29 | const dbTemplatePath = path.join(__dirname, 'database', 'template.sqlite'); |
30 | 30 | ||
@@ -45,7 +45,7 @@ module.exports = async (userPath, port) => { | |||
45 | process.env.DB_PATH = dbPath; | 45 | process.env.DB_PATH = dbPath; |
46 | process.env.USER_PATH = userPath; | 46 | process.env.USER_PATH = userPath; |
47 | process.env.HOST = LOCAL_HOSTNAME; | 47 | process.env.HOST = LOCAL_HOSTNAME; |
48 | process.env.PORT = port; | 48 | process.env.PORT = port.toString(); |
49 | 49 | ||
50 | new Ignitor(fold).appRoot(__dirname).fireHttpServer().catch(console.error); // eslint-disable-line no-console | 50 | new Ignitor(fold).appRoot(__dirname).fireHttpServer().catch(console.error); |
51 | }; | 51 | }; |
diff --git a/src/internal-server/test.js b/src/internal-server/test.ts index ef85743f3..437a2813b 100644 --- a/src/internal-server/test.js +++ b/src/internal-server/test.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | const path = require('path'); | 1 | import path from 'path'; |
2 | const fs = require('fs-extra'); | 2 | import fs from 'fs-extra'; |
3 | const server = require('./start'); | 3 | import { server } from './start'; |
4 | 4 | ||
5 | const dummyUserFolder = path.join(__dirname, 'user_data'); | 5 | const dummyUserFolder = path.join(__dirname, 'user_data'); |
6 | 6 | ||