Use constant for keeping modal open (#11067)
This commit is contained in:
parent
dd921f456f
commit
1f59986a87
|
@ -1,3 +1,7 @@
|
||||||
|
<script context="module">
|
||||||
|
export const keepOpen = Symbol("keepOpen")
|
||||||
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import "@spectrum-css/dialog/dist/index-vars.css"
|
import "@spectrum-css/dialog/dist/index-vars.css"
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
|
@ -30,7 +34,7 @@
|
||||||
|
|
||||||
async function secondary(e) {
|
async function secondary(e) {
|
||||||
loading = true
|
loading = true
|
||||||
if (!secondaryAction || (await secondaryAction(e)) !== false) {
|
if (!secondaryAction || (await secondaryAction(e)) !== keepOpen) {
|
||||||
hide()
|
hide()
|
||||||
}
|
}
|
||||||
loading = false
|
loading = false
|
||||||
|
@ -38,7 +42,7 @@
|
||||||
|
|
||||||
async function confirm() {
|
async function confirm() {
|
||||||
loading = true
|
loading = true
|
||||||
if (!onConfirm || (await onConfirm()) !== false) {
|
if (!onConfirm || (await onConfirm()) !== keepOpen) {
|
||||||
hide()
|
hide()
|
||||||
}
|
}
|
||||||
loading = false
|
loading = false
|
||||||
|
@ -46,7 +50,7 @@
|
||||||
|
|
||||||
async function close() {
|
async function close() {
|
||||||
loading = true
|
loading = true
|
||||||
if (!onCancel || (await onCancel()) !== false) {
|
if (!onCancel || (await onCancel()) !== keepOpen) {
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
loading = false
|
loading = false
|
||||||
|
|
|
@ -42,7 +42,7 @@ export { default as MenuSection } from "./Menu/Section.svelte"
|
||||||
export { default as MenuSeparator } from "./Menu/Separator.svelte"
|
export { default as MenuSeparator } from "./Menu/Separator.svelte"
|
||||||
export { default as MenuItem } from "./Menu/Item.svelte"
|
export { default as MenuItem } from "./Menu/Item.svelte"
|
||||||
export { default as Modal } from "./Modal/Modal.svelte"
|
export { default as Modal } from "./Modal/Modal.svelte"
|
||||||
export { default as ModalContent } from "./Modal/ModalContent.svelte"
|
export { default as ModalContent, keepOpen } from "./Modal/ModalContent.svelte"
|
||||||
export { default as NotificationDisplay } from "./Notification/NotificationDisplay.svelte"
|
export { default as NotificationDisplay } from "./Notification/NotificationDisplay.svelte"
|
||||||
export { default as Notification } from "./Notification/Notification.svelte"
|
export { default as Notification } from "./Notification/Notification.svelte"
|
||||||
export { default as SideNavigation } from "./SideNavigation/Navigation.svelte"
|
export { default as SideNavigation } from "./SideNavigation/Navigation.svelte"
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
import { createEventDispatcher } from "svelte"
|
import { createEventDispatcher } from "svelte"
|
||||||
import { tables } from "stores/backend"
|
import { tables } from "stores/backend"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { ModalContent, keepOpen, notifications } from "@budibase/bbui"
|
||||||
import RowFieldControl from "../RowFieldControl.svelte"
|
import RowFieldControl from "../RowFieldControl.svelte"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { ModalContent } from "@budibase/bbui"
|
|
||||||
import { FIELDS } from "constants/backend"
|
import { FIELDS } from "constants/backend"
|
||||||
|
|
||||||
const FORMULA_TYPE = FIELDS.FORMULA.type
|
const FORMULA_TYPE = FIELDS.FORMULA.type
|
||||||
|
@ -41,8 +40,8 @@
|
||||||
} else {
|
} else {
|
||||||
notifications.error(`Failed to save row - ${error.message}`)
|
notifications.error(`Failed to save row - ${error.message}`)
|
||||||
}
|
}
|
||||||
// Prevent modal closing if there were errors
|
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
import RowFieldControl from "../RowFieldControl.svelte"
|
import RowFieldControl from "../RowFieldControl.svelte"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { ModalContent, Select, Link } from "@budibase/bbui"
|
import { keepOpen, ModalContent, Select, Link } from "@budibase/bbui"
|
||||||
import ErrorsBox from "components/common/ErrorsBox.svelte"
|
import ErrorsBox from "components/common/ErrorsBox.svelte"
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
errors = [...errors, { message: "Role is required" }]
|
errors = [...errors, { message: "Role is required" }]
|
||||||
}
|
}
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -79,8 +79,8 @@
|
||||||
} else {
|
} else {
|
||||||
notifications.error("Error saving user")
|
notifications.error("Error saving user")
|
||||||
}
|
}
|
||||||
// Prevent closing the modal on errors
|
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { ModalContent, Select, Input, Button } from "@budibase/bbui"
|
import { keepOpen, ModalContent, Select, Input, Button } from "@budibase/bbui"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
errors.push({ message: "Please choose permissions" })
|
errors.push({ message: "Please choose permissions" })
|
||||||
}
|
}
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save/create the role
|
// Save/create the role
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
notifications.success("Role saved successfully")
|
notifications.success("Role saved successfully")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error(`Error saving role - ${error.message}`)
|
notifications.error(`Error saving role - ${error.message}`)
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
import {
|
import {
|
||||||
|
keepOpen,
|
||||||
ModalContent,
|
ModalContent,
|
||||||
notifications,
|
notifications,
|
||||||
Body,
|
Body,
|
||||||
|
@ -70,10 +71,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
notifications.success(`Imported successfully.`)
|
notifications.success(`Imported successfully.`)
|
||||||
return true
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error importing queries")
|
notifications.error("Error importing queries")
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
|
keepOpen,
|
||||||
Modal,
|
Modal,
|
||||||
notifications,
|
notifications,
|
||||||
Body,
|
Body,
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
let createVariableModal
|
let createVariableModal
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { RelationshipTypes } from "constants/backend"
|
import { RelationshipTypes } from "constants/backend"
|
||||||
import {
|
import {
|
||||||
|
keepOpen,
|
||||||
Button,
|
Button,
|
||||||
Input,
|
Input,
|
||||||
ModalContent,
|
ModalContent,
|
||||||
|
@ -277,7 +278,7 @@
|
||||||
|
|
||||||
async function saveRelationship() {
|
async function saveRelationship() {
|
||||||
if (!validate()) {
|
if (!validate()) {
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
buildRelationships()
|
buildRelationships()
|
||||||
removeExistingRelationship()
|
removeExistingRelationship()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { derived, writable, get } from "svelte/store"
|
import { derived, writable, get } from "svelte/store"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { keepOpen, notifications } from "@budibase/bbui"
|
||||||
import { datasources, ImportTableError } from "stores/backend"
|
import { datasources, ImportTableError } from "stores/backend"
|
||||||
|
|
||||||
export const createTableSelectionStore = (integration, datasource) => {
|
export const createTableSelectionStore = (integration, datasource) => {
|
||||||
|
@ -37,8 +37,7 @@ export const createTableSelectionStore = (integration, datasource) => {
|
||||||
notifications.error("Error fetching tables.")
|
notifications.error("Error fetching tables.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent modal closing
|
return keepOpen
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
<script>
|
<script>
|
||||||
import { ModalContent, Body, notifications, CopyInput } from "@budibase/bbui"
|
import {
|
||||||
|
ModalContent,
|
||||||
|
keepOpen,
|
||||||
|
Body,
|
||||||
|
notifications,
|
||||||
|
CopyInput,
|
||||||
|
} from "@budibase/bbui"
|
||||||
import { auth } from "stores/portal"
|
import { auth } from "stores/portal"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
|
@ -12,8 +18,8 @@
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notifications.error("Unable to generate new API key")
|
notifications.error("Unable to generate new API key")
|
||||||
}
|
}
|
||||||
// need to return false to keep modal open
|
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
<script>
|
<script>
|
||||||
import { writable, get as svelteGet } from "svelte/store"
|
import { writable, get as svelteGet } from "svelte/store"
|
||||||
import { notifications, Input, ModalContent, Dropzone } from "@budibase/bbui"
|
import {
|
||||||
|
notifications,
|
||||||
|
keepOpen,
|
||||||
|
Input,
|
||||||
|
ModalContent,
|
||||||
|
Dropzone,
|
||||||
|
} from "@budibase/bbui"
|
||||||
import { store, automationStore } from "builderStore"
|
import { store, automationStore } from "builderStore"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { apps, admin, auth } from "stores/portal"
|
import { apps, admin, auth } from "stores/portal"
|
||||||
|
@ -167,7 +173,7 @@
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
if (encryptedFile) {
|
if (encryptedFile) {
|
||||||
currentStep = Step.SET_PASSWORD
|
currentStep = Step.SET_PASSWORD
|
||||||
return false
|
return keepOpen
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
await createNewApp()
|
await createNewApp()
|
||||||
|
@ -190,7 +196,7 @@
|
||||||
message += `: ${lowercase(e.message)}`
|
message += `: ${lowercase(e.message)}`
|
||||||
}
|
}
|
||||||
notifications.error(message)
|
notifications.error(message)
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isValid: $encryptionValidation.valid,
|
isValid: $encryptionValidation.valid,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
ModalContent,
|
ModalContent,
|
||||||
|
keepOpen,
|
||||||
Toggle,
|
Toggle,
|
||||||
Body,
|
Body,
|
||||||
InlineAlert,
|
InlineAlert,
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
exportApp()
|
exportApp()
|
||||||
} else {
|
} else {
|
||||||
currentStep = Step.SET_PASSWORD
|
currentStep = Step.SET_PASSWORD
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isValid: true,
|
isValid: true,
|
||||||
|
@ -43,7 +44,7 @@
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
await validation.check({ password })
|
await validation.check({ password })
|
||||||
if (!$validation.valid) {
|
if (!$validation.valid) {
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
exportApp(password)
|
exportApp(password)
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { Modal } from "@budibase/bbui"
|
import { Modal, keepOpen } from "@budibase/bbui"
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
import { IntegrationTypes } from "constants/backend"
|
import { IntegrationTypes } from "constants/backend"
|
||||||
import GoogleAuthPrompt from "./GoogleAuthPrompt.svelte"
|
import GoogleAuthPrompt from "./GoogleAuthPrompt.svelte"
|
||||||
|
@ -75,8 +75,7 @@
|
||||||
notifications.error(`Error creating datasource: ${e.message}`)
|
notifications.error(`Error creating datasource: ${e.message}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent modal closing
|
return keepOpen
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { Modal, notifications } from "@budibase/bbui"
|
import { keepOpen, Modal, notifications } from "@budibase/bbui"
|
||||||
import { integrationForDatasource } from "stores/selectors"
|
import { integrationForDatasource } from "stores/selectors"
|
||||||
import { datasources, integrations } from "stores/backend"
|
import { datasources, integrations } from "stores/backend"
|
||||||
import DatasourceConfigEditor from "components/backend/Datasources/ConfigEditor/index.svelte"
|
import DatasourceConfigEditor from "components/backend/Datasources/ConfigEditor/index.svelte"
|
||||||
|
@ -23,8 +23,8 @@
|
||||||
)
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notifications.error(err?.message ?? "Error saving datasource")
|
notifications.error(err?.message ?? "Error saving datasource")
|
||||||
// prevent the modal from closing
|
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
import {
|
import {
|
||||||
|
keepOpen,
|
||||||
ModalContent,
|
ModalContent,
|
||||||
notifications,
|
notifications,
|
||||||
Body,
|
Body,
|
||||||
|
@ -70,10 +71,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
notifications.success("Imported successfully")
|
notifications.success("Imported successfully")
|
||||||
return true
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error importing queries")
|
notifications.error("Error importing queries")
|
||||||
return false
|
|
||||||
|
return keepOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { Body, ModalContent, Select } from "@budibase/bbui"
|
import { keepOpen, Body, ModalContent, Select } from "@budibase/bbui"
|
||||||
import { apps, groups } from "stores/portal"
|
import { apps, groups } from "stores/portal"
|
||||||
import { roles } from "stores/backend"
|
import { roles } from "stores/backend"
|
||||||
import RoleSelect from "components/common/RoleSelect.svelte"
|
import RoleSelect from "components/common/RoleSelect.svelte"
|
||||||
|
@ -20,8 +20,8 @@
|
||||||
if (!selectingRole) {
|
if (!selectingRole) {
|
||||||
selectingRole = true
|
selectingRole = true
|
||||||
await roles.fetchByAppId(prodAppId)
|
await roles.fetchByAppId(prodAppId)
|
||||||
// return false to stop closing modal
|
|
||||||
return false
|
return keepOpen
|
||||||
} else {
|
} else {
|
||||||
await groups.actions.addApp(group._id, prodAppId, selectedRoleId)
|
await groups.actions.addApp(group._id, prodAppId, selectedRoleId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
|
keepOpen,
|
||||||
ColorPicker,
|
ColorPicker,
|
||||||
Body,
|
Body,
|
||||||
ModalContent,
|
ModalContent,
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
if (!group.name?.trim()) {
|
if (!group.name?.trim()) {
|
||||||
nameError = "Group name cannot be empty"
|
nameError = "Group name cannot be empty"
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
saveGroup(group)
|
saveGroup(group)
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
|
keepOpen,
|
||||||
Label,
|
Label,
|
||||||
ActionButton,
|
ActionButton,
|
||||||
ModalContent,
|
ModalContent,
|
||||||
|
@ -73,7 +74,7 @@
|
||||||
valid = validateInput(input, index) && valid
|
valid = validateInput(input, index) && valid
|
||||||
})
|
})
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return false
|
return keepOpen
|
||||||
}
|
}
|
||||||
showOnboardingTypeModal({ users: userData, groups: userGroups })
|
showOnboardingTypeModal({ users: userData, groups: userGroups })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue