release notes page update

master
Tudor Stanciu 2020-05-14 17:05:37 +03:00
parent de4f0c5b4f
commit e07a1db7c3
4 changed files with 81 additions and 17 deletions

View File

@ -0,0 +1,27 @@
import React from "react";
import PropTypes from "prop-types";
import Typography from "@material-ui/core/Typography";
const ReleaseNotesComponent = ({ releaseNote }) => {
return (
<div>
{releaseNote.notes.map((note) => {
return (
<Typography
key={releaseNote.notes.indexOf(note)}
variant="body2"
gutterBottom
>
{note}
</Typography>
);
})}
</div>
);
};
ReleaseNotesComponent.propTypes = {
releaseNote: PropTypes.object.isRequired
};
export default ReleaseNotesComponent;

View File

@ -1,4 +1,4 @@
import React, { useEffect } from "react"; import React, { useEffect, useState } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { bindActionCreators } from "redux"; import { bindActionCreators } from "redux";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
@ -6,11 +6,26 @@ import { loadReleaseNotes } from "../actionCreators";
import ReleaseNotesListComponent from "./ReleaseNotesListComponent"; import ReleaseNotesListComponent from "./ReleaseNotesListComponent";
const ReleaseNotesContainer = ({ actions, releaseNotes }) => { const ReleaseNotesContainer = ({ actions, releaseNotes }) => {
const [notesFlags, setNotesFlags] = useState({});
useEffect(() => { useEffect(() => {
actions.loadReleaseNotes(); actions.loadReleaseNotes();
}, []); }, []);
return <ReleaseNotesListComponent releaseNotes={releaseNotes} />; const handleToggle = (version) => (_, expanded) => {
setNotesFlags({
...notesFlags,
[version]: expanded
});
};
return (
<ReleaseNotesListComponent
releaseNotes={releaseNotes}
handleToggle={handleToggle}
notesFlags={notesFlags}
/>
);
}; };
ReleaseNotesContainer.propTypes = { ReleaseNotesContainer.propTypes = {

View File

@ -8,14 +8,25 @@ import PropTypes from "prop-types";
import Spinner from "../../../components/common/Spinner"; import Spinner from "../../../components/common/Spinner";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import ReleaseNotesSummary from "./ReleaseNotesSummary"; import ReleaseNotesSummary from "./ReleaseNotesSummary";
import ReleaseNotesComponent from "./ReleaseNotesComponent";
import styles from "../../../components/common/styles/divStyles"; import styles from "../../../components/common/styles/divStyles";
const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);
const ReleaseNotesListComponent = ({ releaseNotes }) => { const ReleaseNotesListComponent = ({
releaseNotes,
handleToggle,
notesFlags
}) => {
const classes = useStyles(); const classes = useStyles();
const { t } = useTranslation(); const { t } = useTranslation();
const getCollapsed = (version) => {
const flag = notesFlags[version];
const collapsed = !flag || flag === false;
return collapsed;
};
return ( return (
<div className={classes.root}> <div className={classes.root}>
<h2>{t("ReleaseNotes.Title")}</h2> <h2>{t("ReleaseNotes.Title")}</h2>
@ -25,15 +36,21 @@ const ReleaseNotesListComponent = ({ releaseNotes }) => {
releaseNotes.loaded && releaseNotes.loaded &&
releaseNotes.map((note) => { releaseNotes.map((note) => {
return ( return (
<ExpansionPanel key={note.version}> <ExpansionPanel
key={note.version}
onChange={handleToggle(note.version)}
>
<ExpansionPanelSummary <ExpansionPanelSummary
expandIcon={<ExpandMoreIcon />} expandIcon={<ExpandMoreIcon />}
id={`panel-${note.version}-header`} id={`panel-${note.version}-header`}
> >
<ReleaseNotesSummary releaseNote={note} /> <ReleaseNotesSummary
releaseNote={note}
collapsed={getCollapsed(note.version)}
/>
</ExpansionPanelSummary> </ExpansionPanelSummary>
<ExpansionPanelDetails> <ExpansionPanelDetails>
<div>TO DO</div> <ReleaseNotesComponent releaseNote={note} />
</ExpansionPanelDetails> </ExpansionPanelDetails>
</ExpansionPanel> </ExpansionPanel>
); );
@ -44,7 +61,9 @@ const ReleaseNotesListComponent = ({ releaseNotes }) => {
}; };
ReleaseNotesListComponent.propTypes = { ReleaseNotesListComponent.propTypes = {
releaseNotes: PropTypes.array.isRequired releaseNotes: PropTypes.array.isRequired,
handleToggle: PropTypes.func.isRequired,
notesFlags: PropTypes.object.isRequired
}; };
export default ReleaseNotesListComponent; export default ReleaseNotesListComponent;

View File

@ -4,30 +4,33 @@ import { Grid } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import styles from "../../../components/common/styles/gridStyles"; import styles from "../../../components/common/styles/gridStyles";
import Typography from "@material-ui/core/Typography";
const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);
const ReleaseNotesSummary = ({ releaseNote }) => { const ReleaseNotesSummary = ({ releaseNote, collapsed }) => {
const classes = useStyles(); const classes = useStyles();
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<Grid container className={classes.miniContainer}> <Grid container className={classes.miniContainer}>
<Grid item xs={12} sm={5} md={5}> <Grid item xs={12} sm={2} md={2}>
{`${t("ReleaseNotes.Version")}: `} <Typography variant={collapsed ? "subtitle2" : "h6"}>
<span className={classes.value}>{releaseNote.version}</span> {`${t("ReleaseNotes.Version")}: ${releaseNote.version}`}
</Grid> </Typography>
<Grid item xs={12} sm={5} md={5}>
{`${t("ReleaseNotes.Version")}: `}
<span className={classes.value}>{releaseNote.version}</span>
</Grid> </Grid>
{collapsed && (
<Grid item xs={12} sm={10} md={10}>
<Typography variant="body2">{releaseNote.notes[0]}</Typography>
</Grid>
)}
</Grid> </Grid>
); );
}; };
ReleaseNotesSummary.propTypes = { ReleaseNotesSummary.propTypes = {
releaseNote: PropTypes.object.isRequired releaseNote: PropTypes.object.isRequired,
collapsed: PropTypes.bool.isRequired
}; };
export default ReleaseNotesSummary; export default ReleaseNotesSummary;