ci(deploy): back up before migrating and run migrations explicitly (#9)
CD — Deployment / deploy (push) Successful in 23s
CD — Deployment / deploy (push) Successful in 23s
- dump the database to ./backups before applying migrations - run the one-shot migrate service on every deploy instead of relying only on the api depends_on, so a migration is never skipped - translate the workflow comments to English --------- Co-authored-by: xEsiah <[email protected]> Reviewed-on: #9 Reviewed-by: Esiah <[email protected]> Co-authored-by: Gitea Actions <-[email protected]>
This commit was merged in pull request #9.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { cn } from "../ui/index.js";
|
||||
import { api } from "../lib/api.js";
|
||||
import { useI18n } from "../lib/i18n.js";
|
||||
import { ArrowLeftIcon, ArrowRightIcon, CloseIcon, DownloadIcon, FileIcon } from "./icons.js";
|
||||
|
||||
export interface MediaViewerItem {
|
||||
@@ -29,6 +30,7 @@ const actionClass =
|
||||
"inline-flex items-center gap-2 rounded-md border border-white/20 bg-white/10 px-3.5 py-2 text-sm font-medium text-white transition-colors hover:bg-white/20";
|
||||
|
||||
const TextViewer = ({ id }: { id: string }) => {
|
||||
const { t } = useI18n();
|
||||
const [text, setText] = useState<string | null>(null);
|
||||
const [failed, setFailed] = useState(false);
|
||||
|
||||
@@ -49,8 +51,8 @@ const TextViewer = ({ id }: { id: string }) => {
|
||||
};
|
||||
}, [id]);
|
||||
|
||||
if (failed) return <p className="text-sm text-white/70">Lecture impossible.</p>;
|
||||
if (text === null) return <p className="text-sm text-white/70">Chargement…</p>;
|
||||
if (failed) return <p className="text-sm text-white/70">{t("Lecture impossible.")}</p>;
|
||||
if (text === null) return <p className="text-sm text-white/70">{t("Chargement…")}</p>;
|
||||
return (
|
||||
<pre className="max-h-full w-full max-w-3xl overflow-auto rounded-md bg-black/60 p-4 text-left text-sm whitespace-pre-wrap text-white/90">
|
||||
{text}
|
||||
@@ -66,33 +68,37 @@ const Panel = ({
|
||||
item: MediaViewerItem;
|
||||
message: string;
|
||||
openable: boolean;
|
||||
}) => (
|
||||
<div className="flex w-full max-w-md flex-col items-center gap-4 rounded-xl border border-white/10 bg-black/40 p-8 text-center">
|
||||
<FileIcon className="h-12 w-12 text-white/60" />
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-sm font-medium text-white">{item.name}</p>
|
||||
<p className="mt-1 text-xs text-white/60">{message}</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-center gap-2">
|
||||
{openable ? (
|
||||
<a
|
||||
href={api.previewUrl(item.id)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={actionClass}
|
||||
>
|
||||
Ouvrir
|
||||
}) => {
|
||||
const { t } = useI18n();
|
||||
return (
|
||||
<div className="flex w-full max-w-md flex-col items-center gap-4 rounded-xl border border-white/10 bg-black/40 p-8 text-center">
|
||||
<FileIcon className="h-12 w-12 text-white/60" />
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-sm font-medium text-white">{item.name}</p>
|
||||
<p className="mt-1 text-xs text-white/60">{message}</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-center gap-2">
|
||||
{openable ? (
|
||||
<a
|
||||
href={api.previewUrl(item.id)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={actionClass}
|
||||
>
|
||||
{t("Ouvrir")}
|
||||
</a>
|
||||
) : null}
|
||||
<a href={api.downloadUrl(item.id)} download={item.name} className={actionClass}>
|
||||
<DownloadIcon className="h-4 w-4" />
|
||||
{t("Télécharger")}
|
||||
</a>
|
||||
) : null}
|
||||
<a href={api.downloadUrl(item.id)} download={item.name} className={actionClass}>
|
||||
<DownloadIcon className="h-4 w-4" />
|
||||
Télécharger
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
const Body = ({ item }: { item: MediaViewerItem }) => {
|
||||
const { t } = useI18n();
|
||||
const kind = kindOf(item.mime_type);
|
||||
if (kind === "image") {
|
||||
return (
|
||||
@@ -124,11 +130,11 @@ const Body = ({ item }: { item: MediaViewerItem }) => {
|
||||
}
|
||||
if (kind === "text") return <TextViewer id={item.id} />;
|
||||
if (kind === "pdf") {
|
||||
return (
|
||||
<Panel item={item} message="Le PDF s'ouvre dans un nouvel onglet." openable />
|
||||
);
|
||||
return <Panel item={item} message={t("Le PDF s'ouvre dans un nouvel onglet.")} openable />;
|
||||
}
|
||||
return <Panel item={item} message="Aperçu indisponible pour ce format." openable={false} />;
|
||||
return (
|
||||
<Panel item={item} message={t("Aperçu indisponible pour ce format.")} openable={false} />
|
||||
);
|
||||
};
|
||||
|
||||
export const MediaViewer = ({
|
||||
@@ -140,6 +146,7 @@ export const MediaViewer = ({
|
||||
startIndex: number;
|
||||
onClose: () => void;
|
||||
}) => {
|
||||
const { t } = useI18n();
|
||||
const [index, setIndex] = useState(startIndex);
|
||||
const current = items[index];
|
||||
|
||||
@@ -169,11 +176,11 @@ export const MediaViewer = ({
|
||||
href={api.downloadUrl(current.id)}
|
||||
download={current.name}
|
||||
className={controlClass}
|
||||
aria-label="Télécharger"
|
||||
aria-label={t("Télécharger")}
|
||||
>
|
||||
<DownloadIcon className="h-4 w-4" />
|
||||
</a>
|
||||
<button type="button" onClick={onClose} className={controlClass} aria-label="Fermer">
|
||||
<button type="button" onClick={onClose} className={controlClass} aria-label={t("Fermer")}>
|
||||
<CloseIcon className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
@@ -190,7 +197,7 @@ export const MediaViewer = ({
|
||||
type="button"
|
||||
onClick={() => setIndex((value) => value - 1)}
|
||||
className={cn(controlClass, "absolute left-4 z-10")}
|
||||
aria-label="Fichier précédent"
|
||||
aria-label={t("Fichier précédent")}
|
||||
>
|
||||
<ArrowLeftIcon className="h-5 w-5" />
|
||||
</button>
|
||||
@@ -203,7 +210,7 @@ export const MediaViewer = ({
|
||||
type="button"
|
||||
onClick={() => setIndex((value) => value + 1)}
|
||||
className={cn(controlClass, "absolute right-4 z-10")}
|
||||
aria-label="Fichier suivant"
|
||||
aria-label={t("Fichier suivant")}
|
||||
>
|
||||
<ArrowRightIcon className="h-5 w-5" />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user