More styling impr. and less UI contributions

This commit is contained in:
Sven Efftinge
2019-05-09 10:13:33 -07:00
committed by Christian Weichel
parent 20db72fec7
commit 97135bd08e
9 changed files with 254 additions and 179 deletions

View File

@@ -7,7 +7,7 @@ export class ComponentList extends React.Component<ComponentList.Props> {
render(): React.ReactNode {
return <div>
{this.props.items.map((item, idx) => <ComponentListItem key={idx} item={item} windowService={this.props.windowService} install={this.props.install} />)}
{this.props.items.map(item => <ComponentListItem key={item.name} item={item} windowService={this.props.windowService} install={this.props.install} />)}
</div>;
}

View File

@@ -39,26 +39,30 @@ export class FilterableListContainer extends React.Component<FilterableListConta
const { items } = result;
this.setState({
filterText,
items: items.sort((a, b) => {
if (a.name < b.name) {
return -1;
} else if (a.name === b.name) {
return 0;
} else {
return 1;
}
})
items: this.sort(items)
});
});
}
protected sort(items: ArduinoComponent[]): ArduinoComponent[] {
return items.sort((a, b) => {
if (a.name < b.name) {
return -1;
} else if (a.name === b.name) {
return 0;
} else {
return 1;
}
});
}
protected async install(comp: ArduinoComponent): Promise<void> {
const dialog = new InstallationProgressDialog(comp.name);
dialog.open();
try {
await this.props.service.install(comp);
const { items } = await this.props.service.search({ query: this.state.filterText });
this.setState({ items });
this.setState({ items: this.sort(items) });
} finally {
dialog.close();
}