mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 15:43:13 +09:00
Port packages/web_ui to TypeScript (#508)
* .jsx to .tsx * controller: tsc --build before webpack-cli * Type Annotation * disabled move into the <Input/> and <Checkbox/> * cleanup debug left over * documentation * default ModPack * modPackUpdateHandlers no undefined * PluginInfo changes proposition * PluginInfo changes proposition miss * ModRecord & ModInfo feedback loop at const mods = [ ? * ["connect", "drop", "resume", "close"] as const * .tsx to .ts when possible
This commit is contained in:
1 parent
a4893751e9
commit
838170a9ff
92 files changed
+1104
-707
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { notification } from "antd";
|
||||
import { logger } from "@clusterio/lib";
|
||||
|
||||
|
||||
export default function notify(
|
||||
message: string | Error,
|
||||
type: "success"|"info"|"warning"|"error" = "info",
|
||||
description?: string,
|
||||
) {
|
||||
notification[type]({
|
||||
message: typeof message === "string" ? message : "ERROR: See console",
|
||||
description,
|
||||
placement: "bottomRight",
|
||||
});
|
||||
if (typeof message !== "string") {
|
||||
logger.error(message.stack);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Promise rejection handler notifying the user
|
||||
*
|
||||
* Shows the error occuring in a notification card.
|
||||
*
|
||||
* @param message -
|
||||
* User facing message to give context to the error. Should say which
|
||||
* operation failed.
|
||||
* @returns function showing the error passed to it.
|
||||
*/
|
||||
export function notifyErrorHandler(message: string): (err:Error) => void {
|
||||
return function handler(err: Error) {
|
||||
logger.error(err.stack);
|
||||
notification.error({
|
||||
message,
|
||||
description: err.message,
|
||||
duration: 0,
|
||||
placement: "bottomRight",
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user