mirror of
https://github.com/beekeeper-studio/beekeeper-studio.git
synced 2026-03-13 10:12:54 +08:00
add confirm
This commit is contained in:
@@ -206,6 +206,7 @@ import ProductTourPlugin from '@/plugins/ProductTourPlugin'
|
||||
appVersion: window.platformInfo.appVersion,
|
||||
fileHelpers: window.main.fileHelpers,
|
||||
noty: Vue.prototype.$noty,
|
||||
confirm: app.$confirm.bind(app),
|
||||
});
|
||||
webPluginManager.initialize().then(() => {
|
||||
store.commit("webPluginManagerStatus", "ready")
|
||||
|
||||
@@ -186,6 +186,7 @@ export type WebPluginContext = {
|
||||
warning(text: string): Noty;
|
||||
info(text: string): Noty;
|
||||
};
|
||||
confirm(title?: string, message?: string, options?: { confirmLabel?: string, cancelLabel?: string }): Promise<boolean>;
|
||||
}
|
||||
|
||||
export type PluginContext = {
|
||||
|
||||
@@ -277,6 +277,13 @@ export default class WebPluginLoader {
|
||||
case "noty.warning":
|
||||
this.context.noty.warning(response.args.message);
|
||||
break;
|
||||
case "confirm":
|
||||
response.result = await this.context.confirm(
|
||||
response.args.title,
|
||||
response.args.message,
|
||||
response.args.options
|
||||
);
|
||||
break;
|
||||
|
||||
// ======== UI ACTIONS ===========
|
||||
case "expandTableResult":
|
||||
|
||||
@@ -21,6 +21,7 @@ export type WebPluginManagerParams = {
|
||||
warning(text: string): Noty;
|
||||
info(text: string): Noty;
|
||||
};
|
||||
confirm(title?: string, message?: string, options?: { confirmLabel?: string, cancelLabel?: string }): Promise<boolean>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,6 +58,7 @@ export default class WebPluginManager {
|
||||
public readonly appVersion: string;
|
||||
public readonly fileHelpers: FileHelpers;
|
||||
private readonly noty: WebPluginManagerParams['noty'];
|
||||
private readonly confirm: WebPluginManagerParams['confirm'];
|
||||
|
||||
constructor(params: WebPluginManagerParams) {
|
||||
this.utilityConnection = params.utilityConnection;
|
||||
@@ -64,6 +66,7 @@ export default class WebPluginManager {
|
||||
this.appVersion = params.appVersion;
|
||||
this.fileHelpers = params.fileHelpers;
|
||||
this.noty = params.noty;
|
||||
this.confirm = params.confirm;
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
@@ -266,6 +269,7 @@ export default class WebPluginManager {
|
||||
appVersion: this.appVersion,
|
||||
fileHelpers: this.fileHelpers,
|
||||
noty: this.noty,
|
||||
confirm: this.confirm,
|
||||
});
|
||||
await loader.load();
|
||||
this.loaders.set(manifest.id, loader);
|
||||
|
||||
@@ -380,6 +380,53 @@ await noty.warning('This operation may take a while');
|
||||
{ message: string }
|
||||
```
|
||||
|
||||
### confirm
|
||||
|
||||
Display a confirmation dialog to the user and wait for their response.
|
||||
|
||||
**Usage:**
|
||||
```javascript
|
||||
import { confirm } from '@beekeeperstudio/plugin';
|
||||
|
||||
// Basic confirmation
|
||||
const result = await confirm();
|
||||
if (result) {
|
||||
// User clicked confirm
|
||||
} else {
|
||||
// User clicked cancel
|
||||
}
|
||||
|
||||
// With title and message
|
||||
const result = await confirm('Delete Table', 'Are you sure you want to delete this table?');
|
||||
|
||||
// With custom button labels
|
||||
const result = await confirm(
|
||||
'Export Data',
|
||||
'This will export all data to a CSV file. Continue?',
|
||||
{
|
||||
confirmLabel: 'Export',
|
||||
cancelLabel: 'Cancel'
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
**Arguments Schema:**
|
||||
```typescript
|
||||
{
|
||||
title?: string;
|
||||
message?: string;
|
||||
options?: {
|
||||
confirmLabel?: string;
|
||||
cancelLabel?: string;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
**Response Schema:**
|
||||
```typescript
|
||||
boolean // true if confirmed, false if cancelled
|
||||
```
|
||||
|
||||
## Notifications
|
||||
|
||||
### themeChanged
|
||||
|
||||
Reference in New Issue
Block a user