@@ -2,9 +2,13 @@ import React from 'react'
22import { useSelector } from 'react-redux'
33import styles from './styles.module.scss'
44import { CommitsButton , CommitsButtonProps } from './CommitsButton'
5- import { showLessCommits , showMoreCommits } from '../../../../util/messages'
5+ import {
6+ resetCommits ,
7+ showLessCommits ,
8+ showMoreCommits
9+ } from '../../../../util/messages'
610import { ExperimentsState } from '../../../../store'
7- import { Add , Remove } from '../../../../../shared/components/icons'
11+ import { Add , Discard , Remove } from '../../../../../shared/components/icons'
812interface CommitsNavigationProps {
913 branch : string
1014}
@@ -16,26 +20,41 @@ export const CommitsNavigation: React.FC<CommitsNavigationProps> = ({
1620 ( state : ExperimentsState ) => state . tableData
1721 )
1822
19- const commitsButtons : CommitsButtonProps [ ] = [
23+ const getMoreOrLessValues = (
24+ moreOrLess : 'More' | 'Less'
25+ ) : { key : string ; tooltipContent : string } => ( {
26+ key : moreOrLess ,
27+ tooltipContent : `Show ${ moreOrLess } Commits`
28+ } )
29+
30+ const commitsButtons : ( CommitsButtonProps & { key : string } ) [ ] = [
2031 {
2132 action : ( ) => showMoreCommits ( branch ) ,
2233 disabled : ! hasMoreCommits [ branch ] ,
2334 icon : Add ,
24- moreOrLess : 'More'
35+ ... getMoreOrLessValues ( 'More' )
2536 } ,
2637 {
2738 action : ( ) => showLessCommits ( branch ) ,
2839 disabled : ! isShowingMoreCommits [ branch ] ,
2940 icon : Remove ,
30- moreOrLess : 'Less'
41+ ...getMoreOrLessValues ( 'Less' )
42+ } ,
43+ {
44+ action : ( ) => resetCommits ( branch ) ,
45+ disabled : false ,
46+ icon : Discard ,
47+ key : 'Reset' ,
48+ tooltipContent : 'Reset Commits to Default'
3149 }
3250 ]
3351
3452 return (
3553 < div className = { styles . commitsNav } >
36- { commitsButtons . map ( commitButton => (
37- < CommitsButton key = { commitButton . moreOrLess } { ...commitButton } />
38- ) ) }
54+ { commitsButtons . map ( commitButton => {
55+ const { key, ...commitButtonProps } = commitButton
56+ return < CommitsButton key = { key } { ...commitButtonProps } />
57+ } ) }
3958 </ div >
4059 )
4160}
0 commit comments