33
44import { FlashList , type ListRenderItem } from '@shopify/flash-list' ;
55import React , { useCallback , useMemo , useState } from 'react' ;
6- import { defineMessage } from 'react-intl' ;
6+ import { defineMessage , useIntl } from 'react-intl' ;
77import { StyleSheet , View } from 'react-native' ;
88
9+ import Button from '@components/button' ;
910import { Screens } from '@constants' ;
1011import { useTheme } from '@context/theme' ;
1112import useAndroidHardwareBackHandler from '@hooks/android_back_handler' ;
@@ -15,6 +16,8 @@ import {isRunFinished} from '@playbooks/utils/run';
1516import { popTopScreen } from '@screens/navigation' ;
1617import { changeOpacity , makeStyleSheetFromTheme } from '@utils/theme' ;
1718
19+ import { goToSelectPlaybook } from '../navigation' ;
20+
1821import EmptyState from './empty_state' ;
1922import PlaybookCard , { CARD_HEIGHT } from './playbook_card' ;
2023import ShowMoreButton from './show_more_button' ;
@@ -43,6 +46,9 @@ const getStyleFromTheme = makeStyleSheetFromTheme((theme: Theme) => ({
4346 borderBottomWidth : 1 ,
4447 borderBottomColor : changeOpacity ( theme . centerChannelColor , 0.12 ) ,
4548 } ,
49+ startANewRunButtonContainer : {
50+ padding : 20 ,
51+ } ,
4652} ) ) ;
4753
4854const ItemSeparator = ( ) => {
@@ -71,6 +77,7 @@ const PlaybookRuns = ({
7177 allRuns,
7278 componentId,
7379} : Props ) => {
80+ const intl = useIntl ( ) ;
7481 const theme = useTheme ( ) ;
7582 const styles = getStyleFromTheme ( theme ) ;
7683
@@ -132,17 +139,32 @@ const PlaybookRuns = ({
132139 ) ;
133140 } , [ ] ) ;
134141
142+ const startANewRun = useCallback ( ( ) => {
143+ goToSelectPlaybook ( intl , theme ) ;
144+ } , [ intl , theme ] ) ;
145+
135146 let content = ( < EmptyState tab = { activeTab } /> ) ;
136147 if ( ! isEmpty ) {
137148 content = (
138- < FlashList
139- data = { data }
140- renderItem = { renderItem }
141- contentContainerStyle = { styles . container }
142- ItemSeparatorComponent = { ItemSeparator }
143- estimatedItemSize = { CARD_HEIGHT }
144- ListFooterComponent = { footerComponent }
145- />
149+ < >
150+ < FlashList
151+ data = { data }
152+ renderItem = { renderItem }
153+ contentContainerStyle = { styles . container }
154+ ItemSeparatorComponent = { ItemSeparator }
155+ estimatedItemSize = { CARD_HEIGHT }
156+ ListFooterComponent = { footerComponent }
157+ />
158+ < View style = { styles . startANewRunButtonContainer } >
159+ < Button
160+ emphasis = 'tertiary'
161+ onPress = { startANewRun }
162+ text = { intl . formatMessage ( { id : 'playbooks.runs.start_a_new_run' , defaultMessage : 'Start a new run' } ) }
163+ size = 'lg'
164+ theme = { theme }
165+ />
166+ </ View >
167+ </ >
146168 ) ;
147169 }
148170
0 commit comments