Skip to content

Commit bcf4971

Browse files
Merge pull request #893 from terrestris/configurable-layer-upload-button
feat: makes create layer button visibility configurable
2 parents b281a41 + 8f1c2fa commit bcf4971

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

assets/fallbackConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var shogunApplicationConfig = {
2121
geoserver: {
2222
base: '/geoserver',
2323
upload: {
24+
buttonVisible: false,
2425
workspace: 'SHOGUN',
2526
limit: 200000000 // ~200MB
2627
}

src/Component/GeneralEntity/Slots/ToolbarUploadLayerButton/ToolbarUploadLayerButton.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {
22
useContext
33
} from 'react';
44

5+
import config from 'shogunApplicationConfig';
6+
57
import UploadLayerButton, {
68
UploadLayerButtonProps
79
} from '../../../UploadLayerButton/UploadLayerButton';
@@ -15,6 +17,10 @@ export const ToolbarUploadLayerButton: React.FC<UploadLayerButtonProps> = () =>
1517
generalEntityRootContext?.fetchEntities?.();
1618
};
1719

20+
if (!config.geoserver?.upload?.buttonVisible) {
21+
return <></>
22+
}
23+
1824
return (
1925
<UploadLayerButton
2026
onSuccess={onSuccess}

src/Component/UploadLayerButton/UploadLayerButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const UploadLayerButton: React.FC<UploadLayerButtonProps> = ({
8383
} = useTranslation();
8484

8585
const onBeforeFileUpload = (file: RcFile) => {
86-
const maxSize = config.geoserver?.upload?.limit || '200000000';
86+
const maxSize = config.geoserver?.upload?.limit || 200000000;
8787
const fileType = file.type;
8888
const fileSize = file.size;
8989

src/custom.d.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,23 @@ declare module 'shogunApplicationConfig' {
1515
resourcePath?: string;
1616
exposedPaths?: string[];
1717
}
18-
18+
interface GeoServerConfiguration {
19+
base?: string;
20+
upload?: {
21+
buttonVisible?: boolean;
22+
workspace?: string;
23+
limit?: number;
24+
};
25+
}
1926
/**
2027
* Config object which contains the settings to adapt the admin client
2128
* to your application.
2229
*/
2330
interface AdminConfiguration {
24-
/**
25-
* Geoserver configuration object.
26-
*/
27-
geoserver?;
31+
/**
32+
* Geoserver configuration object.
33+
*/
34+
geoserver?: GeoServerConfiguration;
2835
/**
2936
* The path to the admin client on your host, e.g. '/admin'
3037
*/

0 commit comments

Comments
 (0)