core&ui: add addon not found warning

pull/453/head
undefined 2 years ago
parent 2d1c218999
commit 6a4aa14016

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "4.2.10",
"version": "4.2.11",
"bin": "bin/hydrooj.js",
"main": "src/plugin-api",
"module": "src/plugin-api",

@ -695,7 +695,7 @@ export interface Lib extends Record<string, any> {
problemSearch: ProblemSearch;
}
export type UIInjectableFields = 'ProblemAdd' | 'Nav' | 'UserDropdown' | 'DomainManage' | 'ControlPanel';
export type UIInjectableFields = 'ProblemAdd' | 'Notification' | 'Nav' | 'UserDropdown' | 'DomainManage' | 'ControlPanel';
export interface UI {
template: Record<string, string>,
nodes: Record<UIInjectableFields, any[]>,

@ -16,6 +16,8 @@ import { Logger } from './logger';
import { Context } from './context';
// eslint-disable-next-line import/no-duplicates
import { unwrapExports } from './utils';
import { PRIV } from './model/builtin';
import { inject } from './lib/ui';
const argv = cac().parse();
const logger = new Logger('loader');
@ -95,6 +97,7 @@ export function addon(addonPath: string, prepend = false) {
} catch (e) {
logger.error(`Addon not found: ${addonPath}`);
logger.error(e);
inject('Notification', 'Addon not found: {0}', { args: [addonPath] }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION);
}
}

@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.42.8",
"version": "4.42.9",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "index.ts",

@ -6,6 +6,9 @@
<div class="slideout-overlay"></div>
{% if UserContext %}{% include "partials/header_mobile.html" %}{% endif %}
<div class="main">
{% for item in ui.getNodes('Notification') %}{% if item.checker(handler) %}
<div class="row"><blockquote class="warn">{{ _(item.name).format(item.args.args or []) }}</blockquote></div>
{% endif %}{% endfor %}
{% block content %}{% endblock %}
</div>
{% include "partials/footer.html" %}

Loading…
Cancel
Save