diff --git a/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx b/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx index d0ee10f0ee..980ba88633 100644 --- a/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx +++ b/src/renderer/components/cluster-settings/components/cluster-icon-settings.tsx @@ -48,44 +48,36 @@ export class ClusterIconSetting extends React.Component { @boundMethod async onIconPick([file]: File[]) { + if (!file) { + return; + } + const { cluster } = this.props; try { - if (file) { - const buf = Buffer.from(await file.arrayBuffer()); + const buf = Buffer.from(await file.arrayBuffer()); - cluster.preferences.icon = `data:${file.type};base64,${buf.toString("base64")}`; - } else { - // this has to be done as a seperate branch (and not always) because `cluster` - // is observable and triggers an update loop. - cluster.preferences.icon = undefined; - } + cluster.preferences.icon = `data:${file.type};base64,${buf.toString("base64")}`; } catch (e) { this.errorText = e.toString(); this.status = GeneralInputStatus.ERROR; } } + clearIcon() { + this.props.cluster.preferences.icon = undefined; + } + @boundMethod onUploadClick() { - const input = this.element.current.querySelector("input[type=file]") as HTMLInputElement; - - input.click(); + this.element + .current + .querySelector("input[type=file]") + .click(); } render() { const { entity } = this.props; - const label = ( - <> - - - ); return (
@@ -93,16 +85,28 @@ export class ClusterIconSetting extends React.Component {
+ } onOverSizeLimit={OverSizeLimitStyle.FILTER} handler={this.onIconPick} />
- + Upload Icon - this.onIconPick([])} disabled={!this.props.cluster.preferences.icon}> + this.clearIcon()} disabled={!this.props.cluster.preferences.icon}> Clear