From e1e6da7e88e7eef2f8c6b59472f822ccd9fad071 Mon Sep 17 00:00:00 2001
From: Simeon Widdis <sawiddis@gmail.com>
Date: Tue, 16 Apr 2024 14:47:28 -0700
Subject: [PATCH] Add observability-search link rendering for integrations
 (#1642)

* Add observability-search link rendering for integrations

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

* Update snapshots

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>

---------

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>
---
 common/constants/integrations.ts              |  8 +++++++-
 .../added_integration.test.tsx.snap           | 20 +++++++++++++++++++
 .../components/added_integration.tsx          | 12 +++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/common/constants/integrations.ts b/common/constants/integrations.ts
index 2d31c3c0f5..327d3b5b7b 100644
--- a/common/constants/integrations.ts
+++ b/common/constants/integrations.ts
@@ -4,7 +4,13 @@
  */
 
 export const OPENSEARCH_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest/integrations/index';
-export const ASSET_FILTER_OPTIONS = ['index-pattern', 'search', 'visualization', 'dashboard'];
+export const ASSET_FILTER_OPTIONS = [
+  'index-pattern',
+  'search',
+  'visualization',
+  'dashboard',
+  'observability-search',
+];
 export const VALID_INDEX_NAME = /^[a-z\d\.][a-z\d\._\-\*]*$/;
 
 // Upstream doesn't export this, so we need to redeclare it for our use.
diff --git a/public/components/integrations/components/__tests__/__snapshots__/added_integration.test.tsx.snap b/public/components/integrations/components/__tests__/__snapshots__/added_integration.test.tsx.snap
index 648c682511..0c52dc1e85 100644
--- a/public/components/integrations/components/__tests__/__snapshots__/added_integration.test.tsx.snap
+++ b/public/components/integrations/components/__tests__/__snapshots__/added_integration.test.tsx.snap
@@ -453,6 +453,11 @@ exports[`Added Integration View Test Renders added integration view using dummy
                             "value": "dashboard",
                             "view": "dashboard",
                           },
+                          Object {
+                            "name": "observability-search",
+                            "value": "observability-search",
+                            "view": "observability-search",
+                          },
                         ],
                         "type": "field_value_selection",
                       },
@@ -495,6 +500,11 @@ exports[`Added Integration View Test Renders added integration view using dummy
                               "value": "dashboard",
                               "view": "dashboard",
                             },
+                            Object {
+                              "name": "observability-search",
+                              "value": "observability-search",
+                              "view": "observability-search",
+                            },
                           ],
                           "type": "field_value_selection",
                         },
@@ -652,6 +662,11 @@ exports[`Added Integration View Test Renders added integration view using dummy
                                         "value": "dashboard",
                                         "view": "dashboard",
                                       },
+                                      Object {
+                                        "name": "observability-search",
+                                        "value": "observability-search",
+                                        "view": "observability-search",
+                                      },
                                     ],
                                     "type": "field_value_selection",
                                   },
@@ -709,6 +724,11 @@ exports[`Added Integration View Test Renders added integration view using dummy
                                             "value": "dashboard",
                                             "view": "dashboard",
                                           },
+                                          Object {
+                                            "name": "observability-search",
+                                            "value": "observability-search",
+                                            "view": "observability-search",
+                                          },
                                         ],
                                         "type": "field_value_selection",
                                       }
diff --git a/public/components/integrations/components/added_integration.tsx b/public/components/integrations/components/added_integration.tsx
index 7378426d51..3031b2d7ba 100644
--- a/public/components/integrations/components/added_integration.tsx
+++ b/public/components/integrations/components/added_integration.tsx
@@ -220,6 +220,18 @@ export function AddedIntegration(props: AddedIntegrationProps) {
               {_.truncate(record.description, { length: 100 })}
             </EuiLink>
           );
+        case 'observability-search':
+          return (
+            <EuiLink
+              data-test-subj={`SavedQueryLink`}
+              data-click-metric-element="integrations.saved_query_link"
+              onClick={() =>
+                window.location.assign(`observability-logs#/explorer/${record.assetId}`)
+              }
+            >
+              {_.truncate(record.description, { length: 100 })}
+            </EuiLink>
+          );
         default:
           return (
             <EuiText data-test-subj={`IntegrationAssetText`}>