-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[App Search] Add accordion lists for Domains, Seed URLs, and Sitemap …
…URLs to Crawl Details Flyout (#119682) (#120160) * New AccordionList component * Add a domains accordion list to the CrawlDetailsPreview * Add seedUrls to CrawlConfig * Add a seed urls accordion list to the CrawlDetailsPreview * Add sitemapUrls to CrawlConfig * Add a sitemap urls accordion list to the CrawlDetailsPreview * Disable arrow in AccordionList when items are empty * Add spacers to CrawlDetailsPreview * Type fix * Sets a maxWidth on the flyout. * Allows the raw JSON to be copied. * Visual updates to the accordions. * Linting * Review and linting fixes. * Styles the tables in the accordion list. * Uses a subdued color for count badges when the count is zero. Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Davey Holler <[email protected]> Co-authored-by: Byron Hulcher <[email protected]> Co-authored-by: Davey Holler <[email protected]>
- Loading branch information
1 parent
cd7438e
commit 676a829
Showing
14 changed files
with
330 additions
and
7 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...cations/app_search/components/crawler/components/crawl_details_flyout/accordion_list.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.appSearchAccordion--bordered { | ||
border: $euiBorderThin; | ||
border-radius: $euiBorderRadius; | ||
padding: $euiSizeM; | ||
} | ||
|
||
.appSearchAccordion--bordered, .appSearchAccordion { | ||
.euiBasicTable { | ||
.euiTableRow > .euiTableRowCell { | ||
border-bottom: none; | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ons/app_search/components/crawler/components/crawl_details_flyout/accordion_list.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import '../../../../__mocks__/engine_logic.mock'; | ||
|
||
import React from 'react'; | ||
|
||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
|
||
import { EuiAccordion, EuiIcon, EuiTitle, EuiInMemoryTable } from '@elastic/eui'; | ||
|
||
import { AccordionList } from './accordion_list'; | ||
|
||
const MOCK_PROPS = { | ||
title: 'Test Items', | ||
iconType: 'globe', | ||
items: ['first item', 'second item'], | ||
}; | ||
|
||
describe('AccordionList', () => { | ||
let wrapper: ShallowWrapper; | ||
|
||
beforeAll(() => { | ||
wrapper = shallow(<AccordionList {...MOCK_PROPS} />); | ||
}); | ||
|
||
it('renders as an accordion with the passed in title and icon', () => { | ||
expect(wrapper.is(EuiAccordion)).toBe(true); | ||
|
||
const buttonContent = shallow(wrapper.prop('buttonContent')); | ||
|
||
expect(buttonContent.find(EuiIcon).prop('type')).toEqual('globe'); | ||
expect(buttonContent.find(EuiTitle).children().text()).toEqual('Test Items'); | ||
}); | ||
|
||
it('shows the item count', () => { | ||
const extraActionContent = shallow(wrapper.prop('extraAction')); | ||
|
||
expect(extraActionContent.text()).toEqual('2'); | ||
}); | ||
|
||
it('contains an table displaying the items', () => { | ||
const table = wrapper.find(EuiInMemoryTable); | ||
|
||
expect(table.prop('items')).toEqual([{ item: 'first item' }, { item: 'second item' }]); | ||
|
||
expect(table.prop('columns')[0].render({ item: 'first item' })).toEqual('first item'); | ||
}); | ||
|
||
it('is disabled when there are no items', () => { | ||
const disabledWrapper = shallow(<AccordionList {...{ ...MOCK_PROPS, items: [] }} />); | ||
|
||
expect(disabledWrapper.prop('arrowProps').isDisabled).toEqual(true); | ||
}); | ||
}); |
92 changes: 92 additions & 0 deletions
92
...ications/app_search/components/crawler/components/crawl_details_flyout/accordion_list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { | ||
EuiAccordion, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiIcon, | ||
EuiInMemoryTable, | ||
EuiNotificationBadge, | ||
EuiSpacer, | ||
EuiTitle, | ||
IconType, | ||
useGeneratedHtmlId, | ||
} from '@elastic/eui'; | ||
|
||
import './accordion_list.scss'; | ||
|
||
interface Props { | ||
hasBorder?: boolean; | ||
iconType: IconType; | ||
initialIsOpen?: boolean; | ||
items: string[]; | ||
rowCount?: number; | ||
title: string; | ||
} | ||
|
||
export const AccordionList: React.FC<Props> = ({ | ||
hasBorder, | ||
iconType, | ||
initialIsOpen, | ||
items, | ||
rowCount = 10, | ||
title, | ||
}) => { | ||
const accordionId = useGeneratedHtmlId({ | ||
prefix: 'accordionList', | ||
}); | ||
|
||
const showPagination = items.length > rowCount; | ||
|
||
return ( | ||
<EuiAccordion | ||
initialIsOpen={initialIsOpen} | ||
arrowProps={{ | ||
isDisabled: items.length === 0, | ||
}} | ||
className={hasBorder ? 'appSearchAccordion--bordered' : 'appSearchAccordion'} | ||
buttonContent={ | ||
<EuiFlexGroup direction="row" responsive={false} gutterSize="s" alignItems="center"> | ||
<EuiFlexItem grow={false}> | ||
<EuiIcon type={iconType} /> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiTitle size="s"> | ||
<h3>{title}</h3> | ||
</EuiTitle> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
} | ||
id={accordionId} | ||
extraAction={ | ||
<EuiNotificationBadge color={items.length > 0 ? 'accent' : 'subdued'} size="m"> | ||
{items.length} | ||
</EuiNotificationBadge> | ||
} | ||
> | ||
<EuiInMemoryTable | ||
items={items.map((item) => ({ item }))} | ||
columns={[ | ||
{ | ||
render: ({ item }: { item: string }) => item, | ||
}, | ||
]} | ||
pagination={ | ||
showPagination | ||
? { | ||
hidePerPageOptions: true, | ||
} | ||
: false | ||
} | ||
/> | ||
{!showPagination && <EuiSpacer size="s" />} | ||
</EuiAccordion> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.