tangled
alpha
login
or
join now
notnite.com
/
moonlight
3
fork
atom
this repo has no description
3
fork
atom
overview
issues
pulls
pipelines
Add changelog tab, make settings page update without reload
notnite.com
1 year ago
85d48921
19ec3499
+38
-11
8 changed files
expand all
collapse all
unified
split
packages
browser
src
index.ts
core
src
util
config.ts
core-extensions
src
moonbase
types.ts
webpackModules
stores.ts
ui
extensions
card.tsx
settings.tsx
node-preload
src
index.ts
types
src
extension.ts
+1
-1
packages/browser/src/index.ts
···
123
123
},
124
124
getConfigOption(ext, name) {
125
125
const manifest = getManifest(extensions, ext);
126
126
-
return getConfigOption(ext, name, config, manifest);
126
126
+
return getConfigOption(ext, name, config, manifest?.settings);
127
127
},
128
128
setConfigOption(ext, name, value) {
129
129
setConfigOption(config, ext, name, value);
+2
packages/core-extensions/src/moonbase/types.ts
···
28
28
state: ExtensionState;
29
29
compat: ExtensionCompat;
30
30
hasUpdate: boolean;
31
31
+
changelog?: string;
32
32
+
settingsOverride?: ExtensionManifest["settings"];
31
33
};
32
34
33
35
export enum UpdateState {
+11
-4
packages/core-extensions/src/moonbase/webpackModules/stores.ts
···
102
102
updateManifest: ext
103
103
};
104
104
existing.hasUpdate = true;
105
105
+
existing.changelog = ext.meta?.changelog;
105
106
}
106
107
107
108
continue;
···
193
194
194
195
getExtensionConfig<T>(uniqueId: number, key: string): T | undefined {
195
196
const ext = this.getExtension(uniqueId);
196
196
-
return getConfigOption(ext.id, key, this.config, ext.manifest);
197
197
+
const settings = ext.settingsOverride ?? ext.manifest.settings;
198
198
+
return getConfigOption(ext.id, key, this.config, settings);
197
199
}
198
200
199
201
getExtensionConfigRaw<T>(id: string, key: string, defaultValue: T | undefined): T | undefined {
···
204
206
205
207
getExtensionConfigName(uniqueId: number, key: string) {
206
208
const ext = this.getExtension(uniqueId);
207
207
-
return ext.manifest.settings?.[key]?.displayName ?? key;
209
209
+
const settings = ext.settingsOverride ?? ext.manifest.settings;
210
210
+
return settings?.[key]?.displayName ?? key;
208
211
}
209
212
210
213
getExtensionConfigDescription(uniqueId: number, key: string) {
211
214
const ext = this.getExtension(uniqueId);
212
212
-
return ext.manifest.settings?.[key]?.description;
215
215
+
const settings = ext.settingsOverride ?? ext.manifest.settings;
216
216
+
return settings?.[key]?.description;
213
217
}
214
218
215
219
setExtensionConfig(id: string, key: string, value: any) {
···
255
259
this.extensions[uniqueId].state = ExtensionState.Disabled;
256
260
}
257
261
258
258
-
if (update != null) this.extensions[uniqueId].compat = checkExtensionCompat(update.updateManifest);
262
262
+
if (update != null) {
263
263
+
this.extensions[uniqueId].settingsOverride = update.updateManifest.settings;
264
264
+
this.extensions[uniqueId].compat = checkExtensionCompat(update.updateManifest);
265
265
+
}
259
266
260
267
delete this.updates[uniqueId];
261
268
} catch (e) {
+19
-2
packages/core-extensions/src/moonbase/webpackModules/ui/extensions/card.tsx
···
17
17
export enum ExtensionPage {
18
18
Info,
19
19
Description,
20
20
+
Changelog,
20
21
Settings
21
22
}
22
23
···
57
58
const { Card, Text, FormSwitch, TabBar, Button } = Components;
58
59
59
60
const tagline = ext.manifest?.meta?.tagline;
60
60
-
const settings = ext.manifest?.settings;
61
61
+
const settings = ext.settingsOverride ?? ext.manifest?.settings;
61
62
const description = ext.manifest?.meta?.description;
63
63
+
const changelog = ext.changelog;
62
64
const enabledDependants = useStateFromStores([MoonbaseSettingsStore], () =>
63
65
Object.keys(MoonbaseSettingsStore.extensions)
64
66
.filter((uniqueId) => {
···
196
198
</div>
197
199
198
200
<div>
199
199
-
{(description != null || settings != null) && (
201
201
+
{(description != null || changelog != null || settings != null) && (
200
202
<TabBar
201
203
selectedItem={tab}
202
204
type="top"
···
216
218
</TabBar.Item>
217
219
)}
218
220
221
221
+
{changelog != null && (
222
222
+
<TabBar.Item className={TabBarClasses.tabBarItem} id={ExtensionPage.Changelog}>
223
223
+
Changelog
224
224
+
</TabBar.Item>
225
225
+
)}
226
226
+
219
227
{settings != null && (
220
228
<TabBar.Item className={TabBarClasses.tabBarItem} id={ExtensionPage.Settings}>
221
229
Settings
···
235
243
{tab === ExtensionPage.Description && (
236
244
<Text variant="text-md/normal" className={MarkupClasses.markup} style={{ width: "100%" }}>
237
245
{MarkupUtils.parse(description ?? "*No description*", true, {
246
246
+
allowHeading: true,
247
247
+
allowLinks: true,
248
248
+
allowList: true
249
249
+
})}
250
250
+
</Text>
251
251
+
)}
252
252
+
{tab === ExtensionPage.Changelog && (
253
253
+
<Text variant="text-md/normal" className={MarkupClasses.markup} style={{ width: "100%" }}>
254
254
+
{MarkupUtils.parse(changelog ?? "*No changelog*", true, {
238
255
allowHeading: true,
239
256
allowLinks: true,
240
257
allowList: true
+1
-1
packages/core-extensions/src/moonbase/webpackModules/ui/extensions/settings.tsx
···
370
370
export default function Settings({ ext }: { ext: MoonbaseExtension }) {
371
371
return (
372
372
<Flex className="moonbase-settings" direction={Flex.Direction.VERTICAL}>
373
373
-
{Object.entries(ext.manifest.settings!).map(([name, setting]) => (
373
373
+
{Object.entries(ext.settingsOverride ?? ext.manifest.settings!).map(([name, setting]) => (
374
374
<Setting
375
375
ext={ext}
376
376
key={name}
+2
-2
packages/core/src/util/config.ts
···
14
14
ext: string,
15
15
key: string,
16
16
config: Config,
17
17
-
manifest?: ExtensionManifest
17
17
+
settings?: ExtensionManifest["settings"]
18
18
): T | undefined {
19
19
-
const defaultValue: T | undefined = structuredClone(manifest?.settings?.[key]?.default);
19
19
+
const defaultValue: T | undefined = structuredClone(settings?.[key]?.default);
20
20
const cfg = getConfig(ext, config);
21
21
if (cfg == null || typeof cfg === "boolean") return defaultValue;
22
22
return cfg?.[key] ?? defaultValue;
+1
-1
packages/node-preload/src/index.ts
···
57
57
},
58
58
getConfigOption(ext, name) {
59
59
const manifest = getManifest(extensions, ext);
60
60
-
return getConfigOption(ext, name, config, manifest);
60
60
+
return getConfigOption(ext, name, config, manifest?.settings);
61
61
},
62
62
setConfigOption(ext, name, value) {
63
63
setConfigOption(config, ext, name, value);
+1
packages/types/src/extension.ts
···
41
41
deprecated?: boolean;
42
42
tags?: ExtensionTag[];
43
43
source?: string;
44
44
+
changelog?: string;
44
45
};
45
46
46
47
dependencies?: string[];