Skip to content

Commit

Permalink
UI:Adds search and sort implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Shiv Verma <[email protected]>
  • Loading branch information
pratap0007 authored and tekton-robot committed Dec 16, 2020
1 parent c44c2bd commit 5d17a69
Show file tree
Hide file tree
Showing 16 changed files with 319 additions and 209 deletions.
12 changes: 6 additions & 6 deletions ui/src/components/Cards/__snapshots__/Cards.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports[`Cards should render the resources on cards 1`] = `
<CardFooter>
<TextContent className=\\"hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</TextContent>
<div className=\\"hub-tags-container\\">
<Badge className=\\"hub-tags\\">
Expand Down Expand Up @@ -77,7 +77,7 @@ exports[`Cards should render the resources on cards 1`] = `
<CardFooter>
<TextContent className=\\"hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</TextContent>
<div className=\\"hub-tags-container\\">
<Badge className=\\"hub-tags\\">
Expand Down Expand Up @@ -120,7 +120,7 @@ exports[`Cards should render the resources on cards 1`] = `
<CardFooter>
<TextContent className=\\"hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</TextContent>
<div className=\\"hub-tags-container\\">
<Badge className=\\"hub-tags\\">
Expand Down Expand Up @@ -167,7 +167,7 @@ exports[`Cards should render the resources on cards 1`] = `
<CardFooter>
<TextContent className=\\"hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</TextContent>
<div className=\\"hub-tags-container\\">
<Badge className=\\"hub-tags\\">
Expand Down Expand Up @@ -210,7 +210,7 @@ exports[`Cards should render the resources on cards 1`] = `
<CardFooter>
<TextContent className=\\"hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</TextContent>
<div className=\\"hub-tags-container\\">
<Badge className=\\"hub-tags\\">
Expand Down Expand Up @@ -253,7 +253,7 @@ exports[`Cards should render the resources on cards 1`] = `
<CardFooter>
<TextContent className=\\"hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</TextContent>
<div className=\\"hub-tags-container\\">
<Badge className=\\"hub-tags\\">
Expand Down
21 changes: 17 additions & 4 deletions ui/src/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { mount } from 'enzyme';
import { FakeHub } from '../../api/testutil';
import { createProviderAndStore } from '../../store/root';
import Header from '.';
import Search from '../../containers/Search';

it('should render the header component', () => {
const component = renderer.create(<Header />).toJSON();
expect(component).toMatchSnapshot();
const TESTDATA_DIR = `src/store/testdata`;
const api = new FakeHub(TESTDATA_DIR);
const { Provider } = createProviderAndStore(api);

it('should render the header component and finds Search component', () => {
const component = mount(
<Provider>
<Header />
</Provider>
);

expect(component.find(Search).length).toBe(1);
expect(component.debug()).toMatchSnapshot();
});
94 changes: 42 additions & 52 deletions ui/src/components/Header/__snapshots__/Header.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,55 +1,45 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should render the header component 1`] = `
<header
className="pf-c-page__header"
>
<div
className="pf-c-page__header-brand"
>
<a
className="pf-c-page__header-brand-link"
>
<img
alt="Tekton Hub Logo"
className="pf-c-brand"
onClick={[Function]}
src="logo.png"
/>
</a>
</div>
<div
className="pf-c-page__header-tools"
>
<div
className="pf-l-grid"
>
<div
className="pf-l-grid__item pf-m-11-col"
>
<input
aria-invalid={false}
aria-label="text input example"
className="pf-c-form-control hub-search"
disabled={false}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
placeholder="Search for resources..."
readOnly={false}
required={false}
spellCheck="false"
type="search"
value=""
/>
</div>
</div>
<h3
className=""
data-pf-content={true}
>
Login
</h3>
</div>
</header>
exports[`should render the header component and finds Search component 1`] = `
"<Provider>
<Header>
<PageHeader logo={{...}} headerTools={{...}}>
<header role={[undefined]} className=\\"pf-c-page__header\\">
<div className=\\"pf-c-page__header-brand\\">
<a className=\\"pf-c-page__header-brand-link\\">
<Brand src=\\"logo.png\\" alt=\\"Tekton Hub Logo\\" onClick={[Function: onClick]}>
<img onClick={[Function: onClick]} className=\\"pf-c-brand\\" src=\\"logo.png\\" alt=\\"Tekton Hub Logo\\" />
</Brand>
</a>
</div>
<PageHeaderTools>
<div className=\\"pf-c-page__header-tools\\">
<Grid>
<div className=\\"pf-l-grid\\">
<GridItem span={11}>
<div className=\\"pf-l-grid__item pf-m-11-col\\">
<Search>
<ForwardRef value=\\"\\" type=\\"search\\" onChange={[Function: onSearchChange]} onKeyPress={[Function: onSearchKeyPress]} aria-label=\\"text input example\\" placeholder=\\"Search for resources...\\" spellCheck=\\"false\\" className=\\"hub-search\\">
<TextInputBase value=\\"\\" type=\\"search\\" onChange={[Function: onSearchChange]} onKeyPress={[Function: onSearchKeyPress]} aria-label=\\"text input example\\" placeholder=\\"Search for resources...\\" spellCheck=\\"false\\" className=\\"hub-search\\" innerRef={{...}} isRequired={false} validated=\\"default\\" isDisabled={false} isReadOnly={false} isLeftTruncated={false}>
<input onKeyPress={[Function: onSearchKeyPress]} aria-label=\\"text input example\\" placeholder=\\"Search for resources...\\" spellCheck=\\"false\\" onFocus={[Function (anonymous)]} onBlur={[Function (anonymous)]} className=\\"pf-c-form-control hub-search\\" onChange={[Function (anonymous)]} type=\\"search\\" value=\\"\\" aria-invalid={false} required={false} disabled={false} readOnly={false} />
</TextInputBase>
</ForwardRef>
</Search>
</div>
</GridItem>
</div>
</Grid>
<Text component=\\"h3\\">
<h3 data-pf-content={true} className=\\"\\">
Login
</h3>
</Text>
</div>
</PageHeaderTools>
</header>
</PageHeader>
</Header>
</Provider>"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

exports[`LeftPane should find the components and match the count 1`] = `
"<Grid hasGutter={true} className=\\"hub-leftpane\\">
<GridItem span={3}>
<Text component=\\"h1\\" className=\\"hub-leftpane-sort\\">
Sort
</Text>
</GridItem>
<GridItem span={9}>
<GridItem span={8}>
<Sort />
</GridItem>
<GridItem>
Expand Down
13 changes: 2 additions & 11 deletions ui/src/components/LeftPane/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useObserver } from 'mobx-react';
import { GridItem, Grid, Text, TextVariants } from '@patternfly/react-core';
import { GridItem, Grid } from '@patternfly/react-core';
import CatalogFilter from '../../containers/CatalogFilter';
import KindFilter from '../../containers/KindFilter';
import CategoryFilter from '../../containers/CategoryFilter';
Expand All @@ -10,28 +10,19 @@ import './LeftPane.css';
const LeftPane: React.FC = () => {
return useObserver(() => (
<Grid hasGutter className="hub-leftpane">
<GridItem span={3}>
<Text component={TextVariants.h1} className="hub-leftpane-sort">
Sort
</Text>
</GridItem>
<GridItem span={9}>
<GridItem span={8}>
<Sort />
</GridItem>

<GridItem>
<KindFilter />
</GridItem>

<GridItem>
<CatalogFilter />
</GridItem>

<GridItem>
<CategoryFilter />
</GridItem>
</Grid>
));
};

export default LeftPane;
67 changes: 39 additions & 28 deletions ui/src/containers/App/__snapshots__/App.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Array [
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
onKeyPress={[Function]}
placeholder="Search for resources..."
readOnly={false}
required={false}
Expand Down Expand Up @@ -98,46 +99,56 @@ Array [
className="pf-l-grid pf-m-gutter hub-leftpane"
>
<div
className="pf-l-grid__item pf-m-3-col"
className="pf-l-grid__item pf-m-8-col"
>
<h1
className="hub-leftpane-sort"
data-pf-content={true}
<div
className="hub-sort"
>
Sort
</h1>
</div>
<div
className="pf-l-grid__item pf-m-9-col"
>
<div>
<div
className="pf-c-dropdown hub-sort-dropdown"
className="pf-c-select"
data-ouia-component-id={0}
data-ouia-component-type="PF4/Dropdown"
data-ouia-component-type="PF4/Select"
data-ouia-safe={true}
>
<button
aria-expanded={false}
aria-haspopup={true}
className="pf-c-dropdown__toggle"
disabled={false}
id="pf-dropdown-toggle-id-0"
<div
className="pf-c-select__toggle pf-m-typeahead"
onClick={[Function]}
onKeyDown={[Function]}
type="button"
>
<span
className="pf-c-dropdown__toggle-text"
<div
className="pf-c-select__toggle-wrapper"
>
Name
</span>
<span
className="pf-c-dropdown__toggle-icon"
<input
aria-activedescendant={null}
aria-label="Sort By"
autoComplete="off"
className="pf-c-form-control pf-c-select__toggle-typeahead"
disabled={false}
id="pf-select-toggle-id-0-select-typeahead"
onChange={[Function]}
onClick={[Function]}
onFocus={[Function]}
placeholder="Sort By"
type="text"
value=""
/>
</div>
<button
aria-expanded={false}
aria-haspopup="listbox"
aria-label="Options menu"
aria-labelledby=" pf-select-toggle-id-0"
className="pf-c-button pf-c-select__toggle-button pf-m-plain"
disabled={false}
id="pf-select-toggle-id-0"
onClick={[Function]}
tabIndex={-1}
type="button"
>
<svg
aria-hidden={true}
aria-labelledby={null}
className="pf-c-select__toggle-arrow"
fill="currentColor"
height="1em"
role="img"
Expand All @@ -154,8 +165,8 @@ Array [
transform=""
/>
</svg>
</span>
</button>
</button>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ exports[`Resource Component should render the resources component 1`] = `
<TextContent className=\\"hub-resource-updatedAt\\">
<div className=\\"pf-c-content hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</div>
</TextContent>
<div className=\\"hub-tags-container\\">
Expand Down Expand Up @@ -160,7 +160,7 @@ exports[`Resource Component should render the resources component 1`] = `
<TextContent className=\\"hub-resource-updatedAt\\">
<div className=\\"pf-c-content hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</div>
</TextContent>
<div className=\\"hub-tags-container\\">
Expand Down Expand Up @@ -245,7 +245,7 @@ exports[`Resource Component should render the resources component 1`] = `
<TextContent className=\\"hub-resource-updatedAt\\">
<div className=\\"pf-c-content hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</div>
</TextContent>
<div className=\\"hub-tags-container\\">
Expand Down Expand Up @@ -336,7 +336,7 @@ exports[`Resource Component should render the resources component 1`] = `
<TextContent className=\\"hub-resource-updatedAt\\">
<div className=\\"pf-c-content hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</div>
</TextContent>
<div className=\\"hub-tags-container\\">
Expand Down Expand Up @@ -421,7 +421,7 @@ exports[`Resource Component should render the resources component 1`] = `
<TextContent className=\\"hub-resource-updatedAt\\">
<div className=\\"pf-c-content hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</div>
</TextContent>
<div className=\\"hub-tags-container\\">
Expand Down Expand Up @@ -506,7 +506,7 @@ exports[`Resource Component should render the resources component 1`] = `
<TextContent className=\\"hub-resource-updatedAt\\">
<div className=\\"pf-c-content hub-resource-updatedAt\\">
Updated
a month ago
2 months ago
</div>
</TextContent>
<div className=\\"hub-tags-container\\">
Expand Down
Loading

0 comments on commit 5d17a69

Please sign in to comment.