Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM] Add spec for AlertManager #24906

Closed
wants to merge 8 commits into from

Conversation

sasurau4
Copy link
Contributor

Summary

Part of #24875

Changelog

[General] [Added] - Add TurboModule spec for AlertManager

Test Plan

  • yarn flow

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 16, 2019
Copy link

@analysis-bot analysis-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code analysis results:

  • eslint found some issues. Run yarn lint --fix to automatically fix problems.

Libraries/Alert/NativeAlertManager.js Outdated Show resolved Hide resolved
Libraries/Alert/NativeAlertManager.js Outdated Show resolved Hide resolved
Libraries/Alert/NativeAlertManager.js Outdated Show resolved Hide resolved
Libraries/Alert/NativeAlertManager.js Outdated Show resolved Hide resolved
Libraries/Alert/NativeAlertManager.js Outdated Show resolved Hide resolved
Libraries/Alert/NativeAlertManager.js Outdated Show resolved Hide resolved
Libraries/Alert/NativeAlertManager.js Outdated Show resolved Hide resolved
@react-native-bot react-native-bot added API: Alert Type: Enhancement A new feature or enhancement of an existing feature. labels May 16, 2019
@ericlewis ericlewis added the Flow label May 16, 2019
Copy link
Contributor

@RSNara RSNara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

But unfortunately, our current Codegen system doesn't support enums or unions. Could you replace them with strings?

type Button = {|
text: string,
onPress: () => void,
style: 'default' | 'cancel' | 'destructive',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, our Codegen doesn't support unions. 😔

'plain-text': string,
'secure-text': string,
'login-password': string,
}>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also doesn't support enums. 😔

@sasurau4
Copy link
Contributor Author

@RSNara Thanks for reviewing. 👍
I replaced enums and union to string. Please review again 🙏

@@ -10,6 +10,6 @@

'use strict';

const RCTAlertManager = require('../BatchedBridge/NativeModules').AlertManager;
const RCTAlertManager = require('./NativeAlertManager');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sasurau4,
Could you update its call-sites inside Alert.js, pls?

Also, this is a minor, but should we use import RCTAlertManager from './NativeAlertManager' here instead? I saw many PRs replacing it to this format.

@sasurau4 sasurau4 force-pushed the spec-alertmanager branch from fbceb18 to 2b5b22f Compare May 23, 2019 11:06
@sasurau4
Copy link
Contributor Author

@uqmessias Thanks for reviewing 👍
I fixed pointed out. Please review agian 🙏

) => void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('AlertManager');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since, this is an iOS only feature, please export it conditionally.

@uqmessias
Copy link
Contributor

It's almost there, just left a few comments

destructive: string,
}>;
/* 'default' | 'cancel' | 'destructive' */
export type AlertButtonStyle = string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!
But it would be better to keep this inside the spec file, because there is where we're defining types. We're could still exporting it here too or updating all call-sites that uses these types from here to the spec path.

What do you think about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with keeping types inside the spec file. I'll move types to spec file 👍

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fkgozali has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link

@analysis-bot analysis-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code analysis results:

  • eslint found some issues. Run yarn lint --fix to automatically fix problems.

Libraries/Alert/Alert.js Outdated Show resolved Hide resolved
@sasurau4
Copy link
Contributor Author

@uqmessias Thanks for comments! I worked on it! Plz review 🙏

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fkgozali has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

type AlertType,
type AlertButtonStyle,
} from './NativeAlertManager';
import {type Buttons, type Options, type AlertType} from './NativeAlertManager';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a minor and no need to update it, but you also can use

import type { Buttons, Options, AlertType } from './NativeAlertManager';

Copy link
Contributor

@uqmessias uqmessias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@uqmessias
Copy link
Contributor

We still need @RSNara's approval

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @sasurau4 in 122cc8b.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label May 28, 2019
@sasurau4 sasurau4 deleted the spec-alertmanager branch May 28, 2019 06:05
M-i-k-e-l pushed a commit to M-i-k-e-l/react-native that referenced this pull request Mar 10, 2020
Summary:
Part of facebook#24875

## Changelog

[General] [Added] - Add TurboModule spec for AlertManager
Pull Request resolved: facebook#24906

Reviewed By: lunaleaps

Differential Revision: D15471065

Pulled By: fkgozali

fbshipit-source-id: bb22e6454b1f748987f3a8cd957bfd4e027493a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: Alert CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Flow Merged This PR has been merged. Native Module Type: Enhancement A new feature or enhancement of an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants