-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from ssi-dk/feat/create-new-workspace-from-se…
…lection-microreact feat: create workspace from microreact selection
- Loading branch information
Showing
6 changed files
with
158 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/src/app/workspaces/create-workspace-from-microreact.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import HalfHolyGrailLayout from "layouts/half-holy-grail"; | ||
import React from "react"; | ||
import { Box, Heading, Button, Input } from "@chakra-ui/react"; | ||
import { AddIcon } from "@chakra-ui/icons"; | ||
import { useMutation } from "redux-query-react"; | ||
import { useLocation, Redirect } from "react-router-dom"; | ||
import { useMemo } from "react"; | ||
import { createWorkspace } from "./workspaces-query-configs"; | ||
|
||
export function CreateWorkspaceFromMicroreact() { | ||
const [name, setName] = React.useState(""); | ||
const { search } = useLocation(); | ||
const searchParams = useMemo(() => new URLSearchParams(search), [search]); | ||
const [isSending, setIsSending] = React.useState(false); | ||
const [isCreated, setIsCreated] = React.useState(false); | ||
const [isRequired, setIsRequired] = React.useState(false) | ||
|
||
const [ | ||
createWorkspaceQueryState, | ||
createWorkspaceMutation, | ||
] = useMutation((workspaceName: string, samples: string[]) => createWorkspace({ name: workspaceName, samples: samples })); | ||
|
||
const content = ( | ||
<React.Fragment> | ||
<Box role="navigation" gridColumn="2 / 4" pb={5}> | ||
<div style={{ display: "flex", justifyContent: "space-between" }}> | ||
<Heading>New workspace</Heading> | ||
<div style={{ width: "300px" }}></div> | ||
</div> | ||
</Box> | ||
<Box role="main" gridColumn="2 / 4" borderWidth="1px" rounded="md"> | ||
<Input | ||
placeholder="Workspace name" | ||
value={name} | ||
required={isRequired} | ||
onChange={(x) => { | ||
setName(x.target.value); | ||
}} | ||
/> | ||
|
||
<Button | ||
leftIcon={<AddIcon />} | ||
onClick={() => { | ||
if(!name){ | ||
setIsRequired(true) | ||
setTimeout(() => setIsRequired(false), 250) | ||
return; | ||
} | ||
setIsSending(true) | ||
const ids = searchParams.get("ids"); | ||
if (ids) { | ||
const idArr = ids.split(","); | ||
createWorkspaceMutation(name, idArr ); | ||
setIsCreated(true) | ||
setIsSending(false) | ||
alert("Workspace created.") | ||
} | ||
}} | ||
disabled={isSending && !isCreated} | ||
> | ||
{"Create workspace"} | ||
</Button> | ||
</Box> | ||
{isCreated ? <Redirect to="/workspaces" /> : null} | ||
</React.Fragment> | ||
); | ||
|
||
return <HalfHolyGrailLayout content={content} sidebar={null} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,77 @@ | ||
module.exports = { | ||
externalRequests: { | ||
secret: process.env.MICROREACT_ENCRYPTION_SECRET | ||
}, | ||
auth: { | ||
openidconnect: { | ||
id: "keycloak", | ||
name: "Keycloak", | ||
wellKnown: process.env.AUTH_WELLKNOWN_URI, | ||
type: "oauth", | ||
authorization: { | ||
params: { | ||
scope: "openid email profile" | ||
} | ||
}, | ||
checks:[], | ||
idToken: true, | ||
clientSecret: "can-be-any-thing-not-used", | ||
clientId: "SOFI_APP", | ||
idAttribute: "sub" | ||
}, | ||
email: { | ||
server: { | ||
host: process.env.SMTP_HOST, | ||
port: parseInt(process.env.SMTP_PORT), | ||
auth: { | ||
user: process.env.SMTP_USER, | ||
pass: process.env.SMTP_PASS | ||
}, | ||
secure: process.env.SMTP_SECURE === "true" | ||
}, | ||
from: "Microreact <[email protected]>", | ||
subject: "Login link for Microreact", | ||
text: "Hello!\nAccess your account here: http://localhost:80/auth/passwordless/callback?token=<%= tokenToSend %>&uid=", | ||
html: "views/emails/passwordless.html" | ||
}, | ||
secret: process.env.AUTH_SECRET, | ||
session: { | ||
maxAge: 2592000, | ||
updateAge: 86400 | ||
} | ||
}, | ||
baseUrl: process.env.BASE_URL, | ||
bodySizeLimit: "16mb", | ||
experimentalFlags: { | ||
publicFolders: false | ||
}, | ||
helpDesk: { | ||
email: "[email protected]", | ||
subject: "Feedback from Microreact.org" | ||
}, | ||
mapboxApiAccessToken: "NOT-USED", | ||
mongodb: { | ||
url: process.env.MONGODB_CONNECTION, | ||
database: process.env.MONGODB_DATABASE | ||
}, | ||
repoPath: "./files", | ||
showcaseFolders: [], | ||
smtp: { | ||
host: process.env.SMTP_HOST, | ||
port: parseInt(process.env.SMTP_PORT), | ||
auth: { | ||
user: process.env.SMTP_USER, | ||
pass: process.env.SMTP_PASS | ||
}, | ||
secure: process.env.SMTP_SECURE === "true", | ||
from: "Microreact <[email protected]>" | ||
} | ||
module.exports = { | ||
externalRequests: { | ||
secret: process.env.MICROREACT_ENCRYPTION_SECRET | ||
}, | ||
downloadActions: [ | ||
{ | ||
id: "createnewworkspace", | ||
label: "Create new workspace from selection", | ||
type: "selection", | ||
url: process.env.SOFI_BASE_URL + "/createworkspace?ids=" | ||
} | ||
], | ||
auth: { | ||
openidconnect: { | ||
id: "keycloak", | ||
name: "Keycloak", | ||
wellKnown: process.env.AUTH_WELLKNOWN_URI, | ||
type: "oauth", | ||
authorization: { | ||
params: { | ||
scope: "openid email profile" | ||
} | ||
}, | ||
checks:[], | ||
idToken: true, | ||
clientSecret: "can-be-any-thing-not-used", | ||
clientId: "SOFI_APP", | ||
idAttribute: "sub" | ||
}, | ||
email: { | ||
server: { | ||
host: process.env.SMTP_HOST, | ||
port: parseInt(process.env.SMTP_PORT), | ||
auth: { | ||
user: process.env.SMTP_USER, | ||
pass: process.env.SMTP_PASS | ||
}, | ||
secure: process.env.SMTP_SECURE === "true" | ||
}, | ||
from: "Microreact <[email protected]>", | ||
subject: "Login link for Microreact", | ||
text: "Hello!\nAccess your account here: http://localhost:80/auth/passwordless/callback?token=<%= tokenToSend %>&uid=", | ||
html: "views/emails/passwordless.html" | ||
}, | ||
secret: process.env.AUTH_SECRET, | ||
session: { | ||
maxAge: 2592000, | ||
updateAge: 86400 | ||
} | ||
}, | ||
baseUrl: process.env.BASE_URL, | ||
bodySizeLimit: "16mb", | ||
experimentalFlags: { | ||
publicFolders: false | ||
}, | ||
helpDesk: { | ||
email: "[email protected]", | ||
subject: "Feedback from Microreact.org" | ||
}, | ||
mapboxApiAccessToken: "NOT-USED", | ||
mongodb: { | ||
url: process.env.MONGODB_CONNECTION, | ||
database: process.env.MONGODB_DATABASE | ||
}, | ||
repoPath: "./files", | ||
showcaseFolders: [], | ||
smtp: { | ||
host: process.env.SMTP_HOST, | ||
port: parseInt(process.env.SMTP_PORT), | ||
auth: { | ||
user: process.env.SMTP_USER, | ||
pass: process.env.SMTP_PASS | ||
}, | ||
secure: process.env.SMTP_SECURE === "true", | ||
from: "Microreact <[email protected]>" | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters