From cdfb71c1dab970583304fdd2ad26fc9e92fd85be Mon Sep 17 00:00:00 2001 From: Nicolas Beaussart Date: Tue, 13 Jul 2021 18:55:59 +0200 Subject: [PATCH] console: add a feature flag for schema sharing https://github.com/hasura/graphql-engine-mono/pull/1786 GitOrigin-RevId: a35dfa98508a8ef1ea92fe8588e79fc6f8479a2d --- CHANGELOG.md | 2 +- .../integration/data/schema-sharing/test.ts | 2 +- .../Data/Schema/SchemaSharing/Actions.ts | 13 ++++------ .../stubs/schemaSharingNetworkStubs.ts | 7 ++---- .../SchemaSharing/schemaSharingConfig.ts | 9 +++++++ .../components/Services/Data/SourceView.tsx | 14 ++++++++--- .../components/Services/Data/TabbedSchema.tsx | 25 +++++++++++++++++++ 7 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 console/src/components/Services/Data/Schema/SchemaSharing/schemaSharingConfig.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e8236f165f..e7935833e82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,10 +13,10 @@ field in the connection configuration - server: include action and event names in log output - server: log all HTTP errors in remote schema calls as `remote-schema-error` with details -- console: add schema sharing - server: For BigQuery, make `global_select_limit` configuration optional with a default value of `1000` + ## v2.0.1 - server: fix resetting metadata catalog version to 43 while initializing postgres source with v1.0 catalog diff --git a/console/cypress/integration/data/schema-sharing/test.ts b/console/cypress/integration/data/schema-sharing/test.ts index bec81addb98..3b77b2d66d4 100644 --- a/console/cypress/integration/data/schema-sharing/test.ts +++ b/console/cypress/integration/data/schema-sharing/test.ts @@ -13,7 +13,7 @@ const setup = () => { }; export const runSchemaSharingTests = () => { - describe('schema sharing', () => { + describe.skip('schema sharing', () => { it('display content', () => { cy.contains('default').click(); cy.get('[data-test=schema-container-tabs-data-gallery]').click(); diff --git a/console/src/components/Services/Data/Schema/SchemaSharing/Actions.ts b/console/src/components/Services/Data/Schema/SchemaSharing/Actions.ts index 9bdc86a6171..5238c8d83ac 100644 --- a/console/src/components/Services/Data/Schema/SchemaSharing/Actions.ts +++ b/console/src/components/Services/Data/Schema/SchemaSharing/Actions.ts @@ -12,6 +12,11 @@ import { } from '../../../../../metadata/queryUtils'; import { HasuraMetadataV3 } from '../../../../../metadata/types'; import { SchemaSharingFetchingStatus } from './types'; +import { + BASE_URL_PUBLIC, + BASE_URL_TEMPLATE, + ROOT_CONFIG_PATH, +} from './schemaSharingConfig'; type SchemaSharingTemplateDetailFull = { sql: string; @@ -156,14 +161,6 @@ export const schemaSharingSelectors = { .filter(section => section.templates.length > 0), }; -const repo_owner = 'hasura'; -const repo_name = 'schema-sharing'; -const repo_branch = 'main'; - -export const BASE_URL_TEMPLATE = `https://raw.githubusercontent.com/${repo_owner}/${repo_name}/${repo_branch}`; -export const BASE_URL_PUBLIC = `https://github.com/${repo_owner}/${repo_name}/blob/${repo_branch}`; -export const ROOT_CONFIG_PATH = `${BASE_URL_TEMPLATE}/config.json`; - export const fetchGlobalSchemaSharingConfiguration = createAsyncThunk< ServerJsonRootConfig, undefined, diff --git a/console/src/components/Services/Data/Schema/SchemaSharing/__tests__/stubs/schemaSharingNetworkStubs.ts b/console/src/components/Services/Data/Schema/SchemaSharing/__tests__/stubs/schemaSharingNetworkStubs.ts index 0cb5b5e007e..a30650640fc 100644 --- a/console/src/components/Services/Data/Schema/SchemaSharing/__tests__/stubs/schemaSharingNetworkStubs.ts +++ b/console/src/components/Services/Data/Schema/SchemaSharing/__tests__/stubs/schemaSharingNetworkStubs.ts @@ -1,10 +1,7 @@ import { rest } from 'msw'; -import { - BASE_URL_TEMPLATE, - ROOT_CONFIG_PATH, - ServerJsonRootConfig, -} from '../../Actions'; +import { ServerJsonRootConfig } from '../../Actions'; import { HasuraMetadataV3 } from '../../../../../../../metadata/types'; +import { BASE_URL_TEMPLATE, ROOT_CONFIG_PATH } from '../../schemaSharingConfig'; export const CATEGORY_1 = 'AAAAAAAA'; export const CATEGORY_2 = 'BBBBBBBB'; diff --git a/console/src/components/Services/Data/Schema/SchemaSharing/schemaSharingConfig.ts b/console/src/components/Services/Data/Schema/SchemaSharing/schemaSharingConfig.ts new file mode 100644 index 00000000000..b7485837c28 --- /dev/null +++ b/console/src/components/Services/Data/Schema/SchemaSharing/schemaSharingConfig.ts @@ -0,0 +1,9 @@ +export const isSchemaSharingEnabled = false; + +const repo_owner = 'hasura'; +const repo_name = 'schema-sharing'; +const repo_branch = 'main'; + +export const BASE_URL_TEMPLATE = `https://raw.githubusercontent.com/${repo_owner}/${repo_name}/${repo_branch}`; +export const BASE_URL_PUBLIC = `https://github.com/${repo_owner}/${repo_name}/blob/${repo_branch}`; +export const ROOT_CONFIG_PATH = `${BASE_URL_TEMPLATE}/config.json`; diff --git a/console/src/components/Services/Data/SourceView.tsx b/console/src/components/Services/Data/SourceView.tsx index 0d3b30936a6..69d9f65fa2f 100644 --- a/console/src/components/Services/Data/SourceView.tsx +++ b/console/src/components/Services/Data/SourceView.tsx @@ -10,6 +10,7 @@ import { getSchemaPermissionsRoute } from '../../Common/utils/routesUtils'; import _push from './push'; import { isFeatureSupported } from '../../../dataSources'; import Tabbed from './TabbedSchema'; +import { isSchemaSharingEnabled } from './Schema/SchemaSharing/schemaSharingConfig'; interface Props { dispatch: Dispatch; @@ -49,9 +50,16 @@ const SourceView: React.FC = props => { return ( -
+
+ {isSchemaSharingEnabled ? null : ( +

+ {currentDataSource} +

+ )} {isFeatureSupported('schemas.create.enabled') ? ( - + <> {!isCreateActive ? (
)} - + ) : null}
diff --git a/console/src/components/Services/Data/TabbedSchema.tsx b/console/src/components/Services/Data/TabbedSchema.tsx index 326b01fd71f..ed9774a0a46 100644 --- a/console/src/components/Services/Data/TabbedSchema.tsx +++ b/console/src/components/Services/Data/TabbedSchema.tsx @@ -7,6 +7,9 @@ import schemaStyles from './Schema/styles.scss'; import { Tabs } from '../../Common/Layout/ReusableTabs/ReusableTabs'; import styles from '../../../components/Common/Common.scss'; +import { isSchemaSharingEnabled } from './Schema/SchemaSharing/schemaSharingConfig'; +import { getDataSourceBaseRoute } from '../../Common/utils/routesUtils'; +import BreadCrumb from '../../Common/Layout/BreadCrumb/BreadCrumb'; const tabs: Tabs = { display: { @@ -23,6 +26,28 @@ const TabbedSchema: React.FC<{ tabName: 'display' | 'gallery'; currentDataSource: string; }> = ({ children, tabName, currentDataSource }) => { + if (!isSchemaSharingEnabled) { + return ( + + +
+ , + }, + ]} + /> + {children} +
+
+ ); + } const breadCrumbs = [ { title: 'Data',