Skip to content

Commit

Permalink
Fixes inability to delete single profiles + minor UI change
Browse files Browse the repository at this point in the history
Signed-off-by: Nkeiruka <[email protected]>
  • Loading branch information
Kxiru committed May 15, 2024
1 parent 8102f9d commit a28aeab
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 54 deletions.
91 changes: 48 additions & 43 deletions src/pages/profiles/ProfileSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,59 +94,64 @@ const ProfileSelector: FC<Props> = ({
title={title}
></Select>
</div>
{!readOnly && (index > 0 || selected.length > 1) && (
<div>
<Button
appearance="link"
className="profile-action-btn"
onClick={() => {
const newSelection = [...selected];
newSelection.splice(index, 1);
newSelection.splice(index - 1, 0, value);
setSelected(newSelection);
}}
type="button"
aria-label="move profile up"
title="move profile up"
disabled={index === 0}
>
<Icon name="chevron-up" />
</Button>
<Button
appearance="link"
className="profile-action-btn"
onClick={() => {
const newSelection = [...selected];
newSelection.splice(index, 1);
newSelection.splice(index + 1, 0, value);
setSelected(newSelection);
}}
type="button"
aria-label="move profile down"
title="move profile down"
disabled={index === selected.length - 1}
>
<Icon name="chevron-down" />
</Button>
{index > 0 && (

<div className="profile-actions">
{!readOnly && (index > 0 || selected.length > 1) && (
<div>
<Button
appearance="link"
className="profile-delete-btn"
onClick={() =>
setSelected(selected.filter((item) => item !== value))
}
className="profile-action-btn"
onClick={() => {
const newSelection = [...selected];
newSelection.splice(index, 1);
newSelection.splice(index - 1, 0, value);
setSelected(newSelection);
}}
type="button"
aria-label="move profile up"
title="move profile up"
disabled={index === 0}
>
Delete
<Icon name="chevron-up" />
</Button>
)}
</div>
)}
<Button
appearance="link"
className="profile-action-btn"
onClick={() => {
const newSelection = [...selected];
newSelection.splice(index, 1);
newSelection.splice(index + 1, 0, value);
setSelected(newSelection);
}}
type="button"
aria-label="move profile down"
title="move profile down"
disabled={index === selected.length - 1}
>
<Icon name="chevron-down" />
</Button>
</div>
)}

{!readOnly && (
<Button
appearance="link"
className="profile-remove-btn"
onClick={() =>
setSelected(selected.filter((item) => item !== value))
}
type="button"
>
Remove
</Button>
)}
</div>
</div>
))}
{!readOnly && (
<Button
disabled={unselected.length === 0}
className={"profile-add-btn"}
onClick={addProfile}
type="button"
>
Expand Down
33 changes: 22 additions & 11 deletions src/sass/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,23 @@
}
}

.profile-action-btn {
margin-right: $sph--large;
.profile-actions {
display: flex;

.profile-action-btn {
margin-right: $sph--large;
}
}

.profile-delete-btn {
.profile-remove-btn {
align-self: flex-start;
margin-left: $sph--large;
}

.profile-add-btn {
display: block;
}

.delete-device {
margin-top: $spv--x-large;
}
Expand All @@ -111,12 +120,13 @@
}
}

@media screen and (width <= 1400px) {
@media screen and (width <=1400px) {

.cpu-limit-label,
.memory-limit-label {
display: block !important;

> * {
>* {
margin-right: 0 !important;
}
}
Expand All @@ -126,7 +136,7 @@
max-width: 54rem;
}

.read-only .monaco-editor .cursors-layer > .cursor {
.read-only .monaco-editor .cursors-layer>.cursor {
display: none !important;
}

Expand All @@ -136,7 +146,7 @@
align-items: flex-end;
display: flex;

> * {
>* {
margin-bottom: $spv--large;
margin-right: $sph--x-large;
}
Expand All @@ -161,7 +171,7 @@
}

.snapshot-schedule {
> * {
>* {
margin-bottom: $spv--large;
}
}
Expand Down Expand Up @@ -197,7 +207,7 @@
}

.checkbox-label-tooltip {
> span {
>span {
display: inherit !important;
margin-left: $sph--x-small;
}
Expand All @@ -221,7 +231,7 @@
}

.image-select-modal {
> section {
>section {
min-height: 100%;
}

Expand Down Expand Up @@ -288,6 +298,7 @@
}

@include large {

.search-image,
.iso-btn {
margin-top: calc(2.5rem + 3px);
Expand Down Expand Up @@ -352,4 +363,4 @@
margin-top: 1rem;
max-width: 70.5rem;
}
}
}

0 comments on commit a28aeab

Please sign in to comment.