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
This commit is contained in:
@@ -4,10 +4,14 @@ import { Button, ListGroup } from 'react-bootstrap';
|
||||
import FormInput from './FormInput';
|
||||
|
||||
// This is a wrapper for google.script.run that lets us use promises.
|
||||
import { serverFunctions } from '../../utils/serverFunctions';
|
||||
import {
|
||||
serverFunctions,
|
||||
scriptHostFunctions,
|
||||
} from '../../utils/serverFunctions';
|
||||
|
||||
const SheetEditor = () => {
|
||||
const [names, setNames] = useState([]);
|
||||
const [isExpanded, setIsExpanded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
serverFunctions.getSheetsData().then(setNames).catch(alert);
|
||||
@@ -77,6 +81,29 @@ const SheetEditor = () => {
|
||||
))}
|
||||
</TransitionGroup>
|
||||
</ListGroup>
|
||||
{names.length > 0 && (
|
||||
<div className="d-flex justify-content-end py-3">
|
||||
{!isExpanded ? (
|
||||
<Button
|
||||
variant="light"
|
||||
className="mr-2"
|
||||
onClick={() => {
|
||||
scriptHostFunctions.setHeight(1000);
|
||||
scriptHostFunctions.setWidth(1000);
|
||||
setIsExpanded(true);
|
||||
}}
|
||||
>
|
||||
Expand Dialog
|
||||
</Button>
|
||||
) : null}
|
||||
<Button
|
||||
variant="outline-dark"
|
||||
onClick={() => scriptHostFunctions.close()}
|
||||
>
|
||||
Close Dialog Window
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
></script>
|
||||
<script
|
||||
crossorigin
|
||||
src="https://unpkg.com/gas-client@1.1.1/dist/index.js"
|
||||
src="https://unpkg.com/gas-client@1.2.0/dist/index.js"
|
||||
></script>
|
||||
<script
|
||||
crossorigin
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
></script>
|
||||
<script
|
||||
crossorigin
|
||||
src="https://unpkg.com/gas-client@1.1.1/dist/index.js"
|
||||
src="https://unpkg.com/gas-client@1.2.0/dist/index.js"
|
||||
></script>
|
||||
<script
|
||||
crossorigin
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
></script>
|
||||
<script
|
||||
crossorigin
|
||||
src="https://unpkg.com/gas-client@1.1.1/dist/index.js"
|
||||
src="https://unpkg.com/gas-client@1.2.0/dist/index.js"
|
||||
></script>
|
||||
<script
|
||||
crossorigin
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
></script>
|
||||
<script
|
||||
crossorigin
|
||||
src="https://unpkg.com/gas-client@1.1.1/dist/index.js"
|
||||
src="https://unpkg.com/gas-client@1.2.0/dist/index.js"
|
||||
></script>
|
||||
<script
|
||||
crossorigin
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { GASClient } from 'gas-client';
|
||||
import * as publicServerFunctions from '../../server';
|
||||
|
||||
const { serverFunctions } = new GASClient<typeof publicServerFunctions>({
|
||||
const { serverFunctions, scriptHostFunctions } = new GASClient<
|
||||
typeof publicServerFunctions
|
||||
>({
|
||||
// this is necessary for local development but will be ignored in production
|
||||
allowedDevelopmentDomains: (origin) =>
|
||||
/https:\/\/.*\.googleusercontent\.com$/.test(origin),
|
||||
});
|
||||
|
||||
export { serverFunctions };
|
||||
export { serverFunctions, scriptHostFunctions };
|
||||
|
||||
Reference in New Issue
Block a user