mirror of https://github.com/apache/superset.git
fix(query search): use new api to fetch users (#11260)
This commit is contained in:
parent
fc74b5d4a2
commit
a6224a2ed2
|
@ -153,14 +153,10 @@ class QuerySearch extends React.PureComponent {
|
|||
}
|
||||
|
||||
userMutator(data) {
|
||||
const options = [];
|
||||
for (let i = 0; i < data.pks.length; i += 1) {
|
||||
options.push({
|
||||
value: data.pks[i],
|
||||
label: this.userLabel(data.result[i]),
|
||||
});
|
||||
}
|
||||
return options;
|
||||
return data.result.map(({ value, text }) => ({
|
||||
label: text,
|
||||
value,
|
||||
}));
|
||||
}
|
||||
|
||||
dbMutator(data) {
|
||||
|
@ -209,7 +205,7 @@ class QuerySearch extends React.PureComponent {
|
|||
<div id="search-header" className="row space-1">
|
||||
<div className="col-sm-2">
|
||||
<AsyncSelect
|
||||
dataEndpoint="/users/api/read"
|
||||
dataEndpoint="api/v1/query/related/user"
|
||||
mutator={this.userMutator}
|
||||
value={this.state.userId}
|
||||
onChange={this.changeUser}
|
||||
|
|
|
@ -22,7 +22,8 @@ from superset.constants import RouteMethod
|
|||
from superset.models.sql_lab import Query
|
||||
from superset.queries.filters import QueryFilter
|
||||
from superset.queries.schemas import openapi_spec_methods_override
|
||||
from superset.views.base_api import BaseSupersetModelRestApi
|
||||
from superset.views.base_api import BaseSupersetModelRestApi, RelatedFieldFilter
|
||||
from superset.views.filters import FilterRelatedOwners
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -32,7 +33,7 @@ class QueryRestApi(BaseSupersetModelRestApi):
|
|||
|
||||
resource_name = "query"
|
||||
allow_browser_login = True
|
||||
include_route_methods = {RouteMethod.GET, RouteMethod.GET_LIST}
|
||||
include_route_methods = {RouteMethod.GET, RouteMethod.GET_LIST, RouteMethod.RELATED}
|
||||
|
||||
class_permission_name = "QueryView"
|
||||
list_columns = [
|
||||
|
@ -73,3 +74,8 @@ class QueryRestApi(BaseSupersetModelRestApi):
|
|||
|
||||
openapi_spec_tag = "Queries"
|
||||
openapi_spec_methods = openapi_spec_methods_override
|
||||
|
||||
related_field_filters = {
|
||||
"created_by": RelatedFieldFilter("first_name", FilterRelatedOwners),
|
||||
}
|
||||
allowed_rel_fields = {"user"}
|
||||
|
|
Loading…
Reference in New Issue