Extension API to add toast message (#491)

* Extension API to add toast message

* Update readme
This commit is contained in:
Chenlei Hu
2024-08-17 12:44:55 -04:00
committed by GitHub
parent 069766337a
commit 966b1dd057
3 changed files with 33 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
import { SidebarTabExtension } from '@/types/extensionTypes'
import { SidebarTabExtension, ToastManager } from '@/types/extensionTypes'
import { defineStore } from 'pinia'
import { useToastStore } from './toastStore'
interface WorkspaceState {
spinner: boolean
@@ -13,6 +14,11 @@ export const useWorkspaceStore = defineStore('workspace', {
activeSidebarTab: null,
sidebarTabs: []
}),
getters: {
toast(): ToastManager {
return useToastStore()
}
},
actions: {
updateActiveSidebarTab(tabId: string) {
this.activeSidebarTab = tabId

View File

@@ -1,3 +1,4 @@
import type { ToastMessageOptions } from 'primevue/toast'
import { Component } from 'vue'
export interface BaseSidebarTabExtension {
@@ -24,8 +25,18 @@ export type SidebarTabExtension =
| VueSidebarTabExtension
| CustomSidebarTabExtension
export type ToastManager = {
add(message: ToastMessageOptions): void
remove(message: ToastMessageOptions): void
removeAll(): void
}
export interface ExtensionManager {
// Sidebar tabs
registerSidebarTab(tab: SidebarTabExtension): void
unregisterSidebarTab(id: string): void
getSidebarTabs(): SidebarTabExtension[]
// Toast
toast: ToastManager
}