security.txt + bugfixes

This commit is contained in:
2023-03-05 15:30:06 +01:00
parent 5acd13b945
commit c8965e209b
32 changed files with 336 additions and 46 deletions

View File

@@ -23,6 +23,10 @@
text-align: center;
}
.font-monospace {
font-family: monospace;
}
.data-table-clickable {
cursor: pointer;
}

View File

@@ -184,6 +184,60 @@ export class StringColumn extends DataColumn {
}
}
export class ArrayColumn extends DataColumn {
constructor(label, field = null, params = {}) {
super(label, field, params);
this.seperator = params.seperator || ", ";
}
renderData(L, entry, index) {
let data = super.renderData(L, entry, index);
if (!Array.isArray(data)) {
data = Object.values(data);
}
data = data.join(this.seperator);
if (this.params.style) {
let style = (typeof this.params.style === 'function'
? this.params.style(entry) : this.params.style);
data = <span style={style}>{data}</span>
}
return data;
}
}
export class SecretsColumn extends DataColumn {
constructor(label, field = null, params = {}) {
super(label, field, params);
this.asteriskCount = params.asteriskCount || 8;
this.character = params.character || "*";
this.canCopy = params.hasOwnProperty("canCopy") ? params.canCopy : true;
}
renderData(L, entry, index) {
let originalData = super.renderData(L, entry, index);
if (!originalData) {
return "(None)";
}
let properties = this.params.properties || {};
properties.className = clsx(properties.className, "font-monospace");
if (this.canCopy) {
properties.title = L("Click to copy");
properties.className = clsx(properties.className, "data-table-clickable");
properties.onClick = () => {
navigator.clipboard.writeText(originalData);
};
}
return <span {...properties}>{this.character.repeat(this.asteriskCount)}</span>
}
}
export class NumericColumn extends DataColumn {
constructor(label, field = null, params = {}) {
super(label, field, params);

View File

@@ -7,7 +7,7 @@ import {
DialogContent,
DialogContentText,
DialogTitle,
Input, List, ListItem, Select, TextField
Input, List, ListItem, TextField
} from "@mui/material";
export default function Dialog(props) {
@@ -48,8 +48,10 @@ export default function Dialog(props) {
switch (input.type) {
case 'text':
case 'password':
inputElements.push(<TextField
{...inputProps}
type={input.type}
sx={{marginTop: 1}}
size={"small"} fullWidth={true}
key={"input-" + input.name}

View File

@@ -0,0 +1,16 @@
import {useCallback, useEffect} from "react";
export default function useBeforeUnload(modified) {
const capture = useCallback((event) => {
if (modified) {
event.preventDefault();
}
}, [modified]);
useEffect(() => {
window.addEventListener("beforeunload", capture, {capture: true});
return () => window.removeEventListener("beforeunload", capture, { capture: true });
}, []);
}

View File

@@ -0,0 +1,21 @@
import {useNavigate} from "react-router-dom";
export default function useEditorNavigate(L, showDialog) {
const navigate = useNavigate();
return (uri, modified, options = null) => {
if (!modified) {
navigate(uri, options ?? {});
} else {
showDialog(
"You still have unsaved changes, are you really sure you want to leave this view?",
"Unsaved changes",
[L("general.cancel"), L("general.leave")],
(buttonIndex) => buttonIndex === 1 && navigate(uri, options ?? {})
)
}
};
}

View File

@@ -297,7 +297,7 @@ export default function LoginForm(props) {
? <Alert severity="error">
{error}
{emailConfirmed === false
? <> <Link href={"/resendConfirmation"}>Click here</Link> to resend the confirmation email.</>
? <> <Link href={"/resendConfirmEmail"}>Click here</Link> to resend the confirmation email.</>
: <></>
}
</Alert>