Commit 5462248f authored by Sebastian Malton's avatar Sebastian Malton
Browse files

fix label and saving procedure

Signed-off-by: default avatarSebastian Malton <sebastian@malton.name>
parent 4c975d8a
Showing with 37 additions and 15 deletions
+37 -15
...@@ -537,7 +537,7 @@ export class Cluster implements ClusterModel, ClusterState { ...@@ -537,7 +537,7 @@ export class Cluster implements ClusterModel, ClusterState {
return ClusterStatus.AccessGranted; return ClusterStatus.AccessGranted;
} catch (error) { } catch (error) {
logger.error(`Failed to connect cluster "${this.contextName}": ${error}`); logger.error(`Failed to connect cluster "${this.contextName}": ${error}`, { error });
if (error.statusCode) { if (error.statusCode) {
if (error.statusCode >= 400 && error.statusCode < 500) { if (error.statusCode >= 400 && error.statusCode < 500) {
......
...@@ -49,7 +49,11 @@ ...@@ -49,7 +49,11 @@
margin-top: $padding; margin-top: $padding;
} }
.icon-background-color { .icon-background-color label {
max-width: 100px; overflow: hidden;
width: var(--cluster-icon-size);
height: var(--cluster-icon-size);
border-radius: 5px;
margin: 2px;
} }
} }
...@@ -3,12 +3,12 @@ import { Cluster } from "../../../../main/cluster"; ...@@ -3,12 +3,12 @@ import { Cluster } from "../../../../main/cluster";
import { FilePicker, OverSizeLimitStyle } from "../../file-picker"; import { FilePicker, OverSizeLimitStyle } from "../../file-picker";
import { autobind } from "../../../utils"; import { autobind } from "../../../utils";
import { Button } from "../../button"; import { Button } from "../../button";
import { observable } from "mobx"; import { observable, reaction } from "mobx";
import { observer } from "mobx-react"; import { disposeOnUnmount, observer } from "mobx-react";
import { SubTitle } from "../../layout/sub-title"; import { SubTitle } from "../../layout/sub-title";
import { ClusterIcon } from "../../cluster-icon"; import { ClusterIcon } from "../../cluster-icon";
import { Input } from "../../input"; import { Input } from "../../input";
import { debounce } from "lodash"; import { throttle } from "lodash";
enum GeneralInputStatus { enum GeneralInputStatus {
CLEAN = "clean", CLEAN = "clean",
...@@ -23,6 +23,18 @@ interface Props { ...@@ -23,6 +23,18 @@ interface Props {
export class ClusterIconSetting extends React.Component<Props> { export class ClusterIconSetting extends React.Component<Props> {
@observable status = GeneralInputStatus.CLEAN; @observable status = GeneralInputStatus.CLEAN;
@observable errorText?: string; @observable errorText?: string;
@observable iconColour = this.getIconBackgroundColorValue();
componentDidMount() {
disposeOnUnmount(this, [
reaction(() => this.iconColour, background => {
// This is done so that the UI can update as fast as it would like
// without the necessary slowing down of the updates to the Cluster
// Preferences (to prevent too many file writes).
this.onColorChange(background);
}),
]);
}
@autobind() @autobind()
async onIconPick([file]: File[]) { async onIconPick([file]: File[]) {
...@@ -60,9 +72,9 @@ export class ClusterIconSetting extends React.Component<Props> { ...@@ -60,9 +72,9 @@ export class ClusterIconSetting extends React.Component<Props> {
return iconPreference.background; return iconPreference.background;
} }
onColorChange = debounce(background => { onColorChange = throttle(background => {
this.props.cluster.preferences.icon = { background }; this.props.cluster.preferences.icon = { background };
}, 100, { }, 200, {
leading: true, leading: true,
trailing: true, trailing: true,
}); });
...@@ -97,9 +109,9 @@ export class ClusterIconSetting extends React.Component<Props> { ...@@ -97,9 +109,9 @@ export class ClusterIconSetting extends React.Component<Props> {
<Input <Input
className="icon-background-color" className="icon-background-color"
type="color" type="color"
value={this.getIconBackgroundColorValue()} value={this.iconColour}
title="Choose auto generated icon's background color" title="Choose auto generated icon's background color"
onChange={this.onColorChange} onChange={background => this.iconColour = background}
/> />
<small className="hint"> <small className="hint">
This action clears any previously set icon. This action clears any previously set icon.
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
--font-weight-normal: 400; --font-weight-normal: 400;
--font-weight-bold: 500; --font-weight-bold: 500;
--main-layout-header: 40px; --main-layout-header: 40px;
--drag-region-height: 22px --drag-region-height: 22px;
--cluster-icon-size: 37px;
} }
*, *:before, *:after { *, *:before, *:after {
...@@ -82,6 +83,13 @@ html, body { ...@@ -82,6 +83,13 @@ html, body {
pointer-events: none; pointer-events: none;
} }
input[type='color'] {
padding: 0;
margin: -25%;
width: 150%;
height: 150%;
}
body { body {
font: $font-size $font-main; font: $font-size $font-main;
} }
......
.ClusterIcon { .ClusterIcon {
--size: 37px;
position: relative; position: relative;
border-radius: $radius; border-radius: $radius;
padding: $radius; padding: $radius;
...@@ -21,8 +19,8 @@ ...@@ -21,8 +19,8 @@
} }
img { img {
width: var(--size); width: var(--cluster-icon-size);
height: var(--size); height: var(--cluster-icon-size);
} }
&.active, &.interactive:hover { &.active, &.interactive:hover {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment