budibase/packages/bbui/src/Modal/ModalContent.svelte

195 lines
4.7 KiB
Svelte
Raw Normal View History

<script context="module">
export const keepOpen = Symbol("keepOpen")
</script>
2021-03-31 11:59:07 +02:00
<script>
2021-04-16 10:02:16 +02:00
import "@spectrum-css/dialog/dist/index-vars.css"
import { getContext } from "svelte"
2021-03-31 11:59:07 +02:00
import Button from "../Button/Button.svelte"
2021-04-14 14:52:25 +02:00
import Divider from "../Divider/Divider.svelte"
import Icon from "../Icon/Icon.svelte"
2021-03-31 11:59:07 +02:00
import Context from "../context"
import ProgressCircle from "../ProgressCircle/ProgressCircle.svelte"
2021-03-31 11:59:07 +02:00
export let title = undefined
2021-05-04 12:07:26 +02:00
export let size = "S"
2021-03-31 11:59:07 +02:00
export let cancelText = "Cancel"
export let confirmText = "Confirm"
export let showCancelButton = true
export let showConfirmButton = true
export let showCloseIcon = true
export let onConfirm = undefined
export let onCancel = undefined
2021-03-31 11:59:07 +02:00
export let disabled = false
export let showDivider = true
2021-03-31 11:59:07 +02:00
2021-11-25 18:14:07 +01:00
export let showSecondaryButton = false
export let secondaryButtonText = undefined
export let secondaryAction = undefined
2021-12-11 10:59:09 +01:00
export let secondaryButtonWarning = false
const { hide, cancel } = getContext(Context.Modal)
2021-03-31 11:59:07 +02:00
let loading = false
$: confirmDisabled = disabled || loading
async function secondary(e) {
2021-11-25 18:14:07 +01:00
loading = true
if (!secondaryAction || (await secondaryAction(e)) !== keepOpen) {
2021-11-25 18:14:07 +01:00
hide()
}
loading = false
}
2024-01-11 17:31:57 +01:00
export async function confirm() {
2021-03-31 11:59:07 +02:00
loading = true
if (!onConfirm || (await onConfirm()) !== keepOpen) {
2021-03-31 11:59:07 +02:00
hide()
}
loading = false
}
async function close() {
loading = true
if (!onCancel || (await onCancel()) !== keepOpen) {
cancel()
}
loading = false
}
2021-03-31 11:59:07 +02:00
</script>
<div
2021-05-04 12:07:26 +02:00
class="spectrum-Dialog"
class:spectrum-Dialog--small={size === "S"}
class:spectrum-Dialog--medium={size === "M"}
class:spectrum-Dialog--large={size === "L"}
class:spectrum-Dialog--extraLarge={size === "XL"}
style="position: relative;"
role="dialog"
tabindex="-1"
aria-modal="true"
>
<div class="spectrum-Dialog-grid">
2022-04-26 13:04:07 +02:00
{#if title || $$slots.header}
<h1
class="spectrum-Dialog-heading spectrum-Dialog-heading--noHeader"
class:noDivider={!showDivider}
class:header-spacing={$$slots.header}
>
{#if title}
{title}
{:else if $$slots.header}
<slot name="header" />
{/if}
</h1>
{#if showDivider}
<Divider />
2022-04-20 10:23:09 +02:00
{/if}
{/if}
<!-- TODO: Remove content-grid class once Layout components are in bbui -->
<section class="spectrum-Dialog-content content-grid">
<slot />
</section>
2022-09-05 12:27:43 +02:00
{#if showCancelButton || showConfirmButton || $$slots.footer}
<div
class="spectrum-ButtonGroup spectrum-Dialog-buttonGroup spectrum-Dialog-buttonGroup--noFooter"
>
<slot name="footer" />
2021-11-25 18:14:07 +01:00
{#if showSecondaryButton && secondaryButtonText && secondaryAction}
<div class="secondary-action">
2021-12-11 10:59:09 +01:00
<Button
group
secondary
warning={secondaryButtonWarning}
on:click={secondary}>{secondaryButtonText}</Button
2021-11-25 18:14:07 +01:00
>
</div>
{/if}
{#if showCancelButton}
Portal redesign (#9336) * Update BB logo to black * Update top nav bar and core layout * Add redesign for apps pages * Update user and groups pages * More WIP portal redesign! * Fix top nav colours and fix selected tab not updating * Remove log * Update copy on settings pages * Update and standardise page headers and subtitles, and remove side nav titles * Update font styles to allow for easy customisation * Update button styles to always use newStyles, update auth page styles * Update settings pages to new designs * Update structure for account pages * Add initial rewrite of app overview section * Update config checklist to properly center * Update app overview version and name/url screens * Add tooltip to explain why URL cannot be changed until unpublishing * Update overview automation history tab * Update overview backups page * Rewrite app overview access tab * Update table hover colours * Remove scrolling from tables when not required and stop selects from updating their own state locally * Update table styles to support flexible column widths much better * Fix extremely long strings in breadcrumbs not wrapping * Fix multiple issues with long text overflow * Fix flashing in version settings page * Fix loading bugs in app backups page * Add sidebar for portal and use it for automation history. Fix multiple overflow and scrolling issues * Tidy up * Update user details page to use tables and match designs * Update users detail page * Update user and group details pages with new tables * Fix automation error linking from apps page and improve automation fetching logic in automation history * Move theme and API key into user profile dropdown instead of settings * Move settings before account and show plugins for devs * Convert plugins page to table and update components and modals * Update links when going back from the builder * Update plugin search placeholder * Fix URLs in app overview * Properly handle text overflow in plugins table * Remove getting started checklist * Fix checklist removal and fix profile modal * Update email details page to match new designs * Cleanup * Add licensing and env logic to determine which account links to show * Update upgrade button URL for cloud accounts * Update app list to use a more compact style * Make core page layout responsive and update apps list to be responsive * Update mobile design of apps page * Update more pages to be responsive and add mobile specific components * Refactor main portal page into multiple components * Update multiple pages to be responsive and improve loading experience * Make automation history page responsive * Update backups page to be responsive * Update pickers to use absolutely positioned root popover so that overflow does not matter * Fix some responsive styles * Fix update link in app overview * Improve dropdown logic * Lint * Update click outside handler to handle modals properly * Remove log * Fix mobile menu upgrade button not closing menu * Hide groups page if disabled at tenant level * Centralise menu logic and show full menu on mobile * Update app access assignment and fix backups table * Ensure avatars cannot be squished * Standardise disabled field text colour * Allow developer users to access users, groups and usage pages * Allow readonly access to users and groups for developer users * Remove logs * Improve users page loading experience * Improve responsiveness on apps list page and fix discussions link styles * Update spacing on user and group detail page and fix usage page showing wrong copy * Fix logo override not working * Pin minio version to an old one that supports the fs backend in dev * Shrink upgrade button * Shrink user dropdown * Update assignment modal text * Remove clickable visual styles from plugins * Always show groups section in app access page * Update app overview button styles to include more CTAs * Hide edit and view links in more menu on overview page unless on mobile * Make usage stats responsive and fix layout issues * Add comment to docker-compose config
2023-01-18 14:56:53 +01:00
<Button group secondary on:click={close}>
2022-08-02 20:41:43 +02:00
{cancelText}
</Button>
{/if}
{#if showConfirmButton}
<span class="confirm-wrap">
<Button
group
cta
{...$$restProps}
disabled={confirmDisabled}
on:click={confirm}
>
{#if loading}
<ProgressCircle overBackground={true} size="S" />
{/if}
{#if !loading}
{confirmText}
{/if}
</Button>
</span>
{/if}
2021-03-31 11:59:07 +02:00
</div>
{/if}
{#if showCloseIcon}
<div class="close-icon">
<Icon hoverable name="Close" on:click={cancel} />
2021-03-31 11:59:07 +02:00
</div>
{/if}
</div>
2021-03-31 11:59:07 +02:00
</div>
<style>
2021-05-04 12:07:26 +02:00
.spectrum-Dialog--extraLarge {
2021-05-04 11:49:33 +02:00
width: 1000px;
}
.content-grid {
display: grid;
position: relative;
gap: var(--spacing-xl);
}
.spectrum-Dialog-content {
overflow: visible;
}
2021-04-22 14:59:00 +02:00
.spectrum-Dialog-heading {
Portal redesign (#9336) * Update BB logo to black * Update top nav bar and core layout * Add redesign for apps pages * Update user and groups pages * More WIP portal redesign! * Fix top nav colours and fix selected tab not updating * Remove log * Update copy on settings pages * Update and standardise page headers and subtitles, and remove side nav titles * Update font styles to allow for easy customisation * Update button styles to always use newStyles, update auth page styles * Update settings pages to new designs * Update structure for account pages * Add initial rewrite of app overview section * Update config checklist to properly center * Update app overview version and name/url screens * Add tooltip to explain why URL cannot be changed until unpublishing * Update overview automation history tab * Update overview backups page * Rewrite app overview access tab * Update table hover colours * Remove scrolling from tables when not required and stop selects from updating their own state locally * Update table styles to support flexible column widths much better * Fix extremely long strings in breadcrumbs not wrapping * Fix multiple issues with long text overflow * Fix flashing in version settings page * Fix loading bugs in app backups page * Add sidebar for portal and use it for automation history. Fix multiple overflow and scrolling issues * Tidy up * Update user details page to use tables and match designs * Update users detail page * Update user and group details pages with new tables * Fix automation error linking from apps page and improve automation fetching logic in automation history * Move theme and API key into user profile dropdown instead of settings * Move settings before account and show plugins for devs * Convert plugins page to table and update components and modals * Update links when going back from the builder * Update plugin search placeholder * Fix URLs in app overview * Properly handle text overflow in plugins table * Remove getting started checklist * Fix checklist removal and fix profile modal * Update email details page to match new designs * Cleanup * Add licensing and env logic to determine which account links to show * Update upgrade button URL for cloud accounts * Update app list to use a more compact style * Make core page layout responsive and update apps list to be responsive * Update mobile design of apps page * Update more pages to be responsive and add mobile specific components * Refactor main portal page into multiple components * Update multiple pages to be responsive and improve loading experience * Make automation history page responsive * Update backups page to be responsive * Update pickers to use absolutely positioned root popover so that overflow does not matter * Fix some responsive styles * Fix update link in app overview * Improve dropdown logic * Lint * Update click outside handler to handle modals properly * Remove log * Fix mobile menu upgrade button not closing menu * Hide groups page if disabled at tenant level * Centralise menu logic and show full menu on mobile * Update app access assignment and fix backups table * Ensure avatars cannot be squished * Standardise disabled field text colour * Allow developer users to access users, groups and usage pages * Allow readonly access to users and groups for developer users * Remove logs * Improve users page loading experience * Improve responsiveness on apps list page and fix discussions link styles * Update spacing on user and group detail page and fix usage page showing wrong copy * Fix logo override not working * Pin minio version to an old one that supports the fs backend in dev * Shrink upgrade button * Shrink user dropdown * Update assignment modal text * Remove clickable visual styles from plugins * Always show groups section in app access page * Update app overview button styles to include more CTAs * Hide edit and view links in more menu on overview page unless on mobile * Make usage stats responsive and fix layout issues * Add comment to docker-compose config
2023-01-18 14:56:53 +01:00
font-family: var(--font-accent);
font-weight: 600;
2021-04-22 14:59:00 +02:00
}
.spectrum-Dialog-heading.noDivider {
margin-bottom: 12px;
}
.spectrum-Dialog-buttonGroup {
gap: var(--spectrum-global-dimension-static-size-200);
}
2021-03-31 11:59:07 +02:00
.close-icon {
position: absolute;
top: 15px;
right: 15px;
2021-03-31 11:59:07 +02:00
font-size: var(--font-size-m);
}
.close-icon :global(svg) {
margin-right: 0;
}
.header-spacing {
display: flex;
justify-content: space-between;
}
2021-11-25 18:14:07 +01:00
.secondary-action {
margin-right: auto;
}
2022-02-10 00:16:24 +01:00
.spectrum-Dialog-buttonGroup {
padding-left: 0;
}
.confirm-wrap :global(.spectrum-Button-label) {
display: contents;
}
2021-03-31 11:59:07 +02:00
</style>