-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[App Search] Add accordion lists for Domains, Seed URLs, and Sitemap URLs to Crawl Details Flyout #119682
Merged
daveyholler
merged 17 commits into
elastic:main
from
byronhulcher:crawl-details-preview-lists
Dec 1, 2021
Merged
[App Search] Add accordion lists for Domains, Seed URLs, and Sitemap URLs to Crawl Details Flyout #119682
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6c5e07a
New AccordionList component
a6734de
Add a domains accordion list to the CrawlDetailsPreview
28af3ae
Add seedUrls to CrawlConfig
2095078
Add a seed urls accordion list to the CrawlDetailsPreview
37d82e9
Add sitemapUrls to CrawlConfig
052086c
Add a sitemap urls accordion list to the CrawlDetailsPreview
c6da382
Disable arrow in AccordionList when items are empty
da9d756
Add spacers to CrawlDetailsPreview
9c52fc5
Type fix
d68574b
Merge branch 'main' into crawl-details-preview-lists
kibanamachine 9956772
Sets a maxWidth on the flyout.
daveyholler f7e93f8
Allows the raw JSON to be copied.
daveyholler 6204c15
Visual updates to the accordions.
daveyholler c680d3e
Linting
daveyholler 64dbf0d
Review and linting fixes.
daveyholler 828d818
Styles the tables in the accordion list.
daveyholler f9dd39b
Uses a subdued color for count badges when the count is zero.
daveyholler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...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,5 @@ | ||
.appSearchAccordion--bordered { | ||
border: $euiBorderThin; | ||
border-radius: $euiBorderRadius; | ||
padding: $euiSizeM; | ||
} |
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); | ||
}); | ||
}); |
72 changes: 72 additions & 0 deletions
72
...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,72 @@ | ||
/* | ||
* 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, | ||
EuiTitle, | ||
IconType, | ||
useGeneratedHtmlId, | ||
} from '@elastic/eui'; | ||
|
||
import './accordion_list.scss'; | ||
|
||
interface Props { | ||
iconType: IconType; | ||
items: string[]; | ||
hasBorder?: boolean; | ||
initialIsOpen?: boolean; | ||
title: string; | ||
} | ||
|
||
export const AccordionList: React.FC<Props> = ({ iconType, items, hasBorder, initialIsOpen, title }) => { | ||
const accordionId = useGeneratedHtmlId({ | ||
prefix: 'accordionList', | ||
}); | ||
|
||
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 size="m">{items.length}</EuiNotificationBadge>} | ||
> | ||
<EuiInMemoryTable | ||
items={items.map((item) => ({ item }))} | ||
columns={[ | ||
{ | ||
render: ({ item }: { item: string }) => item, | ||
}, | ||
]} | ||
pagination={ items.length > 10 ? { | ||
hidePerPageOptions: true, | ||
} : false} | ||
/> | ||
</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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasBorder
allows the accordion to be rendered with or without a border and padding. I've got some designs in the works that will use be making use of this component in both scenarios.initialIsOpen
allows the accordion to be expanded. In this case specifically, we set the prop totrue
when items exist in the list.