Skip to content

Commit

Permalink
ensure all files present in filters
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Grant <colin.grant@ericsson.com>
  • Loading branch information
colin-grant-work authored and vince-fugnitto committed Jun 24, 2020
1 parent c837b6c commit 4c2af31
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,24 @@ export class FileDialogTreeFilters {

export class FileDialogTreeFiltersRenderer extends ReactRenderer {

readonly appliedFilters: FileDialogTreeFilters;

constructor(
readonly filters: FileDialogTreeFilters,
readonly suppliedFilters: FileDialogTreeFilters,
readonly fileDialogTree: FileDialogTree
) {
super();
this.appliedFilters = { 'All Files': [], ...suppliedFilters, };
}

protected readonly handleFilterChanged = (e: React.ChangeEvent<HTMLSelectElement>) => this.onFilterChanged(e);

protected doRender(): React.ReactNode {
if (!this.filters) {
if (!this.appliedFilters) {
return undefined;
}

const fileTypes = ['All Files'];
Object.keys(this.filters).forEach(element => {
fileTypes.push(element);
});

const options = fileTypes.map(value => this.renderLocation(value));
const options = Object.keys(this.appliedFilters).map(value => this.renderLocation(value));
return <select className={'theia-select ' + FILE_TREE_FILTERS_LIST_CLASS} onChange={this.handleFilterChanged}>{...options}</select>;
}

Expand All @@ -67,7 +65,7 @@ export class FileDialogTreeFiltersRenderer extends ReactRenderer {
const locationList = this.locationList;
if (locationList) {
const value = locationList.value;
const filters = this.filters[value];
const filters = this.appliedFilters[value];
this.fileDialogTree.setFilter(filters);
}

Expand Down

0 comments on commit 4c2af31

Please sign in to comment.