diff --git a/src/components/DetailsMetrics/DetailsMetrics.js b/src/components/DetailsMetrics/DetailsMetrics.js
index d1f496dcc..b8482aefd 100644
--- a/src/components/DetailsMetrics/DetailsMetrics.js
+++ b/src/components/DetailsMetrics/DetailsMetrics.js
@@ -136,25 +136,27 @@ const DetailsMetrics = ({ selectedItem }) => {
}
}, [])
- const expandOrCollapseInvocationCard = useCallback(() => {
- const invocationBodyCard = invocationBodyCardRef.current
- const metricsContainer = metricsContainerRef.current
-
- if (!invocationBodyCard || !metricsContainer) return
+ const expandInvocationCard = useCallback(
+ (isUnpinAction = false) => {
+ const invocationBodyCard = invocationBodyCardRef.current
+ const metricsContainer = metricsContainerRef.current
+ const isOnlyOneMetric = generatedMetrics.length === 1
- const containerOverflow =
- metricsContainer.parentNode.scrollHeight !== metricsContainer.parentNode.clientHeight
+ if (!invocationBodyCard || !metricsContainer) return
- if (containerOverflow) {
- if (isInvocationCardExpanded) {
+ if (!isUnpinAction && isOnlyOneMetric) {
setIsInvocationCardExpanded(true)
- } else {
- setIsInvocationCardExpanded(false)
+ } else if (isUnpinAction) {
+ enableScrollRef.current = false
+ metricsContainer.parentNode.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
+ setIsInvocationCardExpanded(true)
+ setTimeout(() => {
+ enableScrollRef.current = true
+ }, INVOCATION_CARD_SCROLL_DELAY)
}
- } else if (generatedMetrics.length === 1) {
- setIsInvocationCardExpanded(true)
- }
- }, [generatedMetrics, invocationBodyCardRef, isInvocationCardExpanded, metricsContainerRef])
+ },
+ [generatedMetrics]
+ )
const handleWindowScroll = useCallback(
e => {
@@ -190,8 +192,6 @@ const DetailsMetrics = ({ selectedItem }) => {
setTimeout(() => {
enableScrollRef.current = true
}, INVOCATION_CARD_SCROLL_DELAY)
- } else if (!scrollTopPosition && !isInvocationCardExpanded && enableScrollRef.current) {
- setIsInvocationCardExpanded(true)
}
prevScrollPositionRef.current = scrollTopPosition
@@ -227,8 +227,8 @@ const DetailsMetrics = ({ selectedItem }) => {
}, [handleChangeDates])
useEffect(() => {
- expandOrCollapseInvocationCard()
- }, [metrics, expandOrCollapseInvocationCard])
+ expandInvocationCard()
+ }, [metrics, expandInvocationCard])
useEffect(() => {
window.addEventListener('scroll', handleWindowScroll, true)
@@ -401,6 +401,7 @@ const DetailsMetrics = ({ selectedItem }) => {
metric={metric}
previousTotalInvocation={previousTotalInvocation}
selectedDate={selectedDate}
+ expandInvocationCard={expandInvocationCard}
/>
)
}
diff --git a/src/components/DetailsMetrics/DetailsMetrics.scss b/src/components/DetailsMetrics/DetailsMetrics.scss
index 934540938..ccfb4df0d 100644
--- a/src/components/DetailsMetrics/DetailsMetrics.scss
+++ b/src/components/DetailsMetrics/DetailsMetrics.scss
@@ -217,6 +217,12 @@ $stickyHeaderHeight: 55px;
}
}
+ &-pin-icon {
+ position: absolute;
+ top: -10px;
+ left: -15px;
+ }
+
&-invocation-header {
display: flex;
flex: 1;
diff --git a/src/components/DetailsMetrics/IncvocationMetricCard.js b/src/components/DetailsMetrics/IncvocationMetricCard.js
index 8bc840784..76bdf49d5 100644
--- a/src/components/DetailsMetrics/IncvocationMetricCard.js
+++ b/src/components/DetailsMetrics/IncvocationMetricCard.js
@@ -23,6 +23,7 @@ import classNames from 'classnames'
import StatsCard from '../../common/StatsCard/StatsCard'
import MetricChart from '../MetricChart/MetricChart'
+import { RoundedIcon } from 'igz-controls/components'
import {
calculatePercentageDrift,
@@ -34,12 +35,19 @@ import { CHART_TYPE_LINE } from '../../constants'
import { ReactComponent as ArrowUp } from 'igz-controls/images/arrow-up.svg'
import { ReactComponent as ArrowDown } from 'igz-controls/images/arrow-down.svg'
+import { ReactComponent as UnpinIcon } from 'igz-controls/images/unpin-icon.svg'
import colors from 'igz-controls/scss/colors.scss'
const InvocationMetricCard = forwardRef(
(
- { isInvocationCardExpanded, metric, previousTotalInvocation, selectedDate },
+ {
+ isInvocationCardExpanded,
+ metric,
+ previousTotalInvocation,
+ selectedDate,
+ expandInvocationCard
+ },
invocationBodyCardRef
) => {
const invocationCardClassnames = classNames(
@@ -76,6 +84,15 @@ const InvocationMetricCard = forwardRef(
ref={invocationBodyCardRef}
className={`metrics__card-body ${isInvocationCardExpanded ? 'metrics__card-body-expanded' : 'metrics__card-body-collapsed'}`}
>
+ {!isInvocationCardExpanded && (
+