diff --git a/app/assets/javascripts/admin/addon/components/uppy-backup-uploader.gjs b/app/assets/javascripts/admin/addon/components/uppy-backup-uploader.gjs new file mode 100644 index 00000000000..81aa2669a65 --- /dev/null +++ b/app/assets/javascripts/admin/addon/components/uppy-backup-uploader.gjs @@ -0,0 +1,59 @@ +import Component from "@glimmer/component"; +import { getOwner } from "@ember/owner"; +import didInsert from "@ember/render-modifiers/modifiers/did-insert"; +import { service } from "@ember/service"; +import UppyUpload from "discourse/lib/uppy/uppy-upload"; +import i18n from "discourse-common/helpers/i18n"; + +export default class UppyBackupUploader extends Component { + @service siteSettings; + + uppyUpload = new UppyUpload(getOwner(this), { + id: "uppy-backup-uploader", + type: "backup", + uploadRootPath: "/admin/backups", + uploadUrl: "/admin/backups/upload", + + // local backups + useChunkedUploads: this.args.localBackupStorage, + + // direct s3 backups + useMultipartUploadsIfAvailable: + !this.args.localBackupStorage && + this.siteSettings.enable_direct_s3_uploads, + + validateUploadedFilesOptions: { skipValidation: true }, + + uploadDone: (responseData) => { + this.args.done(responseData.file_name); + }, + }); + + get uploadButtonText() { + return this.uppyUpload.uploading + ? i18n("admin.backups.upload.uploading_progress", { + progress: this.uppyUpload.uploadProgress, + }) + : i18n("admin.backups.upload.label"); + } + + +} diff --git a/app/assets/javascripts/discourse/app/components/uppy-backup-uploader.hbs b/app/assets/javascripts/discourse/app/components/uppy-backup-uploader.hbs deleted file mode 100644 index 6f8190e9777..00000000000 --- a/app/assets/javascripts/discourse/app/components/uppy-backup-uploader.hbs +++ /dev/null @@ -1,14 +0,0 @@ - \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/uppy-backup-uploader.js b/app/assets/javascripts/discourse/app/components/uppy-backup-uploader.js deleted file mode 100644 index edc8b83f776..00000000000 --- a/app/assets/javascripts/discourse/app/components/uppy-backup-uploader.js +++ /dev/null @@ -1,40 +0,0 @@ -import Component from "@ember/component"; -import { alias } from "@ember/object/computed"; -import { tagName } from "@ember-decorators/component"; -import UppyUploadMixin from "discourse/mixins/uppy-upload"; -import discourseComputed from "discourse-common/utils/decorators"; -import I18n from "discourse-i18n"; - -@tagName("span") -export default class UppyBackupUploader extends Component.extend( - UppyUploadMixin -) { - id = "uppy-backup-uploader"; - type = "backup"; - uploadRootPath = "/admin/backups"; - uploadUrl = "/admin/backups/upload"; - - // local backups - @alias("localBackupStorage") useChunkedUploads; - - // direct s3 backups - @discourseComputed("localBackupStorage") - useMultipartUploadsIfAvailable(localBackupStorage) { - return !localBackupStorage && this.siteSettings.enable_direct_s3_uploads; - } - - @discourseComputed("uploading", "uploadProgress") - uploadButtonText(uploading, progress) { - return uploading - ? I18n.t("admin.backups.upload.uploading_progress", { progress }) - : I18n.t("admin.backups.upload.label"); - } - - validateUploadedFilesOptions() { - return { skipValidation: true }; - } - - uploadDone(responseData) { - this.done(responseData.file_name); - } -}