-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sebastian Malton <sebastian@malton.name>
- Loading branch information
Showing
17 changed files
with
183 additions
and
196 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
|
||
import "./item-list-layout.scss"; | ||
|
||
import React from "react"; | ||
import { PageFiltersList } from "./page-filters-list"; | ||
import { observer } from "mobx-react"; | ||
import type { Filter } from "./page-filters.store"; | ||
|
||
export interface ItemListLayoutFilterProps { | ||
getIsReady: () => boolean | ||
getFilters: () => Filter[] | ||
getFiltersAreShown: () => boolean | ||
hideFilters: boolean | ||
} | ||
|
||
export const ItemListLayoutFilters = observer(({ getFilters, getFiltersAreShown, getIsReady, hideFilters }: ItemListLayoutFilterProps) => { | ||
const filters = getFilters(); | ||
|
||
if (!getIsReady() || !filters.length || hideFilters || !getFiltersAreShown()) { | ||
return null; | ||
} | ||
|
||
return <PageFiltersList filters={filters} />; | ||
}); | ||
|
17 changes: 17 additions & 0 deletions
17
src/renderer/components/item-object-list/header-filters.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,17 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { observer } from "mobx-react"; | ||
import React from "react"; | ||
import type { HeaderPlaceholders } from "./list-layout"; | ||
|
||
export interface ItemListLayoutHeaderFiltersProps { | ||
headerPlaceholders: HeaderPlaceholders | ||
} | ||
|
||
export const ItemListLayoutHeaderFilters = observer(({ headerPlaceholders }: ItemListLayoutHeaderFiltersProps) => ( | ||
<> | ||
{headerPlaceholders.filters} | ||
</> | ||
)); |
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,54 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import React from "react"; | ||
import { observer } from "mobx-react"; | ||
import type { ItemObject, ItemStore } from "../../../common/item.store"; | ||
import type { Filter } from "./page-filters.store"; | ||
import type { HeaderPlaceholders } from "./list-layout"; | ||
|
||
interface ItemListLayoutHeaderInfoProps<I extends ItemObject> { | ||
headerPlaceholders: HeaderPlaceholders; | ||
getItems: () => I[]; | ||
store: ItemStore<I>; | ||
getFilters: () => Filter[] | ||
toggleFilters: () => void | ||
} | ||
|
||
export const ItemListLayoutHeaderInfo = observer(<I extends ItemObject>({ | ||
headerPlaceholders, | ||
getItems, | ||
getFilters, | ||
store, | ||
toggleFilters, | ||
}: ItemListLayoutHeaderInfoProps<I>) => { | ||
const renderInfo = () => { | ||
const allItemsCount = store.getTotalCount(); | ||
const itemsCount = getItems().length; | ||
|
||
if (getFilters().length > 0) { | ||
return ( | ||
<> | ||
<a onClick={toggleFilters}>Filtered</a>: {itemsCount} / {allItemsCount} | ||
</> | ||
); | ||
} | ||
|
||
return allItemsCount === 1 | ||
? `${allItemsCount} item` | ||
: `${allItemsCount} items`; | ||
}; | ||
|
||
const info = headerPlaceholders.info ?? renderInfo(); | ||
|
||
if (!info) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="info-panel box grow"> | ||
{info} | ||
</div> | ||
); | ||
}); |
27 changes: 27 additions & 0 deletions
27
src/renderer/components/item-object-list/header-search.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,27 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
import { observer } from "mobx-react"; | ||
import type { ItemObject } from "../../../common/item.store"; | ||
import { SearchInputUrl } from "../input"; | ||
import React from "react"; | ||
import type { HeaderPlaceholders, SearchFilter } from "./list-layout"; | ||
|
||
interface ItemListLayoutHeaderSearchProps<I extends ItemObject> { | ||
searchFilters: SearchFilter<I>[]; | ||
headerPlaceholders: HeaderPlaceholders; | ||
} | ||
|
||
export const ItemListLayoutHeaderSearch = observer(<I extends ItemObject>({ | ||
searchFilters, | ||
headerPlaceholders = {}, | ||
}: ItemListLayoutHeaderSearchProps<I>) => { | ||
const { searchProps } = headerPlaceholders; | ||
|
||
if (searchFilters.length === 0 || !searchProps) { | ||
return null; | ||
} | ||
|
||
return <SearchInputUrl {...searchProps} />; | ||
}); |
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
32 changes: 0 additions & 32 deletions
32
...enderer/components/item-object-list/item-list-layout-filters/item-list-layout-filters.tsx
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
...em-list-layout-header/item-list-layout-header-filters/item-list-layout-header-filters.tsx
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
...ist/item-list-layout-header/item-list-layout-header-info/item-list-layout-header-info.tsx
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...item-list-layout-header/item-list-layout-header-search/item-list-layout-header-search.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.