Merge pull request #2878 from beekeeper-studio/fix/unsaved-conn-dupes

fix duplication of unsaved connections
This commit is contained in:
Matthew Rathbone
2025-03-13 18:36:21 -05:00
committed by GitHub
2 changed files with 21 additions and 4 deletions

View File

@@ -203,6 +203,9 @@ export default Vue.extend({
...mapState('data/connections', { 'connections': 'items' }),
...mapGetters(['isUltimate']),
...mapGetters('licenses', ['isTrial', 'trialLicense']),
...mapGetters({
'usedConfigs': 'data/usedconnections/orderedUsedConfigs',
}),
communityConnectionTypes() {
return this.$config.defaults.connectionTypes.filter((ct) => !isUltimateType(ct.value))
},
@@ -384,6 +387,15 @@ export default Vue.extend({
this.connectionError = null
try {
this.connecting = true
// If this is an existing used connection that doesn't have an associated saved connection
// we need to see if changes have been made to the config
if (this.config.connectionId === null && this.config.id) {
const oldConfig = this.usedConfigs.find((c) => c.id === this.config.id);
if (!_.isEqual(this.config, oldConfig)) {
this.config.id = null;
}
}
await this.$store.dispatch('connect', this.config)
} catch (ex) {
this.connectionError = ex
@@ -433,6 +445,13 @@ export default Vue.extend({
}
const id = await this.$store.dispatch('data/connections/save', this.config)
// This feels wrong but it works. It's undefined on savedConnections
if (this.config.connectionId === null) {
this.config.connectionId = id;
await this.$store.dispatch('data/usedconnections/save', this.config);
}
this.$noty.success("Connection Saved")
// we want to fetch the saved one in case it's changed
const connection = this.connections.find((c) => c.id === id)

View File

@@ -206,16 +206,14 @@ export default {
if (this.savedConnection) {
this.$emit('edit', this.savedConnection)
} else {
const editable = await this.$store.dispatch('data/connections/clone', this.config)
this.$emit('edit', editable)
this.$emit('edit', this.config)
}
},
async doubleClick() {
if (this.savedConnection) {
this.$emit('doubleClick', this.savedConnection)
} else {
const editable = await this.$store.dispatch('data/connections/clone', this.config)
this.$emit('doubleClick', editable)
this.$emit('doubleClick', this.config)
}
},
remove() {