mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 22:53:37 +08:00
2 lines
14 KiB
JavaScript
Executable File
2 lines
14 KiB
JavaScript
Executable File
module.exports=function(a){var e={};function t(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return a[n].call(r.exports,r,r.exports,t),r.l=!0,r.exports}return t.m=a,t.c=e,t.d=function(a,e,n){t.o(a,e)||Object.defineProperty(a,e,{enumerable:!0,get:n})},t.r=function(a){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},t.t=function(a,e){if(1&e&&(a=t(a)),8&e)return a;if(4&e&&"object"==typeof a&&a&&a.__esModule)return a;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:a}),2&e&&"string"!=typeof a)for(var r in a)t.d(n,r,function(e){return a[e]}.bind(null,r));return n},t.n=function(a){var e=a&&a.__esModule?function(){return a.default}:function(){return a};return t.d(e,"a",e),e},t.o=function(a,e){return Object.prototype.hasOwnProperty.call(a,e)},t.p="",t(t.s=15)}([function(a,e){a.exports=flarum.core.compat["admin/app"]},function(a,e){a.exports=flarum.core.compat["common/components/Button"]},function(a,e){a.exports=flarum.core.compat["admin/components/LoadingModal"]},function(a,e){a.exports=flarum.core.compat["common/Component"]},function(a,e){a.exports=flarum.core.compat["common/components/Tooltip"]},function(a,e){a.exports=flarum.core.compat["common/extend"]},function(a,e){a.exports=flarum.core.compat["common/components/Alert"]},function(a,e){a.exports=flarum.core.compat["admin/components/ExtensionPage"]},function(a,e){a.exports=flarum.core.compat["common/utils/Stream"]},function(a,e){a.exports=flarum.core.compat["common/components/Modal"]},function(a,e){a.exports=flarum.core.compat["common/helpers/icon"]},function(a,e){a.exports=flarum.core.compat["common/helpers/humanTime"]},function(a,e){a.exports=flarum.core.compat["common/utils/classList"]},function(a,e){a.exports=flarum.core.compat["common/components/LoadingIndicator"]},function(a,e){a.exports=flarum.core.compat["admin/utils/isExtensionEnabled"]},function(a,e,t){"use strict";t.r(e);var n=t(5),r=t(0),o=t.n(r),s=t(6),i=t.n(s),l=t(7),c=t.n(l),u=t(1),d=t.n(u),p=t(2),f=t.n(p);function g(a,e){return(g=Object.setPrototypeOf||function(a,e){return a.__proto__=e,a})(a,e)}function h(a,e){a.prototype=Object.create(e.prototype),a.prototype.constructor=a,g(a,e)}var k=t(3),x=t.n(k),v=t(8),b=t.n(v),y=t(9),_=function(a){function e(){return a.apply(this,arguments)||this}h(e,a);var t=e.prototype;return t.oninit=function(e){a.prototype.oninit.call(this,e),this.attrs.error.guessed_cause&&(this.alertAttrs={type:"error",content:o.a.translator.trans("flarum-package-manager.admin.failure_modal.guessed_cause."+this.attrs.error.guessed_cause)})},t.className=function(){return"Modal--large ComposerFailureModal"},t.title=function(){return o.a.translator.trans("flarum-package-manager.admin.failure_modal.title")},t.content=function(){return m("div",{className:"Modal-body"},m("details",null,m("summary",null,o.a.translator.trans("flarum-package-manager.admin.failure_modal.show_composer_output")),m("pre",{className:"ComposerFailureModal-output"},this.attrs.error.output)))},e}(t.n(y).a),w=function(a){var e=a.response.errors[0];if(!["composer_command_failure","extension_already_installed","extension_not_installed"].includes(e.code))throw a;switch(e.code){case"composer_command_failure":o.a.modal.show(_,{error:e});break;case"extension_already_installed":o.a.alerts.show({type:"error"},o.a.translator.trans("flarum-package-manager.admin.exceptions.extension_already_installed")),o.a.modal.close();break;case"extension_not_installed":o.a.alerts.show({type:"error"},o.a.translator.trans("flarum-package-manager.admin.exceptions.extension_not_installed")),o.a.modal.close()}},P=function(a){function e(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=a.call.apply(a,[this].concat(n))||this).packageName=void 0,e.isLoading=!1,e}h(e,a);var t=e.prototype;return t.oninit=function(e){a.prototype.oninit.call(this,e),this.packageName=b()("")},t.view=function(){return m("div",{className:"Form-group"},m("label",{htmlFor:"install-extension"},o.a.translator.trans("flarum-package-manager.admin.extensions.install")),m("p",{className:"helpText"},o.a.translator.trans("flarum-package-manager.admin.extensions.install_help",{extiverse:m("a",{href:"https://extiverse.com"},"extiverse.com")})),m("div",{className:"FormControl-container"},m("input",{className:"FormControl",id:"install-extension",placeholder:"vendor/package-name",bidi:this.packageName}),m(d.a,{className:"Button",icon:"fas fa-download",onclick:this.onsubmit.bind(this),loading:this.isLoading},o.a.translator.trans("flarum-package-manager.admin.extensions.proceed"))))},t.data=function(){return{package:this.packageName()}},t.onsubmit=function(){var a=this;this.isLoading=!0,o.a.modal.show(f.a),o.a.request({method:"POST",url:o.a.forum.attribute("apiUrl")+"/package-manager/extensions",body:{data:this.data()},errorHandler:w}).then((function(a){var e=a.id;o.a.alerts.show({type:"success"},o.a.translator.trans("flarum-package-manager.admin.extensions.successful_install",{extension:e})),window.location.href=o.a.forum.attribute("adminUrl")+"#/extension/"+e,window.location.reload()})).finally((function(){a.isLoading=!1,m.redraw()}))},e}(x.a),N=t(10),U=t.n(N),M=t(11),L=t.n(M),j=t(4),C=t.n(j),O=t(12),S=t.n(O),T=t(13),B=t.n(T),E=function(a){function e(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=a.call.apply(a,[this].concat(n))||this).isLoading=null,e}h(e,a);var t=e.prototype;return t.view=function(a){return m("div",{className:"Form-group PackageManager-majorUpdate"},m("img",{alt:"flarum logo",src:o.a.forum.attribute("baseUrl")+"/assets/extensions/flarum-package-manager/flarum.svg"}),m("label",null,o.a.translator.trans("flarum-package-manager.admin.major_updater.title",{version:this.attrs.coreUpdate["latest-major"]})),m("p",{className:"helpText"},o.a.translator.trans("flarum-package-manager.admin.major_updater.description")),m("div",{className:"PackageManager-updaterControls"},m(C.a,{text:o.a.translator.trans("flarum-package-manager.admin.major_updater.dry_run_help")},m(d.a,{className:"Button",icon:"fas fa-vial",onclick:this.update.bind(this,!0)},o.a.translator.trans("flarum-package-manager.admin.major_updater.dry_run"))),m(d.a,{className:"Button",icon:"fas fa-play",onclick:this.update.bind(this,!1)},o.a.translator.trans("flarum-package-manager.admin.major_updater.update"))))},t.update=function(a){var e=this;this.isLoading="update-"+(a?"dry-run":"run"),o.a.modal.show(f.a),o.a.request({method:"POST",url:o.a.forum.attribute("apiUrl")+"/package-manager/major-update",body:{data:{dryRun:a}},errorHandler:w}).then((function(){o.a.alerts.show({type:"success"},o.a.translator.trans("flarum-package-manager.admin.update_successful")),window.location.reload()})).finally((function(){e.isLoading=null,m.redraw()}))},e}(x.a),F=function(a){function e(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=a.call.apply(a,[this].concat(n))||this).isLoading=null,e.lastUpdateCheck=o.a.data.lastUpdateCheck||{},e}h(e,a);var t=e.prototype;return t.oninit=function(e){a.prototype.oninit.call(this,e)},t.view=function(){var a,e=this,t=this.getExtensionUpdates(),n=this.getCoreUpdate(),r=null;return n&&(r={title:o.a.translator.trans("flarum-package-manager.admin.updater.flarum"),version:o.a.data.settings.version,icon:{backgroundImage:"url("+o.a.forum.attribute("baseUrl")+"/assets/extensions/flarum-package-manager/flarum.svg"},newPackageUpdate:n}),[m("div",{className:"Form-group"},m("label",null,o.a.translator.trans("flarum-package-manager.admin.updater.updater_title")),m("p",{className:"helpText"},o.a.translator.trans("flarum-package-manager.admin.updater.updater_help")),Object.keys(this.lastUpdateCheck).length?m("p",{className:"PackageManager-lastUpdatedAt"},m("span",{className:"PackageManager-lastUpdatedAt-label"},o.a.translator.trans("flarum-package-manager.admin.updater.last_update_checked_at")),m("span",{className:"PackageManager-lastUpdatedAt-value"},L()(null==(a=this.lastUpdateCheck)?void 0:a.checkedAt))):null,m("div",{className:"PackageManager-updaterControls"},m(d.a,{className:"Button",icon:"fas fa-sync-alt",onclick:this.checkForUpdates.bind(this),loading:"check"===this.isLoading,disabled:null!==this.isLoading&&"check"!==this.isLoading},o.a.translator.trans("flarum-package-manager.admin.updater.check_for_updates")),m(d.a,{className:"Button",icon:"fas fa-play",onclick:this.updateGlobally.bind(this),loading:"global-update"===this.isLoading,disabled:null!==this.isLoading&&"global-update"!==this.isLoading},o.a.translator.trans("flarum-package-manager.admin.updater.run_global_update"))),null!==this.isLoading?m("div",{className:"PackageManager-extensions"},m(B.a,null)):t.length||r?m("div",{className:"PackageManager-extensions"},m("div",{className:"PackageManager-extensions-grid"},r?this.extensionItem(r,!0):null,t.map((function(a){return e.extensionItem(a)})))):null),n&&n["latest-major"]?m(E,{coreUpdate:n}):null]},t.extensionItem=function(a,e){return void 0===e&&(e=!1),m("div",{className:S()({"PackageManager-extension":!0,"PackageManager-extension--core":e})},m("div",{className:"PackageManager-extension-icon ExtensionIcon",style:a.icon},a.icon?U()(a.icon.name):""),m("div",{className:"PackageManager-extension-info"},m("div",{className:"PackageManager-extension-name"},a.title||a.extra["flarum-extension"].title),m("div",{className:"PackageManager-extension-version"},m("span",{className:"PackageManager-extension-version-current"},this.version(a.version)),a.newPackageUpdate["latest-minor"]?m("span",{className:"PackageManager-extension-version-latest PackageManager-extension-version-latest--minor"},this.version(a.newPackageUpdate["latest-minor"])):null,a.newPackageUpdate["latest-major"]&&!e?m("span",{className:"PackageManager-extension-version-latest PackageManager-extension-version-latest--major"},this.version(a.newPackageUpdate["latest-major"])):null)),m("div",{className:"PackageManager-extension-controls"},m(C.a,{text:o.a.translator.trans("flarum-package-manager.admin.extensions.update")},m(d.a,{icon:"fas fa-arrow-alt-circle-up",className:"Button Button--icon Button--flat",onclick:e?this.updateCoreMinor.bind(this):this.updateExtension.bind(this,a),"aria-label":o.a.translator.trans("flarum-package-manager.admin.extensions.update")}))))},t.version=function(a){return"v"+a.replace("v","")},t.getExtensionUpdates=function(){var a,e,t;return null==(a=this.lastUpdateCheck)||null==(e=a.updates)||null==(t=e.installed)||t.filter((function(a){var e=o.a.data.extensions[a.name.replace("/","-").replace(/(flarum-ext-)|(flarum-)/,"")],t=["semver-safe-update","update-possible"].includes(a["latest-status"]);return e&&t&&(e.newPackageUpdate=a),e&&t})),Object.values(o.a.data.extensions).filter((function(a){return a.newPackageUpdate}))},t.getCoreUpdate=function(){var a,e,t;return null==(a=this.lastUpdateCheck)||null==(e=a.updates)||null==(t=e.installed)?void 0:t.filter((function(a){return"flarum/core"===a.name})).pop()},t.checkForUpdates=function(){var a=this;this.isLoading="check",o.a.request({method:"POST",url:o.a.forum.attribute("apiUrl")+"/package-manager/check-for-updates",errorHandler:w}).then((function(e){a.lastUpdateCheck=e})).finally((function(){a.isLoading=null,m.redraw()}))},t.updateCoreMinor=function(){var a=this;o.a.modal.show(f.a),this.isLoading="minor-update",o.a.request({method:"POST",url:o.a.forum.attribute("apiUrl")+"/package-manager/minor-update",errorHandler:w}).then((function(){o.a.alerts.show({type:"success"},o.a.translator.trans("flarum-package-manager.admin.update_successful")),window.location.reload()})).finally((function(){a.isLoading=null,m.redraw()}))},t.updateExtension=function(a){var e=this;o.a.modal.show(f.a),this.isLoading="extension-update",o.a.request({method:"PATCH",url:o.a.forum.attribute("apiUrl")+"/package-manager/extensions/"+a.id,errorHandler:w}).then((function(){o.a.alerts.show({type:"success"},o.a.translator.trans("flarum-package-manager.admin.extensions.successful_update",{extension:a.extra["flarum-extension"].title})),window.location.reload()})).finally((function(){e.isLoading=null,m.redraw()}))},t.updateGlobally=function(){var a=this;o.a.modal.show(f.a),this.isLoading="global-update",o.a.request({method:"POST",url:o.a.forum.attribute("apiUrl")+"/package-manager/global-update",errorHandler:w}).then((function(){o.a.alerts.show({type:"success"},o.a.translator.trans("flarum-package-manager.admin.updater.global_update_successful")),window.location.reload()})).finally((function(){a.isLoading=null,m.redraw()}))},e}(x.a),q=t(14),A=t.n(q);o.a.initializers.add("flarum-package-manager",(function(a){a.extensionData.for("flarum-package-manager").registerSetting((function(){if(!a.data.isRequiredDirectoriesWritable)return m("div",{className:"Form-group"},m(i.a,{type:"warning",dismissible:!1},a.translator.trans("flarum-package-manager.admin.file_permissions")))})).registerSetting((function(){if(a.data.isRequiredDirectoriesWritable)return m(P,null)})).registerSetting((function(){if(a.data.isRequiredDirectoriesWritable)return m(F,null)})),Object(n.extend)(c.a.prototype,"topItems",(function(e){var t=this;"flarum-package-manager"===this.extension.id||A()(this.extension.id)||e.add("remove",m(d.a,{className:"Button Button--danger",icon:"fas fa-times",onclick:function(){a.modal.show(f.a),a.request({url:a.forum.attribute("apiUrl")+"/package-manager/extensions/"+t.extension.id,method:"DELETE"}).then((function(){a.alerts.show({type:"success"},a.translator.trans("flarum-package-manager.admin.extensions.successful_remove")),window.location=a.forum.attribute("adminUrl")})).finally((function(){a.modal.close()}))}},"Remove"))}))}))}]);
|
|
//# sourceMappingURL=admin.js.map
|