Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
"websockets==15.0.1",
"requests==2.32.5",
"itsdangerous==2.2.0",
"Pillow==12.1.0",
"Pillow==12.1.1",
"drf-spectacular==0.29.0",
"asgiref==3.11.0",
"channels[daphne]==4.3.2",
Expand Down
5 changes: 4 additions & 1 deletion backend/src/baserow/api/settings/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ class Meta:
def to_representation(self, instance):
representation = super().to_representation(instance)
# TODO Remove in a future release once email_verification is null=False
if representation["email_verification"] is None:
if (
"email_verification" in representation
and representation["email_verification"] is None
):
representation["email_verification"] = (
Settings.EmailVerificationOptions.NO_VERIFICATION
)
Expand Down
2 changes: 1 addition & 1 deletion backend/src/baserow/api/settings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class UpdateSettingsView(APIView):
200: SettingsSerializer,
},
)
@validate_body(SettingsSerializer, partial=True)
@validate_body(SettingsSerializer, partial=True, return_validated=True)
@transaction.atomic
def patch(self, request, data):
"""
Expand Down
29 changes: 29 additions & 0 deletions backend/tests/baserow/api/settings/test_settings_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,32 @@ def test_update_email_verification_settings(api_client, data_fixture):
)
assert response.status_code == HTTP_200_OK
assert CoreHandler().get_settings().email_verification == "recommended"


@pytest.mark.django_db
def test_partial_update_does_not_overwrite_email_verification(api_client, data_fixture):
user, token = data_fixture.create_user_and_token(is_staff=True)

response = api_client.patch(
reverse("api:settings:update"),
{"email_verification": "recommended"},
format="json",
HTTP_AUTHORIZATION=f"JWT {token}",
)
assert response.status_code == HTTP_200_OK
assert CoreHandler().get_settings().email_verification == "recommended"

response = api_client.patch(
reverse("api:settings:update"),
{"track_workspace_usage": True},
format="json",
HTTP_AUTHORIZATION=f"JWT {token}",
)
assert response.status_code == HTTP_200_OK
response_json = response.json()

assert response_json["track_workspace_usage"] is True

settings = CoreHandler().get_settings()
assert settings.email_verification == "recommended"
assert response_json["email_verification"] == "recommended"
50 changes: 26 additions & 24 deletions backend/uv.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { StoreItemLookupError } from '@baserow/modules/core/errors'

definePageMeta({
layout: 'app',
applicationContext: true,
middleware: [
'settings',
'authenticated',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const actions = {
{ root: true }
)

commit('UNSELECT')
commit('SET_SELECTED', { automation, workflow })

return workflow
Expand Down
1 change: 1 addition & 0 deletions web-frontend/modules/builder/pages/pageEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import _ from 'lodash'

definePageMeta({
layout: 'app',
applicationContext: true,
middleware: [
'settings',
'authenticated',
Expand Down
1 change: 1 addition & 0 deletions web-frontend/modules/builder/store/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const actions = {
// Check if the provided page id is found in the just selected builder.
const page = getters.getById(builder, pageId)

commit('UNSELECT')
commit('SET_SELECTED', { builder, page })

return page
Expand Down
9 changes: 4 additions & 5 deletions web-frontend/modules/core/components/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</template>

<script>
import { uuid } from '@baserow/modules/core/utils/string'
import { useId } from '#app'

export default {
name: 'Checkbox',
Expand Down Expand Up @@ -113,10 +113,9 @@ export default {
},
},
emits: ['update:modelValue', 'input'],
data() {
return {
uniqClipId: uuid(),
}
setup() {
const uniqClipId = useId()
return { uniqClipId }
},
computed: {
currentValue() {
Expand Down
2 changes: 1 addition & 1 deletion web-frontend/modules/core/components/DownloadLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default {
},
computed: {
downloadXHR() {
return this.$config.public.downloadFileViaXhr === '1'
return `${this.$config.public.downloadFileViaXhr}` === '1'
},
href() {
// Add the filename to the query string
Expand Down
14 changes: 14 additions & 0 deletions web-frontend/modules/core/middleware/cleanupApplicationContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Unselect the current application if we are moving away from an application
* context route (dashboard, database, builder, automation)
*/
export default defineNuxtRouteMiddleware((to) => {
const { $store } = useNuxtApp()

if (
!to.meta.applicationContext &&
$store.getters['application/getSelected']
) {
$store.dispatch('application/unselect')
}
})
47 changes: 6 additions & 41 deletions web-frontend/modules/core/module.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import {
defineNuxtModule,
addPlugin,
addServerHandler,
extendViteConfig,
addComponent,
extendPages,
addLayout,
createResolver,
addRouteMiddleware,
addTemplate,
install,
} from '@nuxt/kit'
import { routes } from './routes'
import _ from 'lodash'
Expand All @@ -19,7 +14,6 @@ import { readFileSync, writeFileSync, mkdirSync } from 'node:fs'
import { createRequire } from 'node:module'

import head from './head'
// import { routes as customRoutes } from './routes'

import { locales } from '../../config/locales.js'

Expand All @@ -38,27 +32,6 @@ export default defineNuxtModule({
nuxt: '^3.0.0',
},
},
/*moduleDependencies: {
'@nuxtjs/i18n': {
defaults: {
strategy: 'no_prefix',
defaultLocale: 'en',
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'i18n-language',
},
langDir,
locales: ['en', 'fr'],
vueI18n: {
messages: {
en: { login: { title: 'Translated title' } },
fr: { login: { title: 'Titre traduit' } },
},
},
trailingSlash: true,
},
},
},*/
// Default configuration options for your module, can also be a function returning those
defaults: {},
// Shorthand sugar to register Nuxt hooks
Expand All @@ -67,20 +40,6 @@ export default defineNuxtModule({
setup(moduleOptions, nuxt) {
const { resolve } = createResolver(import.meta.url)

/*nuxt.hook('vue:error', (err, instance, info) => {
console.error('Vue Error:', err, info)
})

nuxt.hook('app:error', (err) => {
console.error('Nuxt App Error:', err)
})
nuxt.hook('router:error', (err) => {
console.error('Router Error:', err)
})*/

// Universal mode
//nuxt.options.ssr = true

// Merge du head
nuxt.options.app.head = _.merge({}, head, nuxt.options.app.head)

Expand Down Expand Up @@ -201,6 +160,12 @@ export default defineNuxtModule({
path: resolve('./middleware/workspacesAndApplications'),
})

addRouteMiddleware({
name: 'cleanupApplicationContext',
path: resolve('./middleware/cleanupApplicationContext'),
global: true,
})

addRouteMiddleware({
name: 'pendingJobs',
path: resolve('./middleware/pendingJobs'),
Expand Down
1 change: 1 addition & 0 deletions web-frontend/modules/core/pages/root.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ definePageMeta({
middleware: [
'settings',
'authenticated',
'impersonate',
'workspacesAndApplications',
'pendingJobs',
],
Expand Down
82 changes: 31 additions & 51 deletions web-frontend/modules/core/pages/workspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
ref="rename"
:value="selectedWorkspace.name"
@change="renameWorkspace(selectedWorkspace, $event)"
></Editable>
>
</Editable>
</div>
<i class="dashboard__workspace-name-icon iconoir-nav-arrow-down"></i>
</h1>
Expand Down Expand Up @@ -91,7 +92,8 @@
class="dashboard__suggested-template"
view-more
@click="$refs.templateModal.show()"
></TemplateCard>
>
</TemplateCard>
</div>
</div>
<div class="dashboard__resources">
Expand Down Expand Up @@ -162,8 +164,9 @@
:workspace="selectedWorkspace"
@click="selectApplication(application)"
/>
<div class="dashboard__application-separator"></div></li
></template>
<div class="dashboard__application-separator"></div>
</li>
</template>
</ul>
<div v-else class="dashboard__no-application">
<img
Expand Down Expand Up @@ -197,7 +200,8 @@
<CreateApplicationContext
ref="createApplicationContext"
:workspace="selectedWorkspace"
></CreateApplicationContext>
>
</CreateApplicationContext>
</div>
<DashboardHelp v-if="dashboardHelpComponents.length === 0"></DashboardHelp>
<template v-else>
Expand Down Expand Up @@ -236,8 +240,8 @@ definePageMeta({
middleware: [
'settings',
'authenticated',
'workspacesAndApplications',
'impersonate',
'workspacesAndApplications',
],
useRouteWorkspaceParam: 'test',
})
Expand Down Expand Up @@ -280,6 +284,24 @@ const createApplicationContextLink2 = ref(null)
const rename = ref(null)
const templateModal = ref(null)

async function fetchWorkspaceExtraData(workspace) {
const plugins = Object.values($registry.getAll('plugin'))
let mergedData = {
selectedWorkspace: workspace,
workspaceComponentArguments: { usageData: [] },
}

for (const p of plugins) {
const workspaceData = await p.fetchAsyncDashboardData(nuxtApp, workspace.id)

if (workspaceData) {
mergedData = p.mergeDashboardData(mergedData, workspaceData)
}
}

return mergedData
}

/**
* Fetch all dashboard-related data for the current workspace.
* `useAsyncData` now returns the data and we hydrate our refs from it.
Expand All @@ -305,26 +327,7 @@ const {

try {
await $store.dispatch('auth/fetchWorkspaceInvitations')

let asyncData = {
workspaceComponentArguments: {},
selectedWorkspace: workspace,
}

// Loop over all plugins and let them extend the dashboard data.
const plugins = Object.values($registry.getAll('plugin'))
for (const p of plugins) {
asyncData = await p.fetchAsyncDashboardData(
nuxtApp,
asyncData,
workspace.id
)
}

return {
selectedWorkspace: asyncData.selectedWorkspace,
workspaceComponentArguments: asyncData.workspaceComponentArguments,
}
return await fetchWorkspaceExtraData(workspace)
} catch {
throw createError({
statusCode: 400,
Expand Down Expand Up @@ -428,30 +431,7 @@ function selectApplication(application) {
}

async function workspaceUpdated(workspace) {
await fetchWorkspaceExtraData(workspace)
}

async function fetchWorkspaceExtraData(workspace) {
const plugins = Object.values($registry.getAll('plugin'))
const asyncData = {}

for (const p of plugins) {
const workspaceData = await p.fetchAsyncDashboardData(
nuxtApp,
asyncData,
workspace.id
)

const base = {
workspaceComponentArguments: workspaceComponentArguments.value,
}

const merged = p.mergeDashboardData(
JSON.parse(JSON.stringify(base)),
workspaceData
)

workspaceComponentArguments.value = merged.workspaceComponentArguments
}
const extraData = await fetchWorkspaceExtraData(workspace)
workspaceComponentArguments.value = extraData.workspaceComponentArguments
}
</script>
4 changes: 2 additions & 2 deletions web-frontend/modules/core/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export class BaserowPlugin extends Registerable {
* Optinally, a workspace id can be provided to fetch only data for a particular
* workspace.
*/
fetchAsyncDashboardData(context, data, workspaceId) {
return data
fetchAsyncDashboardData(context, workspaceId) {
return null
}

/**
Expand Down
Loading
Loading