Skip to content

Commit

Permalink
Added creator/editor read-only fields in edit resource properties mod…
Browse files Browse the repository at this point in the history
…al (#9968)
  • Loading branch information
Igi-ID authored Feb 22, 2024
1 parent f154a58 commit 5d1dd56
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 11 deletions.
14 changes: 14 additions & 0 deletions docs/developer-guide/mapstore-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ This is a list of things to check if you want to update from a previous version

## Migration from 2023.02.02 to 2024.01.00

The resource metadata has been recently extented to include information about resource creator and editor and to provide the advertises/unadvertised resource functionalities.
If your installation has the [database creation mode](https://docs.mapstore.geosolutionsgroup.com/en/latest/developer-guide/database-setup/#database-creation-mode) set to `update` (the default), the columns will be added automatically and you do not have to do any action. If it is set to `validate` instead you will have to run the update scripts.

*In any case*, the update scripts contain also a part to populate the `creator` column, that can not be applied automatically with [database creation mode](https://docs.mapstore.geosolutionsgroup.com/en/latest/developer-guide/database-setup/#database-creation-mode) set to `update`.
So if you want to see this information, even if it is not strictily required, you will have to run the migration scripts anyway.

- For script reference see:

[postgresql migration script 2.0.0 to 2.1.0](https://github.com/geosolutions-it/geostore/blob/master/doc/sql/migration/postgresql/postgresql-migration-from-v.2.0.0-to-v2.1.0.sql)

[h2 migration script 2.0.0 to 2.1.0](https://github.com/geosolutions-it/geostore/blob/master/doc/sql/migration/h2/h2-migration-from-v.2.0.0-to-v2.1.0.sql)

[oracle migration script 2.0.0 to 2.1.0](https://github.com/geosolutions-it/geostore/blob/master/doc/sql/migration/oracle/oracle-migration-from-v.2.0.0-to-v2.1.0.sql)

### Restructuring of Login and Home in Dashboard page

We recently added the sidebar to the dashboard page and by doing so we wanted to keep a uniform position of login and home plugins, by putting them in the omnibar container rather than the sidebar one. The viewer is a specific case that will be reviewed in the future.
Expand Down
20 changes: 18 additions & 2 deletions web/client/components/resources/forms/Metadata.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class Metadata extends React.Component {
titlePlaceholderText: PropTypes.string,
createdAtFieldText: PropTypes.string,
modifiedAtFieldText: PropTypes.string,
unadvertisedText: PropTypes.string
unadvertisedText: PropTypes.string,
creatorFieldText: PropTypes.string,
editorFieldText: PropTypes.string
};

static contextTypes = {
Expand All @@ -60,7 +62,9 @@ class Metadata extends React.Component {
nameFieldFilter: () => {},
namePlaceholderText: "Map Name",
descriptionPlaceholderText: "Map Description",
unadvertisedText: "Unadvertised"
unadvertisedText: "Unadvertised",
creatorFieldText: "Creator",
editorFieldText: "Editor"
};

renderDate = (date) => {
Expand Down Expand Up @@ -110,12 +114,24 @@ class Metadata extends React.Component {
defaultValue={this.props.resource ? this.props.resource.description : ""}
value={this.props.resource && this.props.resource.metadata && this.props.resource.metadata.description || ""} />
</FormGroup>
{
this.props.resource && this.props.resource.creator && <FormGroup>
<ControlLabel>{this.props.creatorFieldText}</ControlLabel>
<ControlLabel>{this.props.resource.creator}</ControlLabel>
</FormGroup>
}
{
this.props.resource && this.props.resource.createdAt && <FormGroup>
<ControlLabel>{this.props.createdAtFieldText}</ControlLabel>
<ControlLabel>{this.props.resource && this.renderDate(this.props.resource.createdAt) || ""}</ControlLabel>
</FormGroup>
}
{
this.props.resource && this.props.resource.editor && <FormGroup>
<ControlLabel>{this.props.editorFieldText}</ControlLabel>
<ControlLabel>{this.props.resource.editor}</ControlLabel>
</FormGroup>
}
{
this.props.resource && this.props.resource.createdAt && <FormGroup>
<ControlLabel>{this.props.modifiedAtFieldText}</ControlLabel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ describe('Metadata component', () => {
});
it('Metadata rendering with meta-data', () => {
const resource = {
editor: "TEST_EDITOR",
modifiedAt: new Date(),
creator: "TEST_CREATOR",
createdAt: new Date(),
metadata: {
name: "NAME",
Expand All @@ -42,7 +44,7 @@ describe('Metadata component', () => {
const container = document.getElementById('container');
const el = container.querySelectorAll('input');
const labels = container.querySelectorAll('label');
expect(labels.length).toBe(8);
expect(labels.length).toBe(12);
expect(el[0].value).toBe("NAME");
expect(el[1].value).toBe("DESCRIPTION");
// the visualisation of the advertised resource attribute is represented as "Unadvertised"
Expand All @@ -51,7 +53,9 @@ describe('Metadata component', () => {
});
it('Metadata rendering with attributes', () => {
const resource = {
editor: "TEST_EDITOR",
modifiedAt: new Date(),
creator: "TEST_CREATOR",
createdAt: new Date(),
attributes: {
title: "TITLE"
Expand All @@ -61,7 +65,7 @@ describe('Metadata component', () => {
const container = document.getElementById('container');
const el = container.querySelectorAll('input');
const labels = container.querySelectorAll('label');
expect(labels.length).toBe(9);
expect(labels.length).toBe(13);
expect(el[1].value).toBe("TITLE");
});
it('Metadata rendering without timestamp', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import ConfirmDialog from '../ConfirmModal';
*/
export default compose(
withStateHandlers(
({resource = {}, linkedResources = {}}) => {
({resource = {}, linkedResources = {}, user = {}}) => {
const detailsSettingsString = resource.detailsSettings || resource.attributes?.detailsSettings;
let detailsSettings = {};

Expand Down Expand Up @@ -59,7 +59,8 @@ export default compose(
},
createdAt: resource.creation,
modifiedAt: resource.lastUpdate,
creator: resource.creator
creator: user?.role === 'ADMIN' ? resource.creator : '',
editor: user?.role === 'ADMIN' ? resource.editor : ''
},
linkedResources
};
Expand Down
2 changes: 2 additions & 0 deletions web/client/components/resources/modals/fragments/MainForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class MainForm extends React.Component {
descriptionPlaceholderText={"saveDialog.descriptionPlaceholder"}
titlePlaceholderText={"saveDialog.titlePlaceholder"}
unadvertisedText={<Message msgId="saveDialog.unadvertised" />}
creatorFieldText={<Message msgId="saveDialog.creator" />}
editorFieldText={<Message msgId="saveDialog.editor" />}
/>
</Col>
</Row>);
Expand Down
4 changes: 3 additions & 1 deletion web/client/translations/data.de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -3068,7 +3068,9 @@
"saveSuccessMessage": "Erfolgreich gespeichert",
"saveTooltip": "Speichern",
"saveAsTooltip": "Speichern als",
"unadvertised": "Nicht geworben"
"unadvertised": "Nicht geworben",
"creator": "Erstellt von",
"editor": "Zuletzt geändert von"
},
"mapEditor": {
"modalTitle": "Karteneditor",
Expand Down
4 changes: 3 additions & 1 deletion web/client/translations/data.en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -3041,7 +3041,9 @@
"saveSuccessMessage": "Saved successfully",
"saveTooltip": "Save",
"saveAsTooltip": "Save As",
"unadvertised": "Unadvertised"
"unadvertised": "Unadvertised",
"creator": "Created by",
"editor": "Last modified by"
},
"mapEditor": {
"modalTitle": "Map Editor",
Expand Down
4 changes: 3 additions & 1 deletion web/client/translations/data.es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -3030,7 +3030,9 @@
"saveSuccessMessage": "Guardado con éxito",
"saveTooltip": "Salvar",
"saveAsTooltip": "Guardar como",
"unadvertised": "Sin publicidad"
"unadvertised": "Sin publicidad",
"creator": "Creado por",
"editor": "Última modificación por"
},
"mapEditor": {
"modalTitle": "Map Editor",
Expand Down
4 changes: 3 additions & 1 deletion web/client/translations/data.fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -3031,7 +3031,9 @@
"saveSuccessMessage": "Enregistré avec succès",
"saveTooltip": "Enregistrer",
"saveAsTooltip": "Enregistrer sous",
"unadvertised": "Non annoncé"
"unadvertised": "Non annoncé",
"creator": "Créé par",
"editor": "Dernière modification par"
},
"mapEditor": {
"modalTitle": "Editeur de carte",
Expand Down
4 changes: 3 additions & 1 deletion web/client/translations/data.it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -3031,7 +3031,9 @@
"saveSuccessMessage": "Salvata con successo",
"saveTooltip": "Salva",
"saveAsTooltip": "Salva con nome",
"unadvertised": "Non pubblicizzato"
"unadvertised": "Non pubblicizzato",
"creator": "Creato da",
"editor": "Ultima modifica di"
},
"mapEditor": {
"modalTitle": "Editor di Mappa",
Expand Down

0 comments on commit 5d1dd56

Please sign in to comment.