-
Notifications
You must be signed in to change notification settings - Fork 272
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
eee2a41
Merge pull request #717 from lowcoder-org/dev
FalkWolsky 8e9ab45
Toasts Notification & Loading Mesages
sudoischenny 36ccf9a
Merge branch 'lowcoder-org:main' into main
sudoischenny 683179c
Update Toasts Image
sudoischenny 3708c30
Added toast.destroy()
sudoischenny 791cff1
Toast Dismiss
sudoischenny 2dea08b
Add migration to fix existing application public view bug
aq-ikhwa-tech 86100fe
Remove unnecessary logs
aq-ikhwa-tech 27d870d
Merge pull request #1 from lowcoder-org/dev
sudoischenny 220c0cc
Merge branch 'lowcoder-org:main' into main
sudoischenny 56d2086
Merge branch 'dev' into main
FalkWolsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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" | ||
} | ||
} |
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
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
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
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 deletions
client/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"); | ||
}, | ||
}, | ||
]); | ||
|
||
|
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
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
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 added
docs/.gitbook/assets/builtin-js-toasts.png
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.