Skip to content

Commit 58d76a4

Browse files
authored
Merge pull request #94 from jspsych/test
Release multi-region support
2 parents ac3896a + d200393 commit 58d76a4

File tree

6 files changed

+51
-39
lines changed

6 files changed

+51
-39
lines changed

.github/workflows/firebase-deploy-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
cache: "npm"
3030
- uses: 'google-github-actions/auth@v2'
3131
with:
32-
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' # Replace with the name of your GitHub Actions secret
32+
credentials_json: '${{ secrets.GOOGLE_TEST_CREDENTIALS }}' # Replace with the name of your GitHub Actions secret
3333
- name: Install firebase tools
3434
run: npm install -g firebase-tools@12.1.0
3535
- name: Enable firebase webframeworks

.github/workflows/firebase-deploy.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
branches: ["main"]
99

1010
env:
11-
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
11+
#FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
1212
NEXT_PUBLIC_FIREBASE_CONFIG: ${{ secrets.FIREBASE_PRODUCTION_CONFIG }}
1313

1414

@@ -18,7 +18,7 @@ jobs:
1818

1919
strategy:
2020
matrix:
21-
node-version: [16.x]
21+
node-version: [20.x]
2222
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2323

2424
steps:
@@ -28,6 +28,9 @@ jobs:
2828
with:
2929
node-version: ${{ matrix.node-version }}
3030
cache: "npm"
31+
- uses: 'google-github-actions/auth@v2'
32+
with:
33+
credentials_json: '${{ secrets.GOOGLE_PRODUCTION_CREDENTIALS }}'
3134
- name: Install firebase tools
3235
run: npm install -g firebase-tools@12.1.0
3336
- name: Enable firebase webframeworks

README.md

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
### Live Server
1+
# DataPipe
22

3-
https://pipe.jspsych.org
4-
5-
### Development
3+
Send your experiment data directly to the OSF, for free.
64

7-
```
8-
npm install -g firebase-tools
9-
npm install
10-
npm run emulators
11-
```
5+
https://pipe.jspsych.org
126

13-
The local site will be available at localhost:5000.

functions/package-lock.json

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

functions/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"logs": "firebase functions:log"
1010
},
1111
"engines": {
12-
"node": "16"
12+
"node": "20"
1313
},
1414
"main": "index.js",
1515
"type": "module",
@@ -18,7 +18,7 @@
1818
"csv-string": "^4.1.1",
1919
"express": "^4.18.2",
2020
"firebase-admin": "^11.9.0",
21-
"firebase-functions": "^4.4.0",
21+
"firebase-functions": "^4.8.0",
2222
"is-base64": "^1.1.0",
2323
"joi": "^17.7.0",
2424
"node-fetch": "^3.2.10"

pages/admin/new.js

+31-15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { customAlphabet } from "nanoid";
22
import AuthCheck from "../../components/AuthCheck";
3-
import {
4-
doc,
5-
getDoc,
6-
writeBatch,
7-
arrayUnion,
8-
} from "firebase/firestore";
3+
import { doc, getDoc, writeBatch, arrayUnion } from "firebase/firestore";
94
import { db, auth } from "../../lib/firebase";
105
import { useContext, useState } from "react";
116
import { UserContext } from "../../lib/context";
@@ -26,6 +21,7 @@ import {
2621
FormHelperText,
2722
VStack,
2823
Text,
24+
Select,
2925
} from "@chakra-ui/react";
3026

3127
export default function NewExperimentPage({}) {
@@ -42,7 +38,7 @@ function NewExperimentForm() {
4238
const [osfError, setOsfError] = useState(false);
4339
const [titleError, setTitleError] = useState(false);
4440
const [dataComponentError, setDataComponentError] = useState(false);
45-
41+
4642
const [data, loading, error] = useDocumentData(doc(db, "users", user.uid));
4743

4844
return (
@@ -53,8 +49,10 @@ function NewExperimentForm() {
5349
<Heading>Create a New Experiment</Heading>
5450
<FormControl id="title" isInvalid={titleError}>
5551
<FormLabel>Title</FormLabel>
56-
<Input type="text" onChange={()=>setTitleError(false)} />
57-
<FormErrorMessage color={"red"}>This field is required</FormErrorMessage>
52+
<Input type="text" onChange={() => setTitleError(false)} />
53+
<FormErrorMessage color={"red"}>
54+
This field is required
55+
</FormErrorMessage>
5856
</FormControl>
5957
<FormControl id="osf-repo" isInvalid={osfError}>
6058
<FormLabel>Existing OSF Project</FormLabel>
@@ -70,9 +68,26 @@ function NewExperimentForm() {
7068
</FormControl>
7169
<FormControl id="osf-component-name" isInvalid={dataComponentError}>
7270
<FormLabel>New OSF Data Component Name</FormLabel>
73-
<Input type="text" onChange={()=>setDataComponentError(false)}/>
74-
<FormErrorMessage color={"red"}>This field is required</FormErrorMessage>
75-
<FormHelperText color="gray">DataPipe will create a new component with this name in the OSF project and store all data in it.</FormHelperText>
71+
<Input type="text" onChange={() => setDataComponentError(false)} />
72+
<FormErrorMessage color={"red"}>
73+
This field is required
74+
</FormErrorMessage>
75+
<FormHelperText color="gray">
76+
DataPipe will create a new component with this name in the OSF
77+
project and store all data in it.
78+
</FormHelperText>
79+
</FormControl>
80+
<FormControl id="osf-component-region">
81+
<FormLabel>Storage Location</FormLabel>
82+
<Select defaultValue="us" sx={{'> option': {background: 'black', color: 'white'}}}>
83+
<option value="us">United States</option>
84+
<option value="de-1">Germany - Frankfurt</option>
85+
<option value="au-1">Australia - Sydney</option>
86+
<option value="ca-1">Canada - Montreal</option>
87+
</Select>
88+
<FormHelperText color="gray">
89+
Choose the region where the data will be stored.
90+
</FormHelperText>
7691
</FormControl>
7792
<Button
7893
onClick={() =>
@@ -120,6 +135,7 @@ async function handleCreateExperiment(
120135
const user = auth.currentUser;
121136
const title = document.querySelector("#title").value;
122137
let osfRepo = document.querySelector("#osf-repo").value;
138+
const region = document.querySelector("#osf-component-region").value;
123139
const osfComponentName = document.querySelector("#osf-component-name").value;
124140
const nConditions = 1;
125141
const useValidation = true;
@@ -128,13 +144,13 @@ async function handleCreateExperiment(
128144
const useSessionLimit = false;
129145
const maxSessions = 1;
130146

131-
if(title.length === 0) {
147+
if (title.length === 0) {
132148
setTitleError(true);
133149
setIsSubmitting(false);
134150
return;
135151
}
136152

137-
if(osfComponentName.length === 0) {
153+
if (osfComponentName.length === 0) {
138154
setDataComponentError(true);
139155
setIsSubmitting(false);
140156
return;
@@ -160,7 +176,7 @@ async function handleCreateExperiment(
160176
}
161177

162178
const osfResult = await fetch(
163-
`https://api.osf.io/v2/nodes/${osfRepo}/children/`,
179+
`https://api.osf.io/v2/nodes/${osfRepo}/children/?region=${region}`,
164180
{
165181
method: "POST",
166182
headers: {

0 commit comments

Comments
 (0)