From f386414058172780c0f3ee92aa6ad27cae76d0d8 Mon Sep 17 00:00:00 2001 From: Aaysha <109507451+aayshasura@users.noreply.github.com> Date: Mon, 16 Oct 2023 18:54:31 +0530 Subject: [PATCH] GT-721-change-schema-regsitry-tab-position PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10335 GitOrigin-RevId: da2e2f53f85477b80e90dd8179ffde28108679f4 --- .../Services/ApiExplorer/TopNav.tsx | 28 ++- .../components/Services/Settings/Sidebar.tsx | 23 +- .../SchemaRegistry/components/Container.tsx | 21 +- .../components/SchemaChangeDetails.tsx | 161 ++++++------- .../components/SchemaDetails.tsx | 2 +- .../components/SchemaRegistryHome.tsx | 217 +++++++++++------- .../NavigationSidebar/NavigationSidebar.tsx | 12 + .../libs/console/legacy-ee/src/lib/routes.js | 5 + 8 files changed, 245 insertions(+), 224 deletions(-) diff --git a/frontend/libs/console/legacy-ce/src/lib/components/Services/ApiExplorer/TopNav.tsx b/frontend/libs/console/legacy-ce/src/lib/components/Services/ApiExplorer/TopNav.tsx index bf055f9d495..fcbc276ded3 100644 --- a/frontend/libs/console/legacy-ce/src/lib/components/Services/ApiExplorer/TopNav.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/components/Services/ApiExplorer/TopNav.tsx @@ -3,6 +3,9 @@ import { Link, RouteComponentProps } from 'react-router'; import { isProConsole } from '../../../utils/proConsole'; import { useEELiteAccess } from '../../../features/EETrial'; import globals from '../../../Globals'; +import { IconTooltip } from '../../../new-components/Tooltip'; +import { FaRegMap } from 'react-icons/fa'; +import { sendTelemetryEvent } from '../../../telemetry'; type TopNavProps = { location: RouteComponentProps['location']; @@ -25,6 +28,12 @@ const TopNav: React.FC = ({ location }) => { dataTestVal: 'rest-explorer-link', title: 'REST', }, + { + key: 'schema-registry', + link: '/api/schema-registry', + dataTestVal: 'schema-registry-link', + title: 'Schema Registry', + }, ], [ { @@ -68,13 +77,30 @@ const TopNav: React.FC = ({ location }) => { : 'border-white hover:border-gray-100' }`} key={section.key} + onClick={() => { + // Send Telemetry data for Schema Registry tab + if (section.key === 'schema-registry') { + sendTelemetryEvent({ + type: 'CLICK_EVENT', + data: { + id: 'schema-registry-top-nav-tab', + }, + }); + } + }} > {section.title} + {section.key === 'schema-registry' && ( + } + message="Detect breaking and dangerous changes, view schema change history. Keep your GraphQL services safe and reliable! 🚀" + /> + )} )) diff --git a/frontend/libs/console/legacy-ce/src/lib/components/Services/Settings/Sidebar.tsx b/frontend/libs/console/legacy-ce/src/lib/components/Services/Settings/Sidebar.tsx index 75213636a49..0b1faf8fcd8 100644 --- a/frontend/libs/console/legacy-ce/src/lib/components/Services/Settings/Sidebar.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/components/Services/Settings/Sidebar.tsx @@ -15,7 +15,6 @@ import { import { useEELiteAccess } from '../../../features/EETrial'; import { getQueryResponseCachingRoute } from '../../../utils/routeUtils'; -import { isCloudConsole } from '../../../utils/cloudConsole'; import { isOpenTelemetrySupported } from '../../../utils/proConsole'; export interface Metadata { @@ -33,8 +32,7 @@ type SectionDataKey = | 'security' | 'monitoring' | 'performance' - | 'about' - | 'graphql'; + | 'about'; const Sidebar: React.FC = ({ location, metadata }) => { const eeLiteAccess = useEELiteAccess(globals); @@ -47,25 +45,6 @@ const Sidebar: React.FC = ({ location, metadata }) => { label: 'Metadata', items: [], }; - - if ( - isCloudConsole(globals) && - (globals.userRole === 'admin' || globals.userRole === 'owner') - ) { - sectionsData.graphql = { - key: 'graphql', - label: 'GraphQL', - items: [ - { - key: 'schema-registry', - label: 'Schema Registry (Beta)', - route: '/settings/schema-registry', - dataTestVal: 'metadata-schema-registry-link', - }, - ], - }; - } - sectionsData.metadata.items.push({ key: 'actions', label: 'Metadata Actions', diff --git a/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/Container.tsx b/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/Container.tsx index 427d247dcaa..aae6699740a 100644 --- a/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/Container.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/Container.tsx @@ -6,23 +6,19 @@ import { SCHEMA_REGISTRY_FEATURE_NAME } from '../constants'; import { FaBell } from 'react-icons/fa'; import { IconTooltip } from '../../../new-components/Tooltip'; import { AlertsDialog } from './AlertsDialog'; -import { Badge } from '../../../new-components/Badge'; -import { SCHEMA_REGISTRY_REF_URL } from '../constants'; -import { Analytics } from '../../Analytics'; +import { Analytics, InitializeTelemetry } from '../../Analytics'; import { useGetV2Info } from '../hooks/useGetV2Info'; +import { telemetryUserEventsTracker } from '../../../telemetry'; const SchemaRegistryHeader: React.VFC = () => { const [isAlertModalOpen, setIsAlertModalOpen] = useState(false); return ( -
+

GraphQL Schema Registry

- - BETA -
{
- - What is Schema Registry? - GraphQL Schema Registry changes will only be retained for 14 days. @@ -96,8 +84,9 @@ export const SchemaRegistryContainer: React.VFC< ); return ( -
+
+ ( -
- - - Schema - - -
- - Roles -
-
-); interface SchemaChangeDetailsProps { schemaId: string; } @@ -113,16 +89,17 @@ const SchemasDetails: React.VFC<{ />
-
-
-

Published

+
+

Published:

+ +
+ {getPublishTime(schema.created_at)}
- {getPublishTime(schema.created_at)}
-
+

Hash

@@ -263,65 +240,64 @@ export const ChangesView: React.VFC<{ changesList.filter(c => c.criticality.level === 'NON_BREAKING'); const showBreakingChanges = - !selectedChangeLevel || selectedChangeLevel === 'breaking'; + (!selectedChangeLevel || selectedChangeLevel === 'breaking') && + !!breakingChanges?.length; const showDangerousChanges = - !selectedChangeLevel || selectedChangeLevel === 'dangerous'; + (!selectedChangeLevel || selectedChangeLevel === 'dangerous') && + !!dangerousChanges?.length; const showSafeChanges = - !selectedChangeLevel || selectedChangeLevel === 'safe'; + (!selectedChangeLevel || selectedChangeLevel === 'safe') && + !!safeChanges?.length; const onFilterChange = (op: Option) => { setSelectedChangeLevel(op.value); }; return (
-
-
- Change Summary -
-
- -
-
-
-
+
Changes
-
+
- { - onFilterChange(op as Option); - }} - filterOption="prefix" - placeholder="Filter" - isClearable={true} - /> -
-
- + +
+ +
+ + +
@@ -329,31 +305,27 @@ export const ChangesView: React.VFC<{ {showBreakingChanges && (
-
+
Breaking -
-
- Content for What is breaking on schema registry +
)} - {showDangerousChanges && ( + {showDangerousChanges && dangerousChanges && (
-
+
Dangerous -
-
- Content for What is dangerous on schema registry +
)} - {showSafeChanges && ( + {showSafeChanges && safeChanges && (
-
Safe
-
- Content for What is safe on schema registry +
+ Safe +
@@ -385,7 +357,7 @@ const ChangesTable: React.FC = ({ changes, level }) => { - {changes && changes.length ? ( + {changes && changes.map((change, index) => ( = ({ changes, level }) => { > {change.message} - )) - ) : ( - - {`No ${level} changes`} - - )} + ))}
diff --git a/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/SchemaDetails.tsx b/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/SchemaDetails.tsx index 79cde6839df..924960592c9 100644 --- a/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/SchemaDetails.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/SchemaDetails.tsx @@ -19,7 +19,7 @@ import AceEditor from 'react-ace'; export const Breadcrumbs = () => (
diff --git a/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/SchemaRegistryHome.tsx b/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/SchemaRegistryHome.tsx index 1e3dc87ad52..89de7edeacd 100644 --- a/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/SchemaRegistryHome.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/features/SchemaRegistry/components/SchemaRegistryHome.tsx @@ -78,7 +78,7 @@ export const SchemaRegistryHome: React.FC = props => { if (schemaRoleID === EMPTY_UUID_STRING) { if (latestAdminRoleID) { setSelectedRoleID(latestAdminRoleID); - dispatch(_push(`/settings/schema-registry/${latestAdminRoleID}`)); + dispatch(_push(`/api/schema-registry/${latestAdminRoleID}`)); } } else { setSelectedRoleID(schemaRoleID); @@ -88,7 +88,7 @@ export const SchemaRegistryHome: React.FC = props => { useEffect(() => { if (latestAdminRoleID) { setSelectedRoleID(latestAdminRoleID); - dispatch(_push(`/settings/schema-registry/${latestAdminRoleID}`)); + dispatch(_push(`/api/schema-registry/${latestAdminRoleID}`)); } setSearchParam(pageNo); }, [latestAdminRoleID, pageNo]); @@ -118,8 +118,8 @@ export const SchemaRegistryHome: React.FC = props => { fetchSchemasResponse.response ); return ( -
-
+
+
-
+
PUBLISHED SCHEMA
+
{schemas.length ? (
- {schemaList.map((schema, index) => ( - setIsOpenSchemaCardIndex(index)} - /> - ))} -
+
+ {schemaList.map((schema, index) => ( + setIsOpenSchemaCardIndex(index)} + /> + ))} +
+