Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add env metadata edit #260

Merged
merged 5 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
REACT_APP_SERVER_HOST=localhost
REACT_APP_SERVER_PORT=8000
REACT_APP_SERVER_PROTO=http

# configs
REACT_APP_EXPDB_METADATA_EDITABLE=true
14 changes: 10 additions & 4 deletions frontend/src/components/Database/DatabaseExperiments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type PopupAttributesProps = {
handleChangeAttributes: (e: ChangeEvent<HTMLTextAreaElement>) => void
exp_id?: string
onSubmit: () => void
readonly?: boolean
}

type DatabaseProps = {
Expand Down Expand Up @@ -325,9 +326,9 @@ const PopupAttributes = ({
role = false,
handleChangeAttributes,
onSubmit,
readonly,
}: PopupAttributesProps) => {
const [error, setError] = useState("")

const isValidJSON = (str: string) => {
try {
JSON.parse(str)
Expand Down Expand Up @@ -366,7 +367,11 @@ const PopupAttributes = ({
>
<DialogContent sx={{ minWidth: 400 }}>
<DialogContentText>
<Content readOnly={!role} value={data} onChange={handleChange} />
<Content
readOnly={!role || readonly}
value={data}
onChange={handleChange}
/>
<span style={{ color: "red", display: "block" }}>{error}</span>
</DialogContentText>
</DialogContent>
Expand All @@ -381,7 +386,7 @@ const PopupAttributes = ({
>
Close
</Button>
{role && (
{role && !readonly && (
<Button variant={"contained"} disabled={!!error} onClick={onSubmit}>
Save
</Button>
Expand Down Expand Up @@ -1049,7 +1054,8 @@ const DatabaseExperiments = ({
open={dataDialog.type === "attribute"}
handleClose={handleCloseDialog}
onSubmit={onSubmitAttributes}
role={!!adminOrManager}
role={!!adminOrManager && !!user}
readonly={readonly}
/>
{loading ? <Loading /> : null}
{openShare.open && openShare.id ? (
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/pages/Database/Experiments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import DatabaseExperiments from "components/Database/DatabaseExperiments"
import DatabaseWrapper from "components/Database/DatabaseWrapper"
import { selectCurrentUser } from "store/slice/User/UserSelector"

const METADATA = process.env.REACT_APP_EXPDB_METADATA_EDITABLE === "true"

const Experiments = () => {
const user = useSelector(selectCurrentUser)

return (
<DatabaseWrapper>
<DatabaseExperiments user={user} cellPath="/console/cells" />
<DatabaseExperiments
user={user}
readonly={!METADATA}
cellPath="/console/cells"
/>
</DatabaseWrapper>
)
}
Expand Down