Skip to content

Commit

Permalink
feat(frontend): consumes latest inquirer-gui 0.5.0 (#758)
Browse files Browse the repository at this point in the history
* feat(frontend): consumes latest inquirer-gui

update inquirer-gui and auto-complete plugin dependencies to provide new funtionality

* refactor(backend): removes commented code, revert bas sdk version change

* chore(yarn.lock): fix repo url to public

* style(yeoman-ui): fixes formatting, reverts version bump
  • Loading branch information
IainSAP authored Apr 18, 2023
1 parent 519c410 commit a8c59fd
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
},
"dependencies": {
"@mdi/font": "5.9.55",
"@sap-devx/inquirer-gui": "0.3.0",
"@sap-devx/inquirer-gui": "0.5.0",
"@sap-devx/inquirer-gui-auto-complete-plugin": "0.0.1",
"@sap-devx/inquirer-gui-file-browser-plugin": "0.0.5",
"@sap-devx/inquirer-gui-folder-browser-plugin": "0.0.3",
"@sap-devx/inquirer-gui-label-plugin": "0.0.1",
Expand Down
15 changes: 13 additions & 2 deletions packages/frontend/src/youi/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
:questions="currentPrompt ? currentPrompt.questions : []"
@parentExecuteCommand="executeCommand"
@answered="onAnswered"
@setBusyIndicator="setBusyIndicator"
/>
</v-slide-x-transition>
<Info
Expand Down Expand Up @@ -122,6 +123,7 @@ import FolderBrowserPlugin from "@sap-devx/inquirer-gui-folder-browser-plugin";
import LoginPlugin from "@sap-devx/inquirer-gui-login-plugin";
import TilesPlugin from "@sap-devx/inquirer-gui-tiles-plugin";
import LabelPlugin from "@sap-devx/inquirer-gui-label-plugin";
import AutoCompletePlugin from "@sap-devx/inquirer-gui-auto-complete-plugin";
import { Severity } from "@sap-devx/yeoman-ui-types";
import utils from "../utils/utils";
import answerUtils from "../utils/answerUtils";
Expand Down Expand Up @@ -273,12 +275,20 @@ export default {
this.promptMessageClass = "";
this.promptMessageIcon = null;
},
setBusyIndicator() {
/**
* Set the busy indicator based on the current prompt status.
* If an optional boolean value is provided this will override the prompt status when determining if the busy indicator should be on or off
* This can be used by custom plugins to activate/deactivate the busy indicator internally
*/
setBusyIndicator(showBusy) {
this.expectedShowBusyIndicator =
showBusy === true ||
_isEmpty(this.prompts) ||
(this.currentPrompt &&
(this.currentPrompt.status === PENDING || this.currentPrompt.status === EVALUATING) &&
!this.isDone);
!this.isDone &&
showBusy !== false);
if (this.expectedShowBusyIndicator) {
setTimeout(() => {
if (this.expectedShowBusyIndicator) {
Expand Down Expand Up @@ -643,6 +653,7 @@ export default {
this.registerPlugin(LoginPlugin);
this.registerPlugin(TilesPlugin);
this.registerPlugin(LabelPlugin);
this.registerPlugin(AutoCompletePlugin);
this.isInVsCode() ? (this.consoleClass = "consoleClassHidden") : (this.consoleClass = "consoleClassVisible");
},
Expand Down
20 changes: 20 additions & 0 deletions packages/frontend/test/App.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,26 @@ describe("App.vue", () => {
expect(wrapper.vm.showBusyIndicator).toBeFalsy();
expect(wrapper.vm.expectedShowBusyIndicator).toBeFalsy();
});

it("Busy indicator can be set manually (to support custom plugin control)", async () => {
const sleeper = function (ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
};
wrapper = initComponent(App);
wrapper.vm.setBusyIndicator(true);
expect(wrapper.vm.expectedShowBusyIndicator).toBeTruthy();
// 1 second delay before busy indicator is shown
await sleeper(1200);
expect(wrapper.vm.showBusyIndicator).toBeTruthy();

// If a custom plugin function is evaluating it can explicitly cancel the busy indicator on callback
wrapper.vm.prompts = [{}, {}];
wrapper.vm.isDone = false;
wrapper.vm.currentPrompt.status = "evaluating";

wrapper.vm.setBusyIndicator(false);
expect(wrapper.vm.showBusyIndicator).toBeFalsy();
});
});

describe("toggleConsole - method", () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/test/components/Breadcrumbs.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { initComponent, unmount } from "../Utils";
import Breadcrumbs from "../../src/components/Breadcrumbs.vue";
import Vue from "vue";

describe("Breadcrumbs.vue", () => {
let wrapper;
Expand Down Expand Up @@ -50,6 +51,7 @@ describe("Breadcrumbs.vue", () => {
await wrapper.setProps({
breadcrumbs: [{ label: "answerLabel1", value: "answerValue1" }],
});
await Vue.nextTick();
expect(calcIsMoreSpy).toHaveBeenCalledTimes(2); // Once by v-resize, once adding answers
const moreLess = wrapper.get('[data-test="moreLessButton"]');
expect(moreLess.html()).toMatchInlineSnapshot(`
Expand Down
16 changes: 12 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,14 @@
dependencies:
"@octokit/openapi-types" "^11.2.0"

"@sap-devx/inquirer-gui-auto-complete-plugin@0.0.1":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@sap-devx/inquirer-gui-auto-complete-plugin/-/inquirer-gui-auto-complete-plugin-0.0.1.tgz#d1050e9b6e023fc8da831e5a01da1d51da48f249"
integrity sha512-S8Bm/wtuTv2g13u7chPpPwTn2hZyaZ5QR2ZBBX9gBiGhFxvpEwYaeIvsmU0RAPSt56FXZFeughViy7WeL9XknQ==
dependencies:
strip-ansi "^6.0.0"
vue "^2.6.10"

"@sap-devx/inquirer-gui-file-browser-plugin@0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@sap-devx/inquirer-gui-file-browser-plugin/-/inquirer-gui-file-browser-plugin-0.0.5.tgz#469dc021cab7b771d16f36199f2ce06d229a9d30"
Expand Down Expand Up @@ -2373,10 +2381,10 @@
dependencies:
vue "^2.6.10"

"@sap-devx/inquirer-gui@0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@sap-devx/inquirer-gui/-/inquirer-gui-0.3.0.tgz#aec200d40cc6d88381f73f773aecb5cf19229e08"
integrity sha512-kBNxug0cF6T/J8LrTTnh7oJ3wU1IQnZKkqmlTdoYLoYcWEXJ/ZVIKhcnzQCoR3mwE9T9XEMY4O0QEJBxDv9gTA==
"@sap-devx/inquirer-gui@0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@sap-devx/inquirer-gui/-/inquirer-gui-0.5.0.tgz#fa6cc903b301fc653f1bfba92772fa224304e3b6"
integrity sha512-4ldYrKyoqtgcJioCxEp+QZMDck2bQgzN/rkh9S2cKPqCJs1oEl0f6hFB1uqmkF2Te+oaK9mI1/CemwCS4BRovA==
dependencies:
strip-ansi "^6.0.0"
vue "2.6.12"
Expand Down

0 comments on commit a8c59fd

Please sign in to comment.