diff --git a/app/assets/javascripts/admin/addon/components/admin-backups-actions.gjs b/app/assets/javascripts/admin/addon/components/admin-backups-actions.gjs new file mode 100644 index 00000000000..5f4d4b2e370 --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/admin-backups-actions.gjs @@ -0,0 +1,100 @@ +import Component from "@glimmer/component"; +import { action } from "@ember/object"; +import { service } from "@ember/service"; +import routeAction from "discourse/helpers/route-action"; +import { ajax } from "discourse/lib/ajax"; +import { popupAjaxError } from "discourse/lib/ajax-error"; +import I18n from "discourse-i18n"; + +export default class AdminBackupsActions extends Component { + @service currentUser; + @service site; + @service dialog; + + @action + toggleReadOnlyMode() { + if (!this.site.isReadOnly) { + this.dialog.yesNoConfirm({ + message: I18n.t("admin.backups.read_only.enable.confirm"), + didConfirm: () => { + this.currentUser.set("hideReadOnlyAlert", true); + this.#toggleReadOnlyMode(true); + }, + }); + } else { + this.#toggleReadOnlyMode(false); + } + } + + get rollbackDisabled() { + return !this.rollbackEnabled; + } + + get rollbackEnabled() { + return ( + this.args.backups.canRollback && + this.args.backups.restoreEnabled && + !this.args.backups.isOperationRunning + ); + } + + async #toggleReadOnlyMode(enable) { + try { + await ajax("/admin/backups/readonly", { + type: "PUT", + data: { enable }, + }); + this.site.set("isReadOnly", enable); + } catch (err) { + popupAjaxError(err); + } + } + + +} diff --git a/app/assets/javascripts/admin/addon/components/admin-plugin-filtered-site-settings.gjs b/app/assets/javascripts/admin/addon/components/admin-filtered-site-settings.gjs similarity index 96% rename from app/assets/javascripts/admin/addon/components/admin-plugin-filtered-site-settings.gjs rename to app/assets/javascripts/admin/addon/components/admin-filtered-site-settings.gjs index 5b4d69160c6..82f775bfb05 100644 --- a/app/assets/javascripts/admin/addon/components/admin-plugin-filtered-site-settings.gjs +++ b/app/assets/javascripts/admin/addon/components/admin-filtered-site-settings.gjs @@ -11,7 +11,7 @@ import discourseDebounce from "discourse-common/lib/debounce"; import AdminSiteSettingsFilterControls from "admin/components/admin-site-settings-filter-controls"; import SiteSetting from "admin/components/site-setting"; -export default class AdminPluginFilteredSiteSettings extends Component { +export default class AdminFilteredSiteSettings extends Component { @service currentUser; @tracked visibleSettings; @tracked loading = true; diff --git a/app/assets/javascripts/admin/addon/components/admin-page-action-button.gjs b/app/assets/javascripts/admin/addon/components/admin-page-action-button.gjs new file mode 100644 index 00000000000..ef14f31203f --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/admin-page-action-button.gjs @@ -0,0 +1,46 @@ +import DButton from "discourse/components/d-button"; + +export const AdminPageActionButton = ; +export const PrimaryButton = ; +export const DangerButton = ; +export const DefaultButton = ; diff --git a/app/assets/javascripts/admin/addon/components/admin-page-header.gjs b/app/assets/javascripts/admin/addon/components/admin-page-header.gjs new file mode 100644 index 00000000000..93d69088dda --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/admin-page-header.gjs @@ -0,0 +1,52 @@ +import { hash } from "@ember/helper"; +import { htmlSafe } from "@ember/template"; +import DBreadcrumbsContainer from "discourse/components/d-breadcrumbs-container"; +import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item"; +import HorizontalOverflowNav from "discourse/components/horizontal-overflow-nav"; +import i18n from "discourse-common/helpers/i18n"; +import { + DangerButton, + DefaultButton, + PrimaryButton, +} from "admin/components/admin-page-action-button"; + +const AdminPageHeader = ; + +export default AdminPageHeader; diff --git a/app/assets/javascripts/admin/addon/components/admin-page-subheader.gjs b/app/assets/javascripts/admin/addon/components/admin-page-subheader.gjs new file mode 100644 index 00000000000..52140dc6649 --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/admin-page-subheader.gjs @@ -0,0 +1,23 @@ +import { hash } from "@ember/helper"; +import i18n from "discourse-common/helpers/i18n"; +import { + DangerButton, + DefaultButton, + PrimaryButton, +} from "admin/components/admin-page-action-button"; + +const AdminPageSubheader = ; + +export default AdminPageSubheader; diff --git a/app/assets/javascripts/admin/addon/components/admin-plugin-config-metadata.gjs b/app/assets/javascripts/admin/addon/components/admin-plugin-config-metadata.gjs index c27dcd4d555..427ecc180bb 100644 --- a/app/assets/javascripts/admin/addon/components/admin-plugin-config-metadata.gjs +++ b/app/assets/javascripts/admin/addon/components/admin-plugin-config-metadata.gjs @@ -3,9 +3,9 @@ import i18n from "discourse-common/helpers/i18n"; const AdminPluginConfigMetadata =