Skip to content

Commit

Permalink
Merge pull request #26932 from software-mansion-labs/@kosmydel/ts/Tab
Browse files Browse the repository at this point in the history
[TS migration] Migrate 'Tab.js' lib to TypeScript
  • Loading branch information
johnmlee101 authored Sep 12, 2023
2 parents cb73cde + 0aa14f2 commit 8032edd
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ const ONYXKEYS = {
// The last update ID that was applied to the client
ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT: 'OnyxUpdatesLastUpdateIDAppliedToClient',

// Manual request tab selector
SELECTED_TAB: 'selectedTab',

// Receipt upload modal
RECEIPT_MODAL: 'receiptModal',

Expand Down Expand Up @@ -255,6 +252,9 @@ const ONYXKEYS = {
SECURITY_GROUP: 'securityGroup_',
TRANSACTION: 'transactions_',

// Manual request tab selector
SELECTED_TAB: 'selectedTab_',

/** This is deprecated, but needed for a migration, so we still need to include it here so that it will be initialized in Onyx.init */
DEPRECATED_POLICY_MEMBER_LIST: 'policyMemberList_',
},
Expand Down Expand Up @@ -364,7 +364,6 @@ type OnyxValues = {
[ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID]: string;
[ONYXKEYS.PREFERRED_THEME]: ValueOf<typeof CONST.THEME>;
[ONYXKEYS.IS_USING_MEMORY_ONLY_KEYS]: boolean;
[ONYXKEYS.SELECTED_TAB]: string;
[ONYXKEYS.RECEIPT_MODAL]: OnyxTypes.ReceiptModal;
[ONYXKEYS.MAPBOX_ACCESS_TOKEN]: OnyxTypes.MapboxAccessToken;
[ONYXKEYS.ONYX_UPDATES_FROM_SERVER]: OnyxTypes.OnyxUpdatesFromServer;
Expand All @@ -391,6 +390,7 @@ type OnyxValues = {
[ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING]: boolean;
[ONYXKEYS.COLLECTION.SECURITY_GROUP]: OnyxTypes.SecurityGroup;
[ONYXKEYS.COLLECTION.TRANSACTION]: OnyxTypes.Transaction;
[ONYXKEYS.COLLECTION.SELECTED_TAB]: string;

// Forms
[ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM]: OnyxTypes.AddDebitCardForm;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/OnyxTabNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ OnyxTabNavigator.displayName = 'OnyxTabNavigator';

export default withOnyx({
selectedTab: {
key: ({id}) => `${ONYXKEYS.SELECTED_TAB}_${id}`,
key: ({id}) => `${ONYXKEYS.COLLECTION.SELECTED_TAB}${id}`,
},
})(OnyxTabNavigator);
7 changes: 2 additions & 5 deletions src/libs/actions/Tab.js → src/libs/actions/Tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ import ONYXKEYS from '../../ONYXKEYS';

/**
* Sets the selected tab for a given tab ID
*
* @param {String} id
* @param {String} index
*/
function setSelectedTab(id, index) {
Onyx.merge(`${ONYXKEYS.SELECTED_TAB}_${id}`, index);
function setSelectedTab(id: string, index: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${id}`, index);
}

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/MoneyRequestDatePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ export default withOnyx({
key: ONYXKEYS.IOU,
},
selectedTab: {
key: `${ONYXKEYS.SELECTED_TAB}_${CONST.TAB.RECEIPT_TAB_ID}`,
key: `${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.RECEIPT_TAB_ID}`,
},
})(MoneyRequestDatePage);
2 changes: 1 addition & 1 deletion src/pages/iou/MoneyRequestDescriptionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ export default withOnyx({
key: ONYXKEYS.IOU,
},
selectedTab: {
key: `${ONYXKEYS.SELECTED_TAB}_${CONST.TAB.RECEIPT_TAB_ID}`,
key: `${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.RECEIPT_TAB_ID}`,
},
})(MoneyRequestDescriptionPage);
2 changes: 1 addition & 1 deletion src/pages/iou/MoneyRequestSelectorPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ export default withOnyx({
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}`,
},
selectedTab: {
key: `${ONYXKEYS.SELECTED_TAB}_${CONST.TAB.RECEIPT_TAB_ID}`,
key: `${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.RECEIPT_TAB_ID}`,
},
})(MoneyRequestSelectorPage);
2 changes: 1 addition & 1 deletion src/pages/iou/steps/MoneyRequestConfirmPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export default compose(
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
selectedTab: {
key: `${ONYXKEYS.SELECTED_TAB}_${CONST.TAB.RECEIPT_TAB_ID}`,
key: `${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.RECEIPT_TAB_ID}`,
},
}),
)(MoneyRequestConfirmPage);
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default compose(
withOnyx({
iou: {key: ONYXKEYS.IOU},
selectedTab: {
key: `${ONYXKEYS.SELECTED_TAB}_${CONST.TAB.RECEIPT_TAB_ID}`,
key: `${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.RECEIPT_TAB_ID}`,
},
}),
)(MoneyRequestParticipantsPage);
2 changes: 1 addition & 1 deletion src/pages/iou/steps/NewRequestAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,6 @@ export default withOnyx({
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(route, 'params.reportID', '')}`,
},
selectedTab: {
key: `${ONYXKEYS.SELECTED_TAB}_${CONST.TAB.RECEIPT_TAB_ID}`,
key: `${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.RECEIPT_TAB_ID}`,
},
})(NewRequestAmountPage);

0 comments on commit 8032edd

Please sign in to comment.