From fc9083727e4079309d528837e15d923b5fafcd3f Mon Sep 17 00:00:00 2001 From: Wellinton Monge Date: Wed, 6 Feb 2019 15:23:02 -0200 Subject: [PATCH 01/12] Merging AlertIOS with Alert - first changes --- Libraries/Alert/Alert.js | 145 ++++++++++++++++++++++++----- Libraries/Alert/AlertIOS.js | 181 ------------------------------------ 2 files changed, 124 insertions(+), 202 deletions(-) delete mode 100644 Libraries/Alert/AlertIOS.js diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index ceab6763680b8e..f2b7f7a2278777 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -10,49 +10,69 @@ 'use strict'; -const AlertIOS = require('AlertIOS'); const NativeModules = require('NativeModules'); +const RCTAlertManager = NativeModules.AlertManager; const Platform = require('Platform'); -import type {AlertType, AlertButtonStyle} from 'AlertIOS'; +/** + * Array or buttons + * @typedef {Array} ButtonsArray + * @property {string=} text Button label + * @property {Function=} onPress Callback function when button pressed + * @property {AlertButtonStyle=} style Button style + */ -export type Buttons = Array<{ - text?: string, - onPress?: ?Function, - style?: AlertButtonStyle, -}>; +/** + * Array or buttons + * @typedef {Array} ButtonsArray + * @property {string=} text Button label + * @property {Function=} onPress Callback function when button pressed + * @property {AlertButtonStyle=} style Button style + */ +export type Buttons = Array<{ + text?: string, + onPress?: ?Function, + style?: AlertButtonStyle, + }>; + type Options = { cancelable?: ?boolean, onDismiss?: ?Function, }; +/** + * An Alert button type + */ +type AlertType = $Enum<{ + default: string, + 'plain-text': string, + 'secure-text': string, + 'login-password': string, + }>; + + /** + * An Alert button style + */ +type AlertButtonStyle = $Enum<{ + default: string, + cancel: string, + destructive: string, + }>; + /** * Launches an alert dialog with the specified title and message. * * See http://facebook.github.io/react-native/docs/alert.html */ class Alert { - /** - * Launches an alert dialog with the specified title and message. - * - * See http://facebook.github.io/react-native/docs/alert.html#alert - */ static alert( title: ?string, message?: ?string, buttons?: Buttons, - options?: Options, - type?: AlertType, + options?: Options ): void { if (Platform.OS === 'ios') { - if (typeof type !== 'undefined') { - console.warn( - 'Alert.alert() with a 5th "type" parameter is deprecated and will be removed. Use AlertIOS.prompt() instead.', - ); - AlertIOS.alert(title, message, buttons, type); - return; - } AlertIOS.alert(title, message, buttons); } else if (Platform.OS === 'android') { AlertAndroid.alert(title, message, buttons, options); @@ -60,6 +80,89 @@ class Alert { } } +/** + * Wrapper around the iOS native module. + */ +class AlertIOS { + static alert( + title: ?string, + message?: ?string, + callbackOrButtons?: ?((() => void) | ButtonsArray) + ): void { + this.prompt(title, message, callbackOrButtons, 'default'); + } + + static prompt( + title: ?string, + message?: ?string, + callbackOrButtons?: ?(((text: string) => void) | ButtonsArray), + type?: ?AlertType = 'plain-text', + defaultValue?: string, + keyboardType?: string, + ): void { + if (typeof type === 'function') { + console.warn( + 'You passed a callback function as the "type" argument to AlertIOS.prompt(). React Native is ' + + 'assuming you want to use the deprecated AlertIOS.prompt(title, defaultValue, buttons, callback) ' + + 'signature. The current signature is AlertIOS.prompt(title, message, callbackOrButtons, type, defaultValue, ' + + 'keyboardType) and the old syntax will be removed in a future version.', + ); + + const callback = type; + RCTAlertManager.alertWithArgs( + { + title: title || '', + type: 'plain-text', + defaultValue: message, + }, + (id, value) => { + callback(value); + }, + ); + return; + } + + let callbacks = []; + const buttons = []; + let cancelButtonKey; + let destructiveButtonKey; + if (typeof callbackOrButtons === 'function') { + callbacks = [callbackOrButtons]; + } else if (callbackOrButtons instanceof Array) { + callbackOrButtons.forEach((btn, index) => { + callbacks[index] = btn.onPress; + if (btn.style === 'cancel') { + cancelButtonKey = String(index); + } else if (btn.style === 'destructive') { + destructiveButtonKey = String(index); + } + if (btn.text || index < (callbackOrButtons || []).length - 1) { + const btnDef = {}; + btnDef[index] = btn.text || ''; + buttons.push(btnDef); + } + }); + } + + RCTAlertManager.alertWithArgs( + { + title: title || '', + message: message || undefined, + buttons, + type: type || undefined, + defaultValue, + cancelButtonKey, + destructiveButtonKey, + keyboardType, + }, + (id, value) => { + const cb = callbacks[id]; + cb && cb(value); + }, + ); + } +} + /** * Wrapper around the Android native module. */ diff --git a/Libraries/Alert/AlertIOS.js b/Libraries/Alert/AlertIOS.js deleted file mode 100644 index b7e1a0d73b7b59..00000000000000 --- a/Libraries/Alert/AlertIOS.js +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - * @jsdoc - */ - -'use strict'; - -const RCTAlertManager = require('NativeModules').AlertManager; - -/** - * An Alert button type - */ -export type AlertType = $Enum<{ - /** - * Default alert with no inputs - */ - default: string, - /** - * Plain text input alert - */ - 'plain-text': string, - /** - * Secure text input alert - */ - 'secure-text': string, - /** - * Login and password alert - */ - 'login-password': string, -}>; - -/** - * An Alert button style - */ -export type AlertButtonStyle = $Enum<{ - /** - * Default button style - */ - default: string, - /** - * Cancel button style - */ - cancel: string, - /** - * Destructive button style - */ - destructive: string, -}>; - -/** - * Array or buttons - * @typedef {Array} ButtonsArray - * @property {string=} text Button label - * @property {Function=} onPress Callback function when button pressed - * @property {AlertButtonStyle=} style Button style - */ -export type ButtonsArray = Array<{ - /** - * Button label - */ - text?: string, - /** - * Callback function when button pressed - */ - onPress?: ?Function, - /** - * Button style - */ - style?: AlertButtonStyle, -}>; - -/** - * Use `AlertIOS` to display an alert dialog with a message or to create a prompt for user input on iOS. If you don't need to prompt for user input, we recommend using `Alert.alert() for cross-platform support. - * - * See http://facebook.github.io/react-native/docs/alertios.html - */ -class AlertIOS { - /** - * Create and display a popup alert. - * - * See http://facebook.github.io/react-native/docs/alertios.html#alert - */ - static alert( - title: ?string, - message?: ?string, - callbackOrButtons?: ?((() => void) | ButtonsArray), - type?: AlertType, - ): void { - if (typeof type !== 'undefined') { - console.warn( - 'AlertIOS.alert() with a 4th "type" parameter is deprecated and will be removed. Use AlertIOS.prompt() instead.', - ); - this.prompt(title, message, callbackOrButtons, type); - return; - } - this.prompt(title, message, callbackOrButtons, 'default'); - } - - /** - * Create and display a prompt to enter some text. - * - * See http://facebook.github.io/react-native/docs/alertios.html#prompt - */ - static prompt( - title: ?string, - message?: ?string, - callbackOrButtons?: ?(((text: string) => void) | ButtonsArray), - type?: ?AlertType = 'plain-text', - defaultValue?: string, - keyboardType?: string, - ): void { - if (typeof type === 'function') { - console.warn( - 'You passed a callback function as the "type" argument to AlertIOS.prompt(). React Native is ' + - 'assuming you want to use the deprecated AlertIOS.prompt(title, defaultValue, buttons, callback) ' + - 'signature. The current signature is AlertIOS.prompt(title, message, callbackOrButtons, type, defaultValue, ' + - 'keyboardType) and the old syntax will be removed in a future version.', - ); - - const callback = type; - RCTAlertManager.alertWithArgs( - { - title: title || '', - type: 'plain-text', - defaultValue: message, - }, - (id, value) => { - callback(value); - }, - ); - return; - } - - let callbacks = []; - const buttons = []; - let cancelButtonKey; - let destructiveButtonKey; - if (typeof callbackOrButtons === 'function') { - callbacks = [callbackOrButtons]; - } else if (callbackOrButtons instanceof Array) { - callbackOrButtons.forEach((btn, index) => { - callbacks[index] = btn.onPress; - if (btn.style === 'cancel') { - cancelButtonKey = String(index); - } else if (btn.style === 'destructive') { - destructiveButtonKey = String(index); - } - if (btn.text || index < (callbackOrButtons || []).length - 1) { - const btnDef = {}; - btnDef[index] = btn.text || ''; - buttons.push(btnDef); - } - }); - } - - RCTAlertManager.alertWithArgs( - { - title: title || '', - message: message || undefined, - buttons, - type: type || undefined, - defaultValue, - cancelButtonKey, - destructiveButtonKey, - keyboardType, - }, - (id, value) => { - const cb = callbacks[id]; - cb && cb(value); - }, - ); - } -} - -module.exports = AlertIOS; From 764f0db79f398954d7f510f73b53059272702cad Mon Sep 17 00:00:00 2001 From: Wellinton Monge Date: Wed, 6 Feb 2019 15:42:32 -0200 Subject: [PATCH 02/12] removing duplicated comments --- Libraries/Alert/Alert.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index f2b7f7a2278777..b71243123fce2c 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -17,15 +17,7 @@ const Platform = require('Platform'); /** * Array or buttons * @typedef {Array} ButtonsArray - * @property {string=} text Button label - * @property {Function=} onPress Callback function when button pressed - * @property {AlertButtonStyle=} style Button style - */ - -/** - * Array or buttons - * @typedef {Array} ButtonsArray - * @property {string=} text Button label + * g@property {string=} text Button label * @property {Function=} onPress Callback function when button pressed * @property {AlertButtonStyle=} style Button style */ From 22d25312c7a739452cc079cc71f8fa060e5a65c1 Mon Sep 17 00:00:00 2001 From: Wellinton Monge Date: Wed, 6 Feb 2019 16:15:03 -0200 Subject: [PATCH 03/12] fixing prettier and Cannot resolve variable --- Libraries/Alert/Alert.js | 302 ++++++++---------- .../react-native-implementation.js | 3 - .../debug/interfaces/DeveloperSettings.java | 1 - 3 files changed, 141 insertions(+), 165 deletions(-) diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index b71243123fce2c..8c64f80c6ad9a3 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -16,41 +16,41 @@ const Platform = require('Platform'); /** * Array or buttons - * @typedef {Array} ButtonsArray + * @typedef {Array} Buttons * g@property {string=} text Button label * @property {Function=} onPress Callback function when button pressed * @property {AlertButtonStyle=} style Button style */ export type Buttons = Array<{ - text?: string, - onPress?: ?Function, - style?: AlertButtonStyle, - }>; - + text?: string, + onPress?: ?Function, + style?: AlertButtonStyle +}>; + type Options = { - cancelable?: ?boolean, - onDismiss?: ?Function, + cancelable?: ?boolean, + onDismiss?: ?Function }; /** * An Alert button type */ type AlertType = $Enum<{ - default: string, - 'plain-text': string, - 'secure-text': string, - 'login-password': string, - }>; - - /** + default: string, + 'plain-text': string, + 'secure-text': string, + 'login-password': string +}>; + +/** * An Alert button style */ type AlertButtonStyle = $Enum<{ - default: string, - cancel: string, - destructive: string, - }>; + default: string, + cancel: string, + destructive: string +}>; /** * Launches an alert dialog with the specified title and message. @@ -58,160 +58,140 @@ type AlertButtonStyle = $Enum<{ * See http://facebook.github.io/react-native/docs/alert.html */ class Alert { - static alert( - title: ?string, - message?: ?string, - buttons?: Buttons, - options?: Options - ): void { - if (Platform.OS === 'ios') { - AlertIOS.alert(title, message, buttons); - } else if (Platform.OS === 'android') { - AlertAndroid.alert(title, message, buttons, options); - } - } + static alert(title: ?string, message?: ?string, buttons?: Buttons, options?: Options): void { + if (Platform.OS === 'ios') { + AlertIOS.alert(title, message, buttons); + } else if (Platform.OS === 'android') { + AlertAndroid.alert(title, message, buttons, options); + } + } } /** * Wrapper around the iOS native module. */ class AlertIOS { - static alert( - title: ?string, - message?: ?string, - callbackOrButtons?: ?((() => void) | ButtonsArray) - ): void { - this.prompt(title, message, callbackOrButtons, 'default'); - } - - static prompt( - title: ?string, - message?: ?string, - callbackOrButtons?: ?(((text: string) => void) | ButtonsArray), - type?: ?AlertType = 'plain-text', - defaultValue?: string, - keyboardType?: string, - ): void { - if (typeof type === 'function') { - console.warn( - 'You passed a callback function as the "type" argument to AlertIOS.prompt(). React Native is ' + - 'assuming you want to use the deprecated AlertIOS.prompt(title, defaultValue, buttons, callback) ' + - 'signature. The current signature is AlertIOS.prompt(title, message, callbackOrButtons, type, defaultValue, ' + - 'keyboardType) and the old syntax will be removed in a future version.', - ); - - const callback = type; - RCTAlertManager.alertWithArgs( - { - title: title || '', - type: 'plain-text', - defaultValue: message, - }, - (id, value) => { - callback(value); - }, - ); - return; - } - - let callbacks = []; - const buttons = []; - let cancelButtonKey; - let destructiveButtonKey; - if (typeof callbackOrButtons === 'function') { - callbacks = [callbackOrButtons]; - } else if (callbackOrButtons instanceof Array) { - callbackOrButtons.forEach((btn, index) => { - callbacks[index] = btn.onPress; - if (btn.style === 'cancel') { - cancelButtonKey = String(index); - } else if (btn.style === 'destructive') { - destructiveButtonKey = String(index); - } - if (btn.text || index < (callbackOrButtons || []).length - 1) { - const btnDef = {}; - btnDef[index] = btn.text || ''; - buttons.push(btnDef); - } - }); - } - - RCTAlertManager.alertWithArgs( - { - title: title || '', - message: message || undefined, - buttons, - type: type || undefined, - defaultValue, - cancelButtonKey, - destructiveButtonKey, - keyboardType, - }, - (id, value) => { - const cb = callbacks[id]; - cb && cb(value); - }, - ); - } + static alert(title: ?string, message?: ?string, callbackOrButtons?: ?((() => void) | Buttons)): void { + this.prompt(title, message, callbackOrButtons, 'default'); + } + + static prompt( + title: ?string, + message?: ?string, + callbackOrButtons?: ?(((text: string) => void) | Buttons), + type?: ?AlertType = 'plain-text', + defaultValue?: string, + keyboardType?: string + ): void { + if (typeof type === 'function') { + console.warn( + 'You passed a callback function as the "type" argument to AlertIOS.prompt(). React Native is ' + + 'assuming you want to use the deprecated AlertIOS.prompt(title, defaultValue, buttons, callback) ' + + 'signature. The current signature is AlertIOS.prompt(title, message, callbackOrButtons, type, defaultValue, ' + + 'keyboardType) and the old syntax will be removed in a future version.' + ); + + const callback = type; + RCTAlertManager.alertWithArgs( + { + title: title || '', + type: 'plain-text', + defaultValue: message + }, + (id, value) => { + callback(value); + } + ); + return; + } + + let callbacks = []; + const buttons = []; + let cancelButtonKey; + let destructiveButtonKey; + if (typeof callbackOrButtons === 'function') { + callbacks = [ callbackOrButtons ]; + } else if (callbackOrButtons instanceof Array) { + callbackOrButtons.forEach((btn, index) => { + callbacks[index] = btn.onPress; + if (btn.style === 'cancel') { + cancelButtonKey = String(index); + } else if (btn.style === 'destructive') { + destructiveButtonKey = String(index); + } + if (btn.text || index < (callbackOrButtons || []).length - 1) { + const btnDef = {}; + btnDef[index] = btn.text || ''; + buttons.push(btnDef); + } + }); + } + + RCTAlertManager.alertWithArgs( + { + title: title || '', + message: message || undefined, + buttons, + type: type || undefined, + defaultValue, + cancelButtonKey, + destructiveButtonKey, + keyboardType + }, + (id, value) => { + const cb = callbacks[id]; + cb && cb(value); + } + ); + } } /** * Wrapper around the Android native module. */ class AlertAndroid { - static alert( - title: ?string, - message?: ?string, - buttons?: Buttons, - options?: Options, - ): void { - let config = { - title: title || '', - message: message || '', - }; - - if (options) { - config = {...config, cancelable: options.cancelable}; - } - // At most three buttons (neutral, negative, positive). Ignore rest. - // The text 'OK' should be probably localized. iOS Alert does that in native. - const validButtons: Buttons = buttons - ? buttons.slice(0, 3) - : [{text: 'OK'}]; - const buttonPositive = validButtons.pop(); - const buttonNegative = validButtons.pop(); - const buttonNeutral = validButtons.pop(); - if (buttonNeutral) { - config = {...config, buttonNeutral: buttonNeutral.text || ''}; - } - if (buttonNegative) { - config = {...config, buttonNegative: buttonNegative.text || ''}; - } - if (buttonPositive) { - config = {...config, buttonPositive: buttonPositive.text || ''}; - } - NativeModules.DialogManagerAndroid.showAlert( - config, - errorMessage => console.warn(errorMessage), - (action, buttonKey) => { - if (action === NativeModules.DialogManagerAndroid.buttonClicked) { - if (buttonKey === NativeModules.DialogManagerAndroid.buttonNeutral) { - buttonNeutral.onPress && buttonNeutral.onPress(); - } else if ( - buttonKey === NativeModules.DialogManagerAndroid.buttonNegative - ) { - buttonNegative.onPress && buttonNegative.onPress(); - } else if ( - buttonKey === NativeModules.DialogManagerAndroid.buttonPositive - ) { - buttonPositive.onPress && buttonPositive.onPress(); - } - } else if (action === NativeModules.DialogManagerAndroid.dismissed) { - options && options.onDismiss && options.onDismiss(); - } - }, - ); - } + static alert(title: ?string, message?: ?string, buttons?: Buttons, options?: Options): void { + let config = { + title: title || '', + message: message || '' + }; + + if (options) { + config = { ...config, cancelable: options.cancelable }; + } + // At most three buttons (neutral, negative, positive). Ignore rest. + // The text 'OK' should be probably localized. iOS Alert does that in native. + const validButtons: Buttons = buttons ? buttons.slice(0, 3) : [ { text: 'OK' } ]; + const buttonPositive = validButtons.pop(); + const buttonNegative = validButtons.pop(); + const buttonNeutral = validButtons.pop(); + if (buttonNeutral) { + config = { ...config, buttonNeutral: buttonNeutral.text || '' }; + } + if (buttonNegative) { + config = { ...config, buttonNegative: buttonNegative.text || '' }; + } + if (buttonPositive) { + config = { ...config, buttonPositive: buttonPositive.text || '' }; + } + NativeModules.DialogManagerAndroid.showAlert( + config, + (errorMessage) => console.warn(errorMessage), + (action, buttonKey) => { + if (action === NativeModules.DialogManagerAndroid.buttonClicked) { + if (buttonKey === NativeModules.DialogManagerAndroid.buttonNeutral) { + buttonNeutral.onPress && buttonNeutral.onPress(); + } else if (buttonKey === NativeModules.DialogManagerAndroid.buttonNegative) { + buttonNegative.onPress && buttonNegative.onPress(); + } else if (buttonKey === NativeModules.DialogManagerAndroid.buttonPositive) { + buttonPositive.onPress && buttonPositive.onPress(); + } + } else if (action === NativeModules.DialogManagerAndroid.dismissed) { + options && options.onDismiss && options.onDismiss(); + } + } + ); + } } module.exports = Alert; diff --git a/Libraries/react-native/react-native-implementation.js b/Libraries/react-native/react-native-implementation.js index 18acbc22165d08..8bfb182dd12a84 100644 --- a/Libraries/react-native/react-native-implementation.js +++ b/Libraries/react-native/react-native-implementation.js @@ -185,9 +185,6 @@ module.exports = { get Alert() { return require('Alert'); }, - get AlertIOS() { - return require('AlertIOS'); - }, get Animated() { return require('Animated'); }, diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/interfaces/DeveloperSettings.java b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/interfaces/DeveloperSettings.java index 79254fdbff95fe..1a844ce800a58a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/interfaces/DeveloperSettings.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/interfaces/DeveloperSettings.java @@ -1,4 +1,3 @@ -/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the From e9658e64503e6254548c75279b554437cb640b6c Mon Sep 17 00:00:00 2001 From: Wellinton Monge Date: Wed, 6 Feb 2019 17:18:26 -0200 Subject: [PATCH 04/12] fixing bugs catch from CLI --- Libraries/Alert/Alert.js | 17 +++++++++++++--- .../react-native-implementation.js | 6 ++++++ RNTester/js/AlertIOSExample.js | 20 +++++++++---------- RNTester/js/PushNotificationIOSExample.js | 10 +++++----- RNTester/js/TimerExample.js | 4 ++-- 5 files changed, 37 insertions(+), 20 deletions(-) diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 8c64f80c6ad9a3..4373c4e1fa766d 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -64,13 +64,24 @@ class Alert { } else if (Platform.OS === 'android') { AlertAndroid.alert(title, message, buttons, options); } - } + } + + static prompt(title: ?string, + message?: ?string, + callbackOrButtons?: ?(((text: string) => void) | Buttons), + type?: ?AlertType = 'plain-text', + defaultValue?: string, + keyboardType?: string): void { + if (Platform.OS === 'ios') { + AlertIOS.prompt(title, message, callbackOrButtons, type, defaultValue, keyboardType); + } + } } /** * Wrapper around the iOS native module. */ -class AlertIOS { +export class AlertIOS { static alert(title: ?string, message?: ?string, callbackOrButtons?: ?((() => void) | Buttons)): void { this.prompt(title, message, callbackOrButtons, 'default'); } @@ -149,7 +160,7 @@ class AlertIOS { /** * Wrapper around the Android native module. */ -class AlertAndroid { +export class AlertAndroid { static alert(title: ?string, message?: ?string, buttons?: Buttons, options?: Options): void { let config = { title: title || '', diff --git a/Libraries/react-native/react-native-implementation.js b/Libraries/react-native/react-native-implementation.js index 8bfb182dd12a84..1f1ab1e65add47 100644 --- a/Libraries/react-native/react-native-implementation.js +++ b/Libraries/react-native/react-native-implementation.js @@ -185,6 +185,12 @@ module.exports = { get Alert() { return require('Alert'); }, + get AlertIOS(){ + warnOnce( + 'AlertIOS', + 'AlertIOS has been moved to Alert. ' + ); + }, get Animated() { return require('Animated'); }, diff --git a/RNTester/js/AlertIOSExample.js b/RNTester/js/AlertIOSExample.js index b1e9f352eafed0..bac7bc1a51cd79 100644 --- a/RNTester/js/AlertIOSExample.js +++ b/RNTester/js/AlertIOSExample.js @@ -12,7 +12,7 @@ const React = require('react'); const ReactNative = require('react-native'); -const {StyleSheet, View, Text, TouchableHighlight, AlertIOS} = ReactNative; +const {StyleSheet, View, Text, TouchableHighlight, Alert} = ReactNative; const {SimpleAlertExampleBlock} = require('./AlertExample'); @@ -55,7 +55,7 @@ class PromptOptions extends React.Component { - AlertIOS.prompt('Type a value', null, this.saveResponse) + Alert.prompt('Type a value', null, this.saveResponse) }> prompt with title & callback @@ -65,7 +65,7 @@ class PromptOptions extends React.Component { - AlertIOS.prompt('Type a value', null, this.customButtons) + Alert.prompt('Type a value', null, this.customButtons) }> prompt with title & custom buttons @@ -75,7 +75,7 @@ class PromptOptions extends React.Component { - AlertIOS.prompt( + Alert.prompt( 'Type a phone number', null, null, @@ -92,7 +92,7 @@ class PromptOptions extends React.Component { - AlertIOS.prompt( + Alert.prompt( 'Type a value', null, this.saveResponse, @@ -108,7 +108,7 @@ class PromptOptions extends React.Component { - AlertIOS.prompt( + Alert.prompt( 'Type a value', null, this.customButtons, @@ -149,7 +149,7 @@ const styles = StyleSheet.create({ }); exports.framework = 'React'; -exports.title = 'AlertIOS'; +exports.title = 'Alert'; exports.description = 'iOS alerts and action sheets'; exports.examples = [ { @@ -171,7 +171,7 @@ exports.examples = [ AlertIOS.prompt('Plain Text Entry')}> + onPress={() => Alert.prompt('Plain Text Entry')}> plain-text @@ -179,7 +179,7 @@ exports.examples = [ - AlertIOS.prompt('Secure Text', null, null, 'secure-text') + Alert.prompt('Secure Text', null, null, 'secure-text') }> secure-text @@ -188,7 +188,7 @@ exports.examples = [ - AlertIOS.prompt('Login & Password', null, null, 'login-password') + Alert.prompt('Login & Password', null, null, 'login-password') }> login-password diff --git a/RNTester/js/PushNotificationIOSExample.js b/RNTester/js/PushNotificationIOSExample.js index a841f126e7de95..576eedf14c7462 100644 --- a/RNTester/js/PushNotificationIOSExample.js +++ b/RNTester/js/PushNotificationIOSExample.js @@ -13,7 +13,7 @@ const React = require('react'); const ReactNative = require('react-native'); const { - AlertIOS, + Alert, PushNotificationIOS, StyleSheet, Text, @@ -110,7 +110,7 @@ class NotificationExample extends React.Component<{}> { } _onRegistered(deviceToken) { - AlertIOS.alert( + Alert.alert( 'Registered For Remote Push', `Device Token: ${deviceToken}`, [ @@ -123,7 +123,7 @@ class NotificationExample extends React.Component<{}> { } _onRegistrationError(error) { - AlertIOS.alert( + Alert.alert( 'Failed To Register For Remote Push', `Error (${error.code}): ${error.message}`, [ @@ -142,7 +142,7 @@ class NotificationExample extends React.Component<{}> { category: ${notification.getCategory()};\n content-available: ${notification.getContentAvailable()}.`; - AlertIOS.alert('Push Notification Received', result, [ + Alert.alert('Push Notification Received', result, [ { text: 'Dismiss', onPress: null, @@ -151,7 +151,7 @@ class NotificationExample extends React.Component<{}> { } _onLocalNotification(notification) { - AlertIOS.alert( + Alert.alert( 'Local Notification Received', 'Alert message: ' + notification.getMessage(), [ diff --git a/RNTester/js/TimerExample.js b/RNTester/js/TimerExample.js index f1be0ece82b460..aaa5268afc3a9c 100644 --- a/RNTester/js/TimerExample.js +++ b/RNTester/js/TimerExample.js @@ -12,7 +12,7 @@ const React = require('react'); const ReactNative = require('react-native'); -const {AlertIOS, Platform, ToastAndroid, Text, View} = ReactNative; +const {Alert, Platform, ToastAndroid, Text, View} = ReactNative; const RNTesterButton = require('./RNTesterButton'); const performanceNow = require('fbjs/lib/performanceNow'); @@ -230,7 +230,7 @@ class TimerTester extends React.Component { ' ms / iter'; console.log(msg); if (Platform.OS === 'ios') { - AlertIOS.alert(msg); + Alert.alert(msg); } else if (Platform.OS === 'android') { ToastAndroid.show(msg, ToastAndroid.SHORT); } From bf0e60eaae34701ac1bcff4757bf6e175b7923a7 Mon Sep 17 00:00:00 2001 From: Wellinton Monge Date: Wed, 6 Feb 2019 17:50:47 -0200 Subject: [PATCH 05/12] fixing to pass on tests --- Libraries/Alert/Alert.js | 319 +++-- .../react-native-implementation.js | 9 +- RNTester/js/AlertIOSExample.js | 4 +- RNTester/js/PushNotificationIOSExample.js | 16 +- reports/junit/js-test-results.xml | 1246 +++++++++++++++++ 5 files changed, 1432 insertions(+), 162 deletions(-) create mode 100644 reports/junit/js-test-results.xml diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 4373c4e1fa766d..02fe4b4c2f8acf 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -23,33 +23,33 @@ const Platform = require('Platform'); */ export type Buttons = Array<{ - text?: string, - onPress?: ?Function, - style?: AlertButtonStyle + text?: string, + onPress?: ?Function, + style?: AlertButtonStyle, }>; type Options = { - cancelable?: ?boolean, - onDismiss?: ?Function + cancelable?: ?boolean, + onDismiss?: ?Function, }; /** * An Alert button type */ type AlertType = $Enum<{ - default: string, - 'plain-text': string, - 'secure-text': string, - 'login-password': string + default: string, + 'plain-text': string, + 'secure-text': string, + 'login-password': string, }>; /** - * An Alert button style - */ + * An Alert button style + */ type AlertButtonStyle = $Enum<{ - default: string, - cancel: string, - destructive: string + default: string, + cancel: string, + destructive: string, }>; /** @@ -58,23 +58,37 @@ type AlertButtonStyle = $Enum<{ * See http://facebook.github.io/react-native/docs/alert.html */ class Alert { - static alert(title: ?string, message?: ?string, buttons?: Buttons, options?: Options): void { - if (Platform.OS === 'ios') { - AlertIOS.alert(title, message, buttons); - } else if (Platform.OS === 'android') { - AlertAndroid.alert(title, message, buttons, options); - } + static alert( + title: ?string, + message?: ?string, + buttons?: Buttons, + options?: Options, + ): void { + if (Platform.OS === 'ios') { + AlertIOS.alert(title, message, buttons); + } else if (Platform.OS === 'android') { + AlertAndroid.alert(title, message, buttons, options); + } } - - static prompt(title: ?string, - message?: ?string, - callbackOrButtons?: ?(((text: string) => void) | Buttons), - type?: ?AlertType = 'plain-text', - defaultValue?: string, - keyboardType?: string): void { - if (Platform.OS === 'ios') { - AlertIOS.prompt(title, message, callbackOrButtons, type, defaultValue, keyboardType); - } + + static prompt( + title: ?string, + message?: ?string, + callbackOrButtons?: ?(((text: string) => void) | Buttons), + type?: ?AlertType = 'plain-text', + defaultValue?: string, + keyboardType?: string, + ): void { + if (Platform.OS === 'ios') { + AlertIOS.prompt( + title, + message, + callbackOrButtons, + type, + defaultValue, + keyboardType, + ); + } } } @@ -82,127 +96,142 @@ class Alert { * Wrapper around the iOS native module. */ export class AlertIOS { - static alert(title: ?string, message?: ?string, callbackOrButtons?: ?((() => void) | Buttons)): void { - this.prompt(title, message, callbackOrButtons, 'default'); - } - - static prompt( - title: ?string, - message?: ?string, - callbackOrButtons?: ?(((text: string) => void) | Buttons), - type?: ?AlertType = 'plain-text', - defaultValue?: string, - keyboardType?: string - ): void { - if (typeof type === 'function') { - console.warn( - 'You passed a callback function as the "type" argument to AlertIOS.prompt(). React Native is ' + - 'assuming you want to use the deprecated AlertIOS.prompt(title, defaultValue, buttons, callback) ' + - 'signature. The current signature is AlertIOS.prompt(title, message, callbackOrButtons, type, defaultValue, ' + - 'keyboardType) and the old syntax will be removed in a future version.' - ); - - const callback = type; - RCTAlertManager.alertWithArgs( - { - title: title || '', - type: 'plain-text', - defaultValue: message - }, - (id, value) => { - callback(value); - } - ); - return; - } - - let callbacks = []; - const buttons = []; - let cancelButtonKey; - let destructiveButtonKey; - if (typeof callbackOrButtons === 'function') { - callbacks = [ callbackOrButtons ]; - } else if (callbackOrButtons instanceof Array) { - callbackOrButtons.forEach((btn, index) => { - callbacks[index] = btn.onPress; - if (btn.style === 'cancel') { - cancelButtonKey = String(index); - } else if (btn.style === 'destructive') { - destructiveButtonKey = String(index); - } - if (btn.text || index < (callbackOrButtons || []).length - 1) { - const btnDef = {}; - btnDef[index] = btn.text || ''; - buttons.push(btnDef); - } - }); - } - - RCTAlertManager.alertWithArgs( - { - title: title || '', - message: message || undefined, - buttons, - type: type || undefined, - defaultValue, - cancelButtonKey, - destructiveButtonKey, - keyboardType - }, - (id, value) => { - const cb = callbacks[id]; - cb && cb(value); - } - ); - } + static alert( + title: ?string, + message?: ?string, + callbackOrButtons?: ?((() => void) | Buttons), + ): void { + this.prompt(title, message, callbackOrButtons, 'default'); + } + + static prompt( + title: ?string, + message?: ?string, + callbackOrButtons?: ?(((text: string) => void) | Buttons), + type?: ?AlertType = 'plain-text', + defaultValue?: string, + keyboardType?: string, + ): void { + if (typeof type === 'function') { + console.warn( + 'You passed a callback function as the "type" argument to AlertIOS.prompt(). React Native is ' + + 'assuming you want to use the deprecated AlertIOS.prompt(title, defaultValue, buttons, callback) ' + + 'signature. The current signature is AlertIOS.prompt(title, message, callbackOrButtons, type, defaultValue, ' + + 'keyboardType) and the old syntax will be removed in a future version.', + ); + + const callback = type; + RCTAlertManager.alertWithArgs( + { + title: title || '', + type: 'plain-text', + defaultValue: message, + }, + (id, value) => { + callback(value); + }, + ); + return; + } + + let callbacks = []; + const buttons = []; + let cancelButtonKey; + let destructiveButtonKey; + if (typeof callbackOrButtons === 'function') { + callbacks = [callbackOrButtons]; + } else if (callbackOrButtons instanceof Array) { + callbackOrButtons.forEach((btn, index) => { + callbacks[index] = btn.onPress; + if (btn.style === 'cancel') { + cancelButtonKey = String(index); + } else if (btn.style === 'destructive') { + destructiveButtonKey = String(index); + } + if (btn.text || index < (callbackOrButtons || []).length - 1) { + const btnDef = {}; + btnDef[index] = btn.text || ''; + buttons.push(btnDef); + } + }); + } + + RCTAlertManager.alertWithArgs( + { + title: title || '', + message: message || undefined, + buttons, + type: type || undefined, + defaultValue, + cancelButtonKey, + destructiveButtonKey, + keyboardType, + }, + (id, value) => { + const cb = callbacks[id]; + cb && cb(value); + }, + ); + } } /** * Wrapper around the Android native module. */ export class AlertAndroid { - static alert(title: ?string, message?: ?string, buttons?: Buttons, options?: Options): void { - let config = { - title: title || '', - message: message || '' - }; - - if (options) { - config = { ...config, cancelable: options.cancelable }; - } - // At most three buttons (neutral, negative, positive). Ignore rest. - // The text 'OK' should be probably localized. iOS Alert does that in native. - const validButtons: Buttons = buttons ? buttons.slice(0, 3) : [ { text: 'OK' } ]; - const buttonPositive = validButtons.pop(); - const buttonNegative = validButtons.pop(); - const buttonNeutral = validButtons.pop(); - if (buttonNeutral) { - config = { ...config, buttonNeutral: buttonNeutral.text || '' }; - } - if (buttonNegative) { - config = { ...config, buttonNegative: buttonNegative.text || '' }; - } - if (buttonPositive) { - config = { ...config, buttonPositive: buttonPositive.text || '' }; - } - NativeModules.DialogManagerAndroid.showAlert( - config, - (errorMessage) => console.warn(errorMessage), - (action, buttonKey) => { - if (action === NativeModules.DialogManagerAndroid.buttonClicked) { - if (buttonKey === NativeModules.DialogManagerAndroid.buttonNeutral) { - buttonNeutral.onPress && buttonNeutral.onPress(); - } else if (buttonKey === NativeModules.DialogManagerAndroid.buttonNegative) { - buttonNegative.onPress && buttonNegative.onPress(); - } else if (buttonKey === NativeModules.DialogManagerAndroid.buttonPositive) { - buttonPositive.onPress && buttonPositive.onPress(); - } - } else if (action === NativeModules.DialogManagerAndroid.dismissed) { - options && options.onDismiss && options.onDismiss(); - } - } - ); - } + static alert( + title: ?string, + message?: ?string, + buttons?: Buttons, + options?: Options, + ): void { + let config = { + title: title || '', + message: message || '', + }; + + if (options) { + config = {...config, cancelable: options.cancelable}; + } + // At most three buttons (neutral, negative, positive). Ignore rest. + // The text 'OK' should be probably localized. iOS Alert does that in native. + const validButtons: Buttons = buttons + ? buttons.slice(0, 3) + : [{text: 'OK'}]; + const buttonPositive = validButtons.pop(); + const buttonNegative = validButtons.pop(); + const buttonNeutral = validButtons.pop(); + if (buttonNeutral) { + config = {...config, buttonNeutral: buttonNeutral.text || ''}; + } + if (buttonNegative) { + config = {...config, buttonNegative: buttonNegative.text || ''}; + } + if (buttonPositive) { + config = {...config, buttonPositive: buttonPositive.text || ''}; + } + NativeModules.DialogManagerAndroid.showAlert( + config, + errorMessage => console.warn(errorMessage), + (action, buttonKey) => { + if (action === NativeModules.DialogManagerAndroid.buttonClicked) { + if (buttonKey === NativeModules.DialogManagerAndroid.buttonNeutral) { + buttonNeutral.onPress && buttonNeutral.onPress(); + } else if ( + buttonKey === NativeModules.DialogManagerAndroid.buttonNegative + ) { + buttonNegative.onPress && buttonNegative.onPress(); + } else if ( + buttonKey === NativeModules.DialogManagerAndroid.buttonPositive + ) { + buttonPositive.onPress && buttonPositive.onPress(); + } + } else if (action === NativeModules.DialogManagerAndroid.dismissed) { + options && options.onDismiss && options.onDismiss(); + } + }, + ); + } } module.exports = Alert; diff --git a/Libraries/react-native/react-native-implementation.js b/Libraries/react-native/react-native-implementation.js index 1f1ab1e65add47..00f84a7198eb0d 100644 --- a/Libraries/react-native/react-native-implementation.js +++ b/Libraries/react-native/react-native-implementation.js @@ -185,10 +185,11 @@ module.exports = { get Alert() { return require('Alert'); }, - get AlertIOS(){ - warnOnce( - 'AlertIOS', - 'AlertIOS has been moved to Alert. ' + get AlertIOS() { + invariant( + false, + 'AlertIOS is deprecated and has been removed from this package. ' + + 'Learn about alternative alert solutions at http://facebook.github.io/react-native/docs/alertios.html', ); }, get Animated() { diff --git a/RNTester/js/AlertIOSExample.js b/RNTester/js/AlertIOSExample.js index bac7bc1a51cd79..390ebf431cd5ed 100644 --- a/RNTester/js/AlertIOSExample.js +++ b/RNTester/js/AlertIOSExample.js @@ -54,9 +54,7 @@ class PromptOptions extends React.Component { - Alert.prompt('Type a value', null, this.saveResponse) - }> + onPress={() => Alert.prompt('Type a value', null, this.saveResponse)}> prompt with title & callback diff --git a/RNTester/js/PushNotificationIOSExample.js b/RNTester/js/PushNotificationIOSExample.js index 576eedf14c7462..62066f1f09a11c 100644 --- a/RNTester/js/PushNotificationIOSExample.js +++ b/RNTester/js/PushNotificationIOSExample.js @@ -110,16 +110,12 @@ class NotificationExample extends React.Component<{}> { } _onRegistered(deviceToken) { - Alert.alert( - 'Registered For Remote Push', - `Device Token: ${deviceToken}`, - [ - { - text: 'Dismiss', - onPress: null, - }, - ], - ); + Alert.alert('Registered For Remote Push', `Device Token: ${deviceToken}`, [ + { + text: 'Dismiss', + onPress: null, + }, + ]); } _onRegistrationError(error) { diff --git a/reports/junit/js-test-results.xml b/reports/junit/js-test-results.xml new file mode 100644 index 00000000000000..75eed3d0c10f13 --- /dev/null +++ b/reports/junit/js-test-results.xml @@ -0,0 +1,1246 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: expect(received).toEqual(expected) + +Expected value to equal: + "AccessibilityInfo" +Received: + "AccessibilityInfo.dummy" + at Object.<anonymous> (C:\projetos\react-native\jest\__tests__\hasteImpl-test.js:76:5) + at Object.asyncJestTest (c:\projetos\react-native\node_modules\jest-jasmine2\build\jasmineAsyncInstall.js:121:37) + at resolve (c:\projetos\react-native\node_modules\jest-jasmine2\build\queueRunner.js:54:12) + at new Promise (<anonymous>) + at mapper (c:\projetos\react-native\node_modules\jest-jasmine2\build\queueRunner.js:41:19) + at promise.then (c:\projetos\react-native\node_modules\jest-jasmine2\build\queueRunner.js:86:41) + at process._tickCallback (internal/process/next_tick.js:68:7) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 71a6c09e3b690e436a4c19d18ca0d34d21cecb68 Mon Sep 17 00:00:00 2001 From: Wellinton Monge Date: Wed, 6 Feb 2019 17:57:39 -0200 Subject: [PATCH 06/12] removing wrong export --- Libraries/Alert/Alert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 02fe4b4c2f8acf..31a10e05dab09d 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -178,7 +178,7 @@ export class AlertIOS { /** * Wrapper around the Android native module. */ -export class AlertAndroid { +class AlertAndroid { static alert( title: ?string, message?: ?string, From 920bcb9ed0fc085d6a4035f9d00ad984ce313e91 Mon Sep 17 00:00:00 2001 From: Wellinton Monge Date: Thu, 7 Feb 2019 00:23:25 -0200 Subject: [PATCH 07/12] removing duplicated export --- Libraries/Alert/Alert.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 31a10e05dab09d..b381c582566747 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -22,7 +22,7 @@ const Platform = require('Platform'); * @property {AlertButtonStyle=} style Button style */ -export type Buttons = Array<{ +type Buttons = Array<{ text?: string, onPress?: ?Function, style?: AlertButtonStyle, @@ -95,7 +95,7 @@ class Alert { /** * Wrapper around the iOS native module. */ -export class AlertIOS { +class AlertIOS { static alert( title: ?string, message?: ?string, From 5fc51b6a01a9bf57353016d7ef7e391ff595dcd2 Mon Sep 17 00:00:00 2001 From: Woraphot Chokratanasombat Date: Fri, 8 Feb 2019 16:06:54 -0200 Subject: [PATCH 08/12] Update Libraries/Alert/Alert.js Co-Authored-By: wellmonge --- Libraries/Alert/Alert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index b381c582566747..8c1ed971f61dfe 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -17,7 +17,7 @@ const Platform = require('Platform'); /** * Array or buttons * @typedef {Array} Buttons - * g@property {string=} text Button label + * @property {string} text Button label * @property {Function=} onPress Callback function when button pressed * @property {AlertButtonStyle=} style Button style */ From 9fd7f6157aec4ef19a74649b21b93fc56cd1528d Mon Sep 17 00:00:00 2001 From: Wellinton Monge Date: Fri, 8 Feb 2019 22:10:15 -0200 Subject: [PATCH 09/12] reverting changes made by prettier --- .../react/modules/debug/interfaces/DeveloperSettings.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/interfaces/DeveloperSettings.java b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/interfaces/DeveloperSettings.java index 1a844ce800a58a..79254fdbff95fe 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/interfaces/DeveloperSettings.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/interfaces/DeveloperSettings.java @@ -1,3 +1,4 @@ +/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the From 2969bc8c616375e038112e9f48661eb5f322c5ae Mon Sep 17 00:00:00 2001 From: Wellinton Monge Date: Fri, 8 Feb 2019 23:06:37 -0200 Subject: [PATCH 10/12] removing incoherent test at XMLHttpReuqesT due the change made by PR #6870 --- .project | 17 + .../Network/__tests__/XMLHttpRequest-test.js | 4 +- reports/junit/js-test-results.xml | 1327 ++++++++--------- 3 files changed, 677 insertions(+), 671 deletions(-) create mode 100644 .project diff --git a/.project b/.project new file mode 100644 index 00000000000000..95797e958d7357 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + react-native + Project react-native created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/Libraries/Network/__tests__/XMLHttpRequest-test.js b/Libraries/Network/__tests__/XMLHttpRequest-test.js index e3b8f1c068194f..81367b045d2881 100644 --- a/Libraries/Network/__tests__/XMLHttpRequest-test.js +++ b/Libraries/Network/__tests__/XMLHttpRequest-test.js @@ -87,9 +87,11 @@ describe('XMLHttpRequest', function() { it('should expose responseType correctly', function() { expect(xhr.responseType).toBe(''); - + console.log(xhr.responseType); // Setting responseType to an unsupported value has no effect. xhr.responseType = 'arrayblobbuffertextfile'; + console.log(xhr.responseType); + expect(xhr.responseType).toBe(''); xhr.responseType = 'arraybuffer'; diff --git a/reports/junit/js-test-results.xml b/reports/junit/js-test-results.xml index 75eed3d0c10f13..4558d93e5104c7 100644 --- a/reports/junit/js-test-results.xml +++ b/reports/junit/js-test-results.xml @@ -1,1246 +1,1233 @@ - - - + + + - + - + + + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + + + - + - + - + - + - + - + - + - + - + - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + - - - + + + - + - + - + - + - + - + - + - + - + - - - - - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - + - + - - - + - + - + - + - + + + - + - + - + - + - + + + - + - + - + - + - + - + - + - + - - + + - + + + - + - + - + - + + + - + - + - + - + + + - + - + - + - + - + - + - + - - - + - + - + - + - + - + - + - + - + - - + + - + + + - + - + - + - + - + - + - + - + - + - + - - - + - + - + - + - + - + - + - + - + - + - + - + + + - + - + - + - + - + - - - + - + - + + + - + - + - + - + + + - + - - + + - + - + - - - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - - - - - + - + - + - - + + - + - + - + - + - + - + + + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + + + + + + + - + - - + + - + - + - + - + - + - + - + + + - - + + - + - - - + - + - + - + - + - + - + - + + + - + - + + + - + - - + + - + - + - + - + - + - + - + - + + + + + + + - - + + - + - + - + - - - + - + - + - + - - - + - + + + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + + + - - + + - + - + - + - + - + - + - + + + - + - + - + - + - + - + + + + + + + - - + + - + - + - + - + - - - + - + - + - + - + - - + + - + - + - + - + - + - + - + - - + + - + - + - + - + + + - + - + + + - + - + - + - + - + - - - + + + - + - + - + - + - + + + - - + + - + - - Error: expect(received).toEqual(expected) - -Expected value to equal: - "AccessibilityInfo" -Received: - "AccessibilityInfo.dummy" - at Object.<anonymous> (C:\projetos\react-native\jest\__tests__\hasteImpl-test.js:76:5) - at Object.asyncJestTest (c:\projetos\react-native\node_modules\jest-jasmine2\build\jasmineAsyncInstall.js:121:37) - at resolve (c:\projetos\react-native\node_modules\jest-jasmine2\build\queueRunner.js:54:12) - at new Promise (<anonymous>) - at mapper (c:\projetos\react-native\node_modules\jest-jasmine2\build\queueRunner.js:41:19) - at promise.then (c:\projetos\react-native\node_modules\jest-jasmine2\build\queueRunner.js:86:41) - at process._tickCallback (internal/process/next_tick.js:68:7) + - + - + - + - + - - - + - + + + - + - + - + - + - + - + - + - - - + - + - + - + + + - + - + - + - + - + - - - + - + - + - + - + + + - + - + + + - + + + - + - + - + - + - - + + - + - + - - - - - + - + - + - - - + - + - + - + - + - + - - + + - + - + - - + + - + - + - + - - + + - + - - - + - + - + - + + + - - + + - + + + - + - + + + - + - + - + - - - + - + + + - - + + - + - + - + - + - - - + - + - + - + - - - + - + + + - - + + - + - - + + - + - - + + - - - + - + - + - - - + - + - + - + - - - + - + - - - + - - - + - + - - + + - + - - - + - + - + + + - + - + - + - + - + - + - + - - - + - - + + - + - + - + - + + + - + - + - + - + - + - - - + - + - + - + - + + + - + - + - + - + - + - - + + - + - + - + - - - - - - - - - - - - - - - - - - - - + + - - - + - + - + - + - + - + - + - + - + - + - - - + - - + + - + - + + + - + - + - + + + - + - + + + - + - + - - + + \ No newline at end of file From 97174fc3d7af8fa9f63d2729a891eff1020e4ef0 Mon Sep 17 00:00:00 2001 From: Wellinton Monge Date: Fri, 8 Feb 2019 23:09:02 -0200 Subject: [PATCH 11/12] removing incoherent test at XMLHttpReuqesT due the change made by PR #6870 --- Libraries/Network/__tests__/XMLHttpRequest-test.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Libraries/Network/__tests__/XMLHttpRequest-test.js b/Libraries/Network/__tests__/XMLHttpRequest-test.js index 81367b045d2881..b6d3eefb51174d 100644 --- a/Libraries/Network/__tests__/XMLHttpRequest-test.js +++ b/Libraries/Network/__tests__/XMLHttpRequest-test.js @@ -86,12 +86,6 @@ describe('XMLHttpRequest', function() { }); it('should expose responseType correctly', function() { - expect(xhr.responseType).toBe(''); - console.log(xhr.responseType); - // Setting responseType to an unsupported value has no effect. - xhr.responseType = 'arrayblobbuffertextfile'; - console.log(xhr.responseType); - expect(xhr.responseType).toBe(''); xhr.responseType = 'arraybuffer'; From cd50468dcdd055559556b441519b1528f2370903 Mon Sep 17 00:00:00 2001 From: cpojer Date: Mon, 11 Feb 2019 22:01:21 +0000 Subject: [PATCH 12/12] Cleanup --- .project | 17 - Libraries/Alert/Alert.js | 16 +- .../Network/__tests__/XMLHttpRequest-test.js | 4 + .../react-native-implementation.js | 8 +- reports/junit/js-test-results.xml | 1233 ----------------- 5 files changed, 9 insertions(+), 1269 deletions(-) delete mode 100644 .project delete mode 100644 reports/junit/js-test-results.xml diff --git a/.project b/.project deleted file mode 100644 index 95797e958d7357..00000000000000 --- a/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - react-native - Project react-native created by Buildship. - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 8c1ed971f61dfe..60db5e4e94cfdf 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -14,15 +14,7 @@ const NativeModules = require('NativeModules'); const RCTAlertManager = NativeModules.AlertManager; const Platform = require('Platform'); -/** - * Array or buttons - * @typedef {Array} Buttons - * @property {string} text Button label - * @property {Function=} onPress Callback function when button pressed - * @property {AlertButtonStyle=} style Button style - */ - -type Buttons = Array<{ +export type Buttons = Array<{ text?: string, onPress?: ?Function, style?: AlertButtonStyle, @@ -33,9 +25,6 @@ type Options = { onDismiss?: ?Function, }; -/** - * An Alert button type - */ type AlertType = $Enum<{ default: string, 'plain-text': string, @@ -43,9 +32,6 @@ type AlertType = $Enum<{ 'login-password': string, }>; -/** - * An Alert button style - */ type AlertButtonStyle = $Enum<{ default: string, cancel: string, diff --git a/Libraries/Network/__tests__/XMLHttpRequest-test.js b/Libraries/Network/__tests__/XMLHttpRequest-test.js index b6d3eefb51174d..e3b8f1c068194f 100644 --- a/Libraries/Network/__tests__/XMLHttpRequest-test.js +++ b/Libraries/Network/__tests__/XMLHttpRequest-test.js @@ -88,6 +88,10 @@ describe('XMLHttpRequest', function() { it('should expose responseType correctly', function() { expect(xhr.responseType).toBe(''); + // Setting responseType to an unsupported value has no effect. + xhr.responseType = 'arrayblobbuffertextfile'; + expect(xhr.responseType).toBe(''); + xhr.responseType = 'arraybuffer'; expect(xhr.responseType).toBe('arraybuffer'); diff --git a/Libraries/react-native/react-native-implementation.js b/Libraries/react-native/react-native-implementation.js index 00f84a7198eb0d..4f9ce9866d91dc 100644 --- a/Libraries/react-native/react-native-implementation.js +++ b/Libraries/react-native/react-native-implementation.js @@ -186,11 +186,11 @@ module.exports = { return require('Alert'); }, get AlertIOS() { - invariant( - false, - 'AlertIOS is deprecated and has been removed from this package. ' + - 'Learn about alternative alert solutions at http://facebook.github.io/react-native/docs/alertios.html', + warnOnce( + 'alert-ios', + 'AlertIOS is deprecated. Use the `Alert` module directly instead.', ); + return require('Alert'); }, get Animated() { return require('Animated'); diff --git a/reports/junit/js-test-results.xml b/reports/junit/js-test-results.xml deleted file mode 100644 index 4558d93e5104c7..00000000000000 --- a/reports/junit/js-test-results.xml +++ /dev/null @@ -1,1233 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file