Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/pages/workspace/WorkspaceMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,17 @@ function WorkspaceMembersPage({personalDetails, route, policy}: WorkspaceMembers
[isPolicyAdmin, policy, policyID, route.params.policyID],
);

const toggleOrNavigate = useCallback(
(item: MemberOption) => {
if (shouldUseNarrowLayout && selectionMode?.isEnabled) {
toggleUser(item.accountID);
return;
}
openMemberDetails(item);
},
[shouldUseNarrowLayout, selectionMode, openMemberDetails, toggleUser],
);

/**
* Dismisses the errors on one item
*/
Expand Down Expand Up @@ -794,7 +805,7 @@ function WorkspaceMembersPage({personalDetails, route, policy}: WorkspaceMembers
shouldUseUserSkeletonView
disableKeyboardShortcuts={removeMembersConfirmModalVisible}
headerMessage={shouldUseNarrowLayout ? headerMessage : undefined}
onSelectRow={openMemberDetails}
onSelectRow={toggleOrNavigate}
shouldSingleExecuteRowSelect={!isPolicyAdmin}
onCheckboxPress={(item) => toggleUser(item.accountID)}
onSelectAll={filteredData.length > 0 ? () => toggleAllUsers(filteredData) : undefined}
Expand Down
13 changes: 12 additions & 1 deletion src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ function PolicyDistanceRatesPage({
};

const toggleRate = (rate: RateForList) => {
if (rate.isDisabledCheckbox) {
return;
}
Comment on lines +246 to +248

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (rate.isDisabledCheckbox) {
return;
}

@ChavdaSachin we don't need this code bcoz onSelectRow only executes if the item is disabled.

setSelectedDistanceRates((prevSelectedRates) => {
if (prevSelectedRates.includes(rate.value)) {
return prevSelectedRates.filter((selectedRate) => selectedRate !== rate.value);
Expand All @@ -263,6 +266,14 @@ function PolicyDistanceRatesPage({
}
};

const toggleOrNavigate = (rate: RateForList) => {
if (shouldUseNarrowLayout && selectionMode?.isEnabled) {
toggleRate(rate);
return;
}
openRateDetails(rate);
};

const getCustomListHeader = () => {
if (filteredDistanceRatesList.length === 0) {
return null;
Expand Down Expand Up @@ -427,7 +438,7 @@ function PolicyDistanceRatesPage({
shouldUseDefaultRightHandSideCheckmark={false}
selectedItems={selectedDistanceRates}
onCheckboxPress={toggleRate}
onSelectRow={openRateDetails}
onSelectRow={toggleOrNavigate}
onSelectAll={filteredDistanceRatesList.length > 0 ? toggleAllRates : undefined}
onDismissError={dismissError}
ListItem={TableListItem}
Expand Down
13 changes: 12 additions & 1 deletion src/pages/workspace/tags/WorkspaceViewTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
}

const toggleTag = (tag: TagListItem) => {
if (tag.isDisabledCheckbox) {
return;
}
Comment on lines +169 to +171

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (tag.isDisabledCheckbox) {
return;
}

setSelectedTags((prev) => {
if (prev.includes(tag.value)) {
return prev.filter((selectedTag) => selectedTag !== tag.value);
Expand Down Expand Up @@ -202,6 +205,14 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
);
};

const toggleOrNavigate = (tag: TagListItem) => {
if (shouldUseNarrowLayout && selectionMode?.isEnabled) {
toggleTag(tag);
return;
}
navigateToTagSettings(tag);
};

const deleteTags = () => {
deletePolicyTags(policyID, selectedTags);
setIsDeleteTagsConfirmModalVisible(false);
Expand Down Expand Up @@ -405,7 +416,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
selectedItems={selectedTags}
shouldUseDefaultRightHandSideCheckmark={false}
onCheckboxPress={toggleTag}
onSelectRow={navigateToTagSettings}
onSelectRow={toggleOrNavigate}
onSelectAll={filteredTagList.length > 0 ? toggleAllTags : undefined}
showScrollIndicator
ListItem={TableListItem}
Expand Down
Loading