Skip to content

Commit a715300

Browse files
committed
fix: added test deploymnen option
1 parent f786750 commit a715300

File tree

15 files changed

+68
-40
lines changed

15 files changed

+68
-40
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
"push": "clasp push",
1212
"setup:https": "mkdirp certs && mkcert -key-file ./certs/key.pem -cert-file ./certs/cert.pem localhost 127.0.0.1",
1313
"build:dev": "tsc && vite build --mode development",
14+
"build:test": "tsc && NODE_ENV=test vite build --mode test",
1415
"build": "tsc && vite build --mode production",
1516
"deploy:dev": "yarn build:dev && yarn push",
17+
"deploy:test": "yarn build:test && yarn push",
1618
"deploy": "yarn build && yarn push",
1719
"start": "yarn deploy:dev && yarn dev"
1820
},

src/client/create-diagram-dialog/components/create-diagram-dialog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const CreateDiagramDialog = () => {
1010

1111
useEffect(() => {
1212
if (!authState?.authorized) return;
13-
// const url = buildUrl('/app/plugins/confluence/select', state.token);
1413
const url = buildUrl(
1514
'/app/diagrams/new?pluginSource=googledocs',
1615
authState.token
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import ReactDOM from 'react-dom';
1+
import { createRoot } from 'react-dom/client';
22
import CreateDiagramDialog from './components/create-diagram-dialog';
33
import './styles.css';
44

55
const container = document.getElementById('index');
6-
const root = ReactDOM.createRoot(container);
6+
const root = createRoot(container);
77
root.render(<CreateDiagramDialog />);
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import ReactDOM from 'react-dom';
1+
import { createRoot } from 'react-dom/client';
22
import EditDiagramDialog from './components/edit-diagram-dialog';
3-
43
import './styles.css';
54

65
const container = document.getElementById('index');
7-
const root = ReactDOM.createRoot(container);
6+
const root = createRoot(container);
87
root.render(<EditDiagramDialog />);

src/client/hooks/useAuth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useCallback, useEffect, useState } from 'react';
22
import { serverFunctions } from '../utils/serverFunctions';
3+
import { baseURL } from '../../config/urls';
34

45
type Status = 'idle' | 'loading' | 'success' | 'error';
56

@@ -21,6 +22,7 @@ const useAuth = () => {
2122
const getAuth = useCallback(async () => {
2223
setAuthStatus('loading');
2324
try {
25+
await serverFunctions.setBaseUrl(baseURL);
2426
const state = await serverFunctions.getAuthorizationState();
2527
setAuthState(state as AuthState);
2628
setAuthStatus('success');
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import ReactDOM from 'react-dom';
1+
import { createRoot } from 'react-dom/client';
22
import PreviewDiagramDialog from './components/preview-diagram-dialog';
33
import './styles.css';
44

55
const container = document.getElementById('index');
6-
const root = ReactDOM.createRoot(container);
6+
const root = createRoot(container);
77
root.render(<PreviewDiagramDialog />);

src/client/select-diagram-dialog/components/select-diagram-dialog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const SelectDiagramDialog = () => {
1010

1111
useEffect(() => {
1212
if (!authState?.authorized) return;
13-
// const url = buildUrl('/app/plugins/confluence/select', state.token);
1413
const url = buildUrl(
1514
'/app/plugins/select?pluginSource=googledocs',
1615
authState.token
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import ReactDOM from 'react-dom';
1+
import { createRoot } from 'react-dom/client';
22
import SelectDiagramDialog from './components/select-diagram-dialog';
33
import './styles.css';
44

55
const container = document.getElementById('index');
6-
const root = ReactDOM.createRoot(container);
6+
const root = createRoot(container);
77
root.render(<SelectDiagramDialog />);

src/client/sidebar/components/Sidebar.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const Sidebar = () => {
3333

3434
useEffect(() => {
3535
if (!authState?.authorized) return;
36-
// const url = buildUrl('/app/plugins/confluence/select', state.token);
3736
const url = buildUrl(
3837
'/app/plugins/recent?pluginSource=googledocs',
3938
authState.token
@@ -65,9 +64,11 @@ const Sidebar = () => {
6564
useEffect(() => {
6665
const handleMessage = async (e: MessageEvent) => {
6766
const action = e.data.action;
68-
console.log('action', action);
67+
const actionData = e.data;
68+
6969
if (action === 'save') {
70-
const data = e.data.data;
70+
const data = actionData.data;
71+
if (!data) return;
7172
const metadata = new URLSearchParams({
7273
projectID: data.projectID,
7374
documentID: data.documentID,
@@ -83,20 +84,24 @@ const Sidebar = () => {
8384
} catch (error) {
8485
console.error('Error inserting image with metadata', error);
8586
}
86-
} else if (action === 'edit') {
87-
const data = e.data;
88-
if (!data.editUrl) return;
87+
return;
88+
}
89+
if (action === 'edit') {
90+
const editUrl = actionData.editUrl;
91+
if (!editUrl) return;
8992
try {
90-
localStorage.setItem('editUrl', data.editUrl);
93+
localStorage.setItem('editUrl', editUrl);
9194
await serverFunctions.openEditDiagramDialogWithUrl();
9295
} catch (error) {
9396
console.error('Error opening edit dialog', error);
9497
}
95-
} else if (action === 'view') {
96-
console.log(e.data);
97-
if (!e.data.url) return;
98+
return;
99+
}
100+
if (action === 'view') {
101+
const viewUrl = actionData.url;
102+
if (!viewUrl) return;
98103
try {
99-
localStorage.setItem('previewUrl', e.data.url);
104+
localStorage.setItem('previewUrl', viewUrl);
100105
await serverFunctions.openPreviewDiagramDialog();
101106
} catch (error) {
102107
console.error('Error opening edit dialog', error);

src/client/utils/helpers.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
import { baseURL } from '../../utils/urls';
2-
3-
interface Document {
4-
documentID: string;
5-
major: string;
6-
minor: string;
7-
}
1+
import { baseURL } from '../../config/urls';
82

93
export const buildUrl = (pathname: string, accessToken: string) => {
104
return `${baseURL}/oauth/frame?token=${accessToken}&redirect=${pathname}`;
115
};
126

13-
export const buildRawUrl = (document: Document, theme = 'light') => {
14-
return `${baseURL}/raw/${document.documentID}?version=v${document.major}.${document.minor}&theme=${theme}&format=png`;
15-
};
16-
177
export const handleDialogClose = () => {
188
if ((window as any).google) {
199
(window as any).google.script.host.close();

0 commit comments

Comments
 (0)