Skip to content

Commit 08a896a

Browse files
authored
Add a 'create new' link in the footer of the DataSourceDropdown. (baserow#4349)
* Adding a 'create new data source' link in the footer of the DataSourceDropdown. * Force a DataSourceCreateEditModal remount by setting a unique key. After an updated event has been emitted, we don't want to edit in the subsequent 'add new' click.
1 parent 1336bdd commit 08a896a

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "feature",
3+
"message": "Added a 'Create new data source' link at the bottom of iterate/table element dropdowns for quicker data source creation.",
4+
"issue_origin": "github",
5+
"issue_number": null,
6+
"domain": "builder",
7+
"bullet_points": [],
8+
"created_at": "2025-11-28"
9+
}

web-frontend/modules/builder/components/dataSource/DataSourceCreateEditModal.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,12 @@ export default {
174174
)
175175
)
176176
177-
await this.actionUpdateDataSource({
177+
const updatedDataSource = await this.actionUpdateDataSource({
178178
page: this.dataSourcePage,
179179
dataSourceId: this.dataSource.id,
180180
values: differences,
181181
})
182+
this.$emit('updated', updatedDataSource)
182183
// Send data source update element event
183184
this.$store.dispatch('element/emitElementEvent', {
184185
event: ELEMENT_EVENTS.DATA_SOURCE_AFTER_UPDATE,

web-frontend/modules/builder/components/dataSource/DataSourceDropdown.vue

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</p>
66
<Dropdown
77
:value="value"
8+
show-footer
89
class="data-source-dropdown"
910
@input="$emit('input', $event)"
1011
>
@@ -37,13 +38,27 @@
3738
}}
3839
</slot>
3940
</template>
41+
<template #footer>
42+
<a class="select__footer-button" @click="openDataSourceModal">
43+
<i class="iconoir-plus"></i>
44+
{{ $t('dataSourceDropdown.addNew') }}
45+
</a>
46+
</template>
4047
</Dropdown>
48+
<DataSourceCreateEditModal
49+
:key="modalKey"
50+
ref="dataSourceCreateEditModal"
51+
@updated="onDataSourceUpdated"
52+
/>
4153
</div>
4254
</template>
4355

4456
<script>
57+
import DataSourceCreateEditModal from '@baserow/modules/builder/components/dataSource/DataSourceCreateEditModal'
58+
4559
export default {
4660
name: 'DataSourceDropdown',
61+
components: { DataSourceCreateEditModal },
4762
props: {
4863
value: {
4964
type: Number,
@@ -65,6 +80,11 @@ export default {
6580
default: false,
6681
},
6782
},
83+
data() {
84+
return {
85+
modalKey: 0,
86+
}
87+
},
6888
computed: {
6989
isOnSharedPage() {
7090
return this.localDataSources === null
@@ -91,6 +111,24 @@ export default {
91111
: this.$t('integrationsCommon.singleRow')
92112
return `${dataSource.name} (${suffix})`
93113
},
114+
openDataSourceModal() {
115+
this.$refs.dataSourceCreateEditModal.show()
116+
},
117+
/**
118+
* When a data source is updated (i.e. the user has created the record,
119+
* *and* updated it), we want to check if it has a valid schema. If it does,
120+
* we emit the input event so that the dropdown updates to select the newly
121+
* created data source.
122+
* @param dataSource - The updated data source.
123+
*/
124+
onDataSourceUpdated(dataSource) {
125+
const serviceType =
126+
dataSource.type && this.$registry.get('service', dataSource.type)
127+
if (serviceType?.getDataSchema(dataSource)) {
128+
this.modalKey++
129+
this.$emit('input', dataSource.id)
130+
}
131+
},
94132
},
95133
}
96134
</script>

web-frontend/modules/builder/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,8 @@
996996
"noDataSources": "No data sources available",
997997
"noSharedDataSources": "No shared data sources available",
998998
"shared": "shared",
999-
"pageOnly": "this page"
999+
"pageOnly": "this page",
1000+
"addNew": "Add new data source"
10001001
},
10011002
"multiPageContainerElementForm": {
10021003
"pagePosition": "Position",

web-frontend/modules/builder/store/dataSource.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,13 @@ const actions = {
140140
dataSource,
141141
values: updatedDataSource,
142142
})
143+
return updatedDataSource
143144
} catch (error) {
144145
await dispatch('forceUpdate', { page, dataSource, values: oldValues })
145146
throw error
147+
} finally {
148+
commit('SET_LOADING', { page, value: false })
146149
}
147-
commit('SET_LOADING', { page, value: false })
148150
},
149151

150152
async debouncedUpdate(

web-frontend/modules/core/assets/scss/components/select.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
margin-bottom: 4px;
278278

279279
@include rounded($rounded);
280-
@include fixed-height(36px, 14px);
280+
@include fixed-height(36px, 13px);
281281
@include flex-align-items(6px);
282282

283283
&:hover {

0 commit comments

Comments
 (0)