Skip to content

Commit

Permalink
feat: view release logs for io-comune and io-comune addons
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed Sep 15, 2023
1 parent 3d5bcc4 commit 22872e8
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 4 deletions.
37 changes: 37 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--- RELEASE file. La cura di questo file è in carico ai dev.
Qui vanno inserite tutte le novità e bugfix, spiegati in un linguaggio comprensibile anche ai non dev.
Se ci sono delle migliorie/novità per cui è stato aggiunto qualcosa nel manuale, linkarlo come nell'esempio sotto.
-->

<!--- -----------------------------------------------------------------
Esempio:
---------------------------------------------------------------------
## Versione 7.10.9
### Migliorie
- Fissato il layout di stampa per pagine con Accordion
### Novità
- Nuovo blocco "Informazioni" [`Istruzioni`](https://docs.google.com/document/d/1SThuxa_ah0BuNXukWs564kKPfprK41WLQE8Mome-0xg/edit#heading=h.7ty110jumgmd)
### Fix
- il numero di telefono dentro card ufficio adesso è visibile anche senza indirizzo
-->

<!--- -----------------------------------------------------------------
TEMPLATE PER RELEASE
----------------------------------------------------------------------
## Versione X.X.X
### Migliorie
- ...
### Novità
- ... [`Istruzioni`](url della documentazione relativa alla novità)
### Fix
- ...
-->

## Versione x.x.x

### Novità

- ciao
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"classnames": "^2.3.2",
"design-react-kit": "italia/design-react-kit#fc9b40257ba3cb613141faf217f1f5b806489740",
"htmldiff-js": "1.0.5",
"marked": "9.0.0",
"react-dropzone": "11.0.1",
"react-google-recaptcha-v3": "1.7.0",
"react-highlight-words": "0.18.0",
Expand Down
4 changes: 4 additions & 0 deletions src/components/ReleaseLog/ReleaseLog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h2 {
border-top: 1px solid grey;
font-weight: 600 !important;
}
148 changes: 148 additions & 0 deletions src/components/ReleaseLog/ReleaseLog.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/**
* ReleaseLog component.
* @module components/ReleaseLog/ReleaseLog
*/

import React, { useState, useEffect } from 'react';

import {
Container,
Nav,
NavItem,
NavLink,
TabContent,
TabPane,
} from 'design-react-kit';
import { Helmet } from '@plone/volto/helpers';
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';

import './ReleaseLog.css';

const ReleaseLog = ({ marked }) => {
let ReleaseDCPT = null;
let ReleaseIoCittadino = null;
let ReleaseIoPrenoto = null;
try {
ReleaseDCPT = require('design-comuni-plone-theme/../RELEASE.md');
} catch {
console.log("design-comuni-plone-theme/../RELEASE.md doesn't exists");
}
try {
ReleaseIoCittadino = require('@redturtle/volto-io-cittadino/../RELEASE.md');
} catch {
console.log("@redturtle/volto-io-cittadino/../RELEASE.md doesn't exists");
}
try {
ReleaseIoPrenoto = require('@redturtle/volto-io-prenoto/../RELEASE.md');
} catch {
console.log("@redturtle/volto-io-prenoto/../RELEASE.md doesn't exists");
}

const LOGS_TO_VIEW = [
{ name: 'io-comune', file: ReleaseDCPT },
{
name: 'io-cittadino',
file: ReleaseIoCittadino,
},
{ name: 'io-prenoto', file: ReleaseIoPrenoto },
];

const Markdown = marked.marked;
const [activeTab, toggleTab] = useState(LOGS_TO_VIEW[0].name);
const [logDCPT, setLogDCPT] = useState('');
const [logIoCittadino, setLogIoCittadino] = useState('');
const [logIoPrenoto, setLogIoPrenoto] = useState('');

useEffect(() => {
if (ReleaseDCPT) {
try {
fetch(ReleaseDCPT)
.then((res) => res.text())
.then((text) => {
setLogDCPT(Markdown(text));
});
} catch {
console.log(ReleaseDCPT + ' not found.');
}
}
if (ReleaseIoCittadino) {
try {
fetch(ReleaseIoCittadino)
.then((res) => res.text())
.then((text) => {
setLogIoCittadino(Markdown(text));
});
} catch {
console.log(ReleaseIoCittadino + ' not found.');
}
}
if (ReleaseIoPrenoto) {
try {
fetch(ReleaseIoPrenoto)
.then((res) => res.text())
.then((text) => {
setLogIoPrenoto(Markdown(text));
});
} catch {
console.log(ReleaseIoPrenoto + ' not found.');
}
}
}, []);

const viewTab = (tab) => {
if (activeTab !== tab) {
toggleTab(tab);
}
};

return (
<div className="public-ui">
<Helmet title="Release LOG" />
<Helmet>
<meta name="robots" content="noindex" />
</Helmet>
<Container className="px-4 my-4">
<Nav tabs className="mb-3">
{LOGS_TO_VIEW.filter((log) => log.file != null).map((log) => (
<NavItem key={log.name}>
<NavLink
href="#"
active={activeTab === log.name}
onClick={() => viewTab(log.name)}
>
<span>{log.name}</span>
</NavLink>
</NavItem>
))}
</Nav>

<TabContent activeTab={activeTab}>
{LOGS_TO_VIEW.filter((log) => log.file != null).map((log) => (
<TabPane
tabId={log.name}
className="p-3"
key={log.name + 'tabcontent'}
>
<div
dangerouslySetInnerHTML={{
__html:
log.name === 'io-comune' ? (
logDCPT
) : log.name == 'io-cittadino' ? (
logIoCittadino
) : log.name == 'io-prenoto' ? (
logIoPrenoto
) : (
<div></div>
),
}}
></div>
</TabPane>
))}
</TabContent>
</Container>
</div>
);
};

export default injectLazyLibs(['marked'])(ReleaseLog);
32 changes: 28 additions & 4 deletions src/config/italiaConfig.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import loadable from '@loadable/component';
import menuSVG from '@plone/volto/icons/menu.svg';
import menuAltSVG from '@plone/volto/icons/menu-alt.svg';
import navSVG from '@plone/volto/icons/nav.svg';
Expand Down Expand Up @@ -54,6 +55,7 @@ import faBuildingSVG from 'design-comuni-plone-theme/icons/building.svg';
import faFileDownloadSVG from 'design-comuni-plone-theme/icons/file-download.svg';
import faQuestionSVG from 'design-comuni-plone-theme/icons/question-solid.svg';
import bandoSVG from 'design-comuni-plone-theme/icons/bando.svg';
import logSVG from 'design-comuni-plone-theme/icons/log.svg';

import applyRichTextConfig from 'design-comuni-plone-theme/config/RichTextEditor/config';

Expand All @@ -63,6 +65,10 @@ import { schemaListing } from 'design-comuni-plone-theme/components/ItaliaTheme/

import reducers from 'design-comuni-plone-theme/reducers';

const ReleaseLog = loadable(() =>
import('design-comuni-plone-theme/components/ReleaseLog/ReleaseLog'),
);

export default function applyConfig(voltoConfig) {
let config = applyRichTextConfig(voltoConfig);

Expand Down Expand Up @@ -155,6 +161,15 @@ export default function applyConfig(voltoConfig) {
great: 1200,
huge: 1600,
},
controlpanels: [
...(config.settings.controlpanels ?? []),
{
'@id': '/release-log',
group: 'Generali',
title: 'Novità ultimi rilasci',
id: 'release-log',
},
],
controlPanelsIcons: {
...config.settings.controlPanelsIcons,
'dropdown-menu-settings': menuSVG,
Expand All @@ -163,6 +178,7 @@ export default function applyConfig(voltoConfig) {
'design-plone-settings': contentSVG,
'bandi-settings': bookSVG,
'social-settings': shareSVG,
'release-log': logSVG,
},
defaultBlockType: 'text',
defaultExcludedFromSearch: {
Expand Down Expand Up @@ -306,6 +322,7 @@ export default function applyConfig(voltoConfig) {
config.settings.nonContentRoutes = config.settings.nonContentRoutes.filter(
(route) => route !== '/contact-form',
);
config.settings.nonContentRoutes.push('/release-log');

/******************************************************************************
* VIEWS
Expand Down Expand Up @@ -462,10 +479,9 @@ export default function applyConfig(voltoConfig) {
},
};
// Remove Horizontal Menu variation of TOC Block
config.blocks.blocksConfig.toc.variations =
config.blocks.blocksConfig.toc.variations.filter(
(v) => v.id !== 'horizontalMenu',
);
config.blocks.blocksConfig.toc.variations = config.blocks.blocksConfig.toc.variations.filter(
(v) => v.id !== 'horizontalMenu',
);

// REDUCERS
config.addonReducers = {
Expand All @@ -484,6 +500,14 @@ export default function applyConfig(voltoConfig) {
path: ['/login', '/**/login'],
component: LoginAgid,
},
{
path: '/controlpanel/release-log',
component: ReleaseLog,
},
{
path: '/release-log',
component: ReleaseLog,
},
];

return config;
Expand Down
1 change: 1 addition & 0 deletions src/config/loadables.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export const loadables = {
reactSlick: loadable.lib(() => import('react-slick')),
rrule: loadable.lib(() => import('rrule')),
htmlDiffLib: loadable.lib(() => import('htmldiff-js')),
marked: loadable.lib(() => import('marked')), //read markdown files
...subsitesLoadables,
};
3 changes: 3 additions & 0 deletions src/icons/log.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4741,6 +4741,7 @@ __metadata:
htmldiff-js: 1.0.5
husky: 8.0.2
lint-staged: 13.0.3
marked: 9.0.0
prettier: 2.0.5
react-dropzone: 11.0.1
react-google-recaptcha-v3: 1.7.0
Expand Down Expand Up @@ -7942,6 +7943,15 @@ __metadata:
languageName: node
linkType: hard

"marked@npm:9.0.0":
version: 9.0.0
resolution: "marked@npm:9.0.0"
bin:
marked: bin/marked.js
checksum: a8e6e7f84f3940259aeb3a2abdd0961cfe1052131a18dfa714fd8d050559f299920bba43c1aa6c4e60293af8da961e3ec96d8f799661fc2c9bcb93598770e942
languageName: node
linkType: hard

"masonry-layout@npm:^4.2.2":
version: 4.2.2
resolution: "masonry-layout@npm:4.2.2"
Expand Down

0 comments on commit 22872e8

Please sign in to comment.