Skip to content

Commit

Permalink
#9250: Share plugin - Permalink functionality (#9288)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 committed Jul 25, 2023
1 parent e3863c5 commit 2ce16e0
Show file tree
Hide file tree
Showing 40 changed files with 2,030 additions and 21 deletions.
104 changes: 104 additions & 0 deletions docs/developer-guide/mapstore-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,110 @@ The old spring maven repositories that do not exist anymore have been removed fr
- </repository>
```

### New Permalink plugin

As part this release, permalink plugin is added to MapStore. The new plugin is already configured in standard MapStore application, but if you are working on a project or if you customized the configuration files, you may need to update them to introduce the new plugin.

In any case on an existing installation you **must** update the database adding the category to make the plugin work.

#### Add Permalink plugin to localConfig.json

In the case you customized your `configs/localConfig.json` file in your project/installation, to add the permalink plugin you will have to update it as following:

- Add the "Permalink" plugin to the pages you want to use this plugin. Pages plugins are in the `plugins` section in the root of `localConfig.json`, so you have to add "Permalink" entry to `desktop`, `dashboard` and `geostory` arrays, like this:

```json
{
"desktop": [
...
"Permalink",
...
],
"dashboard": [
...
"Permalink",
...
],
"geostory": [
...
"Permalink",
...
]
}
```

- To activate the functionality, you must add a new `permalink` section to `plugins` root object of `localConfig.json`, as shown below

```json
{
"permalink": [
"Permalink",
"FeedbackMask"
]
}
```

#### Using Permalink in new contexts

The plugins available for contexts are listed in the file `configs/pluginsConfig.json`. In your project/installation, you may need to edit this configuration to make the plugin selectable for your context.
Existing contexts need to be updated separately, after applying these changes

- Find the "Share" plugin configuration in the `plugins` array in the root of `pluginsConfig.json` configuration file and modify it as shown below (adding `children` and `autoEnableChildren` sections:

```json
{
"name": "Share",
"glyph": "share",
"title": "plugins.Share.title",
"description": "plugins.Share.description",
"dependencies": [
"SidebarMenu"
],
"children": [
"Permalink"
],
"autoEnableChildren": [
"Permalink"
]
}
```

- Add "Permalink" plugin configuration to the `plugins` array in the root of `pluginsConfig.json`

```json
{
"name": "Permalink",
"glyph": "link",
"title": "plugins.Permalink.title",
"description": "plugins.Permalink.description"
},
```

#### Database Update

Add new category `PERMALINK` to `gs_category` table. To update your database you need to apply this SQL scripts to your database

##### PostgreSQL

```sql
-- New PERMALINK category
INSERT INTO geostore.gs_category(id, name) VALUES (nextval('geostore.hibernate_sequence'), 'PERMALINK') ON CONFLICT DO NOTHING;
```

##### H2

```sql
-- New PERMALINK category
INSERT INTO gs_category(name) VALUES ('PERMALINK');
```

##### Oracle

```sql
-- New PERMALINK category
INSERT INTO gs_category(id, name) VALUES (hibernate_sequence.nextval, ‘PERMALINK');
```
## Migration from 2022.02.02 to 2023.01.00
### Log4j update to Log4j2
Expand Down
3 changes: 3 additions & 0 deletions java/web/src/main/resources/sample_categories.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
<Category>
<name>USERSESSION</name>
</Category>
<Category>
<name>PERMALINK</name>
</Category>
</CategoryList>
13 changes: 13 additions & 0 deletions project/standard/templates/configs/pluginsConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,21 @@
"description": "plugins.Share.description",
"dependencies": [
"SidebarMenu"
],
"children": [
"Permalink"
],
"autoEnableChildren": [
"Permalink"
]
},
{
"name": "Permalink",
"glyph": "link",
"title": "plugins.Permalink.title",
"description": "plugins.Permalink.description",
"denyUserSelection": true
},
{
"name": "BackgroundSelector",
"title": "plugins.BackgroundSelector.title",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
<Category>
<name>USERSESSION</name>
</Category>
<Category>
<name>PERMALINK</name>
</Category>
</CategoryList>
65 changes: 65 additions & 0 deletions web/client/actions/__tests__/permalink-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright 2023, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

import expect from "expect";

import {
LOAD_PERMALINK,
LOAD_PERMALINK_ERROR,
PERMALINK_LOADED,
LOADING,
RESET,
SAVE_PERMALINK,
UPDATE_SETTINGS,
loadPermalink,
loadPermalinkError,
permalinkLoaded,
permalinkLoading,
resetPermalink,
savePermalink,
updatePermalinkSettings
} from "../permalink";

describe("Test correctness of the permalink actions", () => {
it("loadPermalink", () => {
const action = loadPermalink("test");
expect(action.type).toBe(LOAD_PERMALINK);
expect(action.id).toBe("test");
});
it("loadPermalinkError", () => {
const error = {message: "error"};
const action = loadPermalinkError(error);
expect(action.type).toBe(LOAD_PERMALINK_ERROR);
expect(action.error).toEqual(error);
});
it("permalinkLoaded", () => {
const action = permalinkLoaded();
expect(action.type).toBe(PERMALINK_LOADED);
});
it("permalinkLoading", () => {
const action = permalinkLoading(true);
expect(action.type).toBe(LOADING);
expect(action.loading).toBeTruthy();
});
it("resetPermalink", () => {
const action = resetPermalink();
expect(action.type).toBe(RESET);
});
it("savePermalink", () => {
const saveObj = {name: "test"};
const action = savePermalink(saveObj);
expect(action.type).toBe(SAVE_PERMALINK);
expect(action.value).toEqual(saveObj);
});
it("updatePermalinkSettings", () => {
const settings = {title: "test"};
const action = updatePermalinkSettings(settings);
expect(action.type).toBe(UPDATE_SETTINGS);
expect(action.settings).toEqual(settings);
});
});
80 changes: 80 additions & 0 deletions web/client/actions/permalink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* Copyright 2023, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
export const LOAD_PERMALINK = "PERMALINK:LOAD";
export const PERMALINK_LOADED = "PERMALINK:LOADED";
export const LOAD_PERMALINK_ERROR = "PERMALINK:LOAD_ERROR";
export const SAVE_PERMALINK = "PERMALINK:SAVE";
export const UPDATE_SETTINGS = "PERMALINK:UPDATE_SETTINGS";
export const LOADING = "PERMALINK:LOADING";
export const RESET = "PERMALINK:RESET";

/**
* Load permalink
* @param {string} id
* @memberof actions.permalink
*/
export const loadPermalink = (id) => ({
type: LOAD_PERMALINK,
id
});

/**
* Trigger on permalink loaded
* @memberof actions.permalink
*/
export const permalinkLoaded = () => ({
type: PERMALINK_LOADED
});

/**
* Trigger on permalink load error
* @param {Object} error
* @memberof actions.permalink
*/
export const loadPermalinkError = (error) => ({
type: LOAD_PERMALINK_ERROR,
error
});

/**
* Trigger on save permalink
* @param {Object} value
* @memberof actions.permalink
*/
export const savePermalink = (value) => ({
type: SAVE_PERMALINK,
value
});

/**
* Trigger on update permalink settings
* @param {Object} settings
* @memberof actions.permalink
*/
export const updatePermalinkSettings = (settings) => ({
type: UPDATE_SETTINGS,
settings
});

/**
* Trigger on loading a permalink
* @param {boolean} loading
* @memberof actions.permalink
*/
export const permalinkLoading = (loading) => ({
type: LOADING,
loading
});

/**
* Trigger on permalink reset
* @memberof actions.permalink
*/
export const resetPermalink = () => ({
type: RESET
});
Loading

0 comments on commit 2ce16e0

Please sign in to comment.