1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-14 09:08:32 +00:00

Improve the user source creation experience.

This commit is contained in:
Peter Evans 2025-03-18 16:45:25 +00:00
parent cac5aaf28e
commit 04c2679ad0
7 changed files with 107 additions and 16 deletions
changelog/entries/unreleased/feature
enterprise/web-frontend/modules/baserow_enterprise/builder/components/elements
web-frontend/modules/builder

View file

@ -0,0 +1,8 @@
{
"type": "feature",
"message": "Introduced a shortcut in the Login form configuration so that it's easier to create a new user source.",
"domain": "builder",
"issue_number": null,
"bullet_points": [],
"created_at": "2025-03-14"
}

View file

@ -12,14 +12,11 @@
required required
class="margin-bottom-2" class="margin-bottom-2"
> >
<Dropdown v-model="values.user_source_id" :show-search="false"> <UserSourceDropdown
<DropdownItem v-model="values.user_source_id"
v-for="userSource in userSources" :builder="builder"
:key="userSource.id" :user-sources="userSources"
:name="userSource.name" ></UserSourceDropdown>
:value="userSource.id"
/>
</Dropdown>
</FormGroup> </FormGroup>
<CustomStyle <CustomStyle
v-model="values.styles" v-model="values.styles"
@ -45,10 +42,12 @@
import elementForm from '@baserow/modules/builder/mixins/elementForm' import elementForm from '@baserow/modules/builder/mixins/elementForm'
import CustomStyle from '@baserow/modules/builder/components/elements/components/forms/style/CustomStyle' import CustomStyle from '@baserow/modules/builder/components/elements/components/forms/style/CustomStyle'
import InjectedFormulaInput from '@baserow/modules/core/components/formula/InjectedFormulaInput' import InjectedFormulaInput from '@baserow/modules/core/components/formula/InjectedFormulaInput'
import UserSourceDropdown from '@baserow/modules/builder/components/userSource/UserSourceDropdown'
export default { export default {
name: 'AuthFormElementForm', name: 'AuthFormElementForm',
components: { components: {
UserSourceDropdown,
CustomStyle, CustomStyle,
InjectedFormulaInput, InjectedFormulaInput,
}, },
@ -69,9 +68,5 @@ export default {
return this.$store.getters['userSource/getUserSources'](this.builder) return this.$store.getters['userSource/getUserSources'](this.builder)
}, },
}, },
methods: {},
validations() {
return {}
},
} }
</script> </script>

View file

@ -32,7 +32,7 @@
:builder="builder" :builder="builder"
:hide-after-create="hideAfterCreate" :hide-after-create="hideAfterCreate"
:force-display-form="displaySelectedSettingForm" :force-display-form="displaySelectedSettingForm"
@hide-modal="hide()" @hide-modal="emitCreatedRecord($event)"
></component> ></component>
</template> </template>
</Modal> </Modal>
@ -117,6 +117,17 @@ export default {
return modal.methods.show.call(this, ...args) return modal.methods.show.call(this, ...args)
}, },
/**
* If this modal is being used with the `hideAfterCreate` prop set to `true`,
* then once a record has been created, we want to hide the modal, and then
* emit the newly created record ID so that it can be used by the component
* implementing this modal.
* @param createdRecordId - The ID of the newly created record.
*/
emitCreatedRecord(createdRecordId) {
this.hide()
this.$emit('created', createdRecordId)
},
}, },
} }
</script> </script>

View file

@ -194,7 +194,6 @@ export default {
this.hideForm() this.hideForm()
// immediately select this user source to edit it. // immediately select this user source to edit it.
this.editedUserSource = createdUserSource this.editedUserSource = createdUserSource
this.hideModalIfRequired()
} catch (error) { } catch (error) {
this.handleError(error) this.handleError(error)
} }
@ -212,6 +211,11 @@ export default {
userSourceId: this.editedUserSource.id, userSourceId: this.editedUserSource.id,
values: clone(newValues), values: clone(newValues),
}) })
// If the builder settings modal is set to hide after create, normally
// we would have hidden the modal and shared the record ID after the user
// source was created, but in this settings component we'll share the ID
// after the update, when there's a better change of having a configure source.
this.hideModalIfRequired(this.editedUserSource.id)
this.hideForm() this.hideForm()
} catch (error) { } catch (error) {
// Restore the previously saved values from the store // Restore the previously saved values from the store

View file

@ -32,9 +32,9 @@ export default {
} }
}, },
methods: { methods: {
hideModalIfRequired() { hideModalIfRequired(createdRecordId) {
if (this.hideAfterCreate) { if (this.hideAfterCreate) {
this.$emit('hide-modal') this.$emit('hide-modal', createdRecordId)
} }
}, },
}, },

View file

@ -0,0 +1,68 @@
<template>
<div>
<Dropdown
:value="value"
fixed-items
show-footer
:show-search="false"
@input="$emit('input', $event)"
>
<DropdownItem
v-for="userSource in userSources"
:key="userSource.id"
:name="userSource.name"
:value="userSource.id"
/>
<template #emptyState>
<slot name="emptyState">
{{ $t('userSourceDropdown.noUserSources') }}
</slot>
</template>
<template #footer>
<a class="select__footer-button" @click="openUserSettings">
<i class="iconoir-plus"></i>
{{ $t('userSourceDropdown.addUserSource') }}
</a>
<BuilderSettingsModal
ref="userSourcesSettingsModal"
hide-after-create
:builder="builder"
@created="$emit('input', $event)"
/>
</template>
</Dropdown>
</div>
</template>
<script>
import BuilderSettingsModal from '@baserow/modules/builder/components/settings/BuilderSettingsModal'
import { UserSourcesBuilderSettingsType } from '@baserow/modules/builder/builderSettingTypes'
export default {
name: 'UserSourceDropdown',
components: { BuilderSettingsModal },
props: {
value: {
type: Number,
required: false,
default: null,
},
builder: {
type: Object,
required: true,
},
userSources: {
type: Array,
required: true,
},
},
methods: {
openUserSettings() {
this.$refs.userSourcesSettingsModal.show(
UserSourcesBuilderSettingsType.getType(),
true
)
},
},
}
</script>

View file

@ -956,6 +956,11 @@
"label": "Property", "label": "Property",
"noProperties": "No properties available" "noProperties": "No properties available"
}, },
"userSourceDropdown": {
"label": "User source",
"addUserSource": "Add new user source",
"noUserSources": "No user sources available"
},
"dataSourceDropdown": { "dataSourceDropdown": {
"label": "Data source", "label": "Data source",
"noDataSources": "No data sources available", "noDataSources": "No data sources available",