-
-
Notifications
You must be signed in to change notification settings - Fork 395
/
cloud-sketchbook-composite-widget.tsx
77 lines (71 loc) · 2.45 KB
/
cloud-sketchbook-composite-widget.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import * as React from '@theia/core/shared/react';
import type { Root } from '@theia/core/shared/react-dom/client';
import {
inject,
injectable,
postConstruct,
} from '@theia/core/shared/inversify';
import { UserStatus } from './cloud-user-status';
import { nls } from '@theia/core/lib/common/nls';
import { CloudSketchbookTreeWidget } from './cloud-sketchbook-tree-widget';
import { AuthenticationClientService } from '../../auth/authentication-client-service';
import { CloudSketchbookTreeModel } from './cloud-sketchbook-tree-model';
import { BaseSketchbookCompositeWidget } from '../sketchbook/sketchbook-composite-widget';
import { CreateNew } from '../sketchbook/create-new';
import { AuthenticationSession } from '../../../node/auth/types';
@injectable()
export class CloudSketchbookCompositeWidget extends BaseSketchbookCompositeWidget<CloudSketchbookTreeWidget> {
@inject(AuthenticationClientService)
private readonly authenticationService: AuthenticationClientService;
@inject(CloudSketchbookTreeWidget)
private readonly cloudSketchbookTreeWidget: CloudSketchbookTreeWidget;
private _session: AuthenticationSession | undefined;
constructor() {
super();
this.id = 'cloud-sketchbook-composite-widget';
this.title.caption = nls.localize(
'arduino/cloud/cloudSketchbook',
'Cloud Sketchbook'
);
this.title.iconClass = 'cloud-sketchbook-tree-icon';
}
@postConstruct()
protected init(): void {
this.toDispose.push(
this.authenticationService.onSessionDidChange((session) => {
const oldSession = this._session;
this._session = session;
if (!!oldSession !== !!this._session) {
this.updateFooter();
}
})
);
}
get treeWidget(): CloudSketchbookTreeWidget {
return this.cloudSketchbookTreeWidget;
}
protected renderFooter(footerRoot: Root): void {
footerRoot.render(
<>
{this._session && (
<CreateNew
label={nls.localize(
'arduino/sketchbook/newCloudSketch',
'New Cloud Sketch'
)}
onClick={this.onDidClickCreateNew}
/>
)}
<UserStatus
model={
this.cloudSketchbookTreeWidget.model as CloudSketchbookTreeModel
}
authenticationService={this.authenticationService}
/>
</>
);
}
private onDidClickCreateNew: () => void = () => {
this.commandService.executeCommand('arduino-new-cloud-sketch');
};
}