Commit 7008bdd7 authored by Sandro Lutz's avatar Sandro Lutz Committed by Sandro Lutz
Browse files

Add "Student for a day" page

* Move studydocuments/ to studies/documents
* Add permanent redirects from studydocuments to /studies/documents
parent ad2900f4
...@@ -14,6 +14,8 @@ import { ThemeProvider } from './src/context/themeContext' ...@@ -14,6 +14,8 @@ import { ThemeProvider } from './src/context/themeContext'
* Control whether to update scroll position on path change. * Control whether to update scroll position on path change.
*/ */
const shouldUpdateScroll = ({ prevRouterProps, routerProps }) => { const shouldUpdateScroll = ({ prevRouterProps, routerProps }) => {
if (!prevRouterProps) return true
const prevPathParts = prevRouterProps.location.pathname.split('/') const prevPathParts = prevRouterProps.location.pathname.split('/')
const pathParts = routerProps.location.pathname.split('/') const pathParts = routerProps.location.pathname.split('/')
......
...@@ -153,5 +153,6 @@ module.exports = { ...@@ -153,5 +153,6 @@ module.exports = {
}, },
}, },
'gatsby-plugin-remove-serviceworker', 'gatsby-plugin-remove-serviceworker',
'gatsby-plugin-meta-redirect',
], ],
} }
...@@ -34,8 +34,8 @@ const clientOnlyPaths = [ ...@@ -34,8 +34,8 @@ const clientOnlyPaths = [
matchPath: prefix => `/${prefix}events/*`, matchPath: prefix => `/${prefix}events/*`,
}, },
{ {
regex: /^\/([a-z,/]{3})*studydocuments/, regex: /^\/([a-z,/]{3})*studies\/documents/,
matchPath: prefix => `/${prefix}studydocuments/*`, matchPath: prefix => `/${prefix}studies/documents/*`,
}, },
{ {
regex: /^\/([a-z,/]{3})*jobs/, regex: /^\/([a-z,/]{3})*jobs/,
...@@ -43,6 +43,36 @@ const clientOnlyPaths = [ ...@@ -43,6 +43,36 @@ const clientOnlyPaths = [
}, },
] ]
exports.createPages = ({ actions }) => {
const { createRedirect } = actions
// Apply redirects for URLs which have changed due to restructuring of the website.
createRedirect({
fromPath: '/en/studydocuments',
toPath: '/en/studies/documents',
isPermanent: true,
redirectInBrowser: true,
})
createRedirect({
fromPath: '/en/studydocuments/new',
toPath: '/en/studies/documents/new',
isPermanent: true,
redirectInBrowser: true,
})
createRedirect({
fromPath: '/de/studydocuments',
toPath: '/de/studies/documents',
isPermanent: true,
redirectInBrowser: true,
})
createRedirect({
fromPath: '/de/studydocuments/new',
toPath: '/de/studies/documents/new',
isPermanent: true,
redirectInBrowser: true,
})
}
exports.onCreatePage = async ({ page, actions }) => { exports.onCreatePage = async ({ page, actions }) => {
const { createPage, deletePage } = actions const { createPage, deletePage } = actions
......
...@@ -39,6 +39,11 @@ server { ...@@ -39,6 +39,11 @@ server {
try_files $uri /$1/$2/index.html =404; try_files $uri /$1/$2/index.html =404;
} }
location ~* ^/(en|de)/studies/documents/([a-z0-9]+)$ {
error_page 404 /$1/404/index.html;
try_files $uri /$1/$2/index.html =404;
}
location ~* ^/(en|de)/ { location ~* ^/(en|de)/ {
error_page 404 /$1/404/index.html; error_page 404 /$1/404/index.html;
try_files $uri $uri/index.html =404; try_files $uri $uri/index.html =404;
......
...@@ -13685,6 +13685,26 @@ ...@@ -13685,6 +13685,26 @@
"resolved": "https://registry.npmjs.org/gatsby-plugin-matomo/-/gatsby-plugin-matomo-0.8.3.tgz", "resolved": "https://registry.npmjs.org/gatsby-plugin-matomo/-/gatsby-plugin-matomo-0.8.3.tgz",
"integrity": "sha512-fv6TgD+WsxziZrtmz6sNF4m9FgSyV+8y3R1sobA5hB5OxJyhs/Y4HVo9jCPRHu5VLKQsg4i7LJhWL0ocJiqEWQ==" "integrity": "sha512-fv6TgD+WsxziZrtmz6sNF4m9FgSyV+8y3R1sobA5hB5OxJyhs/Y4HVo9jCPRHu5VLKQsg4i7LJhWL0ocJiqEWQ=="
}, },
"gatsby-plugin-meta-redirect": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/gatsby-plugin-meta-redirect/-/gatsby-plugin-meta-redirect-1.1.1.tgz",
"integrity": "sha512-Oc4qgU3SlDUM9qoxIMKO+re2bdMs3/a2KXrfL65gb8XMLsHylBbveWtXZRhgjd2QDL/49RX4S9SEykuadRju2w==",
"requires": {
"fs-extra": "^7.0.0"
},
"dependencies": {
"fs-extra": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
}
}
},
"gatsby-plugin-page-creator": { "gatsby-plugin-page-creator": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/gatsby-plugin-page-creator/-/gatsby-plugin-page-creator-2.5.0.tgz", "resolved": "https://registry.npmjs.org/gatsby-plugin-page-creator/-/gatsby-plugin-page-creator-2.5.0.tgz",
...@@ -16918,9 +16938,9 @@ ...@@ -16918,9 +16938,9 @@
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.8",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
}, },
"inline-style-parser": { "inline-style-parser": {
"version": "0.1.1", "version": "0.1.1",
...@@ -44,8 +44,22 @@ const menuItems = [ ...@@ -44,8 +44,22 @@ const menuItems = [
path: '/events', path: '/events',
}, },
{ {
label: 'mainMenu.studydocuments', label: 'mainMenu.studies.label',
path: '/studydocuments', path: '/studies/documents',
submenu: [
{
label: 'mainMenu.studies.studydocuments',
path: '/studies/documents',
},
{
label: 'mainMenu.studies.howToErsti',
path: '/studies/how-to-ersti',
},
{
label: 'mainMenu.studies.studentForADay',
path: '/studies/student-for-a-day',
},
],
}, },
{ {
label: 'mainMenu.jobs.label', label: 'mainMenu.jobs.label',
......
...@@ -128,7 +128,9 @@ const StudydocumentDetails = ({ studydocumentId, ...props }) => { ...@@ -128,7 +128,9 @@ const StudydocumentDetails = ({ studydocumentId, ...props }) => {
<Toolbar className={classes.toolbar} variant="dense"> <Toolbar className={classes.toolbar} variant="dense">
{/* Buttons on the LEFT side */} {/* Buttons on the LEFT side */}
{canEdit && ( {canEdit && (
<Button onClick={() => navigate(`/studydocuments/${data._id}/edit`)}> <Button
onClick={() => navigate(`/studies/documents/${data._id}/edit`)}
>
<FormattedMessage id="studydocuments.actions.edit" /> <FormattedMessage id="studydocuments.actions.edit" />
</Button> </Button>
)} )}
...@@ -156,7 +158,7 @@ const StudydocumentDetails = ({ studydocumentId, ...props }) => { ...@@ -156,7 +158,7 @@ const StudydocumentDetails = ({ studydocumentId, ...props }) => {
) )
.then(() => { .then(() => {
setDeletePending(false) setDeletePending(false)
navigate('/studydocuments') navigate('/studies/documents')
}) })
.catch(() => { .catch(() => {
setDeletePending(false) setDeletePending(false)
...@@ -170,7 +172,7 @@ const StudydocumentDetails = ({ studydocumentId, ...props }) => { ...@@ -170,7 +172,7 @@ const StudydocumentDetails = ({ studydocumentId, ...props }) => {
<span className={classes.toolbarSeparator} /> <span className={classes.toolbarSeparator} />
{/* Buttons on the RIGHT side */} {/* Buttons on the RIGHT side */}
<CopyButton <CopyButton
value={`${window.location.origin}/${intl.locale}/studydocuments/${data._id}`} value={`${window.location.origin}/${intl.locale}/studies/documents/${data._id}`}
> >
<FormattedMessage id="copyDirectLink" /> <FormattedMessage id="copyDirectLink" />
</CopyButton> </CopyButton>
......
...@@ -4,7 +4,7 @@ import { FormattedMessage } from 'gatsby-plugin-intl' ...@@ -4,7 +4,7 @@ import { FormattedMessage } from 'gatsby-plugin-intl'
import { makeStyles } from '@material-ui/styles' import { makeStyles } from '@material-ui/styles'
import Alert from '@material-ui/lab/Alert' import Alert from '@material-ui/lab/Alert'
import Link from '../general/link' import Link from '../../general/link'
const useStyles = makeStyles( const useStyles = makeStyles(
{ {
...@@ -35,7 +35,7 @@ const StudydocumentsUploadHint = ({ className, ...props }) => { ...@@ -35,7 +35,7 @@ const StudydocumentsUploadHint = ({ className, ...props }) => {
<FormattedMessage id="studydocuments.uploadCatchphrase" /> <FormattedMessage id="studydocuments.uploadCatchphrase" />
</b> </b>
&nbsp; &nbsp;
<Link to="/studydocuments/new" className={classes.link}> <Link to="/studies/documents/new" className={classes.link}>
<FormattedMessage id="studydocuments.upload" /> <FormattedMessage id="studydocuments.upload" />
</Link> </Link>
</div> </div>
......
...@@ -6,8 +6,8 @@ import debounce from 'debounce' ...@@ -6,8 +6,8 @@ import debounce from 'debounce'
import { Button } from '@material-ui/core' import { Button } from '@material-ui/core'
import { SearchField } from 'amiv-react-components' import { SearchField } from 'amiv-react-components'
import FilterView from '../filteredListPage/filter' import FilterView from '../../filteredListPage/filter'
import SelectFilterField from '../general/selectFilterField' import SelectFilterField from '../../general/selectFilterField'
import { STUDYDOCUMENTS } from '~store/studydocuments/constants' import { STUDYDOCUMENTS } from '~store/studydocuments/constants'
import { setQueryFromFilterValues } from '~store/studydocuments/actions' import { setQueryFromFilterValues } from '~store/studydocuments/actions'
...@@ -21,9 +21,7 @@ const StudydocumentsFilter = ({ debounceTime, ...props }) => { ...@@ -21,9 +21,7 @@ const StudydocumentsFilter = ({ debounceTime, ...props }) => {
const _loadFilterOptions = (fieldSummary, itemTransformer = item => item) => { const _loadFilterOptions = (fieldSummary, itemTransformer = item => item) => {
if (fieldSummary) { if (fieldSummary) {
return Object.keys(fieldSummary) return Object.keys(fieldSummary).sort().map(itemTransformer)
.sort()
.map(itemTransformer)
} }
return [] return []
} }
...@@ -63,7 +61,7 @@ const StudydocumentsFilter = ({ debounceTime, ...props }) => { ...@@ -63,7 +61,7 @@ const StudydocumentsFilter = ({ debounceTime, ...props }) => {
) )
const setPathIfNeeded = () => { const setPathIfNeeded = () => {
navigate('/studydocuments') navigate('/studies/documents')
} }
const debouncedSetQueryFromFilterValues = React.useCallback( const debouncedSetQueryFromFilterValues = React.useCallback(
...@@ -129,7 +127,7 @@ const StudydocumentsFilter = ({ debounceTime, ...props }) => { ...@@ -129,7 +127,7 @@ const StudydocumentsFilter = ({ debounceTime, ...props }) => {
name="upload" name="upload"
variant="contained" variant="contained"
color="primary" color="primary"
onClick={() => navigate('/studydocuments/new')} onClick={() => navigate('/studies/documents/new')}
> >
<FormattedMessage id="studydocuments.upload" /> <FormattedMessage id="studydocuments.upload" />
</Button> </Button>
......
...@@ -7,13 +7,13 @@ import Alert from '@material-ui/lab/Alert' ...@@ -7,13 +7,13 @@ import Alert from '@material-ui/lab/Alert'
import { useIntl, FormattedMessage, navigate } from 'gatsby-plugin-intl' import { useIntl, FormattedMessage, navigate } from 'gatsby-plugin-intl'
import { ExternalLink, Spinner } from 'amiv-react-components' import { ExternalLink, Spinner } from 'amiv-react-components'
import { loadItem } from '../../../store/common/actions' import { loadItem } from '~store/common/actions'
import { STUDYDOCUMENTS } from '../../../store/studydocuments/constants' import { STUDYDOCUMENTS } from '~store/studydocuments/constants'
import { import {
loadEditFormSummary, loadEditFormSummary,
postStudydocumentItem, postStudydocumentItem,
patchStudydocumentItem, patchStudydocumentItem,
} from '../../../store/studydocuments/actions' } from '~store/studydocuments/actions'
import TitleField from './_titleField' import TitleField from './_titleField'
import SelectTextField from './_selectTextField' import SelectTextField from './_selectTextField'
import TypeField from './_typeField' import TypeField from './_typeField'
...@@ -160,7 +160,7 @@ const StudydocumentForm = ({ studydocumentId, className, ...props }) => { ...@@ -160,7 +160,7 @@ const StudydocumentForm = ({ studydocumentId, className, ...props }) => {
) )
setFilesChanged(false) setFilesChanged(false)
setIsPending(false) setIsPending(false)
navigate(`/studydocuments/${response._id}`) navigate(`/studies/documents/${response._id}`)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
setIsPending(false) setIsPending(false)
......
...@@ -11,9 +11,9 @@ import { ...@@ -11,9 +11,9 @@ import {
import { makeStyles } from '@material-ui/styles' import { makeStyles } from '@material-ui/styles'
import Alert from '@material-ui/lab/Alert' import Alert from '@material-ui/lab/Alert'
import oral_info_en from '../../content/studydocuments-oral-exams.en.md' import oral_info_en from '../../../content/studies/documents/oral-exams.en.md'
import oral_info_de from '../../content/studydocuments-oral-exams.de.md' import oral_info_de from '../../../content/studies/documents/oral-exams.de.md'
import TranslatedContent from '../general/translatedContent' import TranslatedContent from '../../general/translatedContent'
const useStyles = makeStyles( const useStyles = makeStyles(
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment