-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1918] Add support for filtering tree based representations
Bug: #1918 Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
- Loading branch information
1 parent
e90ffd1
commit b20691b
Showing
11 changed files
with
302 additions
and
65 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
15 changes: 15 additions & 0 deletions
15
doc/iterations/2023.6/scopes/filter_tree_based_representations.adoc
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,15 @@ | ||
= Filtering tree based representations | ||
|
||
== First task | ||
|
||
- [x] Shape written, reviewed and merged | ||
- [x] ADR written | ||
- [x] First prototype of the user interface | ||
- [x] Changelog updated | ||
|
||
== Second task | ||
- [ ] Implement expand all action in tree item context menu | ||
- [ ] First version of the user interface done with Cypress tests | ||
- [ ] User guide updated with screenshots | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
30 changes: 30 additions & 0 deletions
30
packages/trees/frontend/sirius-components-trees/src/treeitems/filterTreeItem.ts
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,30 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
import { GQLTreeItem } from '../views/ExplorerView.types'; | ||
|
||
export const isFilterCandidate = (treeItem: GQLTreeItem, highlightRegExp: RegExp): boolean => { | ||
let filter: boolean = false; | ||
const splitLabelWithTextToHighlight: string[] = treeItem.label.split(highlightRegExp); | ||
if (splitLabelWithTextToHighlight.length > 1) { | ||
filter = false; | ||
} else if (!treeItem.hasChildren && splitLabelWithTextToHighlight.length === 1) { | ||
filter = true; | ||
} else if ( | ||
treeItem.hasChildren && | ||
treeItem.expanded && | ||
treeItem.children.map((child) => child.label.split(highlightRegExp).length).every((v) => v === 1) | ||
) { | ||
filter = treeItem.children.map((child) => isFilterCandidate(child, highlightRegExp)).every((v) => v === true); | ||
} | ||
return filter; | ||
}; |
83 changes: 83 additions & 0 deletions
83
packages/trees/frontend/sirius-components-trees/src/trees/FilterBar.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,83 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import InputAdornment from '@material-ui/core/InputAdornment'; | ||
import TextField from '@material-ui/core/TextField'; | ||
import { Theme, makeStyles } from '@material-ui/core/styles'; | ||
import { FilterList } from '@material-ui/icons'; | ||
import CloseIcon from '@material-ui/icons/Close'; | ||
import { useState } from 'react'; | ||
import { FilterBarProps, FilterBarState } from './FilterBar.types'; | ||
|
||
const useFilterBarStyles = makeStyles((theme: Theme) => ({ | ||
filterbar: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
overflow: 'hidden', | ||
paddingLeft: theme.spacing(1), | ||
paddingRight: theme.spacing(1), | ||
paddingBottom: theme.spacing(1), | ||
}, | ||
textfield: { | ||
height: theme.spacing(3), | ||
fontSize: theme.typography.fontSize, | ||
}, | ||
})); | ||
export const FilterBar = ({ onTextChange, onFilterButtonClick, onClose }: FilterBarProps) => { | ||
const classes = useFilterBarStyles(); | ||
|
||
const initialState: FilterBarState = { | ||
filterEnabled: false, | ||
}; | ||
const [state, setState] = useState<FilterBarState>(initialState); | ||
|
||
return ( | ||
<div className={classes.filterbar}> | ||
<TextField | ||
id="filterbar-textfield" | ||
data-testid="filterbar-textfield" | ||
name="filterbar-textfield" | ||
placeholder="Type to filter" | ||
spellCheck={false} | ||
variant="outlined" | ||
size="small" | ||
margin="none" | ||
autoFocus={true} | ||
multiline={false} | ||
fullWidth | ||
onChange={onTextChange} | ||
InputProps={{ | ||
endAdornment: ( | ||
<InputAdornment position="end"> | ||
<IconButton | ||
aria-label="filter" | ||
size="small" | ||
onClick={() => { | ||
onFilterButtonClick(!state.filterEnabled); | ||
setState((prevState) => { | ||
return { filterEnabled: !prevState.filterEnabled }; | ||
}); | ||
}}> | ||
<FilterList fontSize="small" color={state.filterEnabled ? 'primary' : 'secondary'} /> | ||
</IconButton> | ||
</InputAdornment> | ||
), | ||
className: classes.textfield, | ||
}} | ||
/> | ||
<IconButton size="small" aria-label="close" color="inherit" onClick={onClose}> | ||
<CloseIcon fontSize="small" /> | ||
</IconButton> | ||
</div> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
packages/trees/frontend/sirius-components-trees/src/trees/FilterBar.types.ts
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,22 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
export interface FilterBarProps { | ||
onTextChange: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>; | ||
onFilterButtonClick: (enabled: boolean) => void; | ||
onClose: () => void; | ||
} | ||
|
||
export interface FilterBarState { | ||
filterEnabled: boolean; | ||
} |
Oops, something went wrong.