From 6a3684b2d28136e8d746777a34c5cf11c9f09be4 Mon Sep 17 00:00:00 2001 From: Javier Date: Sat, 11 Nov 2023 00:45:08 +0200 Subject: [PATCH 01/58] Disabled instrospection Fixed issue with project submissions allowing multiple submissions if clicking fast enough Added .finally to async call sequence on submissionForm to set isSubmitting to false when all promises settle onSubmit --- backend/modules/graphql.js | 3 +-- frontend/src/components/inputs/BottomBar.js | 1 + .../renderDashboard/participant/project/SubmissionForm.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/modules/graphql.js b/backend/modules/graphql.js index 7455cea87..b384c0ffb 100644 --- a/backend/modules/graphql.js +++ b/backend/modules/graphql.js @@ -80,8 +80,7 @@ module.exports = app => { const server = new ApolloServer({ schema, playground: false, - // TODO make instrospection false in production - introspection: true, + introspection: false, context: ({ req, res }) => ({ req, res, diff --git a/frontend/src/components/inputs/BottomBar.js b/frontend/src/components/inputs/BottomBar.js index c650d46cf..44960a2ff 100644 --- a/frontend/src/components/inputs/BottomBar.js +++ b/frontend/src/components/inputs/BottomBar.js @@ -97,6 +97,7 @@ const BottomBar = ({ - - - - - ) -} diff --git a/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/questions/CustomSectionList/AddSectionModal.js b/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/questions/CustomSectionList/AddSectionModal.js deleted file mode 100644 index 5643bfe01..000000000 --- a/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/questions/CustomSectionList/AddSectionModal.js +++ /dev/null @@ -1,233 +0,0 @@ -import React, { useState, useCallback, useEffect } from 'react' - -import { - Box, - Typography, - Dialog, - DialogTitle, - DialogContent, - DialogActions, - FormControlLabel, - Switch, -} from '@material-ui/core' -import { makeStyles } from '@material-ui/core/styles' -import MarkdownInput from 'components/inputs/MarkdownInput' -import Button from 'components/generic/Button' -import TextInput from 'components/inputs/TextInput' -import { generateSlug } from 'utils/dataModifiers' - -const useStyles = makeStyles(theme => ({ - label: { - fontWeight: 'bold', - }, -})) - -export default ({ - visible, - onVisibleChange, - onSubmit, - onEditDone, - onEditCancel, - editing, - reservedNames, -}) => { - const classes = useStyles() - const [data, setData] = useState({}) - const [isConditional, setIsConditional] = useState(false) - - useEffect(() => { - if (editing) { - setData(editing) - - setIsConditional(!!editing.conditional) // This prevents the conditional question from toggle to always visible - } - }, [editing]) - - const reset = () => { - setData({}) - - // this prevent the conditional to be reset after saving section or editing - if (!editing) { - setIsConditional(false) - } - } - - const validate = () => { - if (!data.label) { - return 'Please give your section a title' - } - - if (!data.name) { - return 'Please give your section a machine name' - } - - if (!/^[a-z-]*$/.test(data.name)) { - return 'Machine name can only contain lowercase characters and dashes (-)' - } - - if (!editing) { - if (reservedNames.indexOf(data.name) !== -1) { - return `The machine-name ${data.name} is already taken, please use something else` - } - } - - if (isConditional && !data.conditional) { - return 'Please give your section a conditional question, or set it to always visible' - } - } - - const handleAdd = () => { - console.log('After handling add:', data) - const error = validate() - if (error) { - window.alert(error) - } else { - onSubmit({ - ...data, - conditional: isConditional ? data.conditional : undefined, - }) - onVisibleChange(false) - reset() - } - } - - const handleEdit = () => { - const error = validate() - if (error) { - window.alert(error) - } else { - onEditDone({ - ...data, - conditional: isConditional ? data.conditional : undefined, - }) - reset() - } - } - - const handleCancel = () => { - if (editing) { - onEditCancel() - } else { - onVisibleChange(false) - } - } - - const handleChange = useCallback( - (field, value) => { - const newData = { ...data } - - if (field === 'label' && !editing) { - newData.name = generateSlug(value, 's') - } - - setData({ - ...newData, - [field]: value, - }) - }, - [data], - ) - - return ( - - - {editing ? `Edit ${editing.label}` : 'Add a new section'} - - - - Section title - - handleChange('label', value)} - /> - {/* - The displayed name of your section - - - Machine name - - handleChange('name', value)} - /> */} - - A machine-readable name for the section - - - - Description - - handleChange('description', value)} - /> - - - Conditional question - - - - Off: The section will always be visible
- On: The - section will only be visible when the conditional question - is answered with yes/no -
- - setIsConditional(value)} - color="primary" - /> - } - label="Is this a conditional field?" - /> - - {isConditional && ( - <> - - - Conditional question - - - Type here your yes/no question. If yes, the section - question will be shown - - - handleChange('conditional', value) - } - /> - - )} -
- - - - - -
- ) -} From 5d7f2ea2e9c6d22cac9d79b3f5023a8bbd86ee0a Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 20 Feb 2024 14:23:42 +0200 Subject: [PATCH 06/58] Added helper text to EditableText to avoid blank invisible fields --- .../organiser/edit/questions/index.js | 60 ------------------- .../components/section/EditableText.js | 6 +- 2 files changed, 3 insertions(+), 63 deletions(-) diff --git a/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/questions/index.js b/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/questions/index.js index 60c91068a..57b120099 100644 --- a/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/questions/index.js +++ b/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/questions/index.js @@ -8,66 +8,6 @@ import FormControl from 'components/inputs/FormControl' import QuestionSelect from './QuestionSelect' export default () => { - // const buildColumns = useCallback((form, field, fieldValue) => { - // return [ - // { - // Header: 'Name', - // accessor: 'label', - // }, - // { - // Header: 'Category', - // accessor: 'category', - // }, - // { - // Header: 'Enabled?', - // accessor: 'enabled', - // Cell: props => { - // const row = props.row.original - // return ( - // { - // form.setFieldValue(field.name, { - // ...fieldValue, - // [row.key]: { - // ...fieldValue[row.key], - // enable, - // require: !enable ? false : row.require, - // }, - // }) - // }} - // /> - // ) - // }, - // }, - // { - // Header: 'Required?', - // accessor: 'require', - // Cell: props => { - // const row = props.row.original - // return ( - // { - // form.setFieldValue(field.name, { - // ...fieldValue, - // [row.key]: { - // ...fieldValue[row.key], - // require, - // }, - // }) - // }} - // /> - // ) - // }, - // }, - // ] - // }, []) - return ( diff --git a/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/submission/components/section/EditableText.js b/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/submission/components/section/EditableText.js index bec009ccc..c625e521f 100644 --- a/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/submission/components/section/EditableText.js +++ b/frontend/src/pages/_dashboard/renderDashboard/organiser/edit/submission/components/section/EditableText.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useEffect } from 'react' const typeToClass = { heading: 'tw-text-xl tw-font-bold', @@ -22,7 +22,7 @@ const EditableText = ({ value, save, className = '', type = 'default' }) => { } } - React.useEffect(() => { + useEffect(() => { setCurrentValue(value) }, [value]) @@ -42,7 +42,7 @@ const EditableText = ({ value, save, className = '', type = 'default' }) => { onClick={() => setIsEditable(true)} className={`tw-w-full tw-items-start tw-justify-start tw-text-gray-800 tw-cursor-pointer ${displayClass}`} > - {currentValue} + {currentValue || 'Click to edit'} ) } From 34b51cabc91886662cc842faf892dc26b0308a90 Mon Sep 17 00:00:00 2001 From: David Amebley Date: Fri, 23 Feb 2024 02:26:50 +0200 Subject: [PATCH 07/58] Create new modal for displaying preview of Event Page Customization --- .../slug/edit/default/EventPageCustomizationPreviewModal.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 frontend/src/pages/_organise/slug/edit/default/EventPageCustomizationPreviewModal.js diff --git a/frontend/src/pages/_organise/slug/edit/default/EventPageCustomizationPreviewModal.js b/frontend/src/pages/_organise/slug/edit/default/EventPageCustomizationPreviewModal.js new file mode 100644 index 000000000..e69de29bb From 3fae76aec6465869b769a946b46ea9c20d862f61 Mon Sep 17 00:00:00 2001 From: David Amebley Date: Sat, 24 Feb 2024 00:54:17 +0200 Subject: [PATCH 08/58] Add state for controlling preview modal open state --- frontend/src/pages/_organise/slug/edit/default/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/_organise/slug/edit/default/index.js b/frontend/src/pages/_organise/slug/edit/default/index.js index 01bf8ca0e..019144719 100644 --- a/frontend/src/pages/_organise/slug/edit/default/index.js +++ b/frontend/src/pages/_organise/slug/edit/default/index.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useState } from 'react' import { useDispatch, useSelector } from 'react-redux' import { Grid, Box, Typography, TextField } from '@material-ui/core' @@ -69,6 +69,7 @@ const themeFields = [ export default () => { const event = useSelector(OrganiserSelectors.event) const [organizations] = useAllOrganizations() + const [previewOpen, setPreviewOpen] = useState(false) const dispatch = useDispatch() return ( From 2439bb3f4bbef6a341349ea8ab0fbdc3254b5471 Mon Sep 17 00:00:00 2001 From: David Amebley Date: Sat, 24 Feb 2024 01:59:17 +0200 Subject: [PATCH 09/58] Add initial code for the structure of the EventPageCustomizationPreviewModal component to show preview of customized event page --- .../EventPageCustomizationPreviewModal.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/frontend/src/pages/_organise/slug/edit/default/EventPageCustomizationPreviewModal.js b/frontend/src/pages/_organise/slug/edit/default/EventPageCustomizationPreviewModal.js index e69de29bb..ae2b90691 100644 --- a/frontend/src/pages/_organise/slug/edit/default/EventPageCustomizationPreviewModal.js +++ b/frontend/src/pages/_organise/slug/edit/default/EventPageCustomizationPreviewModal.js @@ -0,0 +1,27 @@ +import React from 'react' +import { Dialog, DialogTitle, DialogContent, Button } from '@material-ui/core' + +export default function PreviewModal({ open, onClose, eventSlug }) { + return ( + + Event Preview + + {/* Embedding the event page preview here. We could use an iframe or any other component that renders the preview */} +