@kodaris/krubble-app-components 1.0.156 → 1.0.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chatbot.d.ts +2 -7
- package/dist/chatbot.d.ts.map +1 -1
- package/dist/chatbot.js +51 -33
- package/dist/chatbot.js.map +1 -1
- package/dist/krubble-app.bundled.js +51 -33
- package/dist/krubble-app.bundled.js.map +1 -1
- package/dist/krubble-app.bundled.min.js +5 -5
- package/dist/krubble-app.bundled.min.js.map +1 -1
- package/dist/krubble-app.umd.js +51 -33
- package/dist/krubble-app.umd.js.map +1 -1
- package/dist/krubble-app.umd.min.js +1 -1
- package/dist/krubble-app.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/krubble-app.umd.js
CHANGED
|
@@ -4185,9 +4185,11 @@
|
|
|
4185
4185
|
* Enable or disable a global skill on this instance via
|
|
4186
4186
|
* `/aiskills/global/{code}/enabled`, then reflect the server's result on the
|
|
4187
4187
|
* matching card. Ignores clicks while a request for the same code is pending.
|
|
4188
|
+
* Installing a billable skill opens a confirmation instead; see
|
|
4189
|
+
* `_handleSkillInstallConfirm` for the request that runs once the user accepts.
|
|
4188
4190
|
*/
|
|
4189
4191
|
_handleGlobalSkillEnable(skill, e) {
|
|
4190
|
-
// The card body
|
|
4192
|
+
// The card body opens the detail view; the install button must not also do that.
|
|
4191
4193
|
e.stopPropagation();
|
|
4192
4194
|
// The button is shown to everyone so the catalog reads the same for all users,
|
|
4193
4195
|
// but the enable endpoint requires administrator/superuser/skillEdit. Without
|
|
@@ -4203,46 +4205,18 @@
|
|
|
4203
4205
|
if (this._globalSkillPending.has(skill.code)) {
|
|
4204
4206
|
return;
|
|
4205
4207
|
}
|
|
4206
|
-
const btn = e.currentTarget;
|
|
4207
4208
|
// Installing a billable skill charges the account, so confirm before sending.
|
|
4208
4209
|
// Uninstalling is never billed and free installs are one click to undo.
|
|
4209
4210
|
if (!skill.enabled && skill.billable) {
|
|
4210
4211
|
this._skillInstallConfirm = skill;
|
|
4211
4212
|
return;
|
|
4212
4213
|
}
|
|
4213
|
-
this._enableGlobalSkill(skill, btn);
|
|
4214
|
-
}
|
|
4215
|
-
/** Cancel the billable install confirmation without sending anything. */
|
|
4216
|
-
_handleSkillInstallCancel() {
|
|
4217
|
-
this._skillInstallConfirm = null;
|
|
4218
|
-
}
|
|
4219
|
-
/**
|
|
4220
|
-
* The user accepted the charge: run the install with the dialog's own Install
|
|
4221
|
-
* button spinning, and close the dialog once the server confirms. On failure
|
|
4222
|
-
* the button shows the error and the dialog stays open so they can retry or cancel.
|
|
4223
|
-
*/
|
|
4224
|
-
_handleSkillInstallConfirm(e) {
|
|
4225
|
-
if (!this._skillInstallConfirm) {
|
|
4226
|
-
return;
|
|
4227
|
-
}
|
|
4228
|
-
this._enableGlobalSkill(this._skillInstallConfirm, e.currentTarget).then((ok) => {
|
|
4229
|
-
if (ok) {
|
|
4230
|
-
this._skillInstallConfirm = null;
|
|
4231
|
-
}
|
|
4232
|
-
});
|
|
4233
|
-
}
|
|
4234
|
-
/**
|
|
4235
|
-
* Send the enable/disable request for a global skill and reflect the server's
|
|
4236
|
-
* result on its card. `btn` is the button that triggered it (the card's
|
|
4237
|
-
* Install button, or the confirmation dialog's), whose spinner shows while the
|
|
4238
|
-
* request is in flight. Resolves true on success, false on failure.
|
|
4239
|
-
*/
|
|
4240
|
-
_enableGlobalSkill(skill, btn) {
|
|
4241
4214
|
// Drive the clicked button's own spinner (KRButton disables itself while
|
|
4242
4215
|
// loading, so a second click can't fire until the request settles).
|
|
4216
|
+
const btn = e.currentTarget;
|
|
4243
4217
|
this._globalSkillPending.add(skill.code);
|
|
4244
4218
|
btn?.showLoading();
|
|
4245
|
-
|
|
4219
|
+
krubbleHttp.Http.fetch({
|
|
4246
4220
|
url: `/api/system/opensearch/aiskills/global/${encodeURIComponent(skill.code)}/enabled`,
|
|
4247
4221
|
method: 'POST',
|
|
4248
4222
|
body: { enabled: !skill.enabled },
|
|
@@ -4268,12 +4242,56 @@
|
|
|
4268
4242
|
type: 'success',
|
|
4269
4243
|
});
|
|
4270
4244
|
}
|
|
4271
|
-
return true;
|
|
4272
4245
|
})
|
|
4273
4246
|
.catch((error) => {
|
|
4274
4247
|
console.error('kr-chatbot: global skill enable failed', error);
|
|
4275
4248
|
btn?.showError('Error');
|
|
4276
|
-
|
|
4249
|
+
})
|
|
4250
|
+
.finally(() => {
|
|
4251
|
+
this._globalSkillPending.delete(skill.code);
|
|
4252
|
+
});
|
|
4253
|
+
}
|
|
4254
|
+
/** Cancel the billable install confirmation without sending anything. */
|
|
4255
|
+
_handleSkillInstallCancel() {
|
|
4256
|
+
this._skillInstallConfirm = null;
|
|
4257
|
+
}
|
|
4258
|
+
/**
|
|
4259
|
+
* The user accepted the charge: run the install with the dialog's own Install
|
|
4260
|
+
* button spinning, and close the dialog once the server confirms. On failure
|
|
4261
|
+
* the button shows the error and the dialog stays open so they can retry or cancel.
|
|
4262
|
+
*/
|
|
4263
|
+
_handleSkillInstallConfirm(e) {
|
|
4264
|
+
if (!this._skillInstallConfirm) {
|
|
4265
|
+
return;
|
|
4266
|
+
}
|
|
4267
|
+
if (this._globalSkillPending.has(this._skillInstallConfirm.code)) {
|
|
4268
|
+
return;
|
|
4269
|
+
}
|
|
4270
|
+
const skill = this._skillInstallConfirm;
|
|
4271
|
+
const btn = e.currentTarget;
|
|
4272
|
+
this._globalSkillPending.add(skill.code);
|
|
4273
|
+
btn?.showLoading();
|
|
4274
|
+
krubbleHttp.Http.fetch({
|
|
4275
|
+
url: `/api/system/opensearch/aiskills/global/${encodeURIComponent(skill.code)}/enabled`,
|
|
4276
|
+
method: 'POST',
|
|
4277
|
+
body: { enabled: true },
|
|
4278
|
+
})
|
|
4279
|
+
.then((r) => r.json())
|
|
4280
|
+
.then((res) => {
|
|
4281
|
+
// Reflect the server's returned flag on the card and close the confirmation.
|
|
4282
|
+
skill.enabled = res?.data?.enabled;
|
|
4283
|
+
btn?.reset();
|
|
4284
|
+
this._skillInstallConfirm = null;
|
|
4285
|
+
this.requestUpdate();
|
|
4286
|
+
krubbleComponents.Snackbar.show({
|
|
4287
|
+
title: 'Skill Installed',
|
|
4288
|
+
message: `${skill.name} is now available to use.`,
|
|
4289
|
+
type: 'success',
|
|
4290
|
+
});
|
|
4291
|
+
})
|
|
4292
|
+
.catch((error) => {
|
|
4293
|
+
console.error('kr-chatbot: global skill install failed', error);
|
|
4294
|
+
btn?.showError('Error');
|
|
4277
4295
|
})
|
|
4278
4296
|
.finally(() => {
|
|
4279
4297
|
this._globalSkillPending.delete(skill.code);
|