diff --git a/.cypress/integration/9_integrations.spec.js b/.cypress/integration/9_integrations.spec.js index 6ee3b53a76..2c0f39c39a 100644 --- a/.cypress/integration/9_integrations.spec.js +++ b/.cypress/integration/9_integrations.spec.js @@ -21,7 +21,7 @@ const moveToAvailableNginxIntegration = () => { }; const moveToAddedIntegrations = () => { - cy.visit(`${Cypress.env('opensearchDashboards')}/app/integrations#/added`); + cy.visit(`${Cypress.env('opensearchDashboards')}/app/integrations#/installed`); }; 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 bfc7014eee..5ef5da45c2 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 @@ -13,11 +13,11 @@ exports[`Added Integration View Test Renders added integration view using dummy "text": "Integrations", }, Object { - "href": "#/added", - "text": "Added Integration", + "href": "#/installed", + "text": "Installed Integrations", }, Object { - "href": "#/added/undefined", + "href": "#/installed/undefined", "text": "undefined", }, ], diff --git a/public/components/integrations/components/__tests__/__snapshots__/added_integration_table.test.tsx.snap b/public/components/integrations/components/__tests__/__snapshots__/added_integration_table.test.tsx.snap index 41f49f8d26..9cb3e5126d 100644 --- a/public/components/integrations/components/__tests__/__snapshots__/added_integration_table.test.tsx.snap +++ b/public/components/integrations/components/__tests__/__snapshots__/added_integration_table.test.tsx.snap @@ -1053,13 +1053,13 @@ exports[`Added Integration Table View Test Renders added integration table view nginx diff --git a/public/components/integrations/components/__tests__/__snapshots__/available_integration_card_view.test.tsx.snap b/public/components/integrations/components/__tests__/__snapshots__/available_integration_card_view.test.tsx.snap index 8aab820832..9f6372b915 100644 --- a/public/components/integrations/components/__tests__/__snapshots__/available_integration_card_view.test.tsx.snap +++ b/public/components/integrations/components/__tests__/__snapshots__/available_integration_card_view.test.tsx.snap @@ -55,6 +55,7 @@ exports[`Available Integration Card View Test Renders nginx integration card vie ], } } + renderCateogryFilters={[Function]} showModal={[Function]} > @@ -154,6 +155,13 @@ exports[`Available Integration Card View Test Renders nginx integration card vie + +
+ diff --git a/public/components/integrations/components/__tests__/__snapshots__/available_integration_table_view.test.tsx.snap b/public/components/integrations/components/__tests__/__snapshots__/available_integration_table_view.test.tsx.snap index 7105fee03d..2406957a3c 100644 --- a/public/components/integrations/components/__tests__/__snapshots__/available_integration_table_view.test.tsx.snap +++ b/public/components/integrations/components/__tests__/__snapshots__/available_integration_table_view.test.tsx.snap @@ -56,6 +56,7 @@ exports[`Available Integration Table View Test Renders nginx integration table v } } loading={false} + renderCateogryFilters={[Function]} showModal={[Function]} > , + "toolsRight": + + + + + , } } tableLayout="auto" @@ -207,26 +213,31 @@ exports[`Available Integration Table View Test Renders nginx integration table v } onChange={[Function]} toolsRight={ - + + + + + + } > - -
+
- - - Text align - - -
- +
+ + +
- - - - - - -
-
+ htmlFor="random_html_id" + onClick={[Function]} + style={ + Object { + "minWidth": undefined, + } + } + > + + + + + + + + + + grid + + + + + + +
+ + + +
+ + diff --git a/public/components/integrations/components/__tests__/__snapshots__/integration_header.test.tsx.snap b/public/components/integrations/components/__tests__/__snapshots__/integration_header.test.tsx.snap index f27b961ed1..0c71537130 100644 --- a/public/components/integrations/components/__tests__/__snapshots__/integration_header.test.tsx.snap +++ b/public/components/integrations/components/__tests__/__snapshots__/integration_header.test.tsx.snap @@ -126,7 +126,7 @@ exports[`Integration Header Test Renders integration header as expected 1`] = ` - Added + Installed diff --git a/public/components/integrations/components/__tests__/testing_constants.ts b/public/components/integrations/components/__tests__/testing_constants.ts index 6cd79b9c12..32cf5b4e61 100644 --- a/public/components/integrations/components/__tests__/testing_constants.ts +++ b/public/components/integrations/components/__tests__/testing_constants.ts @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import { AddedIntegrationsTableProps } from '../added_integration_overview_page'; import { AvailableIntegrationsCardViewProps, @@ -34,6 +39,7 @@ export const availableCardViewData: AvailableIntegrationsCardViewProps = { ], }, showModal: () => {}, + renderCateogryFilters: () => null as any, }; export const availableTableViewData: AvailableIntegrationsTableProps = { @@ -67,6 +73,7 @@ export const availableTableViewData: AvailableIntegrationsTableProps = { }, showModal: () => {}, loading: false, + renderCateogryFilters: () => null as any, }; export const addedIntegrationData: AddedIntegrationsTableProps = { diff --git a/public/components/integrations/components/added_integration.tsx b/public/components/integrations/components/added_integration.tsx index 6d1c5d77f6..aa69637bcf 100644 --- a/public/components/integrations/components/added_integration.tsx +++ b/public/components/integrations/components/added_integration.tsx @@ -48,12 +48,12 @@ export function AddedIntegration(props: AddedIntegrationProps) { href: '#/', }, { - text: 'Added Integration', - href: '#/added', + text: 'Installed Integrations', + href: '#/installed', }, { text: `${stateData.data?.name}`, - href: `#/added/${stateData.data?.id}`, + href: `#/installed/${stateData.data?.id}`, }, ]); handleDataRequest(); @@ -63,7 +63,6 @@ export function AddedIntegration(props: AddedIntegrationProps) { const [modalLayout, setModalLayout] = useState(); const badge = (status) => { - console.log(status); switch (status) { case 'available': return Healthy; diff --git a/public/components/integrations/components/added_integration_table.tsx b/public/components/integrations/components/added_integration_table.tsx index 53d7db0fec..3153b59fc5 100644 --- a/public/components/integrations/components/added_integration_table.tsx +++ b/public/components/integrations/components/added_integration_table.tsx @@ -43,7 +43,7 @@ export function AddedIntegrationsTable(props: AddedIntegrationsTableProps) { sortable: true, truncateText: true, render: (value, record) => ( - + {_.truncate(record.name, { length: 100 })} ), @@ -99,7 +99,7 @@ export function AddedIntegrationsTable(props: AddedIntegrationsTableProps) { setToast(`Error deleting ${name} or its assets`, 'danger'); }) .finally(() => { - window.location.hash = '#/added'; + window.location.hash = '#/installed'; }); } diff --git a/public/components/integrations/components/available_integration_card_view.tsx b/public/components/integrations/components/available_integration_card_view.tsx index 21922460e0..62d8189b59 100644 --- a/public/components/integrations/components/available_integration_card_view.tsx +++ b/public/components/integrations/components/available_integration_card_view.tsx @@ -29,9 +29,6 @@ import { badges } from './integration_category_badge_group'; export function AvailableIntegrationsCardView(props: AvailableIntegrationsCardViewProps) { const [toggleIconIdSelected, setToggleIconIdSelected] = useState('1'); - // const query = '' - - // const query = useRef(''); const getImage = (url?: string) => { let optionalImg; @@ -112,6 +109,7 @@ export function AvailableIntegrationsCardView(props: AvailableIntegrationsCardVi // onSearch={props.refresh} /> + {props.renderCateogryFilters()} void; isCardView: boolean; setCardView: (input: boolean) => void; + renderCateogryFilters: () => React.JSX.Element; } export interface AvailableIntegrationsList { @@ -47,6 +61,7 @@ export interface AvailableIntegrationsCardViewProps { setCardView: (input: boolean) => void; query: string; setQuery: (input: string) => void; + renderCateogryFilters: () => React.JSX.Element; } export function AvailableIntegrationOverviewPage(props: AvailableIntegrationOverviewPageProps) { @@ -60,6 +75,59 @@ export function AvailableIntegrationOverviewPage(props: AvailableIntegrationOver const [isModalVisible, setIsModalVisible] = useState(false); const [modalLayout, setModalLayout] = useState(); + const [isPopoverOpen, setIsPopoverOpen] = useState(false); + + const onButtonClick = () => { + setIsPopoverOpen(!isPopoverOpen); + }; + + const closePopover = () => { + setIsPopoverOpen(false); + }; + + const [items, setItems] = useState([ + { name: 'http' }, + { name: 'logs' }, + { name: 'communication' }, + { name: 'cloud' }, + { name: 'aws_elb' }, + { name: 'container' }, + ]); + + function updateItem(index) { + if (!items[index]) { + return; + } + + const newItems = [...items]; + + switch (newItems[index].checked) { + case 'on': + newItems[index].checked = undefined; + break; + + default: + newItems[index].checked = 'on'; + } + + setItems(newItems); + } + + const helper = items.filter((item) => item.checked === 'on').map((x) => x.name); + + const button = ( + item.checked === 'on')} + numActiveFilters={items.filter((item) => item.checked === 'on').length} + > + Categories + + ); + const getModal = (name: string) => { setModalLayout( getAddIntegrationModal( @@ -116,25 +184,64 @@ export function AvailableIntegrationOverviewPage(props: AvailableIntegrationOver ); } + const renderCateogryFilters = () => { + return ( + + + + + +
+ {items.map((item, index) => ( + updateItem(index)} + > + {item.name} + + ))} +
+
+
+ ); + }; + return ( - + {IntegrationHeader()} {isCardView ? AvailableIntegrationsCardView({ - data, + data: { + hits: data.hits.filter((hit) => + helper.every((compon) => hit.components.map((x) => x.name).includes(compon)) + ), + }, showModal: getModal, isCardView, setCardView, query, setQuery, + renderCateogryFilters, }) : AvailableIntegrationsTable({ loading: false, - data, + data: { + hits: data.hits.filter((hit) => + helper.every((compon) => hit.components.map((x) => x.name).includes(compon)) + ), + }, showModal: getModal, isCardView, setCardView, + renderCateogryFilters, })} {isModalVisible && modalLayout} diff --git a/public/components/integrations/components/available_integration_table.tsx b/public/components/integrations/components/available_integration_table.tsx index 81d14affd1..f37055f9b5 100644 --- a/public/components/integrations/components/available_integration_table.tsx +++ b/public/components/integrations/components/available_integration_table.tsx @@ -5,15 +5,25 @@ import { EuiButtonGroup, + EuiFieldSearch, + EuiFilterButton, + EuiFilterGroup, + EuiFilterSelectItem, + EuiFlexGroup, + EuiFlexItem, + EuiIcon, EuiInMemoryTable, EuiLink, EuiPageContent, + EuiPopover, + EuiPopoverTitle, EuiSpacer, EuiTableFieldDataColumnType, EuiText, } from '@elastic/eui'; import _ from 'lodash'; import React, { useState } from 'react'; +import { ASSET_FILTER_OPTIONS } from 'common/constants/explorer'; import { AvailableIntegrationsTableProps } from './available_integration_overview_page'; import { badges } from './integration_category_badge_group'; @@ -33,10 +43,10 @@ export function AvailableIntegrationsTable(props: AvailableIntegrationsTableProp }, ]; - const [toggleIconIdSelected, setToggleIconIdSelectedc] = useState('0'); + const [toggleIconIdSelected, setToggleIconIdSelected] = useState('0'); const onChangeIcons = (optionId) => { - setToggleIconIdSelectedc(optionId); + setToggleIconIdSelected(optionId); if (optionId === '0') { props.setCardView(false); } else { @@ -81,13 +91,18 @@ export function AvailableIntegrationsTable(props: AvailableIntegrationsTableProp const renderToggle = () => { return ( - onChangeIcons(id)} - isIconOnly - /> + + {props.renderCateogryFilters()} + + onChangeIcons(id)} + isIconOnly + /> + + ); }; diff --git a/public/components/integrations/components/integration.tsx b/public/components/integrations/components/integration.tsx index e2e8bd5d0d..40657e10e8 100644 --- a/public/components/integrations/components/integration.tsx +++ b/public/components/integrations/components/integration.tsx @@ -198,11 +198,13 @@ export function Integration(props: AvailableIntegrationProps) { body: JSON.stringify({ name, dataSource }), }) .then((_res) => { + console.log(_res); setToast( `${name} integration successfully added!`, 'success', `View the added assets from ${name} in the Added Integrations list` ); + window.location.hash = `#/installed/${_res.data?.id}`; return true; }) .catch((_err) => { diff --git a/public/components/integrations/components/integration_header.tsx b/public/components/integrations/components/integration_header.tsx index df2e1fed59..5ef1772a7e 100644 --- a/public/components/integrations/components/integration_header.tsx +++ b/public/components/integrations/components/integration_header.tsx @@ -20,8 +20,8 @@ import { OPENSEARCH_DOCUMENTATION_URL } from '../../../../common/constants/custo export function IntegrationHeader() { const tabs = [ { - id: 'added', - name: 'Added', + id: 'installed', + name: 'Installed', disabled: false, }, { @@ -32,7 +32,7 @@ export function IntegrationHeader() { ]; const [selectedTabId, setSelectedTabId] = useState( - window.location.hash.substring(2) ? window.location.hash.substring(2) : 'added' + window.location.hash.substring(2) ? window.location.hash.substring(2) : 'installed' ); const onSelectedTabChanged = (id) => { diff --git a/public/components/integrations/components/integration_overview_panel.tsx b/public/components/integrations/components/integration_overview_panel.tsx index d4b46bc048..773be1f3be 100644 --- a/public/components/integrations/components/integration_overview_panel.tsx +++ b/public/components/integrations/components/integration_overview_panel.tsx @@ -20,22 +20,24 @@ import { import React from 'react'; const pageStyles: CSS.Properties = { - width: '80%', + width: '100%', + justifyContent: 'spaceBetween', }; export function IntegrationOverview(props: any) { const config = props.integration; return ( - + - + - - {config.displayName || config.name} - +

{config.displayName || config.name}

diff --git a/public/components/integrations/home.tsx b/public/components/integrations/home.tsx index b0c65becd1..0ed56c86a6 100644 --- a/public/components/integrations/home.tsx +++ b/public/components/integrations/home.tsx @@ -40,12 +40,12 @@ export const Home = (props: HomeProps) => { /> } /> (