Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impl [Models endpoints monitoring, metrics] Use "Clear" button to unselect all metrics #2598

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/elements/MetricsSelector/MetricsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Accordion from '../../common/Accordion/Accordion'

import { filterMetrics, groupMetricByApplication, metricsTypes } from './metricsSelector.util'
import { METRICS_SELECTOR_OPTIONS } from '../../types'
import { SECONDARY_BUTTON, TERTIARY_BUTTON } from 'iguazio.dashboard-react-controls/dist/constants'

import { ReactComponent as Arrow } from 'igz-controls/images/arrow.svg'
import { ReactComponent as SearchIcon } from 'igz-controls/images/search.svg'
Expand Down Expand Up @@ -143,6 +144,10 @@ const MetricsSelector = ({ maxSelectionNumber, metrics, name, onSelect, preselec
setIsOpen(false)
}

const handleClear = () => {
formRef.current?.change('metrics', [])
}

const getSelectValue = () => {
if (isEmpty(appliedMetrics)) {
return 'Chose Metrics...'
Expand Down Expand Up @@ -270,10 +275,13 @@ const MetricsSelector = ({ maxSelectionNumber, metrics, name, onSelect, preselec
</FieldArray>
</ul>
<div className="metrics-selector__footer">
<div data-testid="metrics-selector-counter" className="metrics-selector-counter">
<div data-testid="metrics-selector-counter" className="metrics-selector__footer-counter">
{`${formState.values.metrics?.length ?? 0}/${maxSelectionNumber}`}
</div>
<Button variant="secondary" label="Apply" onClick={handleApply} />
<div data-testid="metrics-selector-buttons" className='metrics-selector__footer-buttons'>
<Button variant={TERTIARY_BUTTON} label="Clear" onClick={handleClear} />
<Button variant={SECONDARY_BUTTON} label="Apply" onClick={handleApply} />
</div>
</div>
</PopUpDialog>
)}
Expand Down
25 changes: 15 additions & 10 deletions src/elements/MetricsSelector/metricsSelector.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,31 @@
}

.metrics-selector__footer {
align-items: flex-end;
display: flex;
gap: 10px;
flex-direction: column;
align-items: flex-end;
margin-left: 10px;
padding: 20px 10px 10px;
}
padding: 5px 10px 10px;

.metrics-selector-counter {
width: 100%;
padding: 6px 15px;
text-align: left;
background-color: inherit;
.metrics-selector__footer-counter {
width: 100%;
padding: 6px 0;
text-align: right;
background-color: inherit;
}

.metrics-selector__footer-buttons {
display: flex;
gap: 10px;
}
}

.metrics-selector-options {
padding-left: 0;

&.options-list {
width: 100%;
max-height: 400px;
max-height: 350px;

.select__item {
height: 50px;
Expand Down
Loading