From bedf7fbcaa960646b965daa19bb8a2ab7284024b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 6 Jun 2021 12:51:23 +0200 Subject: [PATCH] web/admin: don't show backup error when server can't backup Signed-off-by: Jens Langhammer --- web/src/locales/en.po | 4 ++-- web/src/locales/pseudo-LOCALE.po | 2 +- .../pages/admin-overview/cards/BackupStatusCard.ts | 14 +++++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/web/src/locales/en.po b/web/src/locales/en.po index 1d20e8d2f..b1e188bcb 100644 --- a/web/src/locales/en.po +++ b/web/src/locales/en.po @@ -365,8 +365,8 @@ msgid "Backup finished with errors." msgstr "Backup finished with errors." #: src/pages/admin-overview/cards/BackupStatusCard.ts -msgid "Backup finished with warnings." -msgstr "Backup finished with warnings." +msgid "Backup finished with warnings/backup not supported." +msgstr "Backup finished with warnings/backup not supported." #: src/pages/admin-overview/AdminOverviewPage.ts msgid "Backup status" diff --git a/web/src/locales/pseudo-LOCALE.po b/web/src/locales/pseudo-LOCALE.po index 8de96db05..c786adc70 100644 --- a/web/src/locales/pseudo-LOCALE.po +++ b/web/src/locales/pseudo-LOCALE.po @@ -361,7 +361,7 @@ msgid "Backup finished with errors." msgstr "" #: -msgid "Backup finished with warnings." +msgid "Backup finished with warnings/backup not supported." msgstr "" #: diff --git a/web/src/pages/admin-overview/cards/BackupStatusCard.ts b/web/src/pages/admin-overview/cards/BackupStatusCard.ts index 18ff32088..2b0b43bc8 100644 --- a/web/src/pages/admin-overview/cards/BackupStatusCard.ts +++ b/web/src/pages/admin-overview/cards/BackupStatusCard.ts @@ -2,8 +2,9 @@ import { t } from "@lingui/macro"; import { customElement, html, TemplateResult } from "lit-element"; import { AdminStatus, AdminStatusCard } from "./AdminStatusCard"; import { AdminApi, StatusEnum } from "authentik-api"; -import { DEFAULT_CONFIG } from "../../../api/Config"; +import { config, DEFAULT_CONFIG } from "../../../api/Config"; import { convertToTitle } from "../../../utils"; +import { CapabilitiesEnum } from "authentik-api/src"; @customElement("ak-admin-status-card-backup") export class BackupStatusCard extends AdminStatusCard { @@ -14,7 +15,14 @@ export class BackupStatusCard extends AdminStatusCard { }).then((value) => { return value.status; }).catch(() => { - return StatusEnum.Error; + // On error (probably 404), check the config and see if the server + // can even backup + return config().then(c => { + if (c.capabilities.includes(CapabilitiesEnum.Backup)) { + return StatusEnum.Error; + } + return StatusEnum.Warning; + }); }); } @@ -27,7 +35,7 @@ export class BackupStatusCard extends AdminStatusCard { case StatusEnum.Warning: return Promise.resolve({ icon: "fa fa-exclamation-triangle pf-m-warning", - message: t`Backup finished with warnings.`, + message: t`Backup finished with warnings/backup not supported.`, }); case StatusEnum.Error: return Promise.resolve({