Skip to content

Commit 45451de

Browse files
a7medevHeshamMegid
authored andcommitted
[MOB-12609] Unify Discard Alert Buttons Strings (#1001)
* Unify discard alert strings * Update Changelog * Fix Android tests
1 parent 2b0a20d commit 45451de

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v11.13.0...dev)
4+
5+
### Added
6+
7+
- Add new strings (`StringKey.discardAlertStay` and `StringKey.discardAlertDiscard`) for overriding the discard alert buttons for consistency between iOS and Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)).
8+
9+
### Deprecated
10+
11+
- Deprecate the old `StringKey.discardAlertCancel` and `StringKey.discardAlertAction` string keys for overriding the discard alert buttons as they had incosistent behavior between iOS and Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)).
12+
313
## [11.13.0](https://github.com/Instabug/Instabug-React-Native/compare/v11.12.0...v11.13.0) (July 10, 2023)
414

515
### Changed

android/src/main/java/com/instabug/reactlibrary/ArgsRegistry.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ static Map<String, Object> getAll() {
234234
put("discardAlertMessage", Key.REPORT_DISCARD_DIALOG_BODY);
235235
put("discardAlertCancel", Key.REPORT_DISCARD_DIALOG_NEGATIVE_ACTION);
236236
put("discardAlertAction", Key.REPORT_DISCARD_DIALOG_POSITIVE_ACTION);
237+
put("discardAlertStay", Key.REPORT_DISCARD_DIALOG_NEGATIVE_ACTION);
238+
put("discardAlertDiscard", Key.REPORT_DISCARD_DIALOG_POSITIVE_ACTION);
239+
237240
put("addAttachmentButtonTitleStringName", Key.REPORT_ADD_ATTACHMENT_HEADER);
238241

239242
put("reportReproStepsDisclaimerBody", Key.REPORT_REPRO_STEPS_DISCLAIMER_BODY);

android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.util.List;
4242
import java.util.Locale;
4343
import java.util.Map;
44+
import java.util.Set;
4445
import java.util.concurrent.Executors;
4546
import java.util.concurrent.ScheduledExecutorService;
4647

@@ -453,11 +454,15 @@ public void tearDown() {
453454
// given
454455
mockStatic(Log.class);
455456
Map<String, InstabugCustomTextPlaceHolder.Key> args = ArgsRegistry.placeholders;
456-
String[] keysArray = args.keySet().toArray(new String[0]);
457+
Set<String> keys = args.keySet();
458+
459+
// Ignore deprecated keys
460+
keys.remove("discardAlertCancel");
461+
keys.remove("discardAlertAction");
457462

458463
// when
459464
InstabugCustomTextPlaceHolder expectedPlaceHolders = new InstabugCustomTextPlaceHolder();
460-
for (String key : keysArray) {
465+
for (String key : keys) {
461466
InstabugCustomTextPlaceHolder.Key placeHolder = args.get(key);
462467
expectedPlaceHolders.set(placeHolder, key);
463468
rnModule.setString(key, key);
@@ -473,7 +478,7 @@ public void tearDown() {
473478
getDeclaredField("placeHolders");
474479
privateStringField.setAccessible(true);
475480
InstabugCustomTextPlaceHolder placeHolders = (InstabugCustomTextPlaceHolder) privateStringField.get(rnModule);
476-
for (String key : keysArray) {
481+
for (String key : keys) {
477482
InstabugCustomTextPlaceHolder.Key placeHolder = args.get(key);
478483
Assert.assertEquals(placeHolders.get(placeHolder), key);
479484
}

ios/RNInstabug/ArgsRegistry.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ + (ArgsDictionary *) locales {
244244
@"discardAlertMessage": kIBGDiscardAlertMessage,
245245
@"discardAlertCancel": kIBGDiscardAlertCancel,
246246
@"discardAlertAction": kIBGDiscardAlertAction,
247+
@"discardAlertDiscard": kIBGDiscardAlertCancel,
248+
@"discardAlertStay": kIBGDiscardAlertAction,
247249
@"addAttachmentButtonTitleStringName": kIBGAddAttachmentButtonTitleStringName,
248250

249251
@"reportReproStepsDisclaimerBody": kIBGReproStepsDisclaimerBody,

src/native/NativeConstants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ interface NativeStringKey {
144144
conversationTextFieldHint: any;
145145
discardAlertAction: any;
146146
discardAlertCancel: any;
147+
discardAlertStay: any;
148+
discardAlertDiscard: any;
147149
discardAlertMessage: any;
148150
discardAlertTitle: any;
149151
edgeSwipeStartHint: any;

src/utils/ArgsRegistry.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,12 @@ export enum strings {
254254
requestFeatureDescription = constants.requestFeatureDescription,
255255
discardAlertTitle = constants.discardAlertTitle,
256256
discardAlertMessage = constants.discardAlertMessage,
257+
/** @deprecated Use {@link discardAlertStay} and {@link discardAlertDiscard} instead */
257258
discardAlertCancel = constants.discardAlertCancel,
259+
/** @deprecated Use {@link discardAlertStay} and {@link discardAlertDiscard} instead */
258260
discardAlertAction = constants.discardAlertAction,
261+
discardAlertDiscard = constants.discardAlertDiscard,
262+
discardAlertStay = constants.discardAlertStay,
259263
addAttachmentButtonTitleStringName = constants.addAttachmentButtonTitleStringName,
260264
reportReproStepsDisclaimerBody = constants.reportReproStepsDisclaimerBody,
261265
reportReproStepsDisclaimerLink = constants.reportReproStepsDisclaimerLink,

src/utils/Enums.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,12 @@ export enum StringKey {
160160
commentFieldHintForQuestion = constants.commentFieldHintForQuestion,
161161
conversationsHeaderTitle = constants.conversationsHeaderTitle,
162162
conversationTextFieldHint = constants.conversationTextFieldHint,
163+
/** @deprecated Use {@link discardAlertStay} and {@link discardAlertDiscard} instead */
163164
discardAlertAction = constants.discardAlertAction,
165+
/** @deprecated Use {@link discardAlertStay} and {@link discardAlertDiscard} instead */
164166
discardAlertCancel = constants.discardAlertCancel,
167+
discardAlertDiscard = constants.discardAlertDiscard,
168+
discardAlertStay = constants.discardAlertStay,
165169
discardAlertMessage = constants.discardAlertMessage,
166170
discardAlertTitle = constants.discardAlertTitle,
167171
edgeSwipeStartHint = constants.edgeSwipeStartHint,

0 commit comments

Comments
 (0)