Browse Source

fix: handle meta sync properly even if there is no change

- hide meta sync button if there is no change
- ignore invoking populate function if there is no change

re #1047

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1050/head
Pranav C 3 years ago
parent
commit
fd419fca9b
  1. 11
      packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableTables.vue
  2. 5
      packages/nocodb/src/lib/noco/common/handlers/xcMetaDiffSync.ts

11
packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableTables.vue

@ -251,6 +251,7 @@
</x-btn>--> </x-btn>-->
<x-btn <x-btn
v-if="isChanged"
x-large x-large
btn.class="mx-auto primary nc-btn-metasync-sync-now" btn.class="mx-auto primary nc-btn-metasync-sync-now"
tooltip="Sync metadata" tooltip="Sync metadata"
@ -270,17 +271,10 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
// import { isMetaTable } from '@/helpers/xutils'
import XIcon from '@/components/global/xIcon'
import XBtn from '@/components/global/xBtn'
import viewIcons from '~/helpers/viewIcons' import viewIcons from '~/helpers/viewIcons'
export default { export default {
name: 'DisableOrEnableTables', name: 'DisableOrEnableTables',
components: {
XBtn,
XIcon
},
props: ['nodes', 'db'], props: ['nodes', 'db'],
data: () => ({ data: () => ({
viewIcons, viewIcons,
@ -425,6 +419,9 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
isChanged() {
return this.diff && this.diff.some(d => d && d.detectedChanges && d.detectedChanges.length)
},
prefix() { prefix() {
return this.$store.getters['project/GtrProjectPrefix'] || '' return this.$store.getters['project/GtrProjectPrefix'] || ''
} }

5
packages/nocodb/src/lib/noco/common/handlers/xcMetaDiffSync.ts

@ -785,8 +785,13 @@ if (sIndex > -1) {
populateParams.tableNames = populateParams.tableNames?.filter(t => { populateParams.tableNames = populateParams.tableNames?.filter(t => {
return t === populateParams.tableNames.find(t1 => t1.tn === t.tn); return t === populateParams.tableNames.find(t1 => t1.tn === t.tn);
}); });
// invoke only if there is change in at least one table
if (populateParams.tableNames?.length) {
await this.xcTablesPopulate(populateParams); await this.xcTablesPopulate(populateParams);
} else if (populateViewsParams.tableNames?.length) {
await this.xcTablesPopulate(populateViewsParams); await this.xcTablesPopulate(populateViewsParams);
}
if (this instanceof GqlApiBuilder) { if (this instanceof GqlApiBuilder) {
await (this as GqlApiBuilder).reInitializeGraphqlEndpoint(); await (this as GqlApiBuilder).reInitializeGraphqlEndpoint();

Loading…
Cancel
Save