Update backups store to TS£
This commit is contained in:
parent
5088979b18
commit
c21581f4cc
|
@ -1,40 +0,0 @@
|
|||
import { writable } from "svelte/store"
|
||||
import { API } from "@/api"
|
||||
|
||||
export function createBackupsStore() {
|
||||
const store = writable({})
|
||||
|
||||
function selectBackup(backupId) {
|
||||
store.update(state => {
|
||||
state.selectedBackup = backupId
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
||||
async function searchBackups(appId, opts) {
|
||||
return API.searchBackups(appId, opts)
|
||||
}
|
||||
|
||||
async function restoreBackup(appId, backupId, name) {
|
||||
return API.restoreBackup(appId, backupId, name)
|
||||
}
|
||||
|
||||
async function deleteBackup(appId, backupId) {
|
||||
return API.deleteBackup(appId, backupId)
|
||||
}
|
||||
|
||||
async function createManualBackup(appId) {
|
||||
return API.createManualBackup(appId)
|
||||
}
|
||||
|
||||
return {
|
||||
createManualBackup,
|
||||
searchBackups,
|
||||
selectBackup,
|
||||
deleteBackup,
|
||||
restoreBackup,
|
||||
subscribe: store.subscribe,
|
||||
}
|
||||
}
|
||||
|
||||
export const backups = createBackupsStore()
|
|
@ -0,0 +1,38 @@
|
|||
import { API } from "@/api"
|
||||
import { BudiStore } from "../BudiStore"
|
||||
import { SearchAppBackupsRequest } from "@budibase/types"
|
||||
|
||||
interface BackupState {
|
||||
selectedBackup?: string
|
||||
}
|
||||
|
||||
class BackupStore extends BudiStore<BackupState> {
|
||||
constructor() {
|
||||
super({})
|
||||
}
|
||||
|
||||
selectBackup(backupId: string) {
|
||||
this.update(state => {
|
||||
state.selectedBackup = backupId
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
||||
async searchBackups(appId: string, opts: SearchAppBackupsRequest) {
|
||||
return API.searchBackups(appId, opts)
|
||||
}
|
||||
|
||||
async restoreBackup(appId: string, backupId: string, name?: string) {
|
||||
return API.restoreBackup(appId, backupId, name)
|
||||
}
|
||||
|
||||
async deleteBackup(appId: string, backupId: string) {
|
||||
return API.deleteBackup(appId, backupId)
|
||||
}
|
||||
|
||||
async createManualBackup(appId: string) {
|
||||
return API.createManualBackup(appId)
|
||||
}
|
||||
}
|
||||
|
||||
export const backups = new BackupStore()
|
Loading…
Reference in New Issue