From 248a90023c14f35ca94b324a27869cbaba3b58f0 Mon Sep 17 00:00:00 2001 From: Elisha Nuchi <31550519+enuchi@users.noreply.github.com> Date: Sun, 16 Mar 2025 12:13:30 -0400 Subject: [PATCH] Feature: Support closing dialog windows (#233) Supports closing dialogs in development. Upgrades gas-client to 1.2.0 and uses new API here: Add scriptHostFunctions for google.script.host gas-client#36 Example button to close dialog in Bootstrap sample Updates integration tests --- .../workflows/integration-tests-basic.yaml | 4 +- .../workflows/integration-tests-extended.yaml | 4 +- README.md | 10 +- dev/dev-server-wrapper.html | 16 +- package.json | 4 +- .../components/SheetEditor.jsx | 29 +- src/client/dialog-demo-bootstrap/index.html | 2 +- src/client/dialog-demo-mui/index.html | 2 +- src/client/dialog-demo-tailwindcss/index.html | 2 +- src/client/dialog-demo/index.html | 2 +- src/client/utils/serverFunctions.ts | 6 +- ...d-should-load-bootstrap-example-1-snap.png | Bin 55030 -> 64162 bytes ...-modify-bootstrap-title-example-1-snap.png | Bin 55694 -> 63943 bytes ...-title-example-back-to-original-1-snap.png | Bin 55030 -> 64162 bytes test/local-development.test.js | 6 +- test/utils/open-addon.js | 5 +- yarn.lock | 4904 ++++++++--------- 17 files changed, 2494 insertions(+), 2502 deletions(-) diff --git a/.github/workflows/integration-tests-basic.yaml b/.github/workflows/integration-tests-basic.yaml index 587bbfe..9b34706 100644 --- a/.github/workflows/integration-tests-basic.yaml +++ b/.github/workflows/integration-tests-basic.yaml @@ -9,9 +9,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-12, macos-13, windows-2022] + os: [macos-13, windows-2022] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - node-version: [18, 20] + node-version: [20] timeout-minutes: 8 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/integration-tests-extended.yaml b/.github/workflows/integration-tests-extended.yaml index c860844..c4546c5 100644 --- a/.github/workflows/integration-tests-extended.yaml +++ b/.github/workflows/integration-tests-extended.yaml @@ -9,9 +9,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-12, macos-13, windows-2022] + os: [macos-13, windows-2022] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - node-version: [18, 20] + node-version: [20] timeout-minutes: 11 steps: - uses: actions/checkout@v4 diff --git a/README.md b/README.md index cc98b6e..9c07121 100644 --- a/README.md +++ b/README.md @@ -309,8 +309,8 @@ google.script.run .addSheet(sheetTitle); // Using gas-client we can use more familiar promises style like this: -import Server from 'gas-client'; -const { serverFunctions } = new Server(); +import { GASClient } from 'gas-client'; +const { serverFunctions, scriptHostFunctions } = new GASClient({}); // We now have access to all our server functions, which return promises! serverFunctions @@ -327,6 +327,12 @@ async () => { handleError(err); } }; + +// Use scriptHostFunctions to control dialogs +scriptHostFunctions.close(); // close a dialog or sidebar +scriptHostFunctions.setWidth(400); // set dialog width to 400px +scriptHostFunctions.setHeight(800); // set dialog height to 800px + ``` In development, `gas-client` will allow you to call server-side functions from your local environment. In production, it will use Google's underlying `google.script.run` utility. diff --git a/dev/dev-server-wrapper.html b/dev/dev-server-wrapper.html index c050c05..4c129e5 100644 --- a/dev/dev-server-wrapper.html +++ b/dev/dev-server-wrapper.html @@ -20,7 +20,7 @@ Two placeholders are used in this file that will need to be replaced in a build Dev Server - +