Skip to content

Commit

Permalink
feat: Add notification on app save (#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-kov committed Nov 24, 2022
1 parent 9008cd7 commit 79cec36
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
23 changes: 17 additions & 6 deletions frontend/src/lib/components/apps/editor/AppEditorHeader.svelte
Expand Up @@ -7,26 +7,37 @@
import { userStore, workspaceStore } from '$lib/stores'
import { faDisplay, faExternalLink, faHand } from '@fortawesome/free-solid-svg-icons'
import { getContext } from 'svelte'
import { sendUserToast } from '../../../utils'
import type { AppEditorContext, EditorMode } from '../types'
export let title: string
export let mode: EditorMode
const { app } = getContext<AppEditorContext>('AppEditorContext')
export let title: string = $app.title || ''
export let mode: EditorMode
const loading = {
publish: false,
save: false
}
async function save() {
await AppService.updateApp({
loading.save = true
AppService.updateApp({
workspace: $workspaceStore!,
path: $page.params.path,
requestBody: {
value: $app!,
summary: 'App summary',
summary: title,
policy: {
triggerables: {},
execution_mode: Policy.execution_mode.PUBLISHER,
on_behalf_of: `u/${$userStore?.username}`
}
}
}).then(() => {
sendUserToast('Saved successfully.')
}).catch(() => {
sendUserToast('Error during saving. Please try again later.', true)
}).finally(() => {
loading.save = false
})
}
</script>
Expand All @@ -47,6 +58,6 @@
<Button color="dark" size="xs" variant="border" startIcon={{ icon: faExternalLink }}>
Publish
</Button>
<Button on:click={save} color="dark" size="xs">Save</Button>
<Button loading={loading.save} on:click={save} color="dark" size="xs">Save</Button>
</div>
</div>
4 changes: 2 additions & 2 deletions frontend/src/lib/components/common/button/Button.svelte
Expand Up @@ -21,8 +21,8 @@
export let id: string = ''
export let nonCaptureEvent: boolean = false
export let buttonType: 'button' | 'submit' | 'reset' = 'button'
export let loading = false
let loading = false
const dispatch = createEventDispatcher()
// Order of classes: border, border modifier, bg, bg modifier, text, text modifier, everything else
Expand Down Expand Up @@ -68,7 +68,6 @@
btnClasses,
disabled ? 'bg-gray-300' : ''
),
disabled,
href,
target,
tabindex: disabled ? -1 : 0,
Expand Down Expand Up @@ -106,6 +105,7 @@
on:focus
on:blur
{...buttonProps}
disabled={disabled || loading}
type="submit"
>
{#if loading}
Expand Down

0 comments on commit 79cec36

Please sign in to comment.