From 48c32e5a34e6ff535d5ffbae04eda474397dfb4a Mon Sep 17 00:00:00 2001 From: Zilvinas Saltys Date: Wed, 25 Oct 2023 13:51:38 +0100 Subject: [PATCH] feat: adding frontend and backend feature flags (#817) ### Feature or Bugfix - Feature ### Detail - Adding frontend support for all feature flags defined in config.json with a new util method isFeatureEnabled - Adding a new flag **preview_data** in the datasets module to control whether previewing data is allowed - Adding a new flag **glue_crawler** in the datasets module to control whether running glue crawler is allowed - Updating environment features to be hidden or visible based on whether the module is active. Adding a new util isAnyFeatureModuleEnabled to check whether to render the entire feature box. ### Relates N/A ### Security Not relevant By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Zilvinas Saltys --- .../modules/datasets/api/dataset/resolvers.py | 1 + .../modules/datasets/api/table/resolvers.py | 2 + config.json | 4 +- .../Datasets/components/DatasetData.js | 9 +- .../Datasets/components/DatasetTables.js | 21 +- .../src/modules/Datasets/views/DatasetView.js | 17 +- .../components/EnvironmentFeatures.js | 82 +++--- .../components/EnvironmentTeams.js | 58 ++-- .../views/EnvironmentCreateForm.js | 255 +++++++++-------- .../Environments/views/EnvironmentEditForm.js | 263 ++++++++++-------- .../src/modules/Folders/views/FolderView.js | 23 +- .../src/modules/Tables/views/TableView.js | 14 +- frontend/src/utils/helpers/moduleUtils.js | 33 ++- tests/modules/datasets/test_dataset.py | 3 +- 14 files changed, 444 insertions(+), 341 deletions(-) diff --git a/backend/dataall/modules/datasets/api/dataset/resolvers.py b/backend/dataall/modules/datasets/api/dataset/resolvers.py index d1bc301e5..86f342116 100644 --- a/backend/dataall/modules/datasets/api/dataset/resolvers.py +++ b/backend/dataall/modules/datasets/api/dataset/resolvers.py @@ -128,6 +128,7 @@ def get_dataset_assume_role_url(context: Context, source, datasetUri: str = None return DatasetService.get_dataset_assume_role_url(uri=datasetUri) +@is_feature_enabled('modules.datasets.features.glue_crawler') def start_crawler(context: Context, source, datasetUri: str, input: dict = None): return DatasetService.start_crawler(uri=datasetUri, data=input) diff --git a/backend/dataall/modules/datasets/api/table/resolvers.py b/backend/dataall/modules/datasets/api/table/resolvers.py index 2952d8250..09f485a08 100644 --- a/backend/dataall/modules/datasets/api/table/resolvers.py +++ b/backend/dataall/modules/datasets/api/table/resolvers.py @@ -1,5 +1,6 @@ import logging +from dataall.core.feature_toggle_checker import is_feature_enabled from dataall.modules.catalog.db.glossary_repositories import GlossaryRepository from dataall.modules.datasets.api.dataset.resolvers import get_dataset from dataall.base.api.context import Context @@ -23,6 +24,7 @@ def delete_table(context, source, tableUri: str = None): return DatasetTableService.delete_table(uri=tableUri) +@is_feature_enabled('modules.datasets.features.preview_data') def preview(context, source, tableUri: str = None): if not tableUri: return None diff --git a/config.json b/config.json index 15bb40173..7b8845f3f 100644 --- a/config.json +++ b/config.json @@ -14,7 +14,9 @@ "features": { "file_uploads": true, "file_actions": true, - "aws_actions": true + "aws_actions": true, + "preview_data": true, + "glue_crawler": true } }, "worksheets": { diff --git a/frontend/src/modules/Datasets/components/DatasetData.js b/frontend/src/modules/Datasets/components/DatasetData.js index 4b393b2da..ab2318654 100644 --- a/frontend/src/modules/Datasets/components/DatasetData.js +++ b/frontend/src/modules/Datasets/components/DatasetData.js @@ -3,6 +3,7 @@ import React from 'react'; import { Box } from '@mui/material'; import { DatasetTables } from './DatasetTables'; import { DatasetFolders } from './DatasetFolders'; +import { isFeatureEnabled } from 'utils'; export const DatasetData = (props) => { const { dataset, isAdmin } = props; @@ -12,9 +13,11 @@ export const DatasetData = (props) => { - - - + {isFeatureEnabled('datasets', 'file_actions') && ( + + + + )} ); }; diff --git a/frontend/src/modules/Datasets/components/DatasetTables.js b/frontend/src/modules/Datasets/components/DatasetTables.js index 247b71427..ce8d48934 100644 --- a/frontend/src/modules/Datasets/components/DatasetTables.js +++ b/frontend/src/modules/Datasets/components/DatasetTables.js @@ -40,6 +40,7 @@ import { listDatasetTables, deleteDatasetTable, useClient } from 'services'; import { syncTables } from '../services'; import { DatasetStartCrawlerModal } from './DatasetStartCrawlerModal'; +import { isFeatureEnabled } from 'utils'; export const DatasetTables = (props) => { const { dataset, isAdmin } = props; @@ -216,15 +217,17 @@ export const DatasetTables = (props) => { Synchronize - } - sx={{ m: 1 }} - variant="outlined" - > - Start Crawler - + {isFeatureEnabled('datasets', 'glue_crawler') && ( + } + sx={{ m: 1 }} + variant="outlined" + > + Start Crawler + + )} )} diff --git a/frontend/src/modules/Datasets/views/DatasetView.js b/frontend/src/modules/Datasets/views/DatasetView.js index fa0b637f6..e07106659 100644 --- a/frontend/src/modules/Datasets/views/DatasetView.js +++ b/frontend/src/modules/Datasets/views/DatasetView.js @@ -48,6 +48,7 @@ import { DatasetOverview, DatasetUpload } from '../components'; +import { isFeatureEnabled } from 'utils'; const DatasetView = () => { const dispatch = useDispatch(); @@ -81,11 +82,13 @@ const DatasetView = () => { value: 'shares', icon: }); - tabs.push({ - label: 'Upload', - value: 'upload', - icon: - }); + if (isFeatureEnabled('datasets', 'file_uploads')) { + tabs.push({ + label: 'Upload', + value: 'upload', + icon: + }); + } if (settings.isAdvancedMode) { tabs.push({ label: 'Tags', @@ -278,7 +281,9 @@ const DatasetView = () => { > Chat - + {isFeatureEnabled('datasets', 'aws_actions') && ( + + )} )} - } - variant="outlined" - color="primary" - sx={{ m: 1 }} - onClick={goToS3Console} - > - S3 Bucket - + {isFeatureEnabled('datasets', 'aws_actions') && ( + } + variant="outlined" + color="primary" + sx={{ m: 1 }} + onClick={goToS3Console} + > + S3 Bucket + + )} {isAdmin && (