Skip to content

Commit b1b793b

Browse files
committed
add 'button' type for simple config ui
1 parent 2d6f397 commit b1b793b

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

res/html/simple_config_ui/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SimpleUIDef.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export interface SimpleUIBtnInfo {
2121

2222
title: string; // title for button
2323

24+
hidden?: boolean; // hide this button
25+
2426
disabled?: boolean; // button is disabled
2527
}
2628

@@ -33,11 +35,11 @@ export interface SimpleUIConfigData {
3335

3436
export interface SimpleUIConfigItem {
3537

36-
type: 'input' | 'options' | 'table' | 'text' | 'bool' | 'divider' | 'tag';
38+
type: 'input' | 'options' | 'table' | 'text' | 'bool' | 'divider' | 'tag' | 'button';
3739

3840
attrs: { [key: string]: string | boolean | number };
3941

40-
name: string; // readable name
42+
name: string; // readable title
4143

4244
description?: string; // a description for this item
4345

@@ -48,7 +50,8 @@ export interface SimpleUIConfigItem {
4850
SimpleUIConfigData_text |
4951
SimpleUIConfigData_boolean |
5052
SimpleUIConfigData_divider |
51-
SimpleUIConfigData_tag;
53+
SimpleUIConfigData_tag |
54+
SimpleUIConfigData_button;
5255
};
5356

5457
// input box
@@ -135,3 +138,14 @@ export interface SimpleUIConfigData_tag extends SimpleUIConfigData {
135138

136139
value: string;
137140
}
141+
142+
// button
143+
//
144+
// all attrs:
145+
// - 'disabled': [bool] Prevents the user from interacting with the button––it cannot be pressed or focused.
146+
// - 'appearance': [string] Determines the visual appearance (primary, secondary) of the button.
147+
//
148+
export interface SimpleUIConfigData_button extends SimpleUIConfigData {
149+
150+
clickEvent: string; // a message will be emit when button has been clicked
151+
}

src/WebPanelManager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class WebPanelManager {
5151
return _instance;
5252
}
5353

54-
showSimpleConfigUI(cfg: SimpleUIConfig, onSave: (newCfg: SimpleUIConfig) => void): Promise<void> {
54+
showSimpleConfigUI(cfg: SimpleUIConfig, onSubmit: (newCfg: SimpleUIConfig) => void, onMsg?: (msg: string) => void): Promise<void> {
5555

5656
const resManager = ResManager.GetInstance();
5757

@@ -75,14 +75,15 @@ export class WebPanelManager {
7575
panel.webview.postMessage(cfg);
7676
break;
7777
default:
78+
if (onMsg) onMsg(_data);
7879
break;
7980
}
8081
}
8182

8283
/* it's obj data */
8384
else {
8485
try {
85-
onSave(_data);
86+
onSubmit(_data);
8687
panel.webview.postMessage('eide.simple-cfg-ui.status.done');
8788
} catch (error) {
8889
GlobalEvent.emit('error', error);

0 commit comments

Comments
 (0)