mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
DEV: Remove old backup uploader and resumable.js (#15365)
Now that d5e380e5c1
has been
committed there is nothing in the codebase that uses either
resumable.js or the old backup-uploader component.
R.I.P resumable.js
This commit is contained in:
parent
c209be09f1
commit
d330a5447d
@ -1,140 +0,0 @@
|
||||
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
||||
import { later, schedule } from "@ember/runloop";
|
||||
import Component from "@ember/component";
|
||||
import I18n from "I18n";
|
||||
import getURL from "discourse-common/lib/get-url";
|
||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||
|
||||
/*global Resumable:true */
|
||||
|
||||
/**
|
||||
Example usage:
|
||||
|
||||
{{resumable-upload
|
||||
target="/admin/backups/upload"
|
||||
success=(action "successAction")
|
||||
error=(action "errorAction")
|
||||
uploadText="UPLOAD"
|
||||
}}
|
||||
**/
|
||||
export default Component.extend({
|
||||
tagName: "button",
|
||||
classNames: ["btn", "ru"],
|
||||
classNameBindings: ["isUploading"],
|
||||
attributeBindings: ["translatedTitle:title"],
|
||||
resumable: null,
|
||||
isUploading: false,
|
||||
progress: 0,
|
||||
rerenderTriggers: ["isUploading", "progress"],
|
||||
uploadingIcon: null,
|
||||
progressBar: null,
|
||||
|
||||
@on("init")
|
||||
_initialize() {
|
||||
this.resumable = new Resumable({
|
||||
target: getURL(this.target),
|
||||
maxFiles: 1, // only 1 file at a time
|
||||
headers: {
|
||||
"X-CSRF-Token": document.querySelector("meta[name='csrf-token']")
|
||||
.content,
|
||||
},
|
||||
});
|
||||
|
||||
this.resumable.on("fileAdded", () => {
|
||||
// automatically upload the selected file
|
||||
this.resumable.upload();
|
||||
|
||||
// mark as uploading
|
||||
later(() => {
|
||||
this.set("isUploading", true);
|
||||
this._updateIcon();
|
||||
});
|
||||
});
|
||||
|
||||
this.resumable.on("fileProgress", (file) => {
|
||||
// update progress
|
||||
later(() => {
|
||||
this.set("progress", parseInt(file.progress() * 100, 10));
|
||||
this._updateProgressBar();
|
||||
});
|
||||
});
|
||||
|
||||
this.resumable.on("fileSuccess", (file) => {
|
||||
later(() => {
|
||||
// mark as not uploading anymore
|
||||
this._reset();
|
||||
|
||||
// fire an event to allow the parent route to reload its model
|
||||
this.success(file.fileName);
|
||||
});
|
||||
});
|
||||
|
||||
this.resumable.on("fileError", (file, message) => {
|
||||
later(() => {
|
||||
// mark as not uploading anymore
|
||||
this._reset();
|
||||
|
||||
// fire an event to allow the parent route to display the error message
|
||||
this.error(file.fileName, message);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@on("didInsertElement")
|
||||
_assignBrowse() {
|
||||
schedule("afterRender", () => this.resumable.assignBrowse($(this.element)));
|
||||
},
|
||||
|
||||
@on("willDestroyElement")
|
||||
_teardown() {
|
||||
if (this.resumable) {
|
||||
this.resumable.cancel();
|
||||
this.resumable = null;
|
||||
}
|
||||
},
|
||||
|
||||
@discourseComputed("title", "text")
|
||||
translatedTitle(title, text) {
|
||||
return title ? I18n.t(title) : text;
|
||||
},
|
||||
|
||||
@discourseComputed("isUploading", "progress")
|
||||
text(isUploading, progress) {
|
||||
if (isUploading) {
|
||||
return progress + " %";
|
||||
} else {
|
||||
return this.uploadText;
|
||||
}
|
||||
},
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
this._updateIcon();
|
||||
},
|
||||
|
||||
click() {
|
||||
if (this.isUploading) {
|
||||
this.resumable.cancel();
|
||||
later(() => this._reset());
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
_updateIcon() {
|
||||
const icon = this.isUploading ? "times" : "upload";
|
||||
this.set("uploadingIcon", `${iconHTML(icon)}`.htmlSafe());
|
||||
},
|
||||
|
||||
_updateProgressBar() {
|
||||
const pb = `${"width:" + this.progress + "%"}`.htmlSafe();
|
||||
this.set("progressBar", pb);
|
||||
},
|
||||
|
||||
_reset() {
|
||||
this.setProperties({ isUploading: false, progress: 0 });
|
||||
this._updateIcon();
|
||||
this._updateProgressBar();
|
||||
},
|
||||
});
|
@ -1,54 +0,0 @@
|
||||
import Component from "@ember/component";
|
||||
import I18n from "I18n";
|
||||
import UploadMixin from "discourse/mixins/upload";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { on } from "@ember/object/evented";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
||||
export default Component.extend(UploadMixin, {
|
||||
tagName: "span",
|
||||
|
||||
@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() {
|
||||
this.done();
|
||||
},
|
||||
|
||||
calculateUploadUrl() {
|
||||
return "";
|
||||
},
|
||||
|
||||
uploadOptions() {
|
||||
return {
|
||||
type: "PUT",
|
||||
dataType: "xml",
|
||||
autoUpload: false,
|
||||
multipart: false,
|
||||
};
|
||||
},
|
||||
|
||||
_init: on("didInsertElement", function () {
|
||||
const $upload = $(this.element);
|
||||
|
||||
$upload.on("fileuploadadd", (e, data) => {
|
||||
ajax("/admin/backups/upload_url", {
|
||||
data: { filename: data.files[0].name },
|
||||
})
|
||||
.then((result) => {
|
||||
data.url = result.url;
|
||||
data.submit();
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
});
|
||||
}),
|
||||
});
|
@ -1,4 +0,0 @@
|
||||
<label class="btn" disabled={{uploading}} title={{i18n "admin.backups.upload.title"}}>
|
||||
{{d-icon "upload"}}{{uploadButtonText}}
|
||||
<input class="hidden-upload-field" disabled={{uploading}} type="file" accept=".gz">
|
||||
</label>
|
@ -50,10 +50,6 @@ module.exports = function (defaults) {
|
||||
});
|
||||
app.import(discourseRoot + "/app/assets/javascripts/polyfills.js");
|
||||
|
||||
let adminVendor = funnel(vendorJs, {
|
||||
files: ["resumable.js"],
|
||||
});
|
||||
|
||||
return mergeTrees([
|
||||
discourseScss(`${discourseRoot}/app/assets/stylesheets`, "testem.scss"),
|
||||
createI18nTree(discourseRoot, vendorJs),
|
||||
@ -64,7 +60,7 @@ module.exports = function (defaults) {
|
||||
destDir: "assets/highlightjs",
|
||||
}),
|
||||
digest(
|
||||
concat(mergeTrees([app.options.adminTree, adminVendor]), {
|
||||
concat(mergeTrees([app.options.adminTree]), {
|
||||
outputFile: `assets/admin.js`,
|
||||
})
|
||||
),
|
||||
|
@ -1,3 +1,2 @@
|
||||
//= require discourse/app/lib/export-result
|
||||
//= require_tree ./admin/addon
|
||||
//= require resumable.js
|
||||
|
@ -131,8 +131,6 @@ def dependencies
|
||||
}, {
|
||||
source: 'moment-timezone-names-translations/locales/.',
|
||||
destination: 'moment-timezone-names-locale'
|
||||
}, {
|
||||
source: 'resumablejs/resumable.js'
|
||||
}, {
|
||||
source: 'workbox-sw/build/.',
|
||||
destination: 'workbox',
|
||||
|
@ -12,10 +12,10 @@
|
||||
"@json-editor/json-editor": "^2.6.1",
|
||||
"@popperjs/core": "v2.10.2",
|
||||
"@uppy/aws-s3": "^2.0.4",
|
||||
"@uppy/utils": "^4.0.3",
|
||||
"@uppy/aws-s3-multipart": "^2.1.0",
|
||||
"@uppy/core": "^2.1.0",
|
||||
"@uppy/drop-target": "^1.1.0",
|
||||
"@uppy/utils": "^4.0.3",
|
||||
"@uppy/xhr-upload": "^2.0.4",
|
||||
"ace-builds": "1.4.12",
|
||||
"blueimp-file-upload": "10.13.0",
|
||||
@ -33,7 +33,6 @@
|
||||
"moment-timezone": "0.5.31",
|
||||
"moment-timezone-names-translations": "https://github.com/discourse/moment-timezone-names-translations",
|
||||
"pikaday": "1.8.0",
|
||||
"resumablejs": "1.1.0",
|
||||
"spectrum-colorpicker": "1.8.0",
|
||||
"workbox-cacheable-response": "^4.3.1",
|
||||
"workbox-core": "^4.3.1",
|
||||
|
1084
vendor/assets/javascripts/resumable.js
vendored
1084
vendor/assets/javascripts/resumable.js
vendored
File diff suppressed because it is too large
Load Diff
@ -3640,11 +3640,6 @@ restore-cursor@^3.1.0:
|
||||
onetime "^5.1.0"
|
||||
signal-exit "^3.0.2"
|
||||
|
||||
resumablejs@1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/resumablejs/-/resumablejs-1.1.0.tgz#3160633688ac35bc2a0f119803c190ec369ef4d2"
|
||||
integrity sha512-gUTWTtJ2aheRb5svHDGHMtQsBkGxTILpZApT11ODoxEe5D75GhYL7Nc/WYgCcJXY+5RVmm2BEsp2qriCkKWRRg==
|
||||
|
||||
ret@~0.1.10:
|
||||
version "0.1.15"
|
||||
resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
|
||||
|
Loading…
Reference in New Issue
Block a user