contextmenu and deployment
This commit is contained in:
parent
6e6c25e15e
commit
a94adced72
|
@ -1,28 +0,0 @@
|
||||||
import { writable } from "svelte/store"
|
|
||||||
|
|
||||||
export const INITIAL_CONTEXT_MENU_STATE = {
|
|
||||||
id: null,
|
|
||||||
items: [],
|
|
||||||
position: { x: 0, y: 0 },
|
|
||||||
visible: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createViewsStore() {
|
|
||||||
const store = writable({ ...INITIAL_CONTEXT_MENU_STATE })
|
|
||||||
|
|
||||||
const open = (id, items, position) => {
|
|
||||||
store.set({ id, items, position, visible: true })
|
|
||||||
}
|
|
||||||
|
|
||||||
const close = () => {
|
|
||||||
store.set({ ...INITIAL_CONTEXT_MENU_STATE })
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
subscribe: store.subscribe,
|
|
||||||
open,
|
|
||||||
close,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const contextMenuStore = createViewsStore()
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
import { writable } from "svelte/store"
|
||||||
|
|
||||||
|
interface Position {
|
||||||
|
x: number
|
||||||
|
y: number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MenuItem {
|
||||||
|
label: string
|
||||||
|
icon?: string
|
||||||
|
action: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ContextMenuState {
|
||||||
|
id: string | null
|
||||||
|
items: MenuItem[]
|
||||||
|
position: Position
|
||||||
|
visible: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const INITIAL_CONTEXT_MENU_STATE: ContextMenuState = {
|
||||||
|
id: null,
|
||||||
|
items: [],
|
||||||
|
position: { x: 0, y: 0 },
|
||||||
|
visible: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createViewsStore() {
|
||||||
|
const store = writable<ContextMenuState>({ ...INITIAL_CONTEXT_MENU_STATE })
|
||||||
|
|
||||||
|
const open = (id: string, items: MenuItem[], position: Position): void => {
|
||||||
|
store.set({ id, items, position, visible: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const close = (): void => {
|
||||||
|
store.set({ ...INITIAL_CONTEXT_MENU_STATE })
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
subscribe: store.subscribe,
|
||||||
|
open,
|
||||||
|
close,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const contextMenuStore = createViewsStore()
|
|
@ -1,11 +1,12 @@
|
||||||
import { writable } from "svelte/store"
|
import { writable, type Writable } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
|
import { DeploymentProgressResponse } from "@budibase/types"
|
||||||
|
|
||||||
export const createDeploymentStore = () => {
|
export const createDeploymentStore = () => {
|
||||||
let store = writable([])
|
let store: Writable<DeploymentProgressResponse[]> = writable([])
|
||||||
|
|
||||||
const load = async () => {
|
const load = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
store.set(await API.getAppDeployments())
|
store.set(await API.getAppDeployments())
|
||||||
} catch (err) {
|
} catch (err) {
|
Loading…
Reference in New Issue