Skip to content

Commit

Permalink
Fix record view/search form submission
Browse files Browse the repository at this point in the history
Add state for no search results
  • Loading branch information
paustint committed Feb 8, 2025
1 parent d37c8da commit cdd49bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ export function SfdcPageButtonRecordSearch({ sfHost }: SfdcPageButtonRecordSearc
if (!isValidRecordId) {
return;
}
window.open(`${chrome.runtime.getURL('app.html')}?host=${sfHost}&action=VIEW_RECORD&actionValue=${recordId}`, '_blank');
}

function handleEditRecord() {
if (!isValidRecordId) {
return;
}
window.open(`${chrome.runtime.getURL('app.html')}?host=${sfHost}&action=EDIT_RECORD&actionValue=${recordId}`, '_blank');
}

Expand All @@ -37,7 +43,12 @@ export function SfdcPageButtonRecordSearch({ sfHost }: SfdcPageButtonRecordSearc
<button className="slds-button slds-button_stretch slds-button_brand" type="submit" disabled={!isValidRecordId}>
View Record
</button>
<button className="slds-button slds-button_stretch slds-button_neutral" type="submit" disabled={!isValidRecordId}>
<button
className="slds-button slds-button_stretch slds-button_neutral"
type="button"
disabled={!isValidRecordId}
onClick={() => handleEditRecord()}
>
Edit Record
</button>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export function SfdcPageButtonUserSearch({ sfHost }: SfdcPageButtonUserSearchPro
const [loading, setLoading] = useState(false);
const [errorMessage, setErrorMessage] = useState<string | null>(null);

const [selectedUser, setSelectedUser] = useState<User | null>(null);
const [usersResults, setUsersResults] = useState<QueryResults<User>>();

const [org, setOrg] = useState<OrgAndSessionInfo | null>(null);
Expand Down Expand Up @@ -93,7 +92,7 @@ export function SfdcPageButtonUserSearch({ sfHost }: SfdcPageButtonUserSearchPro
})
.then(({ data }) => {
if (currentSearchRef.current === currentSearchValue) {
setUsersResults(data as any);
setUsersResults(data as QueryResults<User>);
setLoading(false);
}
})
Expand Down Expand Up @@ -124,6 +123,9 @@ export function SfdcPageButtonUserSearch({ sfHost }: SfdcPageButtonUserSearchPro
{errorMessage}
</ScopedNotification>
)}
{!!usersResults && !usersResults.queryResults.totalSize && (
<p className="slds-text-align_center slds-m-vertical_x-small slds-text-heading_small">No Results</p>
)}
{!!usersResults?.queryResults?.totalSize && (
<List
css={css`
Expand All @@ -132,12 +134,8 @@ export function SfdcPageButtonUserSearch({ sfHost }: SfdcPageButtonUserSearchPro
`}
items={usersResults.queryResults.records}
isActive={(item: User) => item.Id === searchTerm}
onSelected={(key: string) => {
const user = usersResults?.queryResults.records.find(({ Id }) => Id === key);
if (user) {
setSelectedUser(user);
}
}}
// eslint-disable-next-line @typescript-eslint/no-empty-function
onSelected={(key: string) => {}}
getContent={(user: User) => ({
key: user.Id,
id: user.Id,
Expand Down
2 changes: 1 addition & 1 deletion apps/jetstream-web-extension/src/serviceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ async function handleInitOrg(
}

/**
* Used to make API requests outside of the extension context (e.x. on a Salesforce page)
* Used to make API requests outside of the extension context (e.g. on a Salesforce page)
*/
async function handleApiRequestEvent(
{ method, sfHost, pathname, body, queryParams }: ApiAction['request']['data'],
Expand Down

0 comments on commit cdd49bd

Please sign in to comment.