To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

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'
* Control whether to update scroll position on path change.
*/
const shouldUpdateScroll = ({ prevRouterProps, routerProps }) => {
if (!prevRouterProps) return true
const prevPathParts = prevRouterProps.location.pathname.split('/')
const pathParts = routerProps.location.pathname.split('/')
......
......@@ -153,5 +153,6 @@ module.exports = {
},
},
'gatsby-plugin-remove-serviceworker',
'gatsby-plugin-meta-redirect',
],
}
......@@ -34,8 +34,8 @@ const clientOnlyPaths = [
matchPath: prefix => `/${prefix}events/*`,
},
{
regex: /^\/([a-z,/]{3})*studydocuments/,
matchPath: prefix => `/${prefix}studydocuments/*`,
regex: /^\/([a-z,/]{3})*studies\/documents/,
matchPath: prefix => `/${prefix}studies/documents/*`,
},
{
regex: /^\/([a-z,/]{3})*jobs/,
......@@ -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 }) => {
const { createPage, deletePage } = actions
......
......@@ -39,6 +39,11 @@ server {
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)/ {
error_page 404 /$1/404/index.html;
try_files $uri $uri/index.html =404;
......
......@@ -13685,6 +13685,26 @@
"resolved": "https://registry.npmjs.org/gatsby-plugin-matomo/-/gatsby-plugin-matomo-0.8.3.tgz",
"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": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/gatsby-plugin-page-creator/-/gatsby-plugin-page-creator-2.5.0.tgz",
......@@ -16918,9 +16938,9 @@
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"ini": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
},
"inline-style-parser": {
"version": "0.1.1",
......@@ -44,8 +44,22 @@ const menuItems = [
path: '/events',
},
{
label: 'mainMenu.studydocuments',
path: '/studydocuments',
label: 'mainMenu.studies.label',
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',
......
......@@ -128,7 +128,9 @@ const StudydocumentDetails = ({ studydocumentId, ...props }) => {
<Toolbar className={classes.toolbar} variant="dense">
{/* Buttons on the LEFT side */}
{canEdit && (
<Button onClick={() => navigate(`/studydocuments/${data._id}/edit`)}>
<Button
onClick={() => navigate(`/studies/documents/${data._id}/edit`)}
>
<FormattedMessage id="studydocuments.actions.edit" />
</Button>
)}
......@@ -156,7 +158,7 @@ const StudydocumentDetails = ({ studydocumentId, ...props }) => {
)
.then(() => {
setDeletePending(false)
navigate('/studydocuments')
navigate('/studies/documents')
})
.catch(() => {
setDeletePending(false)
......@@ -170,7 +172,7 @@ const StudydocumentDetails = ({ studydocumentId, ...props }) => {
<span className={classes.toolbarSeparator} />
{/* Buttons on the RIGHT side */}
<CopyButton
value={`${window.location.origin}/${intl.locale}/studydocuments/${data._id}`}
value={`${window.location.origin}/${intl.locale}/studies/documents/${data._id}`}
>
<FormattedMessage id="copyDirectLink" />
</CopyButton>
......
......@@ -4,7 +4,7 @@ import { FormattedMessage } from 'gatsby-plugin-intl'
import { makeStyles } from '@material-ui/styles'
import Alert from '@material-ui/lab/Alert'
import Link from '../general/link'
import Link from '../../general/link'
const useStyles = makeStyles(
{
......@@ -35,7 +35,7 @@ const StudydocumentsUploadHint = ({ className, ...props }) => {
<FormattedMessage id="studydocuments.uploadCatchphrase" />
</b>
&nbsp;
<Link to="/studydocuments/new" className={classes.link}>
<Link to="/studies/documents/new" className={classes.link}>
<FormattedMessage id="studydocuments.upload" />
</Link>
</div>
......
......@@ -6,8 +6,8 @@ import debounce from 'debounce'
import { Button } from '@material-ui/core'
import { SearchField } from 'amiv-react-components'
import FilterView from '../filteredListPage/filter'
import SelectFilterField from '../general/selectFilterField'
import FilterView from '../../filteredListPage/filter'
import SelectFilterField from '../../general/selectFilterField'
import { STUDYDOCUMENTS } from '~store/studydocuments/constants'
import { setQueryFromFilterValues } from '~store/studydocuments/actions'
......@@ -21,9 +21,7 @@ const StudydocumentsFilter = ({ debounceTime, ...props }) => {
const _loadFilterOptions = (fieldSummary, itemTransformer = item => item) => {
if (fieldSummary) {
return Object.keys(fieldSummary)
.sort()
.map(itemTransformer)
return Object.keys(fieldSummary).sort().map(itemTransformer)
}
return []
}
......@@ -63,7 +61,7 @@ const StudydocumentsFilter = ({ debounceTime, ...props }) => {
)
const setPathIfNeeded = () => {
navigate('/studydocuments')
navigate('/studies/documents')
}
const debouncedSetQueryFromFilterValues = React.useCallback(
......@@ -129,7 +127,7 @@ const StudydocumentsFilter = ({ debounceTime, ...props }) => {
name="upload"
variant="contained"
color="primary"
onClick={() => navigate('/studydocuments/new')}
onClick={() => navigate('/studies/documents/new')}
>
<FormattedMessage id="studydocuments.upload" />
</Button>
......
......@@ -7,13 +7,13 @@ import Alert from '@material-ui/lab/Alert'
import { useIntl, FormattedMessage, navigate } from 'gatsby-plugin-intl'
import { ExternalLink, Spinner } from 'amiv-react-components'
import { loadItem } from '../../../store/common/actions'
import { STUDYDOCUMENTS } from '../../../store/studydocuments/constants'
import { loadItem } from '~store/common/actions'
import { STUDYDOCUMENTS } from '~store/studydocuments/constants'
import {
loadEditFormSummary,
postStudydocumentItem,
patchStudydocumentItem,
} from '../../../store/studydocuments/actions'
} from '~store/studydocuments/actions'
import TitleField from './_titleField'
import SelectTextField from './_selectTextField'
import TypeField from './_typeField'
......@@ -160,7 +160,7 @@ const StudydocumentForm = ({ studydocumentId, className, ...props }) => {
)
setFilesChanged(false)
setIsPending(false)
navigate(`/studydocuments/${response._id}`)
navigate(`/studies/documents/${response._id}`)
} catch (e) {
console.log(e)
setIsPending(false)
......
......@@ -11,9 +11,9 @@ import {
import { makeStyles } from '@material-ui/styles'
import Alert from '@material-ui/lab/Alert'
import oral_info_en from '../../content/studydocuments-oral-exams.en.md'
import oral_info_de from '../../content/studydocuments-oral-exams.de.md'
import TranslatedContent from '../general/translatedContent'
import oral_info_en from '../../../content/studies/documents/oral-exams.en.md'
import oral_info_de from '../../../content/studies/documents/oral-exams.de.md'
import TranslatedContent from '../../general/translatedContent'
const useStyles = makeStyles(
{
......
Markdown is supported
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