Merge pull request #8476 from Budibase/fix/2.1.x-fixes
Backups UI improvements and fix for datasource setting saving
This commit is contained in:
commit
45154e0961
|
@ -44,7 +44,7 @@
|
||||||
// run the validation whenever the config changes
|
// run the validation whenever the config changes
|
||||||
$: validation.check(config)
|
$: validation.check(config)
|
||||||
// dispatch the validation result
|
// dispatch the validation result
|
||||||
$: dispatch("valid", $validation.valid)
|
$: dispatch("valid", Object.keys($validation.errors).length === 0)
|
||||||
|
|
||||||
let addButton
|
let addButton
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
||||||
import CreateRestoreModal from "./CreateRestoreModal.svelte"
|
import CreateRestoreModal from "./CreateRestoreModal.svelte"
|
||||||
import { createEventDispatcher } from "svelte"
|
import { createEventDispatcher, onMount } from "svelte"
|
||||||
|
|
||||||
export let row
|
export let row
|
||||||
|
|
||||||
|
@ -49,6 +49,10 @@
|
||||||
async function downloadExport() {
|
async function downloadExport() {
|
||||||
window.open(`/api/apps/${row.appId}/backups/${row._id}/file`, "_blank")
|
window.open(`/api/apps/${row.appId}/backups/${row._id}/file`, "_blank")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
name = row.name
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="cell">
|
<div class="cell">
|
||||||
|
@ -62,7 +66,7 @@
|
||||||
<MenuItem on:click={deleteDialog.show} icon="Delete">Delete</MenuItem>
|
<MenuItem on:click={deleteDialog.show} icon="Delete">Delete</MenuItem>
|
||||||
<MenuItem on:click={downloadExport} icon="Download">Download</MenuItem>
|
<MenuItem on:click={downloadExport} icon="Download">Download</MenuItem>
|
||||||
{/if}
|
{/if}
|
||||||
<MenuItem on:click={updateDialog.show} icon="Edit">Update</MenuItem>
|
<MenuItem on:click={updateDialog.show} icon="Edit">Rename</MenuItem>
|
||||||
</ActionMenu>
|
</ActionMenu>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -100,7 +104,7 @@
|
||||||
title="Update Backup"
|
title="Update Backup"
|
||||||
warning={false}
|
warning={false}
|
||||||
>
|
>
|
||||||
<Input onlabel="Backup name" placeholder={row.name} bind:value={name} />
|
<Input onlabel="Backup name" bind:value={name} />
|
||||||
</ConfirmDialog>
|
</ConfirmDialog>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -21,13 +21,14 @@
|
||||||
import AppSizeRenderer from "./AppSizeRenderer.svelte"
|
import AppSizeRenderer from "./AppSizeRenderer.svelte"
|
||||||
import CreateBackupModal from "./CreateBackupModal.svelte"
|
import CreateBackupModal from "./CreateBackupModal.svelte"
|
||||||
import ActionsRenderer from "./ActionsRenderer.svelte"
|
import ActionsRenderer from "./ActionsRenderer.svelte"
|
||||||
import DateRenderer from "./DateRenderer.svelte"
|
import DateRenderer from "components/common/renderers/DateTimeRenderer.svelte"
|
||||||
import UserRenderer from "./UserRenderer.svelte"
|
import UserRenderer from "./UserRenderer.svelte"
|
||||||
import StatusRenderer from "./StatusRenderer.svelte"
|
import StatusRenderer from "./StatusRenderer.svelte"
|
||||||
import TypeRenderer from "./TypeRenderer.svelte"
|
import TypeRenderer from "./TypeRenderer.svelte"
|
||||||
|
import NameRenderer from "./NameRenderer.svelte"
|
||||||
import BackupsDefault from "assets/backups-default.png"
|
import BackupsDefault from "assets/backups-default.png"
|
||||||
|
import { BackupTrigger, BackupType } from "constants/backend/backups"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
export let app
|
export let app
|
||||||
|
|
||||||
let backupData = null
|
let backupData = null
|
||||||
|
@ -36,30 +37,34 @@
|
||||||
let filterOpt = null
|
let filterOpt = null
|
||||||
let startDate = null
|
let startDate = null
|
||||||
let endDate = null
|
let endDate = null
|
||||||
let filters = getFilters()
|
|
||||||
let loaded = false
|
let loaded = false
|
||||||
|
let filters = [
|
||||||
|
{
|
||||||
|
label: "Manual backup",
|
||||||
|
value: { type: BackupType.BACKUP, trigger: BackupTrigger.MANUAL },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Published backup",
|
||||||
|
value: { type: BackupType.BACKUP, trigger: BackupTrigger.PUBLISH },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Scheduled backup",
|
||||||
|
value: { type: BackupType.BACKUP, trigger: BackupTrigger.SCHEDULED },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Pre-restore backup",
|
||||||
|
value: { type: BackupType.BACKUP, trigger: BackupTrigger.RESTORING },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Manual restore",
|
||||||
|
value: { type: BackupType.RESTORE, trigger: BackupTrigger.MANUAL },
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
$: page = $pageInfo.page
|
$: page = $pageInfo.page
|
||||||
$: fetchBackups(filterOpt, page, startDate, endDate)
|
$: fetchBackups(filterOpt, page, startDate, endDate)
|
||||||
|
|
||||||
function getFilters() {
|
let schema = {
|
||||||
const options = []
|
|
||||||
let types = ["backup"]
|
|
||||||
let triggers = ["manual", "publish", "scheduled", "restoring"]
|
|
||||||
for (let type of types) {
|
|
||||||
for (let trigger of triggers) {
|
|
||||||
let label = `${trigger} ${type}`
|
|
||||||
label = label.charAt(0).toUpperCase() + label?.slice(1)
|
|
||||||
options.push({ label, value: { type, trigger } })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options.push({
|
|
||||||
label: `Manual restore`,
|
|
||||||
value: { type: "restore", trigger: "manual" },
|
|
||||||
})
|
|
||||||
return options
|
|
||||||
}
|
|
||||||
|
|
||||||
const schema = {
|
|
||||||
type: {
|
type: {
|
||||||
displayName: "Type",
|
displayName: "Type",
|
||||||
width: "auto",
|
width: "auto",
|
||||||
|
@ -97,6 +102,7 @@
|
||||||
{ column: "createdBy", component: UserRenderer },
|
{ column: "createdBy", component: UserRenderer },
|
||||||
{ column: "status", component: StatusRenderer },
|
{ column: "status", component: StatusRenderer },
|
||||||
{ column: "type", component: TypeRenderer },
|
{ column: "type", component: TypeRenderer },
|
||||||
|
{ column: "name", component: NameRenderer },
|
||||||
]
|
]
|
||||||
|
|
||||||
function flattenBackups(backups) {
|
function flattenBackups(backups) {
|
||||||
|
@ -260,7 +266,7 @@
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="table">
|
||||||
<Table
|
<Table
|
||||||
{schema}
|
{schema}
|
||||||
disableSorting
|
disableSorting
|
||||||
|
@ -308,7 +314,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.select {
|
.select {
|
||||||
flex-basis: 150px;
|
flex-basis: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination {
|
.pagination {
|
||||||
|
@ -342,4 +348,8 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: var(--spacing-m);
|
gap: var(--spacing-m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table {
|
||||||
|
overflow-x: scroll;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
<script>
|
|
||||||
import DateTimeRenderer from "components/common/renderers/DateTimeRenderer.svelte"
|
|
||||||
import dayjs from "dayjs"
|
|
||||||
import relativeTime from "dayjs/plugin/relativeTime"
|
|
||||||
dayjs.extend(relativeTime)
|
|
||||||
|
|
||||||
export let value
|
|
||||||
$: timeSince = dayjs(value).fromNow()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="cell">
|
|
||||||
{timeSince} - <DateTimeRenderer {value} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.cell {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
gap: var(--spacing-m);
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<script>
|
||||||
|
import { truncate } from "lodash"
|
||||||
|
|
||||||
|
export let value
|
||||||
|
$: truncatedValue = truncate(value, { length: 12 })
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{truncatedValue}
|
|
@ -1,13 +1,29 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { BackupTrigger } from "constants/backend/backups"
|
||||||
export let row
|
export let row
|
||||||
|
|
||||||
$: baseTrig = row?.trigger || "manual"
|
$: trigger = row?.trigger || "manual"
|
||||||
$: type = row?.type || "backup"
|
$: type = row?.type || "backup"
|
||||||
$: trigger = baseTrig.charAt(0).toUpperCase() + baseTrig.slice(1)
|
|
||||||
|
function printTrigger(trig) {
|
||||||
|
let final = "undefined"
|
||||||
|
switch (trig) {
|
||||||
|
case BackupTrigger.PUBLISH:
|
||||||
|
final = "published"
|
||||||
|
break
|
||||||
|
case BackupTrigger.RESTORING:
|
||||||
|
final = "pre-restore"
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
final = trig
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return final.charAt(0).toUpperCase() + final.slice(1)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="cell">
|
<div class="cell">
|
||||||
{trigger}
|
{printTrigger(trigger)}
|
||||||
{type}
|
{type}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
export const BackupTrigger = {
|
||||||
|
MANUAL: "manual",
|
||||||
|
PUBLISH: "publish",
|
||||||
|
RESTORING: "restoring",
|
||||||
|
SCHEDULED: "scheduled",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const BackupType = {
|
||||||
|
BACKUP: "backup",
|
||||||
|
RESTORE: "restore",
|
||||||
|
}
|
|
@ -383,10 +383,5 @@
|
||||||
.user-dropdown {
|
.user-dropdown {
|
||||||
flex: 0 1 0;
|
flex: 0 1 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reduce BBUI page padding */
|
|
||||||
.content :global(> *) {
|
|
||||||
padding: calc(var(--spacing-xl) * 1.5) !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -391,11 +391,7 @@
|
||||||
gap: var(--spacing-l);
|
gap: var(--spacing-l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (max-width: 640px) {
|
|
||||||
.overview-wrap :global(.content > *) {
|
|
||||||
padding: calc(var(--spacing-xl) * 1.5) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.app-title {
|
.app-title {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: var(--spacing-m);
|
gap: var(--spacing-m);
|
||||||
|
|
Loading…
Reference in New Issue