Skip to content

Commit

Permalink
fix(dashboard): Fix scroll behaviour in DashboardBuilderSidepane (#20969
Browse files Browse the repository at this point in the history
)
  • Loading branch information
EugeneTorap authored and hughhhh committed Aug 16, 2022
1 parent d3684c0 commit 746276c
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ export interface BCPProps {

const SUPERSET_HEADER_HEIGHT = 59;
const SIDEPANE_ADJUST_OFFSET = 4;
const SIDEPANE_HEADER_HEIGHT = 64; // including margins
const SIDEPANE_FILTERBAR_HEIGHT = 56;
const TOP_PANEL_OFFSET = 210;

const BuilderComponentPaneTabs = styled(Tabs)`
line-height: inherit;
Expand All @@ -52,20 +51,10 @@ const BuilderComponentPaneTabs = styled(Tabs)`
const DashboardBuilderSidepane = styled.div<{
topOffset: number;
}>`
height: 100%;
height: calc(100% - ${TOP_PANEL_OFFSET}px);
position: fixed;
right: 0;
top: 0;
.ReactVirtualized__List {
padding-bottom: ${({ topOffset }) =>
`${
SIDEPANE_HEADER_HEIGHT +
SIDEPANE_FILTERBAR_HEIGHT +
SIDEPANE_ADJUST_OFFSET +
topOffset
}px`};
}
`;

const BuilderComponentPane: React.FC<BCPProps> = ({
Expand Down
5 changes: 5 additions & 0 deletions superset/initialization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def init_views(self) -> None:
from superset.reports.api import ReportScheduleRestApi
from superset.reports.logs.api import ReportExecutionLogRestApi
from superset.security.api import SecurityRestApi
from superset.sql.api import SqlRestApi
from superset.views.access_requests import AccessRequestsModelView
from superset.views.alerts import AlertView, ReportView
from superset.views.annotations import (
Expand Down Expand Up @@ -176,6 +177,7 @@ def init_views(self) -> None:
from superset.views.log.api import LogRestApi
from superset.views.log.views import LogModelView
from superset.views.redirects import R
from superset.views.sql import SqlView
from superset.views.sql_lab.views import (
SavedQueryView,
SavedQueryViewApi,
Expand Down Expand Up @@ -215,6 +217,8 @@ def init_views(self) -> None:
appbuilder.add_api(ReportScheduleRestApi)
appbuilder.add_api(ReportExecutionLogRestApi)
appbuilder.add_api(SavedQueryRestApi)
appbuilder.add_api(SqlRestApi)

#
# Setup regular views
#
Expand Down Expand Up @@ -308,6 +312,7 @@ def init_views(self) -> None:
appbuilder.add_view_no_menu(TabStateView)
appbuilder.add_view_no_menu(TagView)
appbuilder.add_view_no_menu(ReportView)
appbuilder.add_view_no_menu(SqlView)

#
# Add links
Expand Down
51 changes: 51 additions & 0 deletions superset/sql/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import logging

from flask import g, request, Response
from flask_appbuilder.api import BaseApi, expose, protect, safe

from superset.charts.commands.exceptions import ChartNotFoundError
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
from superset.explore.commands.get import GetExploreCommand
from superset.explore.commands.parameters import CommandParameters
from superset.explore.exceptions import DatasetAccessDeniedError, WrongEndpointError
from superset.explore.permalink.exceptions import ExplorePermalinkGetFailedError
from superset.explore.schemas import ExploreContextSchema
from superset.extensions import event_logger

logger = logging.getLogger(__name__)


class SqlRestApi(BaseApi):
method_permission_name = MODEL_API_RW_METHOD_PERMISSION_MAP
include_route_methods = {RouteMethod.GET}
# allow_browser_login = True
class_permission_name = "Superset"
resource_name = "sql"
# openapi_spec_tag = "Explore"
# openapi_spec_component_schemas = (ExploreContextSchema,)

@expose("/", methods=["GET"])
@protect()
@safe
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get",
log_to_statsd=True,
)
def get(self) -> Response:
return self.response(200, result={"foo": "bar"})
36 changes: 36 additions & 0 deletions superset/views/sql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from flask_appbuilder import permission_name
from flask_appbuilder.api import expose
from flask_appbuilder.security.decorators import has_access

from superset import event_logger
from superset.superset_typing import FlaskResponse

from .base import BaseSupersetView


class SqlView(BaseSupersetView):
route_base = "/sql"
class_permission_name = "Superset"

@expose("/")
# @has_access
# @permission_name("read")
# @event_logger.log_this
def root(self) -> FlaskResponse:
return super().render_app_template()

0 comments on commit 746276c

Please sign in to comment.