From a1cb828064f3988a059f416c198979116cadb826 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Fri, 10 Jan 2025 16:58:44 +0200 Subject: [PATCH] Use AddScreenshot naming --- packages/core/src/js/feedback/FeedbackForm.tsx | 8 ++++---- packages/core/src/js/feedback/FeedbackForm.types.ts | 4 ++-- packages/core/src/js/feedback/defaults.ts | 4 ++-- packages/core/test/feedback/FeedbackForm.test.tsx | 8 ++++---- .../ios/sentryreactnativesample/PrivacyInfo.xcprivacy | 1 + samples/react-native/src/App.tsx | 4 ++-- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/core/src/js/feedback/FeedbackForm.tsx b/packages/core/src/js/feedback/FeedbackForm.tsx index c70bfb22b9..05b6520f19 100644 --- a/packages/core/src/js/feedback/FeedbackForm.tsx +++ b/packages/core/src/js/feedback/FeedbackForm.tsx @@ -94,10 +94,10 @@ export class FeedbackForm extends React.Component void = () => { + public addRemoveScreenshot: () => void = () => { if (!this.state.filename && !this.state.attachment) { - const { onFileChosen } = { ...defaultConfiguration, ...this.props }; - onFileChosen((filename: string, attachement: string | Uint8Array) => { + const { onAddScreenshot } = { ...defaultConfiguration, ...this.props }; + onAddScreenshot((filename: string, attachement: string | Uint8Array) => { this.setState({ filename, attachment: attachement }); }); } else { @@ -183,7 +183,7 @@ export class FeedbackForm extends React.Component {config.enableScreenshot && ( - + {!this.state.filename && !this.state.attachment ? text.addScreenshotButtonLabel diff --git a/packages/core/src/js/feedback/FeedbackForm.types.ts b/packages/core/src/js/feedback/FeedbackForm.types.ts index 5387058992..7f5ea16336 100644 --- a/packages/core/src/js/feedback/FeedbackForm.types.ts +++ b/packages/core/src/js/feedback/FeedbackForm.types.ts @@ -154,9 +154,9 @@ export interface FeedbackCallbacks { onFormClose?: () => void; /** - * Callback when a file is chosen for attachment + * Callback when a screenshot is added */ - onFileChosen?: (attachFile: (filename: string, base64Attachment: string | Uint8Array) => void) => void; + onAddScreenshot?: (attachFile: (filename: string, base64Attachment: string | Uint8Array) => void) => void; } /** diff --git a/packages/core/src/js/feedback/defaults.ts b/packages/core/src/js/feedback/defaults.ts index e2a5844324..dd4f9cec9b 100644 --- a/packages/core/src/js/feedback/defaults.ts +++ b/packages/core/src/js/feedback/defaults.ts @@ -29,9 +29,9 @@ export const defaultConfiguration: Partial = { ); } }, - onFileChosen: (_: (filename: string, base64Attachment: string | Uint8Array) => void) => { + onAddScreenshot: (_: (filename: string, base64Attachment: string | Uint8Array) => void) => { if (__DEV__) { - Alert.alert('Development note', 'onFileChosen callback is not implemented.'); + Alert.alert('Development note', 'onAddScreenshot callback is not implemented.'); } }, diff --git a/packages/core/test/feedback/FeedbackForm.test.tsx b/packages/core/test/feedback/FeedbackForm.test.tsx index 6a03e2148b..d4eada75a0 100644 --- a/packages/core/test/feedback/FeedbackForm.test.tsx +++ b/packages/core/test/feedback/FeedbackForm.test.tsx @@ -7,7 +7,7 @@ import { FeedbackForm } from '../../src/js/feedback/FeedbackForm'; import type { FeedbackFormProps } from '../../src/js/feedback/FeedbackForm.types'; const mockOnFormClose = jest.fn(); -const mockOnFileChosen = jest.fn(); +const mockOnAddScreenshot = jest.fn(); const mockGetUser = jest.fn(() => ({ email: 'test@example.com', name: 'Test User', @@ -25,7 +25,7 @@ jest.mock('@sentry/core', () => ({ const defaultProps: FeedbackFormProps = { onFormClose: mockOnFormClose, - onFileChosen: mockOnFileChosen, + onAddScreenshot: mockOnAddScreenshot, addScreenshotButtonLabel: 'Add Screenshot', formTitle: 'Feedback Form', nameLabel: 'Name', @@ -168,13 +168,13 @@ describe('FeedbackForm', () => { }); }); - it('calls onFileChosen when the screenshot button is pressed', async () => { + it('calls onAddScreenshot when the screenshot button is pressed', async () => { const { getByText } = render(); fireEvent.press(getByText(defaultProps.addScreenshotButtonLabel)); await waitFor(() => { - expect(mockOnFileChosen).toHaveBeenCalled(); + expect(mockOnAddScreenshot).toHaveBeenCalled(); }); }); diff --git a/samples/react-native/ios/sentryreactnativesample/PrivacyInfo.xcprivacy b/samples/react-native/ios/sentryreactnativesample/PrivacyInfo.xcprivacy index e9e7208ef3..2c388f904c 100644 --- a/samples/react-native/ios/sentryreactnativesample/PrivacyInfo.xcprivacy +++ b/samples/react-native/ios/sentryreactnativesample/PrivacyInfo.xcprivacy @@ -10,6 +10,7 @@ NSPrivacyAccessedAPITypeReasons C617.1 + 3B52.1 diff --git a/samples/react-native/src/App.tsx b/samples/react-native/src/App.tsx index 421357045f..14b1f93e35 100644 --- a/samples/react-native/src/App.tsx +++ b/samples/react-native/src/App.tsx @@ -141,7 +141,7 @@ const Stack = isMobileOs : createStackNavigator(); const Tab = createBottomTabNavigator(); -const handleChooseFile = (attachFile: (filename: string, base64Attachment: string | Uint8Array) => void): void => { +const handleChooseImage = (attachFile: (filename: string, base64Attachment: string | Uint8Array) => void): void => { launchImageLibrary({ mediaType: 'photo', includeBase64: true }, (response) => { if (response.didCancel) { console.log('User cancelled image picker'); @@ -176,7 +176,7 @@ const ErrorsTabNavigator = Sentry.withProfiler(