From 5e68914686420bcf4894a2b77bf884879689e2d9 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 13 Apr 2022 19:17:37 -0300 Subject: [PATCH] Add base configuration support for publish dialog --- packages/mindplot/src/components/lang/fr.js | 2 +- packages/webapp/src/classes/app-config/index.ts | 9 +++++++-- .../maps-page/action-dispatcher/publish-dialog/index.tsx | 9 +++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/mindplot/src/components/lang/fr.js b/packages/mindplot/src/components/lang/fr.js index eec4972e..cf9a3e44 100644 --- a/packages/mindplot/src/components/lang/fr.js +++ b/packages/mindplot/src/components/lang/fr.js @@ -83,7 +83,7 @@ const FR = { CTRL: 'Ctrl', SPACE_BAR: 'Space Bar', K_INSERT: 'Insert', - MOUSE_CLICK: 'Mouse Click', + MOUSE_CLICK: 'Clic de Souris', K_DELETE: 'Delete', BACKSPACE: 'Backspace', }; diff --git a/packages/webapp/src/classes/app-config/index.ts b/packages/webapp/src/classes/app-config/index.ts index 9c9be003..19a65d2b 100644 --- a/packages/webapp/src/classes/app-config/index.ts +++ b/packages/webapp/src/classes/app-config/index.ts @@ -15,7 +15,7 @@ interface Config { class _AppConfig { private defaultInstance: Config = { - apiBaseUrl: '/', + apiBaseUrl: `${window.location.protocol}//${window.location.hostname}:${window.location.port}`, clientType: 'mock', recaptcha2Enabled: true, recaptcha2SiteKey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI' @@ -57,7 +57,7 @@ class _AppConfig { const config = this.getInstance(); let result: Client; if (config.clientType == 'rest') { - result = new RestClient(config.apiBaseUrl); + result = new RestClient(this.getBaseUrl()); console.log('Service using rest client. ' + JSON.stringify(config)); } else { console.log('Warning:Service using mockservice client'); @@ -67,6 +67,11 @@ class _AppConfig { // Wrap with a cache decorator ... return new CacheDecoratorClient(result); } + + getBaseUrl(): string { + const config = this.getInstance(); + return config.apiBaseUrl; + } } const AppConfig = new _AppConfig(); diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx index 365ca3d3..6a509d81 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx @@ -18,6 +18,7 @@ import TabPanel from '@mui/lab/TabPanel'; import Typography from '@mui/material/Typography'; import TextareaAutosize from '@mui/material/TextareaAutosize'; import Box from '@mui/system/Box'; +import AppConfig from '../../../../classes/app-config'; const PublishDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => { const { map } = fetchMapById(mapId); @@ -28,7 +29,6 @@ const PublishDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen const [activeTab, setActiveTab] = React.useState('1'); const queryClient = useQueryClient(); const intl = useIntl(); - const classes = useStyles(); const mutation = useMutation( (model: boolean) => { @@ -60,10 +60,11 @@ const PublishDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen setModel(checked); }; - const handleTabChange = (event, newValue) => { + const handleTabChange = (event: React.ChangeEvent, newValue: string) => { setActiveTab(newValue); }; + const baseUrl = AppConfig.getBaseUrl(); return (
`} + defaultValue={``} /> @@ -145,7 +146,7 @@ const PublishDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen readOnly={true} spellCheck={false} maxRows={1} - defaultValue={`https://app.wisemapping.com/c/maps/${mapId}/public`} + defaultValue={`${baseUrl}/c/maps/${mapId}/public`} />