Skip to content

Commit

Permalink
add debug button to views showing mock stoprint data
Browse files Browse the repository at this point in the history
  • Loading branch information
drewvolz committed May 23, 2022
1 parent 909dfa6 commit a565ade
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions source/lib/stoprint/debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {isDevMode} from '@frogpond/constants'

export const isStoprintMocked = isDevMode()
1 change: 1 addition & 0 deletions source/lib/stoprint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ export type {
HeldJobsResponseOrErrorType,
} from './types'
export {showGeneralError} from './errors'
export {isStoprintMocked} from './debug'
4 changes: 3 additions & 1 deletion source/views/stoprint/print-jobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {LoginStateEnum} from '../../redux/parts/login'
import {logInViaCredentials} from '../../redux/parts/login'
import {loadLoginCredentials} from '../../lib/login'
import type {PrintJob} from '../../lib/stoprint'
import {STOPRINT_HELP_PAGE} from '../../lib/stoprint'
import {STOPRINT_HELP_PAGE, isStoprintMocked} from '../../lib/stoprint'
import {
Detail,
ListRow,
Expand All @@ -27,6 +27,7 @@ import {getTimeRemaining} from './lib'
import {Timer} from '@frogpond/timer'
import {NativeStackNavigationOptions} from '@react-navigation/native-stack'
import {useNavigation} from '@react-navigation/native'
import {DebugNoticeButton} from '@frogpond/navigation-buttons'

type ReduxStateProps = {
jobs: Array<PrintJob>
Expand Down Expand Up @@ -216,4 +217,5 @@ export function ConnectedPrintJobsView(): JSX.Element {

export const NavigationOptions: NativeStackNavigationOptions = {
title: 'Print Jobs',
headerRight: () => <DebugNoticeButton shouldShow={isStoprintMocked} />,
}
3 changes: 3 additions & 0 deletions source/views/stoprint/print-release.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as c from '@frogpond/colors'
import {
cancelPrintJobForUser,
heldJobsAvailableAtPrinterForUser,
isStoprintMocked,
releasePrintJobToPrinterForUser,
showGeneralError,
} from '../../lib/stoprint'
Expand All @@ -20,6 +21,7 @@ import {loadLoginCredentials} from '../../lib/login'
import {NativeStackNavigationOptions} from '@react-navigation/native-stack'
import {RouteProp, useNavigation, useRoute} from '@react-navigation/native'
import {RootStackParamList} from '../../navigation/types'
import {DebugNoticeButton} from '@frogpond/navigation-buttons'

const styles = StyleSheet.create({
cancelButton: {
Expand Down Expand Up @@ -236,4 +238,5 @@ export const PrintJobReleaseView = (): JSX.Element => {

export const NavigationOptions: NativeStackNavigationOptions = {
title: 'Release job',
headerRight: () => <DebugNoticeButton shouldShow={isStoprintMocked} />,
}

0 comments on commit a565ade

Please sign in to comment.