chore(spa refactor): refactoring dashboard to use api's instead of bootstrapdata (#13306)

* add hook for future async api calls

* test to see conflict

* add async middleware and update reducers

* working async dashboard load

* implement getcharts api

* add user permissions to explore and dashboard bootstrap data

* integrate api calls with getinitial state

* update namings

* accept an id or a slug in the dashboard charts api

* add permissions function

* fix merge

* update state

* get dashboard charts by id or slug

* fix undefined states

* variable names

* stop using some more bootstrap data

* fix metadata reference

* remove unused bootstrap from the template

* add errorboundry to dashboard

* refactoring, fixing

* update permissions

* add just roles

* id is supposed to be a string

* unused vars

* get datasources from api

* make onError optional

* use resource hooks, better error boundary

* add loading state for dashboardroute

* remove console

* add conditional

* more conditionals

* testing out a possible fix for cypress

* convert edit/standalone test to cypress

* remove bootstrappy assertions

* lint

* fix dashboard edit history issue

* rename stuff

* address recent native filters schema change

* remove unused getInitialState

* remove .only from test

* hooksy redux usage

* Revert "more conditionals"

This reverts commit 25c8ed61b4.

* cleanup

* undo unnecessary change

* actually need conditions here

* certainty

* Revert "certainty"

This reverts commit 77dea1915b.

* more permutations (untested yolo)

* Update superset-frontend/src/chart/chartReducer.ts

Co-authored-by: Evan Rusackas <evan@preset.io>

* import style

* comment

* cleaner dashboardInfo

* remove debug code

* use memo for getPermissions

* fix lint

* adjust name/location of DashboardPage

* move logic for REMOVE_SLICE_LEVEL_LABEL_COLORS to DAO

* stop using full_data()

* remove unused (and now useless) json=true query param

Co-authored-by: David Aaron Suddjian <aasuddjian@gmail.com>
Co-authored-by: David Aaron Suddjian <1858430+suddjian@users.noreply.github.com>
Co-authored-by: Evan Rusackas <evan@preset.io>
This commit is contained in:
Phillip Kelley-Dotson
2021-04-12 16:10:29 -07:00
committed by GitHub
parent 89f5785666
commit 4bb29b6f04
32 changed files with 530 additions and 183 deletions

View File

@@ -128,24 +128,9 @@ class TestDashboard(SupersetTestCase):
dash_count_before = db.session.query(func.count(Dashboard.id)).first()[0]
url = "/dashboard/new/"
resp = self.get_resp(url)
self.assertIn("[ untitled dashboard ]", resp)
dash_count_after = db.session.query(func.count(Dashboard.id)).first()[0]
self.assertEqual(dash_count_before + 1, dash_count_after)
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
def test_dashboard_modes(self):
self.login(username="admin")
dash = db.session.query(Dashboard).filter_by(slug="births").first()
url = dash.url
if dash.url.find("?") == -1:
url += "?"
else:
url += "&"
resp = self.get_resp(url + "edit=true&standalone=true")
self.assertIn("editMode&#34;: true", resp)
self.assertIn("standalone_mode&#34;: true", resp)
self.assertIn('<body class="standalone">', resp)
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
def test_save_dash(self, username="admin"):
self.login(username=username)
@@ -190,9 +175,6 @@ class TestDashboard(SupersetTestCase):
self.assertIn("world_health", new_url)
self.assertNotIn("preselect_filters", new_url)
resp = self.get_resp(new_url)
self.assertIn("North America", resp)
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
def test_save_dash_with_invalid_filters(self, username="admin"):
self.login(username=username)
@@ -408,8 +390,6 @@ class TestDashboard(SupersetTestCase):
resp = self.get_resp("/api/v1/dashboard/")
self.assertIn("/superset/dashboard/births/", resp)
self.assertIn("Births", self.get_resp("/superset/dashboard/births/"))
# Confirm that public doesn't have access to other datasets.
resp = self.get_resp("/api/v1/chart/")
self.assertNotIn("wb_health_population", resp)

View File

@@ -238,6 +238,22 @@ class TestDashboardApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixi
data["result"][0]["slice_name"], dashboard.slices[0].slice_name
)
@pytest.mark.usefixtures("create_dashboards")
def test_get_dashboard_charts_by_slug(self):
"""
Dashboard API: Test getting charts belonging to a dashboard
"""
self.login(username="admin")
dashboard = self.dashboards[0]
uri = f"api/v1/dashboard/{dashboard.slug}/charts"
response = self.get_assert_metric(uri, "get_charts")
self.assertEqual(response.status_code, 200)
data = json.loads(response.data.decode("utf-8"))
self.assertEqual(len(data["result"]), 1)
self.assertEqual(
data["result"][0]["slice_name"], dashboard.slices[0].slice_name
)
@pytest.mark.usefixtures("create_dashboards")
def test_get_dashboard_charts_not_found(self):
"""