1
0
Fork 0
mirror of synced 2024-08-23 14:01:34 +12:00

Merge branch 'master' into BUDI-8286/add-readonly-columns-to-plans

This commit is contained in:
Adria Navarro 2024-06-05 16:20:37 +02:00 committed by GitHub
commit db1e4fcce2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 14 deletions

View file

@ -1,5 +1,5 @@
{
"version": "2.27.6",
"version": "2.28.0",
"npmClient": "yarn",
"packages": [
"packages/*",

View file

@ -25,6 +25,8 @@
},
]
const MAX_DURATION = 120000 // Maximum duration in milliseconds (2 minutes)
onMount(() => {
if (!parameters.type) {
parameters.type = "success"
@ -33,6 +35,14 @@
parameters.autoDismiss = true
}
})
function handleDurationChange(event) {
let newDuration = event.detail
if (newDuration > MAX_DURATION) {
newDuration = MAX_DURATION
}
parameters.duration = newDuration
}
</script>
<div class="root">
@ -47,6 +57,16 @@
/>
<Label />
<Checkbox text="Auto dismiss" bind:value={parameters.autoDismiss} />
{#if parameters.autoDismiss}
<Label>Duration (ms)</Label>
<DrawerBindableInput
title="Duration"
{bindings}
value={parameters.duration}
placeholder="3000"
on:change={handleDurationChange}
/>
{/if}
</div>
<style>

View file

@ -1,7 +1,7 @@
import { writable, get } from "svelte/store"
import { routeStore } from "./routes"
const NOTIFICATION_TIMEOUT = 3000
const DEFAULT_NOTIFICATION_TIMEOUT = 3000
const createNotificationStore = () => {
let block = false
@ -18,13 +18,13 @@ const createNotificationStore = () => {
type = "info",
icon,
autoDismiss = true,
duration,
count = 1
) => {
if (block) {
return
}
// If peeking, pass notifications back to parent window
if (get(routeStore).queryParams?.peek) {
window.parent.postMessage({
type: "notification",
@ -32,11 +32,13 @@ const createNotificationStore = () => {
message,
type,
icon,
duration,
autoDismiss,
},
})
return
}
const _id = id()
store.update(state => {
const duplicateError = state.find(err => err.message === message)
@ -60,7 +62,7 @@ const createNotificationStore = () => {
if (autoDismiss) {
setTimeout(() => {
dismiss(_id)
}, NOTIFICATION_TIMEOUT)
}, duration || DEFAULT_NOTIFICATION_TIMEOUT)
}
}
@ -74,14 +76,14 @@ const createNotificationStore = () => {
subscribe: store.subscribe,
actions: {
send,
info: (msg, autoDismiss) =>
send(msg, "info", "Info", autoDismiss ?? true),
success: (msg, autoDismiss) =>
send(msg, "success", "CheckmarkCircle", autoDismiss ?? true),
warning: (msg, autoDismiss) =>
send(msg, "warning", "Alert", autoDismiss ?? true),
error: (msg, autoDismiss) =>
send(msg, "error", "Alert", autoDismiss ?? false),
info: (msg, autoDismiss, duration) =>
send(msg, "info", "Info", autoDismiss ?? true, duration),
success: (msg, autoDismiss, duration) =>
send(msg, "success", "CheckmarkCircle", autoDismiss ?? true, duration),
warning: (msg, autoDismiss, duration) =>
send(msg, "warning", "Alert", autoDismiss ?? true, duration),
error: (msg, autoDismiss, duration) =>
send(msg, "error", "Alert", autoDismiss ?? false, duration),
blockNotifications,
dismiss,
},

View file

@ -416,11 +416,11 @@ const continueIfHandler = action => {
}
const showNotificationHandler = action => {
const { message, type, autoDismiss } = action.parameters
const { message, type, autoDismiss, duration } = action.parameters
if (!message || !type) {
return
}
notificationStore.actions[type]?.(message, autoDismiss)
notificationStore.actions[type]?.(message, autoDismiss, duration)
}
const promptUserHandler = () => {}