MCPcopy Create free account
hub / github.com/chieapp/chie / constructor

Method constructor

src/view/new-api-window.ts:26–83  ·  view source on GitHub ↗
(credential?: APICredential)

Source from the content-addressed store, hash-verified

24 loginButton?: gui.Button;
25
26 constructor(credential?: APICredential) {
27 super({pressEscToClose: true});
28 this.credential = credential;
29
30 this.contentView.setStyle({
31 gap: basicStyle.padding / 2,
32 padding: basicStyle.padding,
33 paddingLeft: 50,
34 paddingRight: 50,
35 });
36
37 this.apiSelector = new ParamsView([
38 {
39 name: 'name',
40 type: 'string',
41 displayName: 'Name',
42 value: credential?.name,
43 },
44 {
45 name: 'type',
46 type: 'selection',
47 displayName: 'API Type',
48 selected: credential?.type,
49 selections: apiManager.getAPISelections(),
50 },
51 ], {nullable: false});
52 this.apiSelector.onActivate.connect(this.#onSubmit.bind(this));
53 this.contentView.addChildView(this.apiSelector.view);
54
55 if (!credential) {
56 this.createCheckbox = gui.Button.create({
57 type: 'checkbox',
58 title: 'Create an assistant for this API credential...'
59 });
60 this.createCheckbox.setChecked(true);
61 this.createCheckbox.setStyle({marginLeft: valueMarginLeft});
62 this.apiSelector.view.addChildViewAt(this.createCheckbox, 1);
63 }
64
65 this.#updateAPIParamsView(credential);
66 if (credential)
67 this.apiSelector.getRow('type').editor.setEnabled(false);
68 else
69 this.apiSelector.getRow('type').subscribeOnChange(this.#updateAPIParamsView.bind(this));
70
71 const buttonsArea = new ButtonsArea();
72 buttonsArea.view.setStyle({flex: 1, paddingTop: basicStyle.padding / 2});
73 this.contentView.addChildView(buttonsArea.view);
74 this.submitButton = buttonsArea.addButton(credential ? 'OK' : 'Add');
75 this.submitButton.makeDefault();
76 this.submitButton.onClick = this.#onSubmit.bind(this);
77 buttonsArea.addCloseButton();
78
79 this.apiSelector.getRow('name').editor.focus();
80 this.resizeToFitContentView({width: 540});
81
82 this.window.setTitle(credential ? `Edit API Credential: ${credential.name}` : 'Add New API Credential');
83 }

Callers

nothing calls this directly

Calls 8

#updateAPIParamsViewMethod · 0.95
addButtonMethod · 0.95
addCloseButtonMethod · 0.95
getAPISelectionsMethod · 0.80
getRowMethod · 0.80
subscribeOnChangeMethod · 0.45
setTitleMethod · 0.45

Tested by

no test coverage detected