You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jo...@apache.org on 2023/06/07 18:16:04 UTC

[superset] 01/01: chore: Remove unused sliceCanEdit logic

This is an automated email from the ASF dual-hosted git repository.

johnbodley pushed a commit to branch john-bodley--remove-slice-can-edit
in repository https://gitbox.apache.org/repos/asf/superset.git

commit db655d0d7dab6db009dc5892dcd098f77020f34d
Author: John Bodley <jo...@gmail.com>
AuthorDate: Wed Jun 7 10:49:47 2023 -0700

    chore: Remove unused sliceCanEdit logic
---
 superset-frontend/src/dashboard/actions/hydrate.js |  1 -
 .../components/SliceHeader/SliceHeader.test.tsx    | 10 -----
 .../src/dashboard/components/SliceHeader/index.tsx |  2 -
 .../SliceHeaderControls.test.tsx                   |  3 --
 .../components/SliceHeaderControls/index.tsx       |  1 -
 .../dashboard/components/gridComponents/Chart.jsx  |  3 --
 .../components/gridComponents/Chart.test.jsx       |  1 -
 .../src/dashboard/containers/Chart.jsx             |  1 -
 .../versions/2023-06-01_13-13_83e1abbe777f_.py     | 50 ++++++++++++++++++++++
 tests/integration_tests/security_tests.py          |  2 -
 10 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/superset-frontend/src/dashboard/actions/hydrate.js b/superset-frontend/src/dashboard/actions/hydrate.js
index 9cd45eced4..6e1f168fe6 100644
--- a/superset-frontend/src/dashboard/actions/hydrate.js
+++ b/superset-frontend/src/dashboard/actions/hydrate.js
@@ -353,7 +353,6 @@ export const hydrateDashboard =
             roles,
           ),
           superset_can_csv: findPermission('can_csv', 'Superset', roles),
-          slice_can_edit: findPermission('can_slice', 'Superset', roles),
           common: {
             // legacy, please use state.common instead
             flash_messages: common?.flash_messages,
diff --git a/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx b/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx
index 570b7a7813..e16cab8daa 100644
--- a/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx
+++ b/superset-frontend/src/dashboard/components/SliceHeader/SliceHeader.test.tsx
@@ -35,7 +35,6 @@ jest.mock('src/dashboard/components/SliceHeaderControls', () => ({
       data-updated-dttm={props.updatedDttm}
       data-superset-can-explore={props.supersetCanExplore}
       data-superset-can-csv={props.supersetCanCSV}
-      data-slice-can-edit={props.sliceCanEdit}
       data-component-id={props.componentId}
       data-dashboard-id={props.dashboardId}
       data-is-full-size={props.isFullSize}
@@ -114,7 +113,6 @@ const createProps = (overrides: any = {}) => ({
   sliceName: 'Vaccine Candidates per Phase',
   supersetCanExplore: true,
   supersetCanCSV: true,
-  sliceCanEdit: false,
   slice: {
     slice_id: 312,
     slice_url: '/explore/?form_data=%7B%22slice_id%22%3A%20312%7D',
@@ -205,8 +203,6 @@ test('Should render - default props', () => {
   delete props.supersetCanExplore;
   // @ts-ignore
   delete props.supersetCanCSV;
-  // @ts-ignore
-  delete props.sliceCanEdit;
 
   render(<SliceHeader {...props} />, { useRedux: true, useRouter: true });
   expect(screen.getByTestId('slice-header')).toBeInTheDocument();
@@ -247,8 +243,6 @@ test('Should render default props and "call" actions', () => {
   delete props.supersetCanExplore;
   // @ts-ignore
   delete props.supersetCanCSV;
-  // @ts-ignore
-  delete props.sliceCanEdit;
 
   render(<SliceHeader {...props} />, { useRedux: true, useRouter: true });
   userEvent.click(screen.getByTestId('toggleExpandSlice'));
@@ -424,10 +418,6 @@ test('Correct props to "SliceHeaderControls"', () => {
     'data-is-full-size',
     'false',
   );
-  expect(screen.getByTestId('SliceHeaderControls')).toHaveAttribute(
-    'data-slice-can-edit',
-    'false',
-  );
   expect(screen.getByTestId('SliceHeaderControls')).toHaveAttribute(
     'data-superset-can-csv',
     'true',
diff --git a/superset-frontend/src/dashboard/components/SliceHeader/index.tsx b/superset-frontend/src/dashboard/components/SliceHeader/index.tsx
index b4a706c70f..497832766a 100644
--- a/superset-frontend/src/dashboard/components/SliceHeader/index.tsx
+++ b/superset-frontend/src/dashboard/components/SliceHeader/index.tsx
@@ -147,7 +147,6 @@ const SliceHeader: FC<SliceHeaderProps> = ({
   supersetCanExplore = false,
   supersetCanShare = false,
   supersetCanCSV = false,
-  sliceCanEdit = false,
   exportFullCSV,
   slice,
   componentId,
@@ -269,7 +268,6 @@ const SliceHeader: FC<SliceHeaderProps> = ({
                 supersetCanExplore={supersetCanExplore}
                 supersetCanShare={supersetCanShare}
                 supersetCanCSV={supersetCanCSV}
-                sliceCanEdit={sliceCanEdit}
                 componentId={componentId}
                 dashboardId={dashboardId}
                 addSuccessToast={addSuccessToast}
diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx
index d1a33da259..d2bc3e4bcc 100644
--- a/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx
+++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx
@@ -86,7 +86,6 @@ const createProps = (viz_type = 'sunburst') =>
     updatedDttm: 1617213803803,
     supersetCanExplore: true,
     supersetCanCSV: true,
-    sliceCanEdit: false,
     componentId: 'CHART-fYo7IyvKZQ',
     dashboardId: 26,
     isFullSize: false,
@@ -136,8 +135,6 @@ test('Should render default props', () => {
   delete props.isCached;
   // @ts-ignore
   delete props.isExpanded;
-  // @ts-ignore
-  delete props.sliceCanEdit;
 
   renderWrapper(props);
   expect(
diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx
index 72b0fb1aa0..3a0137cbf0 100644
--- a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx
+++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx
@@ -154,7 +154,6 @@ export interface SliceHeaderControlsProps {
   supersetCanExplore?: boolean;
   supersetCanShare?: boolean;
   supersetCanCSV?: boolean;
-  sliceCanEdit?: boolean;
 
   crossFiltersEnabled?: boolean;
 }
diff --git a/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx b/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx
index b16bd63f18..38b6c837e1 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx
@@ -78,7 +78,6 @@ const propTypes = {
   supersetCanExplore: PropTypes.bool.isRequired,
   supersetCanShare: PropTypes.bool.isRequired,
   supersetCanCSV: PropTypes.bool.isRequired,
-  sliceCanEdit: PropTypes.bool.isRequired,
   addSuccessToast: PropTypes.func.isRequired,
   addDangerToast: PropTypes.func.isRequired,
   ownState: PropTypes.object,
@@ -391,7 +390,6 @@ class Chart extends React.Component {
       supersetCanExplore,
       supersetCanShare,
       supersetCanCSV,
-      sliceCanEdit,
       addSuccessToast,
       addDangerToast,
       ownState,
@@ -458,7 +456,6 @@ class Chart extends React.Component {
           supersetCanExplore={supersetCanExplore}
           supersetCanShare={supersetCanShare}
           supersetCanCSV={supersetCanCSV}
-          sliceCanEdit={sliceCanEdit}
           componentId={componentId}
           dashboardId={dashboardId}
           filters={filters}
diff --git a/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx b/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx
index c892f7fff5..28a972069b 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx
@@ -69,7 +69,6 @@ describe('Chart', () => {
     isExpanded: false,
     supersetCanExplore: false,
     supersetCanCSV: false,
-    sliceCanEdit: false,
   };
 
   function setup(overrideProps) {
diff --git a/superset-frontend/src/dashboard/containers/Chart.jsx b/superset-frontend/src/dashboard/containers/Chart.jsx
index b42b4950d5..1e50602b06 100644
--- a/superset-frontend/src/dashboard/containers/Chart.jsx
+++ b/superset-frontend/src/dashboard/containers/Chart.jsx
@@ -95,7 +95,6 @@ function mapStateToProps(
     supersetCanExplore: !!dashboardInfo.superset_can_explore,
     supersetCanShare: !!dashboardInfo.superset_can_share,
     supersetCanCSV: !!dashboardInfo.superset_can_csv,
-    sliceCanEdit: !!dashboardInfo.slice_can_edit,
     ownState: dataMask[id]?.ownState,
     filterState: dataMask[id]?.filterState,
     maxRows: common.conf.SQL_MAX_ROW,
diff --git a/superset/migrations/versions/2023-06-01_13-13_83e1abbe777f_.py b/superset/migrations/versions/2023-06-01_13-13_83e1abbe777f_.py
new file mode 100644
index 0000000000..129f858234
--- /dev/null
+++ b/superset/migrations/versions/2023-06-01_13-13_83e1abbe777f_.py
@@ -0,0 +1,50 @@
+# 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.
+"""drop access_request
+
+Revision ID: 83e1abbe777f
+Revises: 4ea966691069
+Create Date: 2023-06-01 13:13:18.147362
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "83e1abbe777f"
+down_revision = "4ea966691069"
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+    op.drop_table("access_request")
+
+
+def downgrade():
+    op.create_table(
+        "access_request",
+        sa.Column("created_on", sa.DateTime(), nullable=True),
+        sa.Column("changed_on", sa.DateTime(), nullable=True),
+        sa.Column("id", sa.Integer(), nullable=False),
+        sa.Column("datasource_type", sa.String(length=200), nullable=True),
+        sa.Column("datasource_id", sa.Integer(), nullable=True),
+        sa.Column("changed_by_fk", sa.Integer(), nullable=True),
+        sa.Column("created_by_fk", sa.Integer(), nullable=True),
+        sa.ForeignKeyConstraint(["changed_by_fk"], ["ab_user.id"]),
+        sa.ForeignKeyConstraint(["created_by_fk"], ["ab_user.id"]),
+        sa.PrimaryKeyConstraint("id"),
+    )
diff --git a/tests/integration_tests/security_tests.py b/tests/integration_tests/security_tests.py
index c65f5a6dd8..34350a62bd 100644
--- a/tests/integration_tests/security_tests.py
+++ b/tests/integration_tests/security_tests.py
@@ -1364,7 +1364,6 @@ class TestRolePermission(SupersetTestCase):
         self.assertIn(("can_fave_dashboards", "Superset"), perm_set)
         self.assertIn(("can_fave_slices", "Superset"), perm_set)
         self.assertIn(("can_save_dash", "Superset"), perm_set)
-        self.assertIn(("can_slice", "Superset"), perm_set)
         self.assertIn(("can_explore_json", "Superset"), perm_set)
         self.assertIn(("can_userinfo", "UserDBModelView"), perm_set)
         self.assert_can_menu("Databases", perm_set)
@@ -1574,7 +1573,6 @@ class TestRolePermission(SupersetTestCase):
         self.assertIn(("can_fave_dashboards", "Superset"), gamma_perm_set)
         self.assertIn(("can_fave_slices", "Superset"), gamma_perm_set)
         self.assertIn(("can_save_dash", "Superset"), gamma_perm_set)
-        self.assertIn(("can_slice", "Superset"), gamma_perm_set)
         self.assertIn(("can_userinfo", "UserDBModelView"), gamma_perm_set)
 
     def test_views_are_secured(self):