Skip to content

Commit 819416c

Browse files
authored
Merge pull request Expensify#90702 from Expensify/chore/89355-nabs
[No QA] chore: some minor code improvements to edit agent
2 parents e19542f + e30b41b commit 819416c

4 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/pages/settings/Agents/AgentInfoRow.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ type AgentInfoRowProps = {
1818
login: string;
1919

2020
/** Whether the agent is pending deletion */
21-
isDeleted?: boolean;
21+
isPendingDeletion?: boolean;
2222
};
2323

24-
function AgentInfoRow({accountID, displayName, login, isDeleted = false}: AgentInfoRowProps) {
24+
function AgentInfoRow({accountID, displayName, login, isPendingDeletion = false}: AgentInfoRowProps) {
2525
const styles = useThemeStyles();
2626
const StyleUtils = useStyleUtils();
2727

@@ -36,13 +36,13 @@ function AgentInfoRow({accountID, displayName, login, isDeleted = false}: AgentI
3636
<View style={[styles.flex1, styles.gap1]}>
3737
<Text
3838
numberOfLines={1}
39-
style={[styles.textStrong, isDeleted ? styles.offlineFeedbackDeleted : {}]}
39+
style={[styles.textStrong, isPendingDeletion ? styles.offlineFeedbackDeleted : {}]}
4040
>
4141
{displayName}
4242
</Text>
4343
<Text
4444
numberOfLines={1}
45-
style={[styles.mutedNormalTextLabel, isDeleted ? styles.offlineFeedbackDeleted : {}]}
45+
style={[styles.mutedNormalTextLabel, isPendingDeletion ? styles.offlineFeedbackDeleted : {}]}
4646
>
4747
{login}
4848
</Text>

src/pages/settings/Agents/AgentsListRow.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function AgentsListRow({accountID, displayName, login, pendingAction, errors, on
4545
const {shouldUseNarrowLayout} = useResponsiveLayout();
4646
const icons = useMemoizedLazyExpensifyIcons(['DotIndicator']);
4747

48-
const isDeleted = pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
48+
const isPendingDeletion = pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
4949
const navigateToEdit = () => Navigation.navigate(ROUTES.SETTINGS_AGENTS_EDIT.getRoute(accountID));
5050

5151
return (
@@ -63,13 +63,13 @@ function AgentsListRow({accountID, displayName, login, pendingAction, errors, on
6363
accessibilityLabel={displayName}
6464
role={CONST.ROLE.BUTTON}
6565
sentryLabel="AgentsListRow-Edit"
66-
disabled={isDeleted}
66+
disabled={isPendingDeletion}
6767
>
6868
<AgentInfoRow
6969
accountID={accountID}
7070
displayName={displayName}
7171
login={login}
72-
isDeleted={isDeleted}
72+
isPendingDeletion={isPendingDeletion}
7373
/>
7474
{!!brickRoadIndicator && (
7575
<Icon
@@ -84,7 +84,7 @@ function AgentsListRow({accountID, displayName, login, pendingAction, errors, on
8484
accountID={accountID}
8585
displayName={displayName}
8686
login={login}
87-
isDeleted={isDeleted}
87+
isPendingDeletion={isPendingDeletion}
8888
/>
8989
{!!brickRoadIndicator && (
9090
<Icon
@@ -96,7 +96,7 @@ function AgentsListRow({accountID, displayName, login, pendingAction, errors, on
9696
small
9797
text={translate('common.edit')}
9898
onPress={navigateToEdit}
99-
isDisabled={isDeleted}
99+
isDisabled={isPendingDeletion}
100100
/>
101101
</View>
102102
)}

src/pages/settings/Agents/AgentsPage.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ function AgentsPage() {
5959
if (!details) {
6060
return null;
6161
}
62+
const hasNameErrors = Object.keys(agentPrompt?.nameErrors ?? {}).length > 0;
63+
const hasPromptErrors = Object.keys(agentPrompt?.promptErrors ?? {}).length > 0;
6264
return {
6365
accountID,
6466
displayName: details.displayName ?? details.login ?? '',
6567
login: details.login ?? '',
6668
pendingAction: agentPrompt?.pendingAction,
6769
errors: agentPrompt?.errors,
68-
hasUpdateErrors:
69-
!!(agentPrompt?.nameErrors && Object.keys(agentPrompt.nameErrors).length > 0) || !!(agentPrompt?.promptErrors && Object.keys(agentPrompt.promptErrors).length > 0),
70+
hasUpdateErrors: hasNameErrors || hasPromptErrors,
7071
};
7172
})
7273
.filter(Boolean) as AgentItem[];

src/pages/settings/Agents/Fields/EditPromptPage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {View} from 'react-native';
2+
import {Platform, View} from 'react-native';
33
import FormProvider from '@components/Form/FormProvider';
44
import InputWrapper from '@components/Form/InputWrapper';
55
import type {FormInputErrors, FormOnyxValues} from '@components/Form/types';
@@ -42,6 +42,10 @@ function EditPromptPage({route}: EditPromptPageProps) {
4242
};
4343

4444
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER, (e) => {
45+
if (Platform.OS !== 'web') {
46+
return;
47+
}
48+
4549
const textarea = e?.target as HTMLTextAreaElement;
4650

4751
if (!textarea) {

0 commit comments

Comments
 (0)