diff --git a/common/types/data_connections.ts b/common/types/data_connections.ts index a246f662cf..b2dace91e1 100644 --- a/common/types/data_connections.ts +++ b/common/types/data_connections.ts @@ -13,6 +13,15 @@ export interface PermissionsConfigurationProps { hasSecurityAccess: boolean; } +export interface AssociatedObject { + id: string; + name: string; + database: string; + type: string; + createdByIntegration: string; + accelerations: string; +} + export type Role = EuiComboBoxOptionOption; export type DatasourceType = 'S3GLUE' | 'PROMETHEUS'; diff --git a/public/components/datasources/components/__tests__/__snapshots__/data_connection.test.tsx.snap b/public/components/datasources/components/__tests__/__snapshots__/data_connection.test.tsx.snap index 69dcb5b925..ec9e178ea8 100644 --- a/public/components/datasources/components/__tests__/__snapshots__/data_connection.test.tsx.snap +++ b/public/components/datasources/components/__tests__/__snapshots__/data_connection.test.tsx.snap @@ -241,6 +241,48 @@ exports[`Data Connection Page test Renders Prometheus data connection page with Connection configuration + + +
+ + +
{ + return ( + + ); +}; diff --git a/public/components/datasources/components/manage/associated_objects_tab.tsx b/public/components/datasources/components/manage/associated_objects_tab.tsx new file mode 100644 index 0000000000..01a0ca5731 --- /dev/null +++ b/public/components/datasources/components/manage/associated_objects_tab.tsx @@ -0,0 +1,197 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React, { useEffect, useState } from 'react'; +import { + EuiInMemoryTable, + EuiLink, + EuiPanel, + EuiFlexGroup, + EuiFlexItem, + EuiText, + EuiHorizontalRule, + EuiButton, + EuiSpacer, + EuiEmptyPrompt, +} from '@elastic/eui'; +import { AssociatedObject } from 'common/types/data_connections'; +import { AccelerationsRecommendationCallout } from './accelerations_recommendation_callout'; + +interface AssociatedObjectsTabProps { + associatedObjects: AssociatedObject[]; +} + +export const AssociatedObjectsTab: React.FC = ({ + associatedObjects, +}) => { + const [lastUpdated, setLastUpdated] = useState(''); + + // TODO: FINISH THE REFRESH LOGIC + const fetchAssociatedObjects = async () => { + // Placeholder for data fetching logic + // After fetching data: + // setAssociatedObjects(fetchedData); + const now = new Date(); + setLastUpdated(now.toUTCString()); // Update last updated time + }; + + useEffect(() => { + fetchAssociatedObjects(); + }, []); + + const AssociatedObjectsHeader = () => { + return ( + + + +

Associated objects

+ Manage objects associated with this data sources. +
+
+ +
+ + Last updated at: + + + {lastUpdated} + +
+
+ + + Refresh + + +
+ ); + }; + + const noDataMessage = ( + You have no associated objects} + body={

Add or config tables from your data source or use Query Workbench.

} + actions={ + window.open('https://example.com', '_blank')} + iconType="popout" + iconSide="left" + > + Query Workbench + + } + /> + ); + + const columns = [ + { + field: 'name', + name: 'Name', + sortable: true, + 'data-test-subj': 'nameCell', + render: (name: string) => ( + + {name} + + ), + }, + { + field: 'database', + name: 'Database', + truncateText: true, + render: (database: string) => ( + + {database} + + ), + }, + { + field: 'type', + name: 'Type', + sortable: true, + }, + { + field: 'createdByIntegration', + name: 'Created by Integration', + sortable: true, + }, + { + field: 'accelerations', + name: 'Accelerations', + sortable: true, + }, + { + name: 'Actions', + actions: [ + { + name: 'Edit', + description: 'Edit this object', + type: 'icon', + icon: 'discoverApp', + onClick: (item: AssociatedObject) => console.log('Edit', item), + }, + { + name: 'Delete', + description: 'Delete this object', + type: 'icon', + icon: 'bolt', + onClick: (item: AssociatedObject) => console.log('Delete', item), + }, + ], + }, + ]; + + const search = { + box: { + incremental: true, + schema: { + fields: { name: { type: 'string' }, database: { type: 'string' } }, + }, + }, + }; + + const pagination = { + initialPageSize: 10, + pageSizeOptions: [10, 25, 50], + }; + + const sorting = { + sort: { + field: 'name', + direction: 'asc', + }, + }; + + return ( + <> + + + + + + + {associatedObjects.length > 0 ? ( + + ) : ( + noDataMessage + )} + + + + ); +}; diff --git a/public/components/datasources/components/manage/data_connection.tsx b/public/components/datasources/components/manage/data_connection.tsx index 4c9da43a3d..e400952e03 100644 --- a/public/components/datasources/components/manage/data_connection.tsx +++ b/public/components/datasources/components/manage/data_connection.tsx @@ -33,6 +33,7 @@ import { AccessControlTab } from './access_control_tab'; import { ConnectionDetails } from './connection_details'; import { DatasourceType } from '../../../../../common/types/data_connections'; import { DatasourceTypeToDisplayName } from '../../../../../common/constants/data_connections'; +import { AssociatedObjectsTab } from './associated_objects_tab'; interface DatasourceDetails { allowedRoles: string[]; @@ -132,7 +133,7 @@ export const DataConnection = (props: any) => { properties: data.properties, }); }) - .catch((err) => { + .catch((_err) => { setHasAccess(false); }); }, [chrome, http]); @@ -165,6 +166,37 @@ export const DataConnection = (props: any) => { /> ), }, + { + id: 'associated_objects', + name: 'Associated Objects', + disabled: false, + content: ( + + ), + }, + { + id: 'accelerations', + name: 'Accelerations', + disabled: false, + }, + { + id: 'installed_integrations', + name: 'Installed integrations', + disabled: false, + }, ]; const QueryOrAccelerateData = () => {