1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-20 20:00:01 +00:00

Fix dispatch context name everywhere it's needed

This commit is contained in:
Jérémie Pardou 2023-10-31 16:29:20 +00:00
parent b7340cb947
commit 0ffa48f901
10 changed files with 28 additions and 30 deletions
backend/src/baserow
contrib
builder/data_sources
integrations/local_baserow
core/services
web-frontend/modules

View file

@ -263,7 +263,7 @@ class DataSourceHandler:
Dispatch the service related to the data_sources.
:param data_sources: The data sources to be dispatched.
:param runtime_formula_context: The context used to resolve formulas.
:param dispatch_context: The context used for the dispatch.
:return: The result of dispatching the data source mapped by data source ID.
If an Exception occurred during the dispatch the exception is return as
result for this data source.
@ -291,7 +291,7 @@ class DataSourceHandler:
Dispatch the service related to the data_source.
:param data_source: The data source to be dispatched.
:param runtime_formula_context: The context used to resolve formulas.
:param dispatch_context: The context used for the dispatch.
:raises DataSourceImproperlyConfigured: If the data source is
not properly configured.
:return: The result of dispatching the data source.

View file

@ -231,7 +231,7 @@ class DataSourceService:
:param user: The current user.
:param data_sources: The data sources to be dispatched.
:param runtime_formula_context: The context used to resolve formulas.
:param dispatch_context: The context used for the dispatch.
:return: The result of dispatching the data source mapped by data_source ID.
"""
@ -259,7 +259,7 @@ class DataSourceService:
:param user: The current user.
:param page: the page we want to dispatch the data_sources for.
:param runtime_formula_context: The context used to resolve formulas.
:param dispatch_context: The context used for the dispatch.
:return: The result of dispatching all the data source dispatch mapped by ID.
"""
@ -285,7 +285,7 @@ class DataSourceService:
:param user: The current user.
:param data_sources: The data source to be dispatched.
:param runtime_formula_context: The context used to resolve formulas.
:param dispatch_context: The context used for the dispatch.
:return: return the dispatch result.
"""

View file

@ -541,7 +541,7 @@ class LocalBaserowListRowsUserServiceType(
Returns a list of rows from the table stored in the service instance.
:param service: the local baserow get row service.
:param runtime_formula_context: the context used for formula resolution.
:param dispatch_context: The context used for the dispatch.
:raise ServiceImproperlyConfigured: if the table property is missing.
:return: The list of rows.
"""
@ -681,7 +681,7 @@ class LocalBaserowGetRowUserServiceType(
service instance.
:param service: the local baserow get row service.
:param runtime_formula_context: the context used for formula resolution.
:param dispatch_context: The context used for the dispatch.
:raise ServiceImproperlyConfigured: if the table property is missing or if the
formula can't be resolved.
:raise DoesNotExist: if row id doesn't exist.

View file

@ -203,7 +203,7 @@ class ServiceHandler:
Dispatch the given service.
:param service: The service to be dispatched.
:param runtime_formula_context: The context used to resolve formulas.
:param dispatch_context: The context used for the dispatch.
:return: The result of dispatching the service.
"""

View file

@ -3,7 +3,6 @@ from typing import Any, Dict, Optional, Tuple, Type, TypeVar
from django.contrib.auth.models import AbstractUser
from baserow.core.formula.runtime_formula_context import RuntimeFormulaContext
from baserow.core.integrations.handler import IntegrationHandler
from baserow.core.integrations.models import Integration
from baserow.core.registry import (
@ -15,6 +14,7 @@ from baserow.core.registry import (
ModelRegistryMixin,
Registry,
)
from baserow.core.services.dispatch_context import DispatchContext
from .models import Service
from .types import ServiceDictSubClass, ServiceSubClass
@ -123,33 +123,31 @@ class ServiceType(
def dispatch_data(
self,
service: ServiceSubClass,
runtime_formula_context: RuntimeFormulaContext,
dispatch_context: DispatchContext,
) -> Any:
"""
Responsible for executing the service's principle task.
:param service: The service instance to dispatch with.
:param runtime_formula_context: The runtime_formula_context instance used to
resolve formulas (if any).
:param dispatch_context: The context used for the dispatch.
:return: The service `dispatch_data` result if any.
"""
def dispatch(
self,
service: ServiceSubClass,
runtime_formula_context: RuntimeFormulaContext,
dispatch_context: DispatchContext,
) -> Any:
"""
Responsible for calling `dispatch_data` and `dispatch_transform` to execute
the service's task, and generating the dispatch's response, respectively.
:param service: The service instance to dispatch with.
:param runtime_formula_context: The runtime_formula_context instance used to
resolve formulas (if any).
:param dispatch_context: The context used for the dispatch.
:return: The service dispatch result if any.
"""
data = self.dispatch_data(service, runtime_formula_context)
data = self.dispatch_data(service, dispatch_context)
return self.dispatch_transform(data)
def get_property_for_serialization(self, service: Service, prop_name: str):

View file

@ -142,7 +142,7 @@ export default {
clearElementContent: 'elementContent/clearElementContent',
}),
async fetchContent(range, replace) {
const dispatchContext = DataProviderType.getAllBackendContext(
const dispatchContext = DataProviderType.getAllDispatchContext(
this.$registry.getAll('builderDataProvider'),
this.applicationContext
)

View file

@ -30,7 +30,7 @@ export class DataSourceDataProviderType extends DataProviderType {
'dataSourceContent/fetchPageDataSourceContent',
{
page: applicationContext.page,
data: DataProviderType.getAllBackendContext(
data: DataProviderType.getAllDispatchContext(
this.app.$registry.getAll('builderDataProvider'),
applicationContext
),
@ -160,7 +160,7 @@ export class PageParameterDataProviderType extends DataProviderType {
return _.get(content, path.join('.'))
}
getBackendContext(applicationContext) {
getDispatchContext(applicationContext) {
return this.getDataContent(applicationContext)
}
@ -218,7 +218,7 @@ export class CurrentRecordDataProviderType extends DataProviderType {
'dataSource/getPageDataSourceById'
](page, element.data_source_id)
const dispatchContext = DataProviderType.getAllBackendContext(
const dispatchContext = DataProviderType.getAllDispatchContext(
this.app.$registry.getAll('builderDataProvider'),
{ ...applicationContext, element }
)

View file

@ -94,8 +94,8 @@ export default {
dataSources() {
return this.$store.getters['dataSource/getPageDataSources'](this.page)
},
backendContext() {
return DataProviderType.getAllBackendContext(
dispatchContext() {
return DataProviderType.getAllDispatchContext(
this.$registry.getAll('builderDataProvider'),
this.applicationContext
)
@ -112,12 +112,12 @@ export default {
'dataSourceContent/debouncedFetchPageDataSourceContent',
{
page: this.page,
data: this.backendContext,
data: this.dispatchContext,
}
)
},
},
backendContext: {
dispatchContext: {
deep: true,
/**
* Update data source content on backend context changes

View file

@ -126,15 +126,15 @@ export default {
mode: this.mode,
}
},
backendContext() {
return DataProviderType.getAllBackendContext(
dispatchContext() {
return DataProviderType.getAllDispatchContext(
this.$registry.getAll('builderDataProvider'),
this.applicationContext
)
},
},
watch: {
backendContext: {
dispatchContext: {
deep: true,
/**
* Update data source content on backend context changes

View file

@ -51,12 +51,12 @@ export class DataProviderType extends Registerable {
)
}
static getAllBackendContext(dataProviders, applicationContext) {
static getAllDispatchContext(dataProviders, applicationContext) {
return Object.fromEntries(
Object.values(dataProviders).map((dataProvider) => {
return [
dataProvider.type,
dataProvider.getBackendContext(applicationContext),
dataProvider.getDispatchContext(applicationContext),
]
})
)
@ -68,7 +68,7 @@ export class DataProviderType extends Registerable {
* @param {Object} applicationContext the application context.
* @returns An object if the dataProvider wants to send something to the backend.
*/
getBackendContext(applicationContext) {
getDispatchContext(applicationContext) {
return null
}