From 54f03817e0cfcbc508d0451ab93dc8a3f99638af Mon Sep 17 00:00:00 2001 From: Vincent Riemer Date: Tue, 5 Jul 2022 13:01:56 -0700 Subject: [PATCH] Add filter ability to platform test result view Summary: Changelog: [RNTester][Internal] - Add the ability to filter PlatformTest results by test name substrings In certain tests (such as the hoverable pointer attributes test) there are a super large number of results which can make it hard to focus on the ones you're actively trying to work on fixing. This diff adds the ability to filter those results with a simple substring filter on the test name of the results. Reviewed By: lunaleaps Differential Revision: D37558411 fbshipit-source-id: 8f4b19fed9bb9f1b08fd7470cd79d68b6c721c13 --- .../RNTesterPlatformTestResultView.js | 192 +++++++++++++++++- 1 file changed, 184 insertions(+), 8 deletions(-) diff --git a/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestResultView.js b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestResultView.js index 19c418dd529..590d49d40ca 100644 --- a/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestResultView.js +++ b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestResultView.js @@ -19,8 +19,19 @@ import type { } from './RNTesterPlatformTestTypes'; import * as React from 'react'; -import {useMemo} from 'react'; -import {Button, View, Text, StyleSheet, FlatList} from 'react-native'; +import {useMemo, useState, useCallback} from 'react'; +import { + Button, + View, + Text, + StyleSheet, + FlatList, + Modal, + SafeAreaView, + TextInput, + KeyboardAvoidingView, + Platform, +} from 'react-native'; const DISPLAY_STATUS_MAPPING: {[PlatformTestResultStatus]: string} = { PASS: 'Pass', @@ -28,6 +39,75 @@ const DISPLAY_STATUS_MAPPING: {[PlatformTestResultStatus]: string} = { ERROR: 'Error', }; +type FilterModalProps = $ReadOnly<{ + filterText: string, + setFilterText: (newFilterText: string) => void, +}>; +function FilterModalButton(props: FilterModalProps) { + const {filterText, setFilterText} = props; + + const [modalVisible, setModalVisible] = useState(false); + const [pendingFilterText, setPendingFilterText] = useState(filterText); + + const onFilterButtonPress = useCallback(() => { + setPendingFilterText(filterText); + setModalVisible(true); + }, [filterText]); + + const onFilterSubmit = useCallback(() => { + setFilterText(pendingFilterText); + setModalVisible(false); + }, [pendingFilterText, setFilterText]); + + const onFilterCancel = useCallback(() => { + setModalVisible(false); + }, []); + + const onPendingTextChange = useCallback(newText => { + setPendingFilterText(newText); + }, []); + + return ( + <> +