-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move rsd remote name functionality to admin section instead…
… using env variable
- Loading branch information
1 parent
7b75b24
commit 19c8829
Showing
17 changed files
with
863 additions
and
86 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
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
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# SPDX-FileCopyrightText: 2022 - 2024 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences | ||
# SPDX-FileCopyrightText: 2022 Helmholtz Centre for Environmental Research (UFZ) | ||
# SPDX-FileCopyrightText: 2022 Matthias Rüster (GFZ) <[email protected]> | ||
# SPDX-FileCopyrightText: 2023 - 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
# SPDX-FileCopyrightText: 2023 - 2025 Dusan Mijatovic (Netherlands eScience Center) | ||
# SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) (dv4all) | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
@@ -26,9 +26,6 @@ services: | |
- POSTGRES_USER | ||
- POSTGRES_PASSWORD | ||
- POSTGRES_AUTHENTICATOR_PASSWORD | ||
- RSD_REMOTE_NAME | ||
# insert remote_name into postgres settings, this value is used in initial SQL scripts | ||
command: postgres -D /var/lib/postgresql/data -c 'rsd.remote_name=${RSD_REMOTE_NAME}' | ||
volumes: | ||
# persist data in named docker volume | ||
# to remove use: docker compose down --volumes | ||
|
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,5 +1,5 @@ | ||
// SPDX-FileCopyrightText: 2023 - 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2023 - 2024 Netherlands eScience Center | ||
// SPDX-FileCopyrightText: 2023 - 2025 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2023 - 2025 Netherlands eScience Center | ||
// SPDX-FileCopyrightText: 2023 Christian Meeßen (GFZ) <[email protected]> | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) | ||
// SPDX-FileCopyrightText: 2023 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences | ||
|
@@ -31,6 +31,7 @@ import CategoryIcon from '@mui/icons-material/Category' | |
import TerminalIcon from '@mui/icons-material/Terminal' | ||
import ListAltIcon from '@mui/icons-material/ListAlt' | ||
import HubIcon from '@mui/icons-material/Hub' | ||
import CookieIcon from '@mui/icons-material/Cookie' | ||
|
||
import {editMenuItemButtonSx} from '~/config/menuItems' | ||
|
||
|
@@ -107,6 +108,12 @@ export const adminPages = { | |
icon: <ReceiptLongIcon />, | ||
path: '/admin/mentions', | ||
}, | ||
rsd_info:{ | ||
title: 'Rsd info', | ||
subtitle: '', | ||
icon: <CookieIcon />, | ||
path: '/admin/rsd-info', | ||
}, | ||
remote_rsd: { | ||
title: 'Remotes', | ||
subtitle: '', | ||
|
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 |
---|---|---|
@@ -0,0 +1,167 @@ | ||
// SPDX-FileCopyrightText: 2025 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2025 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import {useState} from 'react' | ||
import Button from '@mui/material/Button' | ||
import AddIcon from '@mui/icons-material/Add' | ||
import useMediaQuery from '@mui/material/useMediaQuery' | ||
import Dialog from '@mui/material/Dialog' | ||
import DialogTitle from '@mui/material/DialogTitle' | ||
import DialogContent from '@mui/material/DialogContent' | ||
import DialogActions from '@mui/material/DialogActions' | ||
|
||
import {useForm} from 'react-hook-form' | ||
|
||
import TextFieldWithCounter from '~/components/form/TextFieldWithCounter' | ||
import ControlledSwitch from '~/components/form/ControlledSwitch' | ||
import SubmitButtonWithListener from '~/components/form/SubmitButtonWithListener' | ||
import {RsdInfo} from './apiRsdInfo' | ||
import {rsdInfoForm} from './config' | ||
|
||
type RsdInfoModalProps=Readonly<{ | ||
onCancel: () => void, | ||
onSubmit: (item: RsdInfo) => void | ||
}> | ||
|
||
const formId='add-remote-rsd-form' | ||
|
||
function RsdInfoModal({onCancel,onSubmit}:RsdInfoModalProps){ | ||
const smallScreen = useMediaQuery('(max-width:600px)') | ||
const {formState:{errors,isValid,isDirty}, control, watch, register, handleSubmit} = useForm<RsdInfo>({ | ||
mode: 'onChange', | ||
|
||
}) | ||
|
||
// watch for data change in the form | ||
const [key,value] = watch(['key','value']) | ||
|
||
function handleCancel(e:any,reason: 'backdropClick' | 'escapeKeyDown') { | ||
// close only on escape, not if user clicks outside of the modal | ||
if (reason==='escapeKeyDown') onCancel() | ||
} | ||
|
||
return ( | ||
<Dialog | ||
// use fullScreen modal for small screens (< 600px) | ||
fullScreen={smallScreen} | ||
open={true} | ||
onClose={handleCancel} | ||
> | ||
<DialogTitle sx={{ | ||
fontSize: '1.5rem', | ||
borderBottom: '1px solid', | ||
borderColor: 'divider', | ||
color: 'primary.main', | ||
fontWeight: 500 | ||
}}> | ||
{rsdInfoForm.modalTitle} | ||
</DialogTitle> | ||
<form | ||
id={formId} | ||
onSubmit={handleSubmit(onSubmit)} | ||
className="w-full"> | ||
|
||
<DialogContent sx={{ | ||
width: ['100%', '37rem'], | ||
padding: '2rem 1.5rem 2.5rem' | ||
}}> | ||
<TextFieldWithCounter | ||
options={{ | ||
autofocus:true, | ||
error: errors.key?.message !== undefined, | ||
label: rsdInfoForm.key.label, | ||
helperTextMessage: errors?.key?.message ?? rsdInfoForm.key.help, | ||
helperTextCnt: `${key?.length || 0}/${rsdInfoForm.key.validation.maxLength.value}`, | ||
variant:'outlined', | ||
// endAdornment: validating ? <CircularProgress /> : undefined | ||
}} | ||
register={register('key', { | ||
...rsdInfoForm.key.validation | ||
})} | ||
/> | ||
|
||
<div className="py-4" /> | ||
|
||
<TextFieldWithCounter | ||
options={{ | ||
error: errors.value?.message !== undefined, | ||
label: rsdInfoForm.value.label, | ||
helperTextMessage: errors?.value?.message ?? rsdInfoForm.value.help, | ||
helperTextCnt: `${value?.length || 0}/${rsdInfoForm.value.validation.maxLength.value}`, | ||
variant:'outlined', | ||
// endAdornment: validating ? <CircularProgress /> : undefined | ||
}} | ||
register={register('value', { | ||
...rsdInfoForm.value.validation | ||
})} | ||
/> | ||
|
||
<div className="grid grid-cols-2 gap-20 items-start pt-8"> | ||
<ControlledSwitch | ||
label="Public" | ||
name="public" | ||
control={control} | ||
defaultValue={true} | ||
/> | ||
</div> | ||
|
||
</DialogContent> | ||
<DialogActions sx={{ | ||
padding: '1rem 1.5rem', | ||
borderTop: '1px solid', | ||
borderColor: 'divider' | ||
}}> | ||
<Button | ||
onClick={onCancel} | ||
color="secondary" | ||
sx={{marginRight:'2rem'}} | ||
> | ||
Cancel | ||
</Button> | ||
<SubmitButtonWithListener | ||
formId={formId} | ||
disabled={isSubmitDisabled()} | ||
/> | ||
</DialogActions> | ||
</form> | ||
</Dialog> | ||
) | ||
|
||
function isSubmitDisabled(){ | ||
if (isValid===false) return true | ||
// we need additional check on errors object | ||
// due to custom validation of domain | ||
if (Object.keys(errors).length > 0) return true | ||
if (isDirty===false) return true | ||
return false | ||
} | ||
} | ||
|
||
|
||
export default function AddRsdInfo({onAdd}:Readonly<{onAdd:(data:RsdInfo)=>void}>) { | ||
const [modal,setModal] = useState(false) | ||
|
||
return ( | ||
<> | ||
<Button | ||
variant='contained' | ||
startIcon={<AddIcon/> } | ||
onClick={()=>setModal(true)} | ||
> | ||
Add | ||
</Button> | ||
{ | ||
modal ? <RsdInfoModal | ||
onCancel={()=>setModal(false)} | ||
onSubmit={(data)=>{ | ||
setModal(false) | ||
onAdd(data) | ||
}} | ||
/> | ||
: null | ||
} | ||
</> | ||
) | ||
} |
Oops, something went wrong.