mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* Add backend changes: models, handler, etc. * Add frontend share dashboard modal * Add public dashboard endpoint * Add frontend public dashboard view * Add public dashboard auth * Show the logo in the password page based on license * Add abuse reporting and fix license check * Fix tests * fix tests * Fix aggregation in public dashboard * Fix styling on sharing options * Ensure anonymous dashboard views only return the data it needs * DRY public access token logic * Add changelog * Added UpdateDashboardSharingActionType to ensure audit log accurately records changes. * Add e2e tests * Remove old todo; creation-time check is sufficient * Re-add request serializer field overrides * fix test * Ensure that the password protection modal can be persisted with an Enter keypress. --------- Co-authored-by: peter_baserow <peter@baserow.io>
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
import DashboardService from '@baserow/modules/dashboard/services/dashboard'
|
|
|
|
/**
|
|
* The sharing state of a dashboard as the application endpoints return it.
|
|
*/
|
|
export const DASHBOARD_SHARING_FIELDS = [
|
|
'public',
|
|
'slug',
|
|
'public_has_password',
|
|
'show_logo',
|
|
]
|
|
|
|
/**
|
|
* Updates the sharing state of a dashboard through the dedicated sharing
|
|
* endpoint and copies the state that the backend returns into the store. The
|
|
* generic `application/update` action can't be used: the backend ignores the
|
|
* sharing fields there, and it only copies the requested keys back, which isn't
|
|
* enough here either because `public_password` is write only and a change of
|
|
* `public` also clears the password, so the derived `public_has_password` has
|
|
* to come from the response.
|
|
*
|
|
* @param {object} nuxtApp Anything exposing `$client` and `$store`, like the
|
|
* nuxt app or an options API component.
|
|
* @param {object} dashboard The dashboard application in the store.
|
|
* @param {object} values The sharing values to send, like `{ public: true }`.
|
|
* @returns {object} The updated application as the backend returned it.
|
|
*/
|
|
export async function updateDashboardSharing(
|
|
{ $client, $store },
|
|
dashboard,
|
|
values
|
|
) {
|
|
const { data } = await DashboardService($client).updateSharing(
|
|
dashboard.id,
|
|
values
|
|
)
|
|
const sharing = Object.fromEntries(
|
|
DASHBOARD_SHARING_FIELDS.filter((field) => field in data).map((field) => [
|
|
field,
|
|
data[field],
|
|
])
|
|
)
|
|
await $store.dispatch('application/forceUpdate', {
|
|
application: dashboard,
|
|
data: sharing,
|
|
})
|
|
return data
|
|
}
|