Skip to content

Commit

Permalink
Merge pull request #97 from UtrechtUniversity/dev
Browse files Browse the repository at this point in the history
Second try with DotEnv
  • Loading branch information
Meefish authored Jan 21, 2025
2 parents b70dbfb + bd74506 commit 2d67b08
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 147 deletions.
3 changes: 3 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ runs:
using: 'composite'
steps:
- name: Set up Node.js
env:
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }}
uses: actions/setup-node@v3
with:
node-version: 20.17.0
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/CI_CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
name: Run Integration Tests
env:
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }}
runs-on: ubuntu-latest
needs: unit-tests

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.2",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
"web-vitals": "^2.1.4",
"dotenv": "^16.4.7"
},
"scripts": {
"start": "react-scripts start",
Expand Down Expand Up @@ -47,7 +48,6 @@
"@types/webpack-dev-server": "^4.7.1",
"cross-fetch": "^4.0.0",
"cypress": "^13.15.1",
"dotenv": "^16.4.7",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"msw": "^2.4.10",
Expand Down
2 changes: 1 addition & 1 deletion src/components/QuestionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const QuestionView: React.FC<QuestionViewProps> = ({ fields, experiment, loggedI
// If NOT creator
if (!isCreator) {
messageIcon = "/assets/MessageGraySVG.svg";
messageTitle = "Messages can only be linked by the creator of the experiment before it goes live";
messageTitle = "Messages can only be linked by the owner of the experiment before it goes live";
messageOnClick = () => {}; // No action
}
// Else if it IS creator, but experiment is not upcoming
Expand Down
127 changes: 0 additions & 127 deletions src/components/Questionnaire.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ const Dashboard: React.FC = () => {
</th>
{allExperimentsChecked && (
<th>
Creator
Owner
</th>
)}
</tr>
Expand Down
12 changes: 6 additions & 6 deletions src/pages/Experiment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const Experiment: React.FC = () => {
{ name: 'Responses on Questionnaires', value: currentExperiment.questionnaireActivity?.toString() || '0' },
{ name: 'Number of Messages', value: currentExperiment.numberOfMessages?.toString() || '0' },
{ name: 'Messages Sent', value: currentExperiment.messageActivity?.toString() || '0' },
{ name: 'Creator of the experiment', value: currentExperiment.user?.name || 'N/A' },
{ name: 'Owner of the experiment', value: currentExperiment.user?.name || 'N/A' },
];

// Navigation handlers
Expand Down Expand Up @@ -357,7 +357,7 @@ const Experiment: React.FC = () => {
}`}
title={
!isCreator
? 'An experiment can only be stopped by the creator when it is live'
? 'An experiment can only be stopped by the owner when it is live'
: status !== 'Live'
? 'An experiment can only be stopped when it is live'
: ''
Expand All @@ -375,14 +375,14 @@ const Experiment: React.FC = () => {
/>
</button>

{/* Delete Experiment (red if deletable and creator, else gray) */}
{/* Delete Experiment (red if deletable and owner, else gray) */}
<button
className={`experiment-button ${
isCreator && status !== 'Live' && status !== 'Completed' ? 'red-button' : 'gray-button'
}`}
title={
!isCreator
? 'An experiment can only be deleted by the creator before being live'
? 'An experiment can only be deleted by the owner before being live'
: status === 'Live' || status === 'Completed'
? 'An experiment can only be deleted while it is not live or completed'
: ''
Expand All @@ -400,14 +400,14 @@ const Experiment: React.FC = () => {
/>
</button>

{/* Edit Experiment (blue if Upcoming and creator, else gray) */}
{/* Edit Experiment (blue if Upcoming and owner, else gray) */}
<button
className={`experiment-button ${
status === 'Upcoming' && isCreator ? 'blue-button' : 'gray-button'
}`}
title={
!isCreator
? 'An experiment can only be edited by the creator before being live'
? 'An experiment can only be edited by the owner before being live'
: status !== 'Upcoming'
? 'An experiment can only be edited before being live'
: ''
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ const Export: React.FC = () => {
/>
</th>
{allExperimentsChecked && (
<th className="export-creator-header">Creator</th>
<th className="export-creator-header">Owner</th>
)}
<th className="export-actions-header">Export Options</th>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const Message: React.FC = () => {
disabled={status !== 'Upcoming' || !isCreator}
title={
!isCreator
? 'Messages can only be deleted by the creator of the experiment before it goes live'
? 'Messages can only be deleted by the owner of the experiment before it goes live'
: status !== 'Upcoming'
? 'Messages can only be deleted before the experiment goes live'
: ''
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MessageDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ const MessageDashboard: React.FC = () => {
disabled={!isCreator || status !== 'Upcoming'}
title={
!isCreator
? 'Messages can only be created by the creator of the experiment before it goes live'
? 'Messages can only be created by the owner of the experiment before it goes live'
: status !== 'Upcoming'
? 'Messages can only be created before the experiment goes live'
: ''
Expand Down
9 changes: 9 additions & 0 deletions src/pages/QuestionCreation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ const QuestionCreation: React.FC = () => {
}
}
}

if (fq.allowOpenResponse && fq.openResponseFormat?.trim()) {
try {
new RegExp(fq.openResponseFormat);
} catch {
alert(`Question "${fq.indexValue}" has an invalid regex: ${fq.openResponseFormat}`);
return false;
}
}
}
return true;
};
Expand Down
11 changes: 9 additions & 2 deletions src/pages/QuestionEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const QuestionEdit: React.FC = () => {
const [originalAnswerIDs, setOriginalAnswerIDs] = useState<string[]>([]);

useEffect(() => {
//BRRRRRRRRRRRRRRRRRRRRRRRRRRRRREEEEEEEEEAAAAAAAAAAAAAAAAAAAAAAAAKPPPPPPOIIIIINTS
if (questionnaire && Array.isArray(questionnaire.questions)) {
const questionIDs: string[] = [];
const answerIDs: string[] = [];
Expand Down Expand Up @@ -195,13 +194,21 @@ const QuestionEdit: React.FC = () => {
}
}
}

if (fq.allowOpenResponse && fq.openResponseFormat?.trim()) {
try {
new RegExp(fq.openResponseFormat);
} catch {
alert(`Question "${fq.indexValue}" has an invalid regex: ${fq.openResponseFormat}`);
return false;
}
}
}
return true;
};

const saveQuestionsAndAnswers = async () => {
try {
//BRRRRRRRRRRRRRRRRRRRRRRRRRRRRREEEEEEEEEAAAAAAAAAAAAAAAAAAAAAAAAKPPPPPPOIIIIINTS
const sortedQuestions = [...questions].sort((a, b) => a.indexValue - b.indexValue);
const finalQuestions = sortedQuestions.map(q => fullQuestions[q.localId]).filter(Boolean);

Expand Down
8 changes: 4 additions & 4 deletions src/pages/Questionnaire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ const Questionnaire: React.FC = () => {
disabled={status !== 'Upcoming' || !isCreator}
title={
!isCreator
? 'A questionnaire can only be deleted by the creator.'
? 'A questionnaire can only be deleted by the owner.'
: status !== 'Upcoming'
? 'Questionnaires can only be deleted before the experiment goes live.'
: ''
Expand All @@ -279,7 +279,7 @@ const Questionnaire: React.FC = () => {
disabled={status !== 'Upcoming' || !isCreator}
title={
!isCreator
? 'A questionnaire can only be edited by the creator.'
? 'A questionnaire can only be edited by the owner.'
: status !== 'Upcoming'
? 'Questionnaires can only be edited before the experiment goes live.'
: ''
Expand All @@ -304,7 +304,7 @@ const Questionnaire: React.FC = () => {
disabled={status !== 'Upcoming' || !isCreator}
title={
!isCreator
? 'Questions can only be edited by the creator of the experiment before it goes live'
? 'Questions can only be edited by the owner of the experiment before it goes live'
: status !== 'Upcoming'
? 'Questions can only be edited before the experiment goes live'
: ''
Expand All @@ -323,7 +323,7 @@ const Questionnaire: React.FC = () => {
disabled={status !== 'Upcoming' || !isCreator}
title={
!isCreator
? 'Questions can only be created by the creator of the experiment before it goes live'
? 'Questions can only be created by the owner of the experiment before it goes live'
: status !== 'Upcoming'
? 'Questions can only be created before the experiment goes live'
: ''
Expand Down
2 changes: 1 addition & 1 deletion src/pages/QuestionnaireDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ const QuestionnaireDashboard: React.FC = () => {
disabled={!isCreator || status !== 'Upcoming'}
title={
!isCreator
? 'A questionnaire can only be created by the creator of the experiment before it goes live.'
? 'A questionnaire can only be created by the owner of the experiment before it goes live.'
: status !== 'Upcoming'
? 'Questionnaires can only be created before the experiment goes live'
: 'Add Questionnaire'
Expand Down

0 comments on commit 2d67b08

Please sign in to comment.