8000 Layout improvements of the filter for boards and libs manager by francescospissu · Pull Request #1369 · arduino/arduino-ide · GitHub
[go: up one dir, main page]

Skip to content

Layout improvements of the filter for boards and libs manager #1369

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

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Can reset types from an action.
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
  • Loading branch information
Akos Kitta committed Aug 29, 2022
commit e00fa2b89d9c4abdf68f1b194db81df330ae50e1
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ export class BoardsAutoInstaller implements FrontendApplicationContribution {
this.boardsManagerFrontendContribution
.openView({ reveal: true })
.then((widget) =>
widget.refresh(candidate.name.toLocaleLowerCase())
widget.refresh({
query: candidate.name.toLocaleLowerCase(),
type: 'All',
})
);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,37 @@ export class CheckForUpdates extends Contribution {
}

private promptUpdateLibraries(items: LibraryPackage[]): void {
this.prompt(
this.prompt({
items,
this.libraryService,
this.librariesContribution,
UpdatesLibraries
);
installable: this.libraryService,
viewContribution: this.librariesContribution,
message: UpdatesLibraries,
viewSearchOptions: { query: '', type: 'Updatable', topic: 'All' },
});
}

private promptUpdateBoards(items: BoardsPackage[]): void {
this.prompt(
this.prompt({
items,
this.boardsService,
this.boardsContribution,
UpdatesBoards
);
installable: this.boardsService,
viewContribution: this.boardsContribution,
message: UpdatesBoards,
viewSearchOptions: { query: '', type: 'Updatable' },
});
}

private prompt<T extends ArduinoComponent, S extends Searchable.Options>(
items: T[],
installable: Installable<T>,
viewContribution: AbstractViewContribution<ListWidget<T, S>>,
message: string
): void {
private prompt<
T extends ArduinoComponent,
S extends Searchable.Options
>(options: {
items: T[];
installable: Installable<T>;
viewContribution: AbstractViewContribution<ListWidget<T, S>>;
viewSearchOptions: S;
message: string;
}): void {
const { items, installable, viewContribution, message, viewSearchOptions } =
options;
if (!items.length) {
return;
}
Expand All @@ -139,7 +147,7 @@ export class CheckForUpdates extends Contribution {
} else if (answer === InstallManually) {
viewContribution
.openView({ reveal: true })
.then((widget) => widget.refresh(candidate.name.toLocaleLowerCase()));
.then((widget) => widget.refresh(viewSearchOptions));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export class FilterableListContainer<
override componentDidMount(): void {
this.search = debounce(this.search, 500);
this.search(this.state.searchOptions);
this.props.filterTextChangeEvent(this.handlePropChange.bind(this));
this.props.searchOptionsDidChange((newSearchOptions) => {
const { searchOptions } = this.state;
this.setSearchOptionsAndUpdate({ ...searchOptions, ...newSearchOptions });
});
}

override componentDidUpdate(): void {
Expand Down Expand Up @@ -95,9 +98,13 @@ export class FilterableListContainer<
...this.state.searchOptions,
[prop]: value,
};
this.setState({ searchOptions }, () => this.search(searchOptions));
this.setSearchOptionsAndUpdate(searchOptions);
};

private setSearchOptionsAndUpdate(searchOptions: S) {
this.setState({ searchOptions }, () => this.search(searchOptions));
}

protected search(searchOptions: S): void {
const { searchable } = this.props;
searchable
Expand Down Expand Up @@ -175,7 +182,7 @@ export namespace FilterableListContainer {
readonly itemRenderer: ListItemRenderer<T>;
readonly filterRenderer: FilterRenderer<S>;
readonly resolveFocus: (element: HTMLElement | undefined) => void;
readonly filterTextChangeEvent: Event<string | undefined>;
readonly searchOptionsDidChange: Event<Partial<S> | undefined>;
readonly messageService: MessageService;
readonly responseService: ResponseServiceClient;
readonly install: ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ export abstract class ListWidget<
* Do not touch or use it. It is for setting the focus on the `input` after the widget activation.
*/
protected focusNode: HTMLElement | undefined;
// protected readonly deferredContainer = new Deferred<HTMLElement>();
protected readonly filterTextChangeEmitter = new Emitter<
string | undefined
protected readonly searchOptionsChangeEmitter = new Emitter<
Partial<S> | undefined
>();
/**
* Instead of running an `update` from the `postConstruct` `init` method,
Expand All @@ -63,7 +62,7 @@ export abstract class ListWidget<
this.addClass('arduino-list-widget');
this.node.tabIndex = 0; // To be able to set the focus on the widget.
this.scrollOptions = undefined;
this.toDispose.push(this.filterTextChangeEmitter);
this.toDispose.push(this.searchOptionsChangeEmitter);
}

@postConstruct()
Expand Down Expand Up @@ -142,7 +141,7 @@ export abstract class ListWidget<
itemDeprecated={this.options.itemDeprecated}
itemRenderer={this.options.itemRenderer}
filterRenderer={this.options.filterRenderer}
filterTextChangeEvent={this.filterTextChangeEmitter.event}
searchOptionsDidChange={this.searchOptionsChangeEmitter.event}
messageService={this.messageService}
commandService={this.commandService}
responseService={this.responseService}
Expand All @@ -154,8 +153,8 @@ export abstract class ListWidget<
* If `filterText` is defined, sets the filter text to the argument.
* If it is `undefined`, updates the view state by re-running the search with the current `filterText` term.
*/
refresh(filterText: string | undefined): void {
this.filterTextChangeEmitter.fire(filterText);
refresh(searchOptions: Partial<S> | undefined): void {
this.searchOptionsChangeEmitter.fire(searchOptions);
}

updateScrollBar(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 2364 +87,7 @@ export namespace LibrarySearch {
'Signal Input/Output',
'Timing',
'Uncategorized',
];
] as const;
export type Topic = typeof TopicLiterals[number];
export const TopicLabels: Record<Topic, string> = {
All: All,
Expand Down
0