1
0
Fork 0

Compare commits

...

4 Commits

Author SHA1 Message Date
Elias Schneider 47188a47a7
Merge ab553e9608 into f52dffdaac 2024-02-16 18:06:37 +00:00
Elias Schneider ab553e9608 New translations en-us.ts (Italian) 2024-02-16 19:06:35 +01:00
Elias Schneider f52dffdaac
fix: back links on error modals 2024-02-05 16:13:54 +01:00
Elias Schneider e572506d4f
refactor: run formatter 2024-02-05 16:11:49 +01:00
8 changed files with 57 additions and 30 deletions

View File

@ -139,7 +139,7 @@ export class AuthService {
async updatePassword(user: User, newPassword: string, oldPassword?: string) {
const isPasswordValid =
!user.password || await argon.verify(user.password, oldPassword);
!user.password || (await argon.verify(user.password, oldPassword));
if (!isPasswordValid) throw new ForbiddenException("Invalid password");

View File

@ -1,4 +1,11 @@
import { Button, Center, Stack, Text, Title, useMantineTheme } from "@mantine/core";
import {
Button,
Center,
Stack,
Text,
Title,
useMantineTheme,
} from "@mantine/core";
import { modals } from "@mantine/modals";
import Link from "next/link";
import React, { Dispatch, SetStateAction, useEffect, useState } from "react";
@ -116,41 +123,38 @@ const ImagePreview = () => {
const TextPreview = () => {
const { shareId, fileId } = React.useContext(FilePreviewContext);
const [ text, setText ] = useState<string>("");
const [text, setText] = useState<string>("");
const { colorScheme } = useMantineTheme();
useEffect(() => {
api
.get(`/shares/${shareId}/files/${fileId}?download=false`)
.then((res) => setText(res.data ?? "Preview couldn't be fetched."));
}, [ shareId, fileId ]);
}, [shareId, fileId]);
const options = {
overrides: {
pre: {
props: {
style: {
backgroundColor: colorScheme == "dark"
? "rgba(50, 50, 50, 0.5)"
: "rgba(220, 220, 220, 0.5)",
backgroundColor:
colorScheme == "dark"
? "rgba(50, 50, 50, 0.5)"
: "rgba(220, 220, 220, 0.5)",
padding: "0.75em",
whiteSpace: "pre-wrap",
}
}
},
},
},
table: {
props: {
className: "md"
}
}
}
className: "md",
},
},
},
};
return (
<Markdown options={options}>
{text}
</Markdown>
);
return <Markdown options={options}>{text}</Markdown>;
};
const PdfPreview = () => {

View File

@ -8,6 +8,7 @@ const showErrorModal = (
modals: ModalsContextProps,
title: string,
text: string,
action: "go-back" | "go-home" = "go-back",
) => {
return modals.openModal({
closeOnClickOutside: false,
@ -15,11 +16,17 @@ const showErrorModal = (
closeOnEscape: false,
title: title,
children: <Body text={text} />,
children: <Body text={text} action={action} />,
});
};
const Body = ({ text }: { text: string }) => {
const Body = ({
text,
action,
}: {
text: string;
action: "go-back" | "go-home";
}) => {
const modals = useModals();
const router = useRouter();
return (
@ -29,10 +36,14 @@ const Body = ({ text }: { text: string }) => {
<Button
onClick={() => {
modals.closeAll();
router.back();
if (action === "go-back") {
router.back();
} else if (action === "go-home") {
router.push("/");
}
}}
>
<FormattedMessage id="common.button.go-back" />
<FormattedMessage id={`common.button.${action}`} />
</Button>
</Stack>
</>

View File

@ -529,6 +529,7 @@ export default {
"common.text.navigate-to-link": "Go to the link",
"common.text.or": "or",
"common.button.go-back": "Go back",
"common.button.go-home": "Go home",
"common.notify.copied": "Your link was copied to the clipboard",
"common.success": "Success",

View File

@ -262,7 +262,7 @@ export default {
"share.table.name": "Nome",
"share.table.size": "Dimensione",
"share.modal.file-preview.error.not-supported.title": "Anteprima non supportata",
"share.modal.file-preview.error.not-supported.description": "A preview for this file type is unsupported. Please download the file to view it.",
"share.modal.file-preview.error.not-supported.description": "Un'anteprima per questo tipo di file non è supportata. Per favore scarica il file per visualizzarlo.",
// END /share/[id]
// /share/[id]/edit
"share.edit.title": "Modifica {shareId}",
@ -407,7 +407,7 @@ export default {
"common.text.navigate-to-link": "Vai al collegamento",
"common.text.or": "o",
"common.button.go-back": "Torna indietro",
"common.button.go-home": "Go home",
"common.button.go-home": "Vai alla Home Page",
"common.notify.copied": "Il tuo collegamento e' stato copiato negli appunti",
"common.success": "Successo",
"common.error": "Errore",

View File

@ -37,6 +37,7 @@ const Share = ({ shareId }: { shareId: string }) => {
modals,
t("share.error.visitor-limit-exceeded.title"),
t("share.error.visitor-limit-exceeded.description"),
"go-home",
);
} else {
toast.axiosError(e);
@ -58,12 +59,14 @@ const Share = ({ shareId }: { shareId: string }) => {
modals,
t("share.error.removed.title"),
e.response.data.message,
"go-home",
);
} else {
showErrorModal(
modals,
t("share.error.not-found.title"),
t("share.error.not-found.description"),
"go-home",
);
}
} else if (error == "share_password_required") {
@ -71,7 +74,12 @@ const Share = ({ shareId }: { shareId: string }) => {
} else if (error == "share_token_required") {
getShareToken();
} else {
showErrorModal(modals, t("common.error"), t("common.error.unknown"));
showErrorModal(
modals,
t("common.error"),
t("common.error.unknown"),
"go-home",
);
}
});
};

View File

@ -30,6 +30,7 @@ const Share = ({ reverseShareToken }: { reverseShareToken: string }) => {
modals,
"Invalid Link",
"This link is invalid. Please check your link.",
"go-home",
);
setIsLoading(false);
});

View File

@ -8,11 +8,13 @@ const GlobalStyle = () => {
color: "inherit",
textDecoration: "none",
},
"table.md, table.md th:nth-of-type(odd), table.md td:nth-of-type(odd)": {
background: theme.colorScheme == "dark"
? "rgba(50, 50, 50, 0.5)"
: "rgba(220, 220, 220, 0.5)",
},
"table.md, table.md th:nth-of-type(odd), table.md td:nth-of-type(odd)":
{
background:
theme.colorScheme == "dark"
? "rgba(50, 50, 50, 0.5)"
: "rgba(220, 220, 220, 0.5)",
},
"table.md td": {
paddingLeft: "0.5em",
paddingRight: "0.5em",