diff --git a/common/types/data_connections.ts b/common/types/data_connections.ts index ba13c2eb7..be1f663c3 100644 --- a/common/types/data_connections.ts +++ b/common/types/data_connections.ts @@ -5,6 +5,8 @@ import { EuiComboBoxOptionOption } from '@elastic/eui'; +export type AccelerationStatus = 'ACTIVE' | 'INACTIVE'; + export interface PermissionsConfigurationProps { roles: Role[]; selectedRoles: Role[]; @@ -13,13 +15,33 @@ export interface PermissionsConfigurationProps { hasSecurityAccess: boolean; } +export interface TableColumn { + name: string; + dataType: string; +} + +export interface Acceleration { + name: string; + status: AccelerationStatus; + type: string; + database: string; + table: string; + destination: string; + dateCreated: number; + dateUpdated: number; + index: string; + sql: string; +} + export interface AssociatedObject { + datasource: string; id: string; name: string; database: string; type: string; createdByIntegration: string; - accelerations: string[]; + accelerations: Acceleration[]; + columns: TableColumn[]; } export type Role = EuiComboBoxOptionOption; diff --git a/public/components/datasources/components/__tests__/__snapshots__/associated_objects_tab.test.tsx.snap b/public/components/datasources/components/__tests__/__snapshots__/associated_objects_tab.test.tsx.snap index a973ea0ca..c687978d5 100644 --- a/public/components/datasources/components/__tests__/__snapshots__/associated_objects_tab.test.tsx.snap +++ b/public/components/datasources/components/__tests__/__snapshots__/associated_objects_tab.test.tsx.snap @@ -6,72 +6,216 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object Array [ Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_1", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + Object { + "dataType": "dataType3", + "name": "column3", + }, + Object { + "dataType": "dataType4", + "name": "column4", + }, + ], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "1", "name": "Table_name_1", "type": "Table", }, Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "2", "name": "Table_name_2", "type": "Table", }, Object { "accelerations": Array [ - "skipping_index_2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "3", - "name": "Table_name_3", - "type": "Table", + "name": "skipping_index_2", + "type": "Skip Index", }, Object { "accelerations": Array [ - "skipping_index_2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], + "createdByIntegration": "integration_1", "database": "db2", + "datasource": "flint_s3", "id": "4", "name": "Table_name_4", "type": "Table", }, Object { - "accelerations": Array [ - "skipping_index_3", + "accelerations": Array [], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], - "createdByIntegration": "xx", + "createdByIntegration": "integration_1", "database": "db3", + "datasource": "flint_s3", "id": "5", "name": "Table_name_5", "type": "Table", }, Object { - "accelerations": Array [], + "accelerations": Array [ + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "covering_index_3", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], "createdByIntegration": "", "database": "db3", + "datasource": "flint_s3", "id": "6", - "name": "Table_name_5", - "type": "CI", + "name": "covering_index_3", + "type": "Cover Index", }, Object { "accelerations": Array [ - "acc1", - "acc2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_4", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_5", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], "createdByIntegration": "", "database": "db3", - "id": "6", - "name": "Table_name_5", - "type": "CI", + "datasource": "flint_s3", + "id": "7", + "name": "Table_name_6", + "type": "Table", }, ] } @@ -403,72 +547,216 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object Array [ Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_1", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + Object { + "dataType": "dataType3", + "name": "column3", + }, + Object { + "dataType": "dataType4", + "name": "column4", + }, + ], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "1", "name": "Table_name_1", "type": "Table", }, Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "2", "name": "Table_name_2", "type": "Table", }, Object { "accelerations": Array [ - "skipping_index_2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "3", - "name": "Table_name_3", - "type": "Table", + "name": "skipping_index_2", + "type": "Skip Index", }, Object { "accelerations": Array [ - "skipping_index_2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], + "createdByIntegration": "integration_1", "database": "db2", + "datasource": "flint_s3", "id": "4", "name": "Table_name_4", "type": "Table", }, Object { - "accelerations": Array [ - "skipping_index_3", + "accelerations": Array [], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], - "createdByIntegration": "xx", + "createdByIntegration": "integration_1", "database": "db3", + "datasource": "flint_s3", "id": "5", "name": "Table_name_5", "type": "Table", }, Object { - "accelerations": Array [], + "accelerations": Array [ + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "covering_index_3", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], "createdByIntegration": "", "database": "db3", + "datasource": "flint_s3", "id": "6", - "name": "Table_name_5", - "type": "CI", + "name": "covering_index_3", + "type": "Cover Index", }, Object { "accelerations": Array [ - "acc1", - "acc2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_4", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_5", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], "createdByIntegration": "", "database": "db3", - "id": "6", - "name": "Table_name_5", - "type": "CI", + "datasource": "flint_s3", + "id": "7", + "name": "Table_name_6", + "type": "Table", }, ] } @@ -528,12 +816,8 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object "name": "Accelerations", "options": Array [ Object { - "text": "acc1", - "value": "acc1", - }, - Object { - "text": "acc2", - "value": "acc2", + "text": "covering_index_3", + "value": "covering_index_3", }, Object { "text": "skipping_index_1", @@ -544,8 +828,12 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object "value": "skipping_index_2", }, Object { - "text": "skipping_index_3", - "value": "skipping_index_3", + "text": "skipping_index_4", + "value": "skipping_index_4", + }, + Object { + "text": "skipping_index_5", + "value": "skipping_index_5", }, ], "type": "field_value_selection", @@ -612,12 +900,8 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object "name": "Accelerations", "options": Array [ Object { - "text": "acc1", - "value": "acc1", - }, - Object { - "text": "acc2", - "value": "acc2", + "text": "covering_index_3", + "value": "covering_index_3", }, Object { "text": "skipping_index_1", @@ -628,8 +912,12 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object "value": "skipping_index_2", }, Object { - "text": "skipping_index_3", - "value": "skipping_index_3", + "text": "skipping_index_4", + "value": "skipping_index_4", + }, + Object { + "text": "skipping_index_5", + "value": "skipping_index_5", }, ], "type": "field_value_selection", @@ -791,12 +1079,8 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object "name": "Accelerations", "options": Array [ Object { - "text": "acc1", - "value": "acc1", - }, - Object { - "text": "acc2", - "value": "acc2", + "text": "covering_index_3", + "value": "covering_index_3", }, Object { "text": "skipping_index_1", @@ -807,8 +1091,12 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object "value": "skipping_index_2", }, Object { - "text": "skipping_index_3", - "value": "skipping_index_3", + "text": "skipping_index_4", + "value": "skipping_index_4", + }, + Object { + "text": "skipping_index_5", + "value": "skipping_index_5", }, ], "type": "field_value_selection", @@ -1014,12 +1302,8 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object "name": "Accelerations", "options": Array [ Object { - "text": "acc1", - "value": "acc1", - }, - Object { - "text": "acc2", - "value": "acc2", + "text": "covering_index_3", + "value": "covering_index_3", }, Object { "text": "skipping_index_1", @@ -1030,8 +1314,12 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object "value": "skipping_index_2", }, Object { - "text": "skipping_index_3", - "value": "skipping_index_3", + "text": "skipping_index_4", + "value": "skipping_index_4", + }, + Object { + "text": "skipping_index_5", + "value": "skipping_index_5", }, ], "type": "field_value_selection", @@ -1252,72 +1540,216 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object Array [ Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_1", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + Object { + "dataType": "dataType3", + "name": "column3", + }, + Object { + "dataType": "dataType4", + "name": "column4", + }, + ], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "1", "name": "Table_name_1", "type": "Table", }, Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "2", "name": "Table_name_2", "type": "Table", }, Object { "accelerations": Array [ - "skipping_index_2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", - "database": "db1", - "id": "3", - "name": "Table_name_3", - "type": "Table", - }, - Object { - "accelerations": Array [ - "skipping_index_2", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], - "createdByIntegration": "xx", + "createdByIntegration": "integration_1", "database": "db2", + "datasource": "flint_s3", "id": "4", "name": "Table_name_4", "type": "Table", }, Object { - "accelerations": Array [ - "skipping_index_3", + "accelerations": Array [], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], - "createdByIntegration": "xx", + "createdByIntegration": "integration_1", "database": "db3", + "datasource": "flint_s3", "id": "5", "name": "Table_name_5", "type": "Table", }, Object { - "accelerations": Array [], + "accelerations": Array [ + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_4", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_5", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], "createdByIntegration": "", "database": "db3", - "id": "6", - "name": "Table_name_5", - "type": "CI", + "datasource": "flint_s3", + "id": "7", + "name": "Table_name_6", + "type": "Table", }, Object { "accelerations": Array [ - "acc1", - "acc2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "covering_index_3", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], "createdByIntegration": "", "database": "db3", + "datasource": "flint_s3", "id": "6", - "name": "Table_name_5", - "type": "CI", + "name": "covering_index_3", + "type": "Cover Index", + }, + Object { + "accelerations": Array [ + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [], + "createdByIntegration": "integration_1", + "database": "db1", + "datasource": "flint_s3", + "id": "3", + "name": "skipping_index_2", + "type": "Skip Index", }, ] } @@ -1966,16 +2398,17 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object > - Table_name_1 - + @@ -2091,7 +2524,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object onClick={[Function]} type="button" > - xx + integration_1 @@ -2183,10 +2616,40 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_1", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + Object { + "dataType": "dataType3", + "name": "column3", + }, + Object { + "dataType": "dataType4", + "name": "column4", + }, + ], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "1", "name": "Table_name_1", "type": "Table", @@ -2210,10 +2673,40 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_1", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + Object { + "dataType": "dataType3", + "name": "column3", + }, + Object { + "dataType": "dataType4", + "name": "column4", + }, + ], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "1", "name": "Table_name_1", "type": "Table", @@ -2307,10 +2800,40 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_1", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + Object { + "dataType": "dataType3", + "name": "column3", + }, + Object { + "dataType": "dataType4", + "name": "column4", + }, ], - "createdByIntegration": "xx", + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "1", "name": "Table_name_1", "type": "Table", @@ -2433,16 +2956,17 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object > - Table_name_2 - + @@ -2558,7 +3082,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object onClick={[Function]} type="button" > - xx + integration_1 @@ -2601,7 +3125,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object onClick={[Function]} type="button" > - skipping_index_1 + skipping_index_2 @@ -2650,10 +3174,23 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "2", "name": "Table_name_2", "type": "Table", @@ -2677,10 +3214,23 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "2", "name": "Table_name_2", "type": "Table", @@ -2774,10 +3324,23 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_1", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [], + "createdByIntegration": "integration_1", "database": "db1", + "datasource": "flint_s3", "id": "2", "name": "Table_name_2", "type": "Table", @@ -2900,16 +3463,17 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object > - - Table_name_3 - + Table_name_4 + @@ -2945,7 +3509,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object - db1 + db2 @@ -3025,7 +3589,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object onClick={[Function]} type="button" > - xx + integration_1 @@ -3117,12 +3681,34 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", - "database": "db1", - "id": "3", - "name": "Table_name_3", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], + "createdByIntegration": "integration_1", + "database": "db2", + "datasource": "flint_s3", + "id": "4", + "name": "Table_name_4", "type": "Table", } } @@ -3144,12 +3730,34 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", - "database": "db1", - "id": "3", - "name": "Table_name_3", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], + "createdByIntegration": "integration_1", + "database": "db2", + "datasource": "flint_s3", + "id": "4", + "name": "Table_name_4", "type": "Table", } } @@ -3241,12 +3849,34 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", - "database": "db1", - "id": "3", - "name": "Table_name_3", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], + "createdByIntegration": "integration_1", + "database": "db2", + "datasource": "flint_s3", + "id": "4", + "name": "Table_name_4", "type": "Table", } } @@ -3367,16 +3997,17 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object > - - Table_name_4 - + Table_name_5 + @@ -3412,7 +4043,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object - db2 + db3 @@ -3492,7 +4123,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object onClick={[Function]} type="button" > - xx + integration_1 @@ -3526,18 +4157,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object
- - - + -
@@ -3583,13 +4203,22 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object className="euiTableCellContent__hoverItem" item={ Object { - "accelerations": Array [ - "skipping_index_2", + "accelerations": Array [], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], - "createdByIntegration": "xx", - "database": "db2", - "id": "4", - "name": "Table_name_4", + "createdByIntegration": "integration_1", + "database": "db3", + "datasource": "flint_s3", + "id": "5", + "name": "Table_name_5", "type": "Table", } } @@ -3610,13 +4239,22 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object enabled={true} item={ Object { - "accelerations": Array [ - "skipping_index_2", + "accelerations": Array [], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], - "createdByIntegration": "xx", - "database": "db2", - "id": "4", - "name": "Table_name_4", + "createdByIntegration": "integration_1", + "database": "db3", + "datasource": "flint_s3", + "id": "5", + "name": "Table_name_5", "type": "Table", } } @@ -3707,13 +4345,22 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object enabled={true} item={ Object { - "accelerations": Array [ - "skipping_index_2", + "accelerations": Array [], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], - "createdByIntegration": "xx", - "database": "db2", - "id": "4", - "name": "Table_name_4", + "createdByIntegration": "integration_1", + "database": "db3", + "datasource": "flint_s3", + "id": "5", + "name": "Table_name_5", "type": "Table", } } @@ -3834,16 +4481,17 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object > - - Table_name_5 - + Table_name_6 + @@ -3948,20 +4596,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object
- - - + -
@@ -4002,7 +4637,20 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object onClick={[Function]} type="button" > - skipping_index_3 + skipping_index_4 + + + , + + @@ -4051,12 +4699,46 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_3", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_4", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_5", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, ], - "createdByIntegration": "xx", + "createdByIntegration": "", "database": "db3", - "id": "5", - "name": "Table_name_5", + "datasource": "flint_s3", + "id": "7", + "name": "Table_name_6", "type": "Table", } } @@ -4078,12 +4760,46 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_3", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_4", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_5", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], + "createdByIntegration": "", "database": "db3", - "id": "5", - "name": "Table_name_5", + "datasource": "flint_s3", + "id": "7", + "name": "Table_name_6", "type": "Table", } } @@ -4175,12 +4891,46 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "skipping_index_3", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_4", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_5", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "xx", + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], + "createdByIntegration": "", "database": "db3", - "id": "5", - "name": "Table_name_5", + "datasource": "flint_s3", + "id": "7", + "name": "Table_name_6", "type": "Table", } } @@ -4301,16 +5051,17 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object > - - Table_name_5 - + covering_index_3 + @@ -4382,7 +5133,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object - CI + Cover Index @@ -4447,7 +5198,18 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object
- - + + +
@@ -4485,12 +5247,36 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object className="euiTableCellContent__hoverItem" item={ Object { - "accelerations": Array [], + "accelerations": Array [ + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "covering_index_3", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], "createdByIntegration": "", "database": "db3", + "datasource": "flint_s3", "id": "6", - "name": "Table_name_5", - "type": "CI", + "name": "covering_index_3", + "type": "Cover Index", } } itemId={5} @@ -4510,12 +5296,36 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object enabled={true} item={ Object { - "accelerations": Array [], + "accelerations": Array [ + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "covering_index_3", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, + ], + "columns": Array [ + Object { + "dataType": "dataType1", + "name": "column1", + }, + Object { + "dataType": "dataType2", + "name": "column2", + }, + ], "createdByIntegration": "", "database": "db3", + "datasource": "flint_s3", "id": "6", - "name": "Table_name_5", - "type": "CI", + "name": "covering_index_3", + "type": "Cover Index", } } key="item_action_5_0" @@ -4635,16 +5445,17 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object > - - Table_name_5 - + skipping_index_2 + @@ -4680,7 +5491,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object - db3 + db1 @@ -4716,7 +5527,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object - CI + Skip Index @@ -4749,7 +5560,20 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object
- - + + +
@@ -4790,20 +5614,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object onClick={[Function]} type="button" > - acc1 - - - , - - @@ -4844,14 +5655,26 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "acc1", - "acc2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "", - "database": "db3", - "id": "6", - "name": "Table_name_5", - "type": "CI", + "columns": Array [], + "createdByIntegration": "integration_1", + "database": "db1", + "datasource": "flint_s3", + "id": "3", + "name": "skipping_index_2", + "type": "Skip Index", } } itemId={6} @@ -4872,14 +5695,26 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object item={ Object { "accelerations": Array [ - "acc1", - "acc2", + Object { + "database": "db1", + "dateCreated": 1709339290, + "dateUpdated": 1709339290, + "destination": "N/A", + "index": "security_logs_2022", + "name": "skipping_index_2", + "sql": "SELECT * FROM Table_name_1 WHERE ...", + "status": "ACTIVE", + "table": "Table_name_1", + "type": "skip", + }, ], - "createdByIntegration": "", - "database": "db3", - "id": "6", - "name": "Table_name_5", - "type": "CI", + "columns": Array [], + "createdByIntegration": "integration_1", + "database": "db1", + "datasource": "flint_s3", + "id": "3", + "name": "skipping_index_2", + "type": "Skip Index", } } key="item_action_6_0" 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 7cec0b604..76fc411ae 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 @@ -789,13 +789,12 @@ exports[`Data Connection Page test Renders Prometheus data connection page with
- Table_name_1 - +
- xx + integration_1 @@ -957,13 +956,12 @@ exports[`Data Connection Page test Renders Prometheus data connection page with
- Table_name_2 - +
- xx + integration_1 @@ -1036,7 +1034,7 @@ exports[`Data Connection Page test Renders Prometheus data connection page with class="euiLink euiLink--primary" type="button" > - skipping_index_1 + skipping_index_2 @@ -1125,13 +1123,12 @@ exports[`Data Connection Page test Renders Prometheus data connection page with
- - Table_name_3 - + Table_name_4 +
- db1 + db2 @@ -1185,7 +1182,7 @@ exports[`Data Connection Page test Renders Prometheus data connection page with class="euiLink euiLink--primary" type="button" > - xx + integration_1 @@ -1293,13 +1290,12 @@ exports[`Data Connection Page test Renders Prometheus data connection page with
- - Table_name_4 - + Table_name_5 +
- db2 + db3 @@ -1353,7 +1349,7 @@ exports[`Data Connection Page test Renders Prometheus data connection page with class="euiLink euiLink--primary" type="button" > - xx + integration_1 @@ -1368,13 +1364,7 @@ exports[`Data Connection Page test Renders Prometheus data connection page with
- - + -
- - Table_name_5 - + Table_name_6 + - + - - skipping_index_3 + skipping_index_4 + + , + @@ -1629,13 +1620,12 @@ exports[`Data Connection Page test Renders Prometheus data connection page with
- - Table_name_5 - + covering_index_3 +
- CI + Cover Index @@ -1699,7 +1689,13 @@ exports[`Data Connection Page test Renders Prometheus data connection page with
- - + +
- - Table_name_5 - + skipping_index_2 + - db3 + db1 @@ -1797,7 +1792,7 @@ exports[`Data Connection Page test Renders Prometheus data connection page with - CI + Skip Index @@ -1812,7 +1807,12 @@ exports[`Data Connection Page test Renders Prometheus data connection page with
- - +
- acc1 - - , - @@ -2964,13 +2957,12 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`]
- Table_name_1 - +
- xx + integration_1 @@ -3136,13 +3128,12 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`]
- Table_name_2 - +
- xx + integration_1 @@ -3215,7 +3206,7 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`] class="euiLink euiLink--primary" type="button" > - skipping_index_1 + skipping_index_2 @@ -3308,13 +3299,12 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`]
- - Table_name_3 - + Table_name_4 +
- db1 + db2 @@ -3368,7 +3358,7 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`] class="euiLink euiLink--primary" type="button" > - xx + integration_1 @@ -3480,13 +3470,12 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`]
- - Table_name_4 - + Table_name_5 +
- db2 + db3 @@ -3540,7 +3529,7 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`] class="euiLink euiLink--primary" type="button" > - xx + integration_1 @@ -3555,13 +3544,7 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`]
- - + -
- - Table_name_5 - + Table_name_6 + - + - - skipping_index_3 + skipping_index_4 + + , + @@ -3824,13 +3808,12 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`]
- - Table_name_5 - + covering_index_3 +
- CI + Cover Index @@ -3894,7 +3877,13 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`]
- - + +
- - Table_name_5 - + skipping_index_2 + - db3 + db1 @@ -3996,7 +3984,7 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`] - CI + Skip Index @@ -4011,7 +3999,12 @@ exports[`Data Connection Page test Renders S3 data connection page with data 1`]
- - +
- acc1 - - , - diff --git a/public/components/datasources/components/__tests__/associated_objects_flyout.test.tsx b/public/components/datasources/components/__tests__/associated_objects_flyout.test.tsx new file mode 100644 index 000000000..256df3945 --- /dev/null +++ b/public/components/datasources/components/__tests__/associated_objects_flyout.test.tsx @@ -0,0 +1,84 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { mount, configure } from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; +import { AssociatedObjectsDetailsFlyout } from '../manage/associated_objects/associated_objects_details_flyout'; +import { mockAssociatedObjects } from '../manage/associated_objects/utils/associated_objects_tab_utils'; +import * as plugin from '../../../../plugin'; +import { act } from '@testing-library/react'; + +configure({ adapter: new Adapter() }); + +jest.mock('../../../../plugin', () => ({ + getRenderAccelerationDetailsFlyout: jest.fn(() => jest.fn()), + getRenderAssociatedObjectsDetailsFlyout: jest.fn(() => jest.fn()), +})); + +describe('AssociatedObjectsDetailsFlyout Integration Tests', () => { + const mockTableDetail = mockAssociatedObjects[0]; + + beforeEach(() => { + plugin.getRenderAccelerationDetailsFlyout.mockClear(); + }); + + it('renders acceleration details correctly and triggers flyout on click', () => { + const wrapper = mount(); + expect(wrapper.find('EuiInMemoryTable').at(0).find('EuiLink').length).toBeGreaterThan(0); + + wrapper.find('EuiInMemoryTable').at(0).find('EuiLink').first().simulate('click'); + expect(plugin.getRenderAccelerationDetailsFlyout).toHaveBeenCalled(); + }); + + it('displays no data message for accelerations but still renders schema table', () => { + const mockDetailNoAccelerations = { + ...mockTableDetail, + accelerations: [], + columns: [ + { name: 'column1', dataType: 'string' }, + { name: 'column2', dataType: 'number' }, + ], + }; + + const wrapper = mount( + + ); + + expect(wrapper.text()).toContain('You have no accelerations'); + expect(wrapper.find('EuiInMemoryTable').exists()).toBe(true); + expect(wrapper.text()).toContain('column1'); + expect(wrapper.text()).toContain('column2'); + }); + + it('renders schema table correctly with column data', () => { + const wrapper = mount(); + + expect(wrapper.find('EuiInMemoryTable').at(1).exists()).toBe(true); + expect(wrapper.find('EuiInMemoryTable').at(1).text()).toContain( + mockTableDetail.columns[0].name + ); + }); + + it('triggers details flyout on acceleration link click', async () => { + const wrapper = mount(); + + await act(async () => { + // Wait a tick for async updates + await new Promise((resolve) => setTimeout(resolve, 0)); + wrapper.update(); + }); + + const accName = mockTableDetail.accelerations[0]?.name; + const accLink = wrapper + .find('EuiLink') + .findWhere((node) => node.text() === accName) + .first(); + expect(accLink.exists()).toBe(true); + + accLink.simulate('click'); + expect(plugin.getRenderAccelerationDetailsFlyout).toHaveBeenCalled(); + }); +}); diff --git a/public/components/datasources/components/__tests__/associated_objects_tab.test.tsx b/public/components/datasources/components/__tests__/associated_objects_tab.test.tsx index fbca035aa..bad411c4d 100644 --- a/public/components/datasources/components/__tests__/associated_objects_tab.test.tsx +++ b/public/components/datasources/components/__tests__/associated_objects_tab.test.tsx @@ -12,6 +12,11 @@ import { ASSC_OBJ_TABLE_SUBJ, } from '../manage/associated_objects/utils/associated_objects_tab_utils'; +jest.mock('../../../../plugin', () => ({ + getRenderAccelerationDetailsFlyout: jest.fn(() => jest.fn()), + getRenderAssociatedObjectsDetailsFlyout: jest.fn(() => jest.fn()), +})); + describe('AssociatedObjectsTab Component', () => { configure({ adapter: new Adapter() }); @@ -41,32 +46,6 @@ describe('AssociatedObjectsTab Component', () => { expect(wrapper.find('EuiLink').length).toBeGreaterThan(0); }); - it('initializes with correct search filters based on associatedObjects prop', () => { - const wrapper = mount(); - - const searchConfig = wrapper - .find(`[data-test-subj="${ASSC_OBJ_TABLE_SUBJ}"]`) - .first() - .prop('search'); - - expect(searchConfig.filters).toBeDefined(); - expect(searchConfig.filters.length).toBeGreaterThan(0); - - const databaseFilterOption = searchConfig.filters.find((filter) => filter.field === 'database'); - expect(databaseFilterOption).toBeDefined(); - expect(databaseFilterOption.options.length).toEqual( - new Set(mockAssociatedObjects.map((obj) => obj.database)).size - ); - - const accelerationFilterOption = searchConfig.filters.find( - (filter) => filter.field === 'accelerations' - ); - expect(accelerationFilterOption).toBeDefined(); - expect(accelerationFilterOption.options.length).toEqual( - new Set(mockAssociatedObjects.flatMap((obj) => obj.accelerations).filter(Boolean)).size - ); - }); - it('initializes database and acceleration filter options correctly from associated objects', () => { const wrapper = mount(); @@ -82,9 +61,46 @@ describe('AssociatedObjectsTab Component', () => { .size; expect(databaseFilter.options.length).toEqual(expectedDatabaseOptionsCount); - const allAccelerations = mockAssociatedObjects.flatMap((obj) => obj.accelerations); - const uniqueAccelerations = new Set(allAccelerations); - const expectedAccelerationOptionsCount = Array.from(uniqueAccelerations).filter(Boolean).length; + const allAccelerationNames = mockAssociatedObjects.flatMap((obj) => + obj.accelerations.map((acceleration) => acceleration.name) + ); + const uniqueAccelerationNames = new Set(allAccelerationNames.filter(Boolean)); + const expectedAccelerationOptionsCount = uniqueAccelerationNames.size; expect(accelerationFilter.options.length).toEqual(expectedAccelerationOptionsCount); }); + + it('correctly filters associated objects by acceleration name', () => { + const wrapper = mount(); + + const mockQueryObject = { + queryText: 'accelerations:skipping_index_2', + ast: { + _clauses: [ + { + type: 'term', + value: 'skipping_index_2', + field: 'accelerations', + }, + ], + }, + }; + + const searchProps = wrapper.find('EuiInMemoryTable').prop('search'); + if (searchProps && searchProps.onChange) { + searchProps.onChange({ query: mockQueryObject }); + } + + wrapper.update(); + + const filteredItems = wrapper.find('EuiInMemoryTable').prop('items'); + const expectedFilteredItems = mockAssociatedObjects.filter((obj) => + obj.accelerations.some((acc) => acc.name === 'skipping_index_2') + ); + + expect(filteredItems.length).toEqual(expectedFilteredItems.length); + + expectedFilteredItems.forEach((expectedItem) => { + expect(filteredItems.some((item) => item.id === expectedItem.id)).toBeTruthy(); + }); + }); }); diff --git a/public/components/datasources/components/__tests__/data_connection.test.tsx b/public/components/datasources/components/__tests__/data_connection.test.tsx index bf7aae451..f17ef2c82 100644 --- a/public/components/datasources/components/__tests__/data_connection.test.tsx +++ b/public/components/datasources/components/__tests__/data_connection.test.tsx @@ -15,6 +15,15 @@ import { DataConnection } from '../manage/data_connection'; import ReactDOM from 'react-dom'; import { coreRefs } from '../../../../../public/framework/core_refs'; +jest.mock('../../../../plugin', () => ({ + getRenderAccelerationDetailsFlyout: jest.fn(() => + jest.fn().mockImplementation(() => console.log('Acceleration Details Flyout Rendered')) + ), + getRenderAssociatedObjectsDetailsFlyout: jest.fn(() => + jest.fn().mockImplementation(() => console.log('Associated Objects Details Flyout Rendered')) + ), +})); + jest.mock('../../../../../public/framework/core_refs', () => ({ coreRefs: { chrome: { diff --git a/public/components/datasources/components/manage/associated_objects/associated_objects_details_flyout.tsx b/public/components/datasources/components/manage/associated_objects/associated_objects_details_flyout.tsx new file mode 100644 index 000000000..86fb12d82 --- /dev/null +++ b/public/components/datasources/components/manage/associated_objects/associated_objects_details_flyout.tsx @@ -0,0 +1,230 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { + EuiFlyoutBody, + EuiFlyoutHeader, + EuiSpacer, + EuiText, + EuiIcon, + EuiButtonEmpty, + EuiFlexItem, + EuiFlexGroup, + EuiDescriptionList, + EuiDescriptionListTitle, + EuiDescriptionListDescription, + EuiHorizontalRule, + EuiTitle, + EuiTableFieldDataColumnType, + EuiInMemoryTable, + EuiLink, + EuiButton, + EuiEmptyPrompt, +} from '@elastic/eui'; +import { AssociatedObject } from 'common/types/data_connections'; +import { i18n } from '@osd/i18n'; +import { + onAccelerateButtonClick, + onDeleteButtonClick, + onDiscoverButtonClick, +} from './utils/associated_objects_tab_utils'; +import { getRenderAccelerationDetailsFlyout } from '../../../../../plugin'; +import { AccelerationStatus } from '../accelerations/helpers/utils'; +import { + ACCE_NO_DATA_TITLE, + ACCE_NO_DATA_DESCRIPTION, + CREATE_ACCELERATION_DESCRIPTION, +} from '../associated_objects/utils/associated_objects_tab_utils'; + +export interface AssociatedObjectsFlyoutProps { + tableDetail: AssociatedObject; +} + +export const AssociatedObjectsDetailsFlyout = ({ tableDetail }: AssociatedObjectsFlyoutProps) => { + const DiscoverButton = () => { + // TODO: display button if can be sent to discover + return ( + + + + ); + }; + + const AccelerateButton = () => { + return ( + + + + ); + }; + + const DeleteButton = () => { + return ( + + + + ); + }; + + const DetailComponent = (detailProps: { title: string; description: any }) => { + const { title, description } = detailProps; + return ( + + + {title} + {description} + + + ); + }; + + const ConnectionComponent = () => { + return ( + + + + + + ); + }; + + const TableTitleComponent = (titleProps: { title: string }) => { + const { title } = titleProps; + return ( + <> + +

{title}

+
+ + + ); + }; + + const accelerationData = tableDetail.accelerations.map((acc, index) => ({ + ...acc, + id: index, + })); + + const schemaData = tableDetail.columns.map((column, index) => ({ + ...column, + id: index, + })); + + const accelerationColumns = [ + { + field: 'name', + name: 'Name', + 'data-test-subj': 'accelerationName', + render: (name: string, item: AssociatedObject) => ( + renderAccelerationDetailsFlyout(item)}>{name} + ), + }, + { + field: 'status', + name: 'Status', + render: (status) => , + }, + { + field: 'type', + name: 'Type', + }, + ] as Array>; + + const noDataMessage = ( + + {i18n.translate('datasources.associatedObjectsFlyout.noAccelerationTitle', { + defaultMessage: ACCE_NO_DATA_TITLE, + })} + + } + body={ +

+ {i18n.translate('datasources.associatedObjectsFlyout.noAccelerationDescription', { + defaultMessage: ACCE_NO_DATA_DESCRIPTION, + })} +

+ } + actions={ + window.open('https://example.com', '_blank')} + iconType="popout" + iconSide="left" + > + {i18n.translate('datasources.associatedObjectsFlyout.createAccelerationButton', { + defaultMessage: CREATE_ACCELERATION_DESCRIPTION, + })} + + } + /> + ); + + const schemaColumns = [ + { + field: 'name', + name: 'Column Name', + 'data-test-subj': 'columnName', + }, + { + field: 'dataType', + name: 'Data Type', + 'data-test-subj': 'columnDataType', + }, + ] as Array>; + + const renderAccelerationDetailsFlyout = getRenderAccelerationDetailsFlyout(); + + return ( + <> + + + + +

{tableDetail.name}

+
+
+ + + + + + + + + +
+
+ + + + + {accelerationData.length > 0 ? ( + <> + + + ) : ( + noDataMessage + )} + + + + + + ); +}; diff --git a/public/components/datasources/components/manage/associated_objects/associated_objects_tab.tsx b/public/components/datasources/components/manage/associated_objects/associated_objects_tab.tsx index 4f820836e..165023c3f 100644 --- a/public/components/datasources/components/manage/associated_objects/associated_objects_tab.tsx +++ b/public/components/datasources/components/manage/associated_objects/associated_objects_tab.tsx @@ -21,6 +21,10 @@ import { } from '@elastic/eui'; import { AssociatedObject } from 'common/types/data_connections'; import { i18n } from '@osd/i18n'; +import { + getRenderAccelerationDetailsFlyout, + getRenderAssociatedObjectsDetailsFlyout, +} from '../../../../../plugin'; import { AccelerationsRecommendationCallout } from './accelerations_recommendation_callout'; import { ASSC_OBJ_TABLE_ACC_COLUMN_NAME, @@ -34,7 +38,7 @@ import { ASSC_OBJ_TABLE_SUBJ, } from './utils/associated_objects_tab_utils'; -interface AssociatedObjectsTabProps { +export interface AssociatedObjectsTabProps { associatedObjects: AssociatedObject[]; } @@ -50,12 +54,6 @@ interface AssociatedTableFilter { value: string; } -function isClauseMatched(record: AssociatedObject, filterObj: AssociatedTableFilter): boolean { - const entries = Object.entries(record); - - return entries.some(([key, value]) => key === filterObj.field && filterObj.value === value); -} - export const AssociatedObjectsTab: React.FC = ({ associatedObjects, }) => { @@ -82,10 +80,14 @@ export const AssociatedObjectsTab: React.FC = ({ setDatabaseFilterOptions(databaseOptions); const accelerationOptions = Array.from( - new Set(associatedObjects.flatMap((obj) => obj.accelerations).filter(Boolean)) + new Set( + associatedObjects + .flatMap((obj) => obj.accelerations.map((acceleration) => acceleration.name)) + .filter(Boolean) + ) ) .sort() - .map((acceleration) => ({ value: acceleration, text: acceleration })); + .map((name) => ({ value: name, text: name })); setAccelerationFilterOptions(accelerationOptions); setFilteredObjects(associatedObjects); @@ -173,7 +175,19 @@ export const AssociatedObjectsTab: React.FC = ({ }), sortable: true, 'data-test-subj': 'nameCell', - render: (name: string) => {name}, + render: (name: string, item: AssociatedObject) => ( + { + if (item.type === 'Table') { + renderAssociatedObjectsDetailsFlyout(item); + } else { + renderAccelerationDetailsFlyout(item.accelerations[0]); + } + }} + > + {name} + + ), }, { field: 'database', @@ -214,7 +228,9 @@ export const AssociatedObjectsTab: React.FC = ({ return accelerations.length > 0 ? accelerations.map((acceleration, index) => ( - openFlyout(acceleration)}>{acceleration} + renderAccelerationDetailsFlyout(acceleration)}> + {acceleration.name} + {index < accelerations.length - 1 ? ', ' : ''} )) @@ -267,11 +283,18 @@ export const AssociatedObjectsTab: React.FC = ({ const matchesClauses = (obj: AssociatedObject, clauses: AssociatedTableFilter[]): boolean => { if (clauses.length === 0) return true; + return clauses.some((clause) => { - if (clause.type !== 'field' && clause.field !== ASSC_OBJ_TABLE_ACC_COLUMN_NAME) return true; - if (clause.field === ASSC_OBJ_TABLE_ACC_COLUMN_NAME) - return obj[ASSC_OBJ_TABLE_ACC_COLUMN_NAME].includes(clause.value); - return isClauseMatched(obj, clause); + if (clause.field !== ASSC_OBJ_TABLE_ACC_COLUMN_NAME) { + return obj[clause.field] === clause.value; + } else if ( + clause.field === ASSC_OBJ_TABLE_ACC_COLUMN_NAME && + Array.isArray(obj.accelerations) + ) { + return obj.accelerations.some((acceleration) => acceleration.name === clause.value); + } + + return false; }); }; @@ -326,6 +349,9 @@ export const AssociatedObjectsTab: React.FC = ({ }, }; + const renderAccelerationDetailsFlyout = getRenderAccelerationDetailsFlyout(); + const renderAssociatedObjectsDetailsFlyout = getRenderAssociatedObjectsDetailsFlyout(); + return ( <> diff --git a/public/components/datasources/components/manage/associated_objects/utils/associated_objects_tab_utils.tsx b/public/components/datasources/components/manage/associated_objects/utils/associated_objects_tab_utils.tsx index a9f810813..f5bb03565 100644 --- a/public/components/datasources/components/manage/associated_objects/utils/associated_objects_tab_utils.tsx +++ b/public/components/datasources/components/manage/associated_objects/utils/associated_objects_tab_utils.tsx @@ -6,59 +6,216 @@ export const mockAssociatedObjects = [ { id: '1', + datasource: 'flint_s3', name: 'Table_name_1', database: 'db1', type: 'Table', - createdByIntegration: 'xx', - accelerations: ['skipping_index_1'], + createdByIntegration: 'integration_1', + accelerations: [ + { + name: 'skipping_index_1', + status: 'ACTIVE', + type: 'skip', + database: 'db1', + table: 'Table_name_1', + destination: 'N/A', + dateCreated: 1709339290, + dateUpdated: 1709339290, + index: 'security_logs_2022', + sql: 'SELECT * FROM Table_name_1 WHERE ...', + }, + ], + columns: [ + { + name: 'column1', + dataType: 'dataType1', + }, + { + name: 'column2', + dataType: 'dataType2', + }, + { + name: 'column3', + dataType: 'dataType3', + }, + { + name: 'column4', + dataType: 'dataType4', + }, + ], }, { id: '2', + datasource: 'flint_s3', name: 'Table_name_2', database: 'db1', type: 'Table', - createdByIntegration: 'xx', - accelerations: ['skipping_index_1'], + createdByIntegration: 'integration_1', + accelerations: [ + { + name: 'skipping_index_2', + status: 'ACTIVE', + type: 'skip', + database: 'db1', + table: 'Table_name_1', + destination: 'N/A', + dateCreated: 1709339290, + dateUpdated: 1709339290, + index: 'security_logs_2022', + sql: 'SELECT * FROM Table_name_1 WHERE ...', + }, + ], + columns: [], }, { id: '3', - name: 'Table_name_3', + datasource: 'flint_s3', + name: 'skipping_index_2', database: 'db1', - type: 'Table', - createdByIntegration: 'xx', - accelerations: ['skipping_index_2'], + type: 'Skip Index', + createdByIntegration: 'integration_1', + accelerations: [ + { + name: 'skipping_index_2', + status: 'ACTIVE', + type: 'skip', + database: 'db1', + table: 'Table_name_1', + destination: 'N/A', + dateCreated: 1709339290, + dateUpdated: 1709339290, + index: 'security_logs_2022', + sql: 'SELECT * FROM Table_name_1 WHERE ...', + }, + ], + columns: [], }, { id: '4', + datasource: 'flint_s3', name: 'Table_name_4', database: 'db2', type: 'Table', - createdByIntegration: 'xx', - accelerations: ['skipping_index_2'], + createdByIntegration: 'integration_1', + accelerations: [ + { + name: 'skipping_index_2', + status: 'ACTIVE', + type: 'skip', + database: 'db1', + table: 'Table_name_1', + destination: 'N/A', + dateCreated: 1709339290, + dateUpdated: 1709339290, + index: 'security_logs_2022', + sql: 'SELECT * FROM Table_name_1 WHERE ...', + }, + ], + columns: [ + { + name: 'column1', + dataType: 'dataType1', + }, + { + name: 'column2', + dataType: 'dataType2', + }, + ], }, { id: '5', + datasource: 'flint_s3', name: 'Table_name_5', database: 'db3', type: 'Table', - createdByIntegration: 'xx', - accelerations: ['skipping_index_3'], + createdByIntegration: 'integration_1', + accelerations: [], + columns: [ + { + name: 'column1', + dataType: 'dataType1', + }, + { + name: 'column2', + dataType: 'dataType2', + }, + ], }, { id: '6', - name: 'Table_name_5', + datasource: 'flint_s3', + name: 'covering_index_3', database: 'db3', - type: 'CI', + type: 'Cover Index', createdByIntegration: '', - accelerations: [], + accelerations: [ + { + name: 'covering_index_3', + status: 'ACTIVE', + type: 'skip', + database: 'db1', + table: 'Table_name_1', + destination: 'N/A', + dateCreated: 1709339290, + dateUpdated: 1709339290, + index: 'security_logs_2022', + sql: 'SELECT * FROM Table_name_1 WHERE ...', + }, + ], + columns: [ + { + name: 'column1', + dataType: 'dataType1', + }, + { + name: 'column2', + dataType: 'dataType2', + }, + ], }, { - id: '6', - name: 'Table_name_5', + id: '7', + datasource: 'flint_s3', + name: 'Table_name_6', database: 'db3', - type: 'CI', + type: 'Table', createdByIntegration: '', - accelerations: ['acc1', 'acc2'], + accelerations: [ + { + name: 'skipping_index_4', + status: 'ACTIVE', + type: 'skip', + database: 'db1', + table: 'Table_name_1', + destination: 'N/A', + dateCreated: 1709339290, + dateUpdated: 1709339290, + index: 'security_logs_2022', + sql: 'SELECT * FROM Table_name_1 WHERE ...', + }, + { + name: 'skipping_index_5', + status: 'ACTIVE', + type: 'skip', + database: 'db1', + table: 'Table_name_1', + destination: 'N/A', + dateCreated: 1709339290, + dateUpdated: 1709339290, + index: 'security_logs_2022', + sql: 'SELECT * FROM Table_name_1 WHERE ...', + }, + ], + columns: [ + { + name: 'column1', + dataType: 'dataType1', + }, + { + name: 'column2', + dataType: 'dataType2', + }, + ], }, ]; @@ -81,3 +238,24 @@ export const ASSC_OBJ_NO_DATA_DESCRIPTION = export const ASSC_OBJ_REFRESH_BTN = 'Refresh'; export const ASSC_OBJ_FRESH_MSG = 'Last updated at:'; + +export const ACCE_NO_DATA_TITLE = 'You have no accelerations'; + +export const ACCE_NO_DATA_DESCRIPTION = 'Accelerate query performing through OpenSearch Indexing'; + +export const CREATE_ACCELERATION_DESCRIPTION = 'Create Acceleration'; + +export const onAccelerateButtonClick = (tableDetail: any) => { + // TODO: create acceleration of this table + console.log('accelerating', tableDetail.name); +}; + +export const onDiscoverButtonClick = (tabaleDetail: any) => { + // TODO: send user to Discover + console.log('sending user to discover for', tabaleDetail.name); +}; + +export const onDeleteButtonClick = (tableDetail: any) => { + // TODO: delete table + console.log('deleting', tableDetail.name); +}; diff --git a/public/plugin.tsx b/public/plugin.tsx index b2a99f19a..ff60e8430 100644 --- a/public/plugin.tsx +++ b/public/plugin.tsx @@ -84,6 +84,10 @@ import { ObservabilityStart, SetupDependencies, } from './types'; +import { + AssociatedObjectsDetailsFlyout, + AssociatedObjectsFlyoutProps, +} from './components/datasources/components/manage/associated_objects/associated_objects_details_flyout'; interface PublicConfig { query_assist: { @@ -99,6 +103,11 @@ export const [ setRenderAccelerationDetailsFlyout, ] = createGetterSetter('renderAccelerationDetailsFlyout'); +export const [ + getRenderAssociatedObjectsDetailsFlyout, + setRenderAssociatedObjectsDetailsFlyout, +] = createGetterSetter('renderAssociatedObjectsDetailsFlyout'); + export class ObservabilityPlugin implements Plugin { @@ -378,9 +387,16 @@ export class ObservabilityPlugin ); setRenderAccelerationDetailsFlyout(renderAccelerationDetailsFlyout); + const renderAssociatedObjectsDetailsFlyout = (tableDetail: AssociatedObjectsFlyoutProps) => + core.overlays.openFlyout( + toMountPoint() + ); + setRenderAssociatedObjectsDetailsFlyout(renderAssociatedObjectsDetailsFlyout); + // Export so other plugins can use this flyout return { renderAccelerationDetailsFlyout, + renderAssociatedObjectsDetailsFlyout, }; }