Skip to content
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

Ensure 'All Files' key present in File Dialog Filters #8073

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
vince-fugnitto marked this conversation as resolved.
Show resolved Hide resolved
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'];
colin-grant-work marked this conversation as resolved.
Show resolved Hide resolved
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