Files
Davide Silvestri 3486ba237a feat: data sync run history - record every sync as a job and show it to users (#5706)
* fix: call JobType.on_error hook again when a job fails

The call was accidentally dropped in e0a07588a, leaving the documented
post-transaction error hook dead. Job types rely on it to persist error
details that would otherwise be lost to the rolled-back job transaction.

* feat: record data sync runs as jobs and show the sync history

Periodic data syncs now run through the job system on behalf of the
authorized user, so every sync run (manual or periodic) is recorded as a
SyncDataSyncTableJob with a triggered_by discriminator. A new JobType
scoping hook lets the generic jobs listing expose runs started by other
users after a ListDataSyncJobsOperationType permission check, on both the
type-filter and job_ids polling paths. The frontend shows a paginated run
history (state, trigger, user, time, duration, error) in the data sync
configuration modal and below the manual sync modal, live-updating
through the existing job store poller.

* fix: address feedback
2026-07-22 13:35:50 +02:00

92 lines
2.5 KiB
Vue

<template>
<Modal
ref="modal"
:can-close="!syncLoading && (!jobIsRunning || attachedToExistingRun)"
@hidden="hidden"
>
<template #content>
<div class="import-modal__header">
<h2 class="import-modal__title">
{{ $t('syncTableModal.title', { name: table.name }) }}
</h2>
</div>
<p>
{{ $t('syncTableModal.description') }}
</p>
<Error :error="error"></Error>
<div class="modal-progress__actions margin-top-2">
<ProgressBar
v-if="syncLoading || jobIsRunning || jobIsFinished"
:value="job?.progress_percentage || 0"
:status="jobHumanReadableState"
/>
<div class="align-right">
<Button
v-if="!jobIsFinished"
type="primary"
size="large"
:disabled="syncLoading || jobIsRunning"
:loading="syncLoading || jobIsRunning"
@click="startSync()"
>
{{ $t('syncTableModal.sync') }}
</Button>
<Button v-else type="secondary" size="large" @click="hide()">{{
$t('syncTableModal.hide')
}}</Button>
</div>
</div>
<div v-if="table.data_sync" class="margin-top-3">
<h3>{{ $t('dataSyncRuns.previousRuns') }}</h3>
<DataSyncRunsList
:data-sync-id="table.data_sync.id"
@running-job="attachToRunningJob"
/>
</div>
</template>
</Modal>
</template>
<script>
import modal from '@baserow/modules/core/mixins/modal'
import dataSync from '@baserow/modules/database/mixins/dataSync'
import DataSyncRunsList from '@baserow/modules/database/components/dataSync/DataSyncRunsList'
export default {
name: 'SyncTableModal',
components: { DataSyncRunsList },
mixins: [modal, dataSync],
props: {
table: {
type: Object,
required: true,
},
},
data() {
return {
attachedToExistingRun: false,
}
},
methods: {
show() {
this.job = null
this.attachedToExistingRun = false
this.hideError()
modal.methods.show.bind(this)()
},
startSync() {
this.attachedToExistingRun = false
return this.syncTable(this.table)
},
// Show an in-flight run's progress instead of failing with "already running".
async attachToRunningJob(job) {
if (!this.jobIsRunning) {
this.attachedToExistingRun = true
await this.createAndMonitorJob(job)
}
},
hidden() {},
},
}
</script>