1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Moving cluster icon settings on top

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-06-23 09:49:41 +03:00
parent 1f3b733d83
commit a1437ad8ac
3 changed files with 39 additions and 34 deletions

View File

@ -39,18 +39,17 @@ export function GeneralSettings({ entity }: EntitySettingViewProps) {
return (
<section>
<section>
<div className="flex">
<div className="flex-grow pr-8">
<components.ClusterNameSetting cluster={cluster} />
</div>
<div>
<components.ClusterIconSetting cluster={cluster} entity={entity as KubernetesCluster} />
</div>
</div>
</section>
<section className="small">
<p>General Cluster settings.</p>
</section>
<section>
<components.ClusterNameSetting cluster={cluster} />
</section>
<hr/>
<section>
<components.ClusterIconSetting cluster={cluster} entity={entity as KubernetesCluster} />
</section>
<hr/>
<section>
<components.ClusterKubeconfig cluster={cluster} />
</section>
</section>

View File

@ -22,13 +22,12 @@
import React from "react";
import type { Cluster } from "../../../../main/cluster";
import { boundMethod } from "../../../utils";
import { Button } from "../../button";
import { observable } from "mobx";
import { observer } from "mobx-react";
import { SubTitle } from "../../layout/sub-title";
import { HotbarIcon } from "../../hotbar/hotbar-icon";
import type { KubernetesCluster } from "../../../../common/catalog-entities";
import { FilePicker, OverSizeLimitStyle } from "../../file-picker";
import { MenuActions, MenuItem } from "../../menu";
enum GeneralInputStatus {
CLEAN = "clean",
@ -45,6 +44,8 @@ export class ClusterIconSetting extends React.Component<Props> {
@observable status = GeneralInputStatus.CLEAN;
@observable errorText?: string;
private element = React.createRef<HTMLDivElement>();
@boundMethod
async onIconPick([file]: File[]) {
const { cluster } = this.props;
@ -65,13 +66,11 @@ export class ClusterIconSetting extends React.Component<Props> {
}
}
getClearButton() {
return <Button
label="Clear"
onClick={() => this.onIconPick([])}
disabled={!this.props.cluster.preferences.icon}
className="ml-5"
/>;
@boundMethod
onUploadClick() {
const input = this.element.current.querySelector("input[type=file]") as HTMLInputElement;
input.click();
}
render() {
@ -83,25 +82,32 @@ export class ClusterIconSetting extends React.Component<Props> {
title={entity.metadata.name}
source={entity.metadata.source}
src={entity.spec.icon?.src}
size={50}
size={53}
/>
<Button className="ml-5">Upload Icon</Button>
</>
);
return (
<>
<SubTitle title="Cluster Icon" />
<div className="file-loader flex flex-row items-center mt-2">
<FilePicker
accept="image/*"
label={label}
onOverSizeLimit={OverSizeLimitStyle.FILTER}
handler={this.onIconPick}
/>
{this.getClearButton()}
<div ref={this.element}>
<div className="file-loader flex flex-row items-center">
<div className="mr-5">
<FilePicker
accept="image/*"
label={label}
onOverSizeLimit={OverSizeLimitStyle.FILTER}
handler={this.onIconPick}
/>
</div>
<MenuActions toolbar={false} autoCloseOnSelect={true} triggerIcon={{ material: "more_horiz" }}>
<MenuItem onClick={this.onUploadClick}>
Upload Icon
</MenuItem>
<MenuItem onClick={() => this.onIconPick([])} disabled={!this.props.cluster.preferences.icon}>
Clear
</MenuItem>
</MenuActions>
</div>
</>
</div>
);
}
}

View File

@ -211,7 +211,7 @@
font-size: 18px;
line-height: 20px;
font-weight: 600;
margin-bottom: 20px;
margin-bottom: 30px;
}
a {