- Notifications
You must be signed in to change notification settings - Fork278
Add toast notifications & loading message type.#721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
11 commits Select commitHold shift + click to select a range
eee2a41
Merge pull request #717 from lowcoder-org/dev
FalkWolsky8e9ab45
Toasts Notification & Loading Mesages
sudoischenny36ccf9a
Merge branch 'lowcoder-org:main' into main
sudoischenny683179c
Update Toasts Image
sudoischenny3708c30
Added toast.destroy()
sudoischenny791cff1
Toast Dismiss
sudoischenny2dea08b
Add migration to fix existing application public view bug
aq-ikhwa-tech86100fe
Remove unnecessary logs
aq-ikhwa-tech27d870d
Merge pull request #1 from lowcoder-org/dev
sudoischenny220c0cc
Merge branch 'lowcoder-org:main' into main
sudoischenny56d2086
Merge branch 'dev' into main
FalkWolskyFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions.vscode/settings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"workbench.colorCustomizations": { | ||
"activityBar.background": "#2A3012", | ||
"titleBar.activeBackground": "#3B431A", | ||
"titleBar.activeForeground": "#F9FAF2" | ||
} | ||
} |
2 changes: 2 additions & 0 deletionsclient/packages/lowcoder/src/comps/hooks/hookComp.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionsclient/packages/lowcoder/src/comps/hooks/hookCompTypes.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsclient/packages/lowcoder/src/comps/hooks/hookListComp.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletionclient/packages/lowcoder/src/comps/hooks/messageComp.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletionsclient/packages/lowcoder/src/comps/hooks/toastComp.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { withMethodExposing } from "../generators/withMethodExposing"; | ||
import { simpleMultiComp } from "../generators"; | ||
import { withExposingConfigs } from "../generators/withExposing"; | ||
import { EvalParamType, ParamsConfig } from "../controls/actionSelector/executeCompTypes"; | ||
import { JSONObject } from "../../util/jsonTypes"; | ||
import { trans } from "i18n"; | ||
import { notificationInstance } from "lowcoder-design"; | ||
import type { ArgsProps, NotificationPlacement } from 'antd/es/notification/interface'; | ||
const params: ParamsConfig = [ | ||
{ name: "text", type: "string" }, | ||
{ name: "options", type: "JSON" }, | ||
]; | ||
const showNotification = ( | ||
params: EvalParamType[], | ||
level: "open" | "info" | "success" | "warning" | "error" | ||
) => { | ||
const text = params?.[0] as string; | ||
const options = params?.[1] as JSONObject; | ||
const { message , duration, id, placement, dismissible } = options; | ||
const closeIcon: boolean | undefined = dismissible === true ? undefined : (dismissible === false ? false : undefined); | ||
const durationNumberOrNull: number | null = typeof duration === 'number' ? duration : null; | ||
const notificationArgs: ArgsProps = { | ||
message: text, | ||
description: message as React.ReactNode, | ||
duration: durationNumberOrNull ?? 3, | ||
key: id as React.Key, | ||
placement: placement as NotificationPlacement ?? "bottomRight", | ||
closeIcon: closeIcon as boolean, | ||
}; | ||
// Use notificationArgs to trigger the notification | ||
text && notificationInstance[level](notificationArgs); | ||
}; | ||
const destroy = ( | ||
params: EvalParamType[] | ||
) => { | ||
// Extract the id from the params | ||
const id = params[0] as React.Key; | ||
// Call notificationInstance.destroy with the provided id | ||
notificationInstance.destroy(id); | ||
}; | ||
//what we would like to expose: title, text, duration, id, btn-obj, onClose, placement | ||
const ToastCompBase = simpleMultiComp({}); | ||
export let ToastComp = withExposingConfigs(ToastCompBase, []); | ||
ToastComp = withMethodExposing(ToastComp, [ | ||
{ | ||
method: { name: "destroy", description: trans("toastComp.destroy"), params: params }, | ||
execute: (comp, params) => destroy(params), | ||
}, | ||
{ | ||
method: { name: "open", description: trans("toastComp.info"), params: params }, | ||
execute: (comp, params) => { | ||
showNotification(params, "open"); | ||
}, | ||
}, | ||
{ | ||
method: { name: "info", description: trans("toastComp.info"), params: params }, | ||
execute: (comp, params) => { | ||
showNotification(params, "info"); | ||
}, | ||
}, | ||
{ | ||
method: { name: "success", description: trans("toastComp.success"), params: params }, | ||
execute: (comp, params) => { | ||
showNotification(params, "success"); | ||
}, | ||
}, | ||
{ | ||
method: { name: "warn", description: trans("toastComp.warn"), params: params }, | ||
execute: (comp, params) => { | ||
showNotification(params, "warning"); | ||
}, | ||
}, | ||
{ | ||
method: { name: "error", description: trans("toastComp.error"), params: params }, | ||
execute: (comp, params) => { | ||
showNotification(params, "error"); | ||
}, | ||
}, | ||
]); | ||
8 changes: 8 additions & 0 deletionsclient/packages/lowcoder/src/i18n/locales/de.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletionsclient/packages/lowcoder/src/i18n/locales/en.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletionsclient/packages/lowcoder/src/i18n/locales/zh.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Binary file addeddocs/.gitbook/assets/builtin-js-toasts.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 35 additions & 8 deletionsdocs/build-apps/write-javascript/built-in-javascript-functions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.