Skip to content

Commit e35c890

Browse files
committed
fix: [GSHDF-846] update header plugin for mapstore
1 parent 5f8803f commit e35c890

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

.github/workflows/mapstore.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on: [push, pull_request]
33

44
jobs:
55
build:
6-
runs-on: ubuntu-20.04
6+
runs-on: ubuntu-latest
77
permissions:
88
contents: read
99
packages: write
@@ -67,7 +67,7 @@ jobs:
6767
run: mkdir -p scratch && cp web/target/georchestra-mapstore*.deb scratch/georchestra-mapstore-${{ github.sha }}.deb
6868

6969
- name: "publish deb as artifact"
70-
uses: actions/upload-artifact@v1
70+
uses: actions/upload-artifact@v4
7171
with:
7272
name: georchestra-mapstore.deb
7373
path: scratch/georchestra-mapstore-${{ github.sha }}.deb
@@ -76,7 +76,7 @@ jobs:
7676
run: mkdir -p scratch && cp web/target/mapstore.war scratch/mapstore-${{ github.sha }}.war
7777

7878
- name: "publish war as artifact"
79-
uses: actions/upload-artifact@v1
79+
uses: actions/upload-artifact@v4
8080
with:
8181
name: mapstore.war
8282
path: scratch/mapstore-${{ github.sha }}.war

js/plugins/EasyTheming.jsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2019, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
import {useEffect} from "react";
9+
import {createPlugin, connect} from "@mapstore/utils/PluginsUtils";
10+
11+
export const Easytheming = ({stylesheet = ""}) => {
12+
useEffect(() => {
13+
if (stylesheet) {
14+
const link = document.createElement("link");
15+
link.setAttribute("rel", "stylesheet");
16+
link.setAttribute("type", "text/css");
17+
link.setAttribute("href", stylesheet);
18+
document.head.appendChild(link);
19+
}
20+
}, []);
21+
return null;
22+
};
23+
24+
export default createPlugin('Easytheming', {
25+
component: connect((state) => ({
26+
stylesheet: state.localConfig && state.localConfig.stylesheetUri
27+
}))(Easytheming)
28+
});

js/plugins/Header.jsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
import {useEffect} from "react";
99
import { createPlugin, connect } from "@mapstore/utils/PluginsUtils";
1010

11-
export const Header = ({url = "/header/", page = "mapstore", height = 90, ignoreIFrame = false}) => {
11+
export const Header = ({url = "/header/", page = "mapstore", height = 90, ignoreIFrame = false,
12+
script = "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js",
13+
legacy = false,
14+
logoUrl = "https://www.georchestra.org/public/georchestra-logo.svg",
15+
stylesheet = "", configFile = ""}) => {
1216
useEffect(() => {
1317
const header = document.getElementById("georchestra-header");
18+
const headerScript = document.getElementById("georchestra-header-script");
1419
const container = document.getElementById("container");
1520
if (header) {
1621
if (!ignoreIFrame && window.location !== window.parent.location) {
@@ -19,9 +24,14 @@ export const Header = ({url = "/header/", page = "mapstore", height = 90, ignore
1924
container.style.top = '0';
2025
}
2126
} else {
22-
header.style.display = 'block';
23-
header.src = url + "?active=" + page;
24-
header.style.height = height + "px";
27+
header.setAttribute("active-app", page);
28+
header.setAttribute("legacy-url", url);
29+
header.setAttribute("legacy-header", legacy);
30+
header.setAttribute("logo-url", logoUrl);
31+
header.setAttribute("stylesheet", stylesheet);
32+
header.setAttribute("config-file", configFile);
33+
header.setAttribute("height", height);
34+
headerScript.src = script;
2535

2636
if (container) {
2737
container.style.top = height + "px";
@@ -36,6 +46,11 @@ export const Header = ({url = "/header/", page = "mapstore", height = 90, ignore
3646
export default createPlugin('Header', {
3747
component: connect((state) => ({
3848
url: state.localConfig && state.localConfig.header && state.localConfig.header.url,
39-
height: state.localConfig && state.localConfig.header && state.localConfig.header.height
49+
height: state.localConfig && state.localConfig.header && state.localConfig.header.height,
50+
script: state.localConfig && state.localConfig.header && state.localConfig.header.script,
51+
legacy: state.localConfig && state.localConfig.header && state.localConfig.header.legacy,
52+
logoUrl: state.localConfig && state.localConfig.header && state.localConfig.header.logoUrl,
53+
stylesheet: state.localConfig && state.localConfig.header && state.localConfig.header.stylesheet,
54+
configFile: state.localConfig && state.localConfig.header && state.localConfig.header.configFile
4055
}))(Header)
4156
});

0 commit comments

Comments
 (0)