mirror of
https://github.com/flarum/core.git
synced 2025-08-20 15:21:49 +02:00
Improve the logic behind the different features
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
import app from 'flarum/admin/app';
|
||||
import Modal from 'flarum/common/components/Modal';
|
||||
import { ComponentAttrs } from 'flarum/common/Component';
|
||||
import Alert from 'flarum/common/components/Alert';
|
||||
import Mithril from 'mithril';
|
||||
|
||||
interface Attrs extends ComponentAttrs {
|
||||
output: string;
|
||||
}
|
||||
|
||||
export default class ComposerFailureModal<T extends Attrs = Attrs> extends Modal<T> {
|
||||
oninit(vnode: Mithril.Vnode<T, this>) {
|
||||
super.oninit(vnode);
|
||||
|
||||
if (this.attrs.error.guessed_cause) {
|
||||
this.alertAttrs = {
|
||||
type: 'error',
|
||||
content: app.translator.trans(`flarum-package-manager.admin.failure_modal.guessed_cause.${this.attrs.error.guessed_cause}`),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
className() {
|
||||
return 'Modal--large ComposerFailureModal';
|
||||
}
|
||||
|
||||
title() {
|
||||
return app.translator.trans('flarum-package-manager.admin.failure_modal.title');
|
||||
}
|
||||
|
||||
content() {
|
||||
return (
|
||||
<div className="Modal-body">
|
||||
<details>
|
||||
<summary>{app.translator.trans('flarum-package-manager.admin.failure_modal.show_composer_output')}</summary>
|
||||
<pre className="ComposerFailureModal-output">{this.attrs.error.output}</pre>
|
||||
</details>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
@@ -4,14 +4,13 @@ import Component from 'flarum/common/Component';
|
||||
import Button from 'flarum/common/components/Button';
|
||||
import Stream from 'flarum/common/utils/Stream';
|
||||
import LoadingModal from 'flarum/admin/components/LoadingModal';
|
||||
import ComposerFailureModal from './ComposerFailureModal';
|
||||
import errorHandler from '../utils/errorHandler';
|
||||
|
||||
export default class Installer extends Component {
|
||||
export default class Installer<Attrs> extends Component<Attrs> {
|
||||
packageName!: Stream<string>;
|
||||
isLoading: boolean = false;
|
||||
|
||||
oninit(vnode: Mithril.Vnode): void {
|
||||
oninit(vnode: Mithril.Vnode<Attrs, this>): void {
|
||||
super.oninit(vnode);
|
||||
|
||||
this.packageName = Stream('');
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import app from 'flarum/admin/app';
|
||||
import ComposerFailureModal from '../components/ComposerFailureModal';
|
||||
|
||||
export default function (e: any) {
|
||||
const error = e.response.errors[0];
|
||||
@@ -10,7 +9,10 @@ export default function (e: any) {
|
||||
|
||||
switch (error.code) {
|
||||
case 'composer_command_failure':
|
||||
app.modal.show(ComposerFailureModal, { error });
|
||||
if (error.guessed_cause) {
|
||||
app.alerts.show({type: 'error'}, app.translator.trans(`flarum-package-manager.admin.exceptions.guessed_cause.${error.guessed_cause}`))
|
||||
app.modal.close();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'extension_already_installed':
|
||||
|
Reference in New Issue
Block a user