aboutsummaryrefslogtreecommitdiffstats
path: root/src/features
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-10-02 09:24:32 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-02 09:24:32 +0200
commitbfe8847d72cd0893230f2e654242658214943e61 (patch)
tree3384b02ebad7a74cbb106ddd95546e0e24ff0bb8 /src/features
parentfix: Fix navigation shortcut accelerator for non-macos (fixes #1172) (#2012) (diff)
downloadferdium-app-bfe8847d72cd0893230f2e654242658214943e61.tar.gz
ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.tar.zst
ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.zip
chore: convert various files from JS to TS (#2010)
Diffstat (limited to 'src/features')
-rw-r--r--src/features/basicAuth/Form.ts1
-rw-r--r--src/features/communityRecipes/store.ts (renamed from src/features/communityRecipes/store.js)23
-rw-r--r--src/features/nightlyBuilds/store.ts (renamed from src/features/nightlyBuilds/store.js)0
-rw-r--r--src/features/publishDebugInfo/store.ts (renamed from src/features/publishDebugInfo/store.js)0
-rw-r--r--src/features/quickSwitch/store.ts (renamed from src/features/quickSwitch/store.js)0
-rw-r--r--src/features/serviceProxy/index.js38
-rw-r--r--src/features/serviceProxy/index.ts54
-rwxr-xr-xsrc/features/settingsWS/actions.ts (renamed from src/features/settingsWS/actions.js)0
-rwxr-xr-xsrc/features/settingsWS/index.ts (renamed from src/features/settingsWS/index.js)11
-rwxr-xr-xsrc/features/settingsWS/state.ts (renamed from src/features/settingsWS/state.js)0
-rw-r--r--src/features/todos/actions.js28
-rw-r--r--src/features/todos/actions.ts31
-rw-r--r--src/features/todos/constants.ts (renamed from src/features/todos/constants.js)0
-rw-r--r--src/features/todos/index.ts (renamed from src/features/todos/index.js)11
14 files changed, 113 insertions, 84 deletions
diff --git a/src/features/basicAuth/Form.ts b/src/features/basicAuth/Form.ts
index 95721d0e9..e84156d96 100644
--- a/src/features/basicAuth/Form.ts
+++ b/src/features/basicAuth/Form.ts
@@ -1,5 +1,6 @@
1import Form from '../../lib/Form'; 1import Form from '../../lib/Form';
2 2
3// @ts-expect-error Expected 0 arguments, but got 1
3export default new Form({ 4export default new Form({
4 fields: { 5 fields: {
5 user: { 6 user: {
diff --git a/src/features/communityRecipes/store.js b/src/features/communityRecipes/store.ts
index 05e18e2f7..a8d358ba0 100644
--- a/src/features/communityRecipes/store.js
+++ b/src/features/communityRecipes/store.ts
@@ -4,7 +4,11 @@ import { FeatureStore } from '../utils/FeatureStore';
4const debug = require('debug')('Ferdi:feature:communityRecipes:store'); 4const debug = require('debug')('Ferdi:feature:communityRecipes:store');
5 5
6export class CommunityRecipesStore extends FeatureStore { 6export class CommunityRecipesStore extends FeatureStore {
7 start(stores, actions) { 7 stores: any;
8
9 actions: any;
10
11 start(stores: any, actions: any) {
8 debug('start'); 12 debug('start');
9 this.stores = stores; 13 this.stores = stores;
10 this.actions = actions; 14 this.actions = actions;
@@ -18,14 +22,17 @@ export class CommunityRecipesStore extends FeatureStore {
18 @computed get communityRecipes() { 22 @computed get communityRecipes() {
19 if (!this.stores) return []; 23 if (!this.stores) return [];
20 24
21 return this.stores.recipePreviews.dev.map(recipePreview => { 25 return this.stores.recipePreviews.dev.map(
22 // TODO: Need to figure out if this is even necessary/used 26 (recipePreview: { isDevRecipe: boolean; author: any[] }) => {
23 recipePreview.isDevRecipe = !!recipePreview.author.some( 27 // TODO: Need to figure out if this is even necessary/used
24 author => author.email === this.stores.user.data.email, 28 recipePreview.isDevRecipe = !!recipePreview.author.some(
25 ); 29 (author: { email: any }) =>
30 author.email === this.stores.user.data.email,
31 );
26 32
27 return recipePreview; 33 return recipePreview;
28 }); 34 },
35 );
29 } 36 }
30} 37}
31 38
diff --git a/src/features/nightlyBuilds/store.js b/src/features/nightlyBuilds/store.ts
index ed06e5a7d..ed06e5a7d 100644
--- a/src/features/nightlyBuilds/store.js
+++ b/src/features/nightlyBuilds/store.ts
diff --git a/src/features/publishDebugInfo/store.js b/src/features/publishDebugInfo/store.ts
index ed06e5a7d..ed06e5a7d 100644
--- a/src/features/publishDebugInfo/store.js
+++ b/src/features/publishDebugInfo/store.ts
diff --git a/src/features/quickSwitch/store.js b/src/features/quickSwitch/store.ts
index ed06e5a7d..ed06e5a7d 100644
--- a/src/features/quickSwitch/store.js
+++ b/src/features/quickSwitch/store.ts
diff --git a/src/features/serviceProxy/index.js b/src/features/serviceProxy/index.js
deleted file mode 100644
index b9320cda9..000000000
--- a/src/features/serviceProxy/index.js
+++ /dev/null
@@ -1,38 +0,0 @@
1import { autorun, observable } from 'mobx';
2import { session } from '@electron/remote';
3
4const debug = require('debug')('Ferdi:feature:serviceProxy');
5
6export const config = observable({
7 isEnabled: true,
8});
9
10export default function init(stores) {
11 debug('Initializing `serviceProxy` feature');
12
13 autorun(() => {
14 config.isEnabled = true;
15
16 const services = stores.services.enabled;
17 const proxySettings = stores.settings.proxy;
18
19 debug('Service Proxy autorun');
20
21 for (const service of services) {
22 const s = session.fromPartition(`persist:service-${service.id}`);
23
24 if (config.isEnabled) {
25 const serviceProxyConfig = proxySettings[service.id];
26
27 if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) {
28 const proxyHost = `${serviceProxyConfig.host}${serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : ''}`;
29 debug(`Setting proxy config from service settings for "${service.name}" (${service.id}) to`, proxyHost);
30
31 s.setProxy({ proxyRules: proxyHost }, () => {
32 debug(`Using proxy "${proxyHost}" for "${service.name}" (${service.id})`);
33 });
34 }
35 }
36 }
37 });
38}
diff --git a/src/features/serviceProxy/index.ts b/src/features/serviceProxy/index.ts
new file mode 100644
index 000000000..f095b286a
--- /dev/null
+++ b/src/features/serviceProxy/index.ts
@@ -0,0 +1,54 @@
1import { autorun, observable } from 'mobx';
2import { session } from '@electron/remote';
3
4const debug = require('debug')('Ferdi:feature:serviceProxy');
5
6export const config = observable({
7 isEnabled: true,
8});
9
10export default function init(stores: {
11 services: { enabled: any };
12 settings: { proxy: any };
13}) {
14 debug('Initializing `serviceProxy` feature');
15
16 autorun(() => {
17 config.isEnabled = true;
18
19 const services = stores.services.enabled;
20 const proxySettings = stores.settings.proxy;
21
22 debug('Service Proxy autorun');
23
24 for (const service of services) {
25 const s = session.fromPartition(`persist:service-${service.id}`);
26
27 if (config.isEnabled) {
28 const serviceProxyConfig = proxySettings[service.id];
29
30 if (
31 serviceProxyConfig &&
32 serviceProxyConfig.isEnabled &&
33 serviceProxyConfig.host
34 ) {
35 const proxyHost = `${serviceProxyConfig.host}${
36 serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : ''
37 }`;
38 debug(
39 `Setting proxy config from service settings for "${service.name}" (${service.id}) to`,
40 proxyHost,
41 );
42
43 s.setProxy({ proxyRules: proxyHost })
44 .then(() => {
45 debug(
46 `Using proxy "${proxyHost}" for "${service.name}" (${service.id})`,
47 );
48 })
49 .catch(error => console.error(error));
50 }
51 }
52 }
53 });
54}
diff --git a/src/features/settingsWS/actions.js b/src/features/settingsWS/actions.ts
index 631670c8a..631670c8a 100755
--- a/src/features/settingsWS/actions.js
+++ b/src/features/settingsWS/actions.ts
diff --git a/src/features/settingsWS/index.js b/src/features/settingsWS/index.ts
index 7771421d6..9bb206d82 100755
--- a/src/features/settingsWS/index.js
+++ b/src/features/settingsWS/index.ts
@@ -5,15 +5,16 @@ const debug = require('debug')('Ferdi:feature:settingsWS');
5 5
6export const settingsStore = new SettingsWSStore(); 6export const settingsStore = new SettingsWSStore();
7 7
8export default function initSettingsWebSocket(stores, actions) { 8export default function initSettingsWebSocket(
9 stores: { features: any },
10 actions: any,
11) {
9 const { features } = stores; 12 const { features } = stores;
10 13
11 // Toggle SettingsWebSocket feature 14 // Toggle SettingsWebSocket feature
12 reaction( 15 reaction(
13 () => ( 16 () => features.features.isSettingsWSEnabled,
14 features.features.isSettingsWSEnabled 17 isEnabled => {
15 ),
16 (isEnabled) => {
17 if (isEnabled) { 18 if (isEnabled) {
18 debug('Initializing `settingsWS` feature'); 19 debug('Initializing `settingsWS` feature');
19 settingsStore.start(stores, actions); 20 settingsStore.start(stores, actions);
diff --git a/src/features/settingsWS/state.js b/src/features/settingsWS/state.ts
index 7b16b2b6e..7b16b2b6e 100755
--- a/src/features/settingsWS/state.js
+++ b/src/features/settingsWS/state.ts
diff --git a/src/features/todos/actions.js b/src/features/todos/actions.js
deleted file mode 100644
index cc17e919b..000000000
--- a/src/features/todos/actions.js
+++ /dev/null
@@ -1,28 +0,0 @@
1import PropTypes from 'prop-types';
2import { createActionsFromDefinitions } from '../../actions/lib/actions';
3
4export const todoActions = createActionsFromDefinitions({
5 resize: {
6 width: PropTypes.number.isRequired,
7 },
8 toggleTodosPanel: {},
9 toggleTodosFeatureVisibility: {},
10 setTodosWebview: {
11 webview: PropTypes.instanceOf(Element).isRequired,
12 },
13 handleHostMessage: {
14 action: PropTypes.string.isRequired,
15 data: PropTypes.object,
16 },
17 handleClientMessage: {
18 channel: PropTypes.string.isRequired,
19 message: PropTypes.shape({
20 action: PropTypes.string.isRequired,
21 data: PropTypes.object,
22 }),
23 },
24 openDevTools: {},
25 reload: {},
26}, PropTypes.checkPropTypes);
27
28export default todoActions;
diff --git a/src/features/todos/actions.ts b/src/features/todos/actions.ts
new file mode 100644
index 000000000..04e299e71
--- /dev/null
+++ b/src/features/todos/actions.ts
@@ -0,0 +1,31 @@
1import PropTypes from 'prop-types';
2import { createActionsFromDefinitions } from '../../actions/lib/actions';
3
4export const todoActions = createActionsFromDefinitions(
5 {
6 resize: {
7 width: PropTypes.number.isRequired,
8 },
9 toggleTodosPanel: {},
10 toggleTodosFeatureVisibility: {},
11 setTodosWebview: {
12 webview: PropTypes.instanceOf(Element).isRequired,
13 },
14 handleHostMessage: {
15 action: PropTypes.string.isRequired,
16 data: PropTypes.object,
17 },
18 handleClientMessage: {
19 channel: PropTypes.string.isRequired,
20 message: PropTypes.shape({
21 action: PropTypes.string.isRequired,
22 data: PropTypes.object,
23 }),
24 },
25 openDevTools: {},
26 reload: {},
27 },
28 PropTypes.checkPropTypes,
29);
30
31export default todoActions;
diff --git a/src/features/todos/constants.js b/src/features/todos/constants.ts
index 303a7a16e..303a7a16e 100644
--- a/src/features/todos/constants.js
+++ b/src/features/todos/constants.ts
diff --git a/src/features/todos/index.js b/src/features/todos/index.ts
index 573190881..3665812e6 100644
--- a/src/features/todos/index.js
+++ b/src/features/todos/index.ts
@@ -5,16 +5,17 @@ const debug = require('debug')('Ferdi:feature:todos');
5 5
6export const todosStore = new TodoStore(); 6export const todosStore = new TodoStore();
7 7
8export default function initTodos(stores, actions) { 8export default function initTodos(
9 stores: { todos?: any; features?: any },
10 actions: any,
11) {
9 stores.todos = todosStore; 12 stores.todos = todosStore;
10 const { features } = stores; 13 const { features } = stores;
11 14
12 // Toggle todos feature 15 // Toggle todos feature
13 reaction( 16 reaction(
14 () => ( 17 () => features.features.isTodosEnabled,
15 features.features.isTodosEnabled 18 isEnabled => {
16 ),
17 (isEnabled) => {
18 if (isEnabled) { 19 if (isEnabled) {
19 debug('Initializing `todos` feature'); 20 debug('Initializing `todos` feature');
20 todosStore.start(stores, actions); 21 todosStore.start(stores, actions);