Skip to content

Commit 61cc803

Browse files
chore: desugar decorators in subclass
1 parent fc9a820 commit 61cc803

5 files changed

Lines changed: 23 additions & 16 deletions

File tree

ui/src/application/AppStore.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export class AppStore extends BaseStore<IApplication> {
1212

1313
public constructor(private readonly snack: SnackReporter) {
1414
super();
15+
this.uploadImage = action(this.uploadImage);
16+
this.update = action(this.update);
17+
this.create = action(this.create);
18+
this.reorder = action(this.reorder);
1519
}
1620

1721
protected requestItems = (): Promise<IApplication[]> =>
@@ -25,7 +29,6 @@ export class AppStore extends BaseStore<IApplication> {
2529
return this.snack('Application deleted');
2630
});
2731

28-
@action
2932
public uploadImage = async (id: number, file: Blob): Promise<void> => {
3033
const formData = new FormData();
3134
formData.append('file', file);
@@ -57,7 +60,6 @@ export class AppStore extends BaseStore<IApplication> {
5760
}
5861
}
5962

60-
@action
6163
public reorder = async (fromId: number, toId: number): Promise<void> => {
6264
const fromIndex = this.items.findIndex((app) => app.id === fromId);
6365
const toIndex = this.items.findIndex((app) => app.id === toId);
@@ -80,7 +82,6 @@ export class AppStore extends BaseStore<IApplication> {
8082
await this.update({...toUpdate, sortKey: newSortKey});
8183
};
8284

83-
@action
8485
public update = async ({
8586
id,
8687
...app
@@ -93,7 +94,6 @@ export class AppStore extends BaseStore<IApplication> {
9394
this.snack('Application updated');
9495
};
9596

96-
@action
9797
public create = async (
9898
name: string,
9999
description: string,

ui/src/client/ClientStore.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ import {SnackReporter} from '../snack/SnackManager';
66
import {IClient} from '../types';
77

88
export class ClientStore extends BaseStore<IClient> {
9-
public constructor(private readonly snack: SnackReporter) {
9+
private readonly snack: SnackReporter;
10+
public constructor(snack: SnackReporter) {
1011
super();
12+
this.snack = snack;
13+
this.update = action(this.update);
14+
this.createNoNotifcation = action(this.createNoNotifcation);
15+
this.create = action(this.create);
16+
this.elevate = action(this.elevate);
1117
}
1218

1319
protected requestItems = (): Promise<IClient[]> =>
@@ -19,7 +25,6 @@ export class ClientStore extends BaseStore<IClient> {
1925
.then(() => this.snack('Client deleted'));
2026
}
2127

22-
@action
2328
public update = async (
2429
id: number,
2530
name: string,
@@ -33,7 +38,6 @@ export class ClientStore extends BaseStore<IClient> {
3338
this.snack('Client updated');
3439
};
3540

36-
@action
3741
public createNoNotifcation = async (
3842
name: string,
3943
expiresAfterInactivitySeconds = 0
@@ -46,14 +50,12 @@ export class ClientStore extends BaseStore<IClient> {
4650
return client.data;
4751
};
4852

49-
@action
5053
public create = async (name: string, expiresAfterInactivitySeconds = 0): Promise<string> => {
5154
const client = await this.createNoNotifcation(name, expiresAfterInactivitySeconds);
5255
this.snack('Client added');
5356
return client.token;
5457
};
5558

56-
@action
5759
public elevate = async (id: number, durationSeconds: number): Promise<void> => {
5860
await axios.post(`${config.get('url')}client/${id}/elevate`, {durationSeconds});
5961
await this.refresh();

ui/src/plugin/PluginStore.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ import {SnackReporter} from '../snack/SnackManager';
66
import {IPlugin} from '../types';
77

88
export class PluginStore extends BaseStore<IPlugin> {
9+
private readonly snack: SnackReporter;
910
public onDelete: () => void = () => {};
1011

11-
public constructor(private readonly snack: SnackReporter) {
12+
public constructor(snack: SnackReporter) {
1213
super();
14+
this.snack = snack;
15+
this.changeConfig = action(this.changeConfig);
16+
this.changeEnabledState = action(this.changeEnabledState);
1317
}
1418

1519
public requestConfig = (id: number): Promise<string> =>
@@ -31,7 +35,6 @@ export class PluginStore extends BaseStore<IPlugin> {
3135
return id === -1 ? 'All Plugins' : plugin !== undefined ? plugin.name : 'unknown';
3236
};
3337

34-
@action
3538
public changeConfig = async (id: number, newConfig: string): Promise<void> => {
3639
await axios.post(`${config.get('url')}plugin/${id}/config`, newConfig, {
3740
headers: {'content-type': 'application/x-yaml'},
@@ -40,7 +43,6 @@ export class PluginStore extends BaseStore<IPlugin> {
4043
await this.refresh();
4144
};
4245

43-
@action
4446
public changeEnabledState = async (id: number, enabled: boolean): Promise<void> => {
4547
await axios.post(`${config.get('url')}plugin/${id}/${enabled ? 'enable' : 'disable'}`);
4648
this.snack(`Plugin ${enabled ? 'enabled' : 'disabled'}`);

ui/src/user/UserStore.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ import {SnackReporter} from '../snack/SnackManager';
66
import {IUser} from '../types';
77

88
export class UserStore extends BaseStore<IUser> {
9-
constructor(private readonly snack: SnackReporter) {
9+
private readonly snack: SnackReporter;
10+
11+
constructor(snack: SnackReporter) {
1012
super();
13+
this.snack = snack;
14+
this.create = action(this.create);
15+
this.update = action(this.update);
1116
}
1217

1318
protected requestItems = (): Promise<IUser[]> =>
@@ -19,14 +24,12 @@ export class UserStore extends BaseStore<IUser> {
1924
.then(() => this.snack('User deleted'));
2025
}
2126

22-
@action
2327
public create = async (name: string, pass: string, admin: boolean) => {
2428
await axios.post(`${config.get('url')}user`, {name, pass, admin});
2529
await this.refresh();
2630
this.snack('User created');
2731
};
2832

29-
@action
3033
public update = async (id: number, name: string, pass: string | null, admin: boolean) => {
3134
await axios.post(config.get('url') + 'user/' + id, {name, pass, admin});
3235
await this.refresh();

ui/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default defineConfig({
3232
plugins: [
3333
react(),
3434
babel({
35-
presets: [decoratorPreset({version: '2022-03'})],
35+
presets: [decoratorPreset({version: '2023-11'})],
3636
}),
3737
],
3838
define: {

0 commit comments

Comments
 (0)