Skip to content

Commit 9102f4d

Browse files
authored
Merge pull request Expensify#89887 from software-mansion-labs/jakubstec/domains/disable-deep-link-access-to-group-details
[Domain Control] Fix security group details visible after offline deletion
2 parents 9782e9e + 7d50863 commit 9102f4d

8 files changed

Lines changed: 55 additions & 14 deletions

File tree

src/libs/API/parameters/DeleteDomainSecurityGroupParams.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
type DeleteDomainSecurityGroupParams = {
2+
/** The account ID of the domain */
23
domainAccountID: number;
4+
5+
/** The key of the security group (e.g domain_securityGroup_12345) */
36
name: string;
47
};
58

src/libs/actions/Domain.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ function deleteDomainSecurityGroup(domainAccountID: number, groupID: string) {
19691969
key: `${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`,
19701970
value: {
19711971
[SECURITY_GROUP_KEY]: {
1972-
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
1972+
deleteGroup: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
19731973
},
19741974
},
19751975
},
@@ -1990,7 +1990,7 @@ function deleteDomainSecurityGroup(domainAccountID: number, groupID: string) {
19901990
key: `${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`,
19911991
value: {
19921992
[SECURITY_GROUP_KEY]: {
1993-
pendingAction: null,
1993+
deleteGroup: null,
19941994
},
19951995
},
19961996
},
@@ -2020,7 +2020,7 @@ function deleteDomainSecurityGroup(domainAccountID: number, groupID: string) {
20202020
key: `${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`,
20212021
value: {
20222022
[SECURITY_GROUP_KEY]: {
2023-
pendingAction: null,
2023+
deleteGroup: null,
20242024
},
20252025
},
20262026
},

src/pages/domain/Groups/DeleteGroupRow.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import ONYXKEYS from '@src/ONYXKEYS';
1212
import ROUTES from '@src/ROUTES';
1313

1414
type DeleteGroupRowProps = {
15+
/** The account ID of the domain */
1516
domainAccountID: number;
17+
18+
/** The ID of the security group */
1619
groupID: string;
1720
};
1821

@@ -48,9 +51,9 @@ function DeleteGroupRow({domainAccountID, groupID}: DeleteGroupRowProps) {
4851
if (result.action !== ModalActions.CONFIRM) {
4952
return;
5053
}
51-
52-
deleteDomainSecurityGroup(domainAccountID, groupID);
53-
Navigation.goBack(ROUTES.DOMAIN_GROUPS.getRoute(domainAccountID));
54+
Navigation.goBack(ROUTES.DOMAIN_GROUPS.getRoute(domainAccountID), {
55+
afterTransition: () => deleteDomainSecurityGroup(domainAccountID, groupID),
56+
});
5457
};
5558

5659
return groupID !== defaultSecurityGroupID ? (

src/pages/domain/Groups/DomainGroupDetailsPage.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,18 @@ function DomainGroupDetailsPage({route}: DomainGroupDetailsPageProps) {
4141
const [namePendingAction] = useOnyx(`${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`, {selector: domainSecurityGroupSettingPendingActionSelector('name', groupID)});
4242
const [nameErrors] = useOnyx(`${ONYXKEYS.COLLECTION.DOMAIN_ERRORS}${domainAccountID}`, {selector: domainSecurityGroupSettingErrorsSelector('nameErrors', groupID)});
4343

44+
const [deleteGroupPendingAction] = useOnyx(`${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`, {
45+
selector: domainSecurityGroupSettingPendingActionSelector('deleteGroup', groupID),
46+
});
47+
4448
return (
45-
<DomainNotFoundPageWrapper domainAccountID={domainAccountID}>
49+
<DomainNotFoundPageWrapper
50+
domainAccountID={domainAccountID}
51+
shouldBeBlocked={!group || !!deleteGroupPendingAction}
52+
fullPageNotFoundViewProps={{
53+
onBackButtonPress: () => Navigation.goBack(ROUTES.DOMAIN_GROUPS.getRoute(domainAccountID)),
54+
}}
55+
>
4656
<ScreenWrapper
4757
shouldEnableMaxHeight
4858
testID="DomainGroupDetailsPage"

src/pages/domain/Groups/DomainGroupEditNamePage.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {selectGroupByID} from '@selectors/Domain';
1+
import {domainSecurityGroupSettingPendingActionSelector, selectGroupByID} from '@selectors/Domain';
22
import React, {useRef} from 'react';
33
import FormProvider from '@components/Form/FormProvider';
44
import InputWrapper from '@components/Form/InputWrapper';
@@ -35,6 +35,10 @@ function DomainGroupEditNamePage({route}: DomainGroupEditNamePageProps) {
3535
selector: selectGroupByID(groupID),
3636
});
3737

38+
const [deleteGroupPendingAction] = useOnyx(`${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`, {
39+
selector: domainSecurityGroupSettingPendingActionSelector('deleteGroup', groupID),
40+
});
41+
3842
const inputRef = useRef<AnimatedTextInputRef>(null);
3943

4044
const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.EDIT_DOMAIN_GROUP_NAME_FORM>): Errors => {
@@ -50,7 +54,13 @@ function DomainGroupEditNamePage({route}: DomainGroupEditNamePageProps) {
5054
};
5155

5256
return (
53-
<DomainNotFoundPageWrapper domainAccountID={domainAccountID}>
57+
<DomainNotFoundPageWrapper
58+
domainAccountID={domainAccountID}
59+
shouldBeBlocked={!group || !!deleteGroupPendingAction}
60+
fullPageNotFoundViewProps={{
61+
onBackButtonPress: () => Navigation.goBack(ROUTES.DOMAIN_GROUPS.getRoute(domainAccountID)),
62+
}}
63+
>
5464
<ScreenWrapper
5565
onEntryTransitionEnd={() => inputRef.current?.focus()}
5666
shouldEnableMaxHeight

src/pages/domain/Groups/DomainGroupPreferredWorkspacePage.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {selectGroupByID} from '@selectors/Domain';
1+
import {domainSecurityGroupSettingPendingActionSelector, selectGroupByID} from '@selectors/Domain';
22
import {createAdminPoliciesSelector} from '@selectors/Policy';
33
import React from 'react';
44
import HeaderWithBackButton from '@components/HeaderWithBackButton';
@@ -40,6 +40,10 @@ function DomainGroupPreferredWorkspacePage({route}: DomainGroupPreferredWorkspac
4040
selector: selectGroupByID(groupID),
4141
});
4242

43+
const [deleteGroupPendingAction] = useOnyx(`${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`, {
44+
selector: domainSecurityGroupSettingPendingActionSelector('deleteGroup', groupID),
45+
});
46+
4347
const currentPolicyID = group?.restrictedPrimaryPolicyID;
4448

4549
const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: createAdminPoliciesSelector(currentPolicyID)});
@@ -69,7 +73,13 @@ function DomainGroupPreferredWorkspacePage({route}: DomainGroupPreferredWorkspac
6973
}
7074

7175
return (
72-
<DomainNotFoundPageWrapper domainAccountID={domainAccountID}>
76+
<DomainNotFoundPageWrapper
77+
domainAccountID={domainAccountID}
78+
shouldBeBlocked={!group || !!deleteGroupPendingAction}
79+
fullPageNotFoundViewProps={{
80+
onBackButtonPress: () => Navigation.goBack(ROUTES.DOMAIN_GROUPS.getRoute(domainAccountID)),
81+
}}
82+
>
7383
<ScreenWrapper
7484
shouldEnableMaxHeight
7585
testID="DomainGroupPreferredWorkspacePage"

src/types/onyx/DomainPendingActions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ type DomainMemberPendingActions = {
4040
* Represents the pending actions related to a domain's security group.
4141
*/
4242
type DomainSecurityGroupPendingActions = {
43+
/**
44+
* Pending action for deleting a security group
45+
*/
46+
deleteGroup?: OnyxCommon.PendingAction;
47+
4348
/**
4449
* Pending action for the security group name
4550
*/

tests/actions/DomainTest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ describe('actions/Domain', () => {
11121112
optimisticData: expect.arrayContaining([
11131113
expect.objectContaining({
11141114
key: `${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`,
1115-
value: {[SECURITY_GROUP_KEY]: {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}},
1115+
value: {[SECURITY_GROUP_KEY]: {deleteGroup: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}},
11161116
}),
11171117
expect.objectContaining({
11181118
key: `${ONYXKEYS.COLLECTION.DOMAIN_ERRORS}${domainAccountID}`,
@@ -1137,7 +1137,7 @@ describe('actions/Domain', () => {
11371137
}),
11381138
expect.objectContaining({
11391139
key: `${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`,
1140-
value: {[SECURITY_GROUP_KEY]: {pendingAction: null}},
1140+
value: {[SECURITY_GROUP_KEY]: {deleteGroup: null}},
11411141
}),
11421142
expect.objectContaining({
11431143
key: `${ONYXKEYS.COLLECTION.DOMAIN_ERRORS}${domainAccountID}`,
@@ -1158,7 +1158,7 @@ describe('actions/Domain', () => {
11581158
failureData: expect.arrayContaining([
11591159
expect.objectContaining({
11601160
key: `${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`,
1161-
value: {[SECURITY_GROUP_KEY]: {pendingAction: null}},
1161+
value: {[SECURITY_GROUP_KEY]: {deleteGroup: null}},
11621162
}),
11631163
expect.objectContaining({
11641164
key: `${ONYXKEYS.COLLECTION.DOMAIN_ERRORS}${domainAccountID}`,

0 commit comments

Comments
 (0)