Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc/dec-11-2023 #675

Merged
merged 10 commits into from
Dec 18, 2023
2 changes: 1 addition & 1 deletion apps/api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"configurations": {
"production": {
"optimization": true,
"optimization": false,
"extractLicenses": true,
"inspect": false,
"sourceMap": true,
Expand Down
4 changes: 2 additions & 2 deletions apps/jetstream-e2e/src/pageObjectModels/QueryPage.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class QueryPage {
}
await this.page.getByRole('button', { name: 'Collapse SOQL Query' }).click();

await this.page.getByRole('button', { name: 'History' }).click();
await this.page.getByLabel('Query History').click();

// verify query history
await expect(
Expand All @@ -229,7 +229,7 @@ export class QueryPage {
buttonName = 'Saved';
role = 'button';
}
await this.page.getByRole('button', { name: 'History' }).click();
await this.page.getByLabel('Query History').click();
await this.page.getByTestId(`query-history-${query}`).getByRole(role, { name: buttonName }).click();
}

Expand Down
20 changes: 16 additions & 4 deletions apps/jetstream/src/app/components/anonymous-apex/AnonymousApex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ import {
CopyToClipboard,
Grid,
Icon,
KeyboardShortcut,
SalesforceLogin,
Spinner,
Tooltip,
ViewDocsLink,
getModifierKey,
} from '@jetstream/ui';
import Editor, { OnMount, useMonaco } from '@monaco-editor/react';
import localforage from 'localforage';
Expand Down Expand Up @@ -248,10 +251,19 @@ export const AnonymousApex: FunctionComponent<AnonymousApexProps> = () => {
onSelected={(item) => setLogLevel(item.id)}
/>
</div>
<button className="slds-button slds-button_brand" onClick={() => onSubmit(apex)}>
<Icon type="utility" icon="apex" className="slds-button__icon slds-button__icon_left" omitContainer />
Submit
</button>
<Tooltip
delay={[300, null]}
content={
<div className="slds-p-bottom_small">
<KeyboardShortcut inverse keys={[getModifierKey(), 'enter']} />
</div>
}
>
<button className="slds-button slds-button_brand" onClick={() => onSubmit(apex)}>
<Icon type="utility" icon="apex" className="slds-button__icon slds-button__icon_left" omitContainer />
Submit
</button>
</Tooltip>
</Fragment>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const LogViewedRenderer: FunctionComponent<RenderCellProps<ApexLogWithVie
return null;
};

const INITIAL_SORT = [{ columnKey: 'LastModifiedDate', direction: 'DESC' } as const];

const COLUMNS: ColumnWithFilter<ApexLogWithViewed>[] = [
{
name: '',
Expand Down Expand Up @@ -101,7 +103,13 @@ export const DebugLogViewerTable: FunctionComponent<DebugLogViewerTableProps> =

return (
<AutoFullHeightContainer fillHeight setHeightAttr bottomBuffer={75}>
<DataTable columns={COLUMNS} data={logs} getRowKey={getRowId} onCellClick={handleSelectionChanged} />
<DataTable
columns={COLUMNS}
data={logs}
getRowKey={getRowId}
initialSortColumns={INITIAL_SORT}
onCellClick={handleSelectionChanged}
/>
</AutoFullHeightContainer>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function useDebugLogs(org: SalesforceOrgUi, { limit, pollInterval, userId
setLogs(queryResults.records);
} else {
setLogs((logs) =>
orderBy(Object.values({ ...getMapOf(logs, 'Id'), ...getMapOf(queryResults.records, 'Id') }), ['Id'], ['asc'])
orderBy(Object.values({ ...getMapOf(logs, 'Id'), ...getMapOf(queryResults.records, 'Id') }), ['LastModifiedDate'], ['desc'])
);
}
setLoading(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export const DeployMetadataDeployment: FunctionComponent<DeployMetadataDeploymen
/>
<DeployMetadataToOrg selectedOrg={selectedOrg} loading={loading} selectedRows={selectedRows} />
<DropDown
className="slds-button_last"
position="right"
items={[
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { css } from '@emotion/react';
import { logger } from '@jetstream/shared/client-logger';
import { ANALYTICS_KEYS } from '@jetstream/shared/constants';
import { useRollbar } from '@jetstream/shared/ui-utils';
import { hasModifierKey, isHKey, useGlobalEventHandler, useRollbar } from '@jetstream/shared/ui-utils';
import { MapOf, SalesforceDeployHistoryItem, SalesforceOrgUi } from '@jetstream/types';
import { EmptyState, FileDownloadModal, Icon, Modal, OpenRoadIllustration, ScopedNotification, Spinner, fireToast } from '@jetstream/ui';
import {
EmptyState,
FileDownloadModal,
Icon,
KeyboardShortcut,
Modal,
OpenRoadIllustration,
ScopedNotification,
Spinner,
Tooltip,
fireToast,
getModifierKey,
} from '@jetstream/ui';
import classNames from 'classnames';
import { Fragment, useEffect, useRef, useState } from 'react';
import { Fragment, useCallback, useEffect, useRef, useState } from 'react';
import { useRecoilState, useRecoilValue } from 'recoil';
import * as fromAppState from '../../../app-state';
import ConfirmPageChange from '../../core/ConfirmPageChange';
Expand Down Expand Up @@ -57,6 +69,20 @@ export const DeployMetadataHistoryModal = ({ className }: DeployMetadataHistoryM
const [errorMessage, setError] = useState<string | null>(null);
const orgsById = useRecoilValue(fromAppState.salesforceOrgsById);

const onKeydown = useCallback(
(event: KeyboardEvent) => {
if (!isOpen && hasModifierKey(event as any) && isHKey(event as any)) {
event.stopPropagation();
event.preventDefault();
handleToggleOpen(true, 'keyboardShortcut');
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[isOpen]
);

useGlobalEventHandler('keydown', onKeydown);

useEffect(() => {
if (isOpen) {
setIsLoading(true);
Expand All @@ -77,10 +103,10 @@ export const DeployMetadataHistoryModal = ({ className }: DeployMetadataHistoryM
}
}, [isOpen]);

function handleToggleOpen(open: boolean) {
function handleToggleOpen(open: boolean, source = 'buttonClick') {
setIsOpen(open);
if (open) {
trackEvent(ANALYTICS_KEYS.deploy_history_opened);
trackEvent(ANALYTICS_KEYS.deploy_history_opened, source);
}
}

Expand Down Expand Up @@ -161,15 +187,23 @@ export const DeployMetadataHistoryModal = ({ className }: DeployMetadataHistoryM

return (
<Fragment>
<button
className={classNames('slds-button slds-button_neutral', className)}
aria-haspopup="true"
title="View deployment history"
onClick={() => handleToggleOpen(true)}
<Tooltip
content={
<div className="slds-p-bottom_small">
<KeyboardShortcut inverse keys={[getModifierKey(), 'h']} />
</div>
}
>
<Icon type="utility" icon="date_time" className="slds-button__icon slds-button__icon_left" omitContainer />
<span>History</span>
</button>
<button
className={classNames('slds-button slds-button_neutral slds-m-right_xx-small', className)}
aria-haspopup="true"
title="View deployment history"
onClick={() => handleToggleOpen(true)}
>
<Icon type="utility" icon="date_time" className="slds-button__icon slds-button__icon_left" omitContainer />
<span>History</span>
</button>
</Tooltip>
{downloadPackageModalState.open && downloadPackageModalState.org && downloadPackageModalState.data && (
<FileDownloadModal
org={downloadPackageModalState.org}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,12 @@ export function getDataGraph(
(
{
transformedRecord,
externalIdValue,
recordIdForUpdate,
dependencies,
}: { transformedRecord: MapOf<any>; externalIdValue: string | null; recordIdForUpdate: string | null; dependencies: string[] },
header
) => {
let externalIdValue: string | null = null;
const field = dataset.fieldsByName[header.toLowerCase()];
let value = record[header];
const valueIsNull = isNil(value) || (isString(value) && !value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { css } from '@emotion/react';
import { TITLES } from '@jetstream/shared/constants';
import { useTitle } from '@jetstream/shared/ui-utils';
import { useNonInitialEffect, useTitle } from '@jetstream/shared/ui-utils';
import { SplitWrapper as Split } from '@jetstream/splitjs';
import { ListItem, SalesforceOrgUi } from '@jetstream/types';
import { ListItem, ListItemGroup, SalesforceOrgUi } from '@jetstream/types';
import { AutoFullHeightContainer } from '@jetstream/ui';
import type { DescribeGlobalSObjectResult } from 'jsforce';
import { FunctionComponent, useEffect, useRef, useState } from 'react';
import { useRecoilState, useRecoilValue } from 'recoil';
import { applicationCookieState, selectedOrgState } from '../../app-state';
import PlatformEventMonitorFetchEventStatus from './PlatformEventMonitorFetchEventStatus';
import PlatformEventMonitorListenerCard from './PlatformEventMonitorListenerCard';
import PlatformEventMonitorPublisherCard from './PlatformEventMonitorPublisherCard';
import { PlatformEventObject } from './platform-event-monitor.types';
import { usePlatformEvent } from './usePlatformEvent';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand All @@ -32,8 +32,9 @@ export const PlatformEventMonitor: FunctionComponent<PlatformEventMonitorProps>
subscribe,
unsubscribe,
} = usePlatformEvent({ selectedOrg });
const [platformEventsList, setPlatformEventsList] = useState<ListItem<string, DescribeGlobalSObjectResult>[]>([]);
const [subscribedPlatformEventsList, setSubscribedPlatformEventsList] = useState<ListItem<string, DescribeGlobalSObjectResult>[]>([]);
const [platformEventsListSubscriptions, setPlatformEventsListSubscriptions] = useState<ListItemGroup<string, PlatformEventObject>[]>([]);
const [platformEventsListPublisher, setPlatformEventsListPublisher] = useState<ListItem<string, PlatformEventObject>[]>([]);
const [subscribedPlatformEventsList, setSubscribedPlatformEventsList] = useState<ListItem<string, PlatformEventObject>[]>([]);
const [picklistKey, setPicklistKey] = useState<number>(1);
const [selectedSubscribeEvent, setSelectedSubscribeEvent] = useState<string | null>(null);
const [selectedPublishEvent, setSelectedPublishEvent] = useState<string | null>(null);
Expand All @@ -45,30 +46,88 @@ export const PlatformEventMonitor: FunctionComponent<PlatformEventMonitorProps>
};
}, []);

useNonInitialEffect(() => {
setSelectedPublishEvent(null);
}, [selectedOrg]);

useEffect(() => {
const events = platformEvents.map<ListItem<string, DescribeGlobalSObjectResult>>((event) => ({
id: event.name,
label: event.label,
secondaryLabel: event.name,
value: event.name,
meta: event,
}));
if (events.length) {
setPlatformEventsList(events);
setSelectedSubscribeEvent(events[0].id);
setSelectedPublishEvent(events[0].id);
const subscriptionEvents: ListItemGroup<string, PlatformEventObject>[] = [
{
id: 'PLATFORM_EVENT',
label: 'Platform Events (Custom)',
items: platformEvents
.filter((item) => item.type === 'PLATFORM_EVENT')
.map<ListItem<string, PlatformEventObject>>((event) => ({
id: event.channel,
label: `${event.label} (${event.name})`,
secondaryLabel: event.channel,
secondaryLabelOnNewLine: true,
value: event.channel,
meta: event,
})),
},
{
id: 'PLATFORM_EVENT_STANDARD',
label: 'Platform Events (Standard)',
items: platformEvents
.filter((item) => item.type === 'PLATFORM_EVENT_STANDARD')
.map<ListItem<string, PlatformEventObject>>((event) => ({
id: event.channel,
label: `${event.label} (${event.name})`,
secondaryLabel: event.channel,
secondaryLabelOnNewLine: true,
value: event.channel,
meta: event,
})),
},
{
id: 'CHANGE_EVENT',
label: 'Change Data Capture Events',
items: platformEvents
.filter((item) => item.type === 'CHANGE_EVENT')
.map<ListItem<string, PlatformEventObject>>((event) => ({
id: event.channel,
label: `${event.label} (${event.name})`,
secondaryLabel: event.channel,
secondaryLabelOnNewLine: true,
value: event.channel,
meta: event,
})),
},
];

setPlatformEventsListSubscriptions(subscriptionEvents);
setSelectedSubscribeEvent(platformEvents.length ? platformEvents[0].channel : null);
setPicklistKey((prevKey) => prevKey + 1);

const publisherEvents = platformEvents
.filter((event) => event.type === 'PLATFORM_EVENT')
.map<ListItem<string, PlatformEventObject>>((event) => ({
id: event.name,
label: event.label,
secondaryLabel: event.name,
secondaryLabelOnNewLine: true,
value: event.name,
meta: event,
}));

if (publisherEvents.length) {
setPlatformEventsListPublisher(publisherEvents);
setSelectedPublishEvent(publisherEvents[0].id);
setPicklistKey((prevKey) => prevKey + 1);
}
}, [platformEvents]);

useEffect(() => {
setSubscribedPlatformEventsList(platformEventsList.filter((item) => !!messagesByChannel[item.value]));
}, [messagesByChannel]);
setSubscribedPlatformEventsList(
platformEventsListSubscriptions.flatMap((item) => item.items).filter((item) => !!messagesByChannel[item.value])
);
}, [messagesByChannel, platformEventsListSubscriptions]);

const hasErrorOrNoEvents = !hasPlatformEvents || platformEventFetchError;

return (
<AutoFullHeightContainer className="slds-p-horizontal_x-small slds-scrollable_none">
<AutoFullHeightContainer className="slds-p-horizontal_x-small slds-scrollable_none" key={selectedOrg.uniqueId}>
{hasErrorOrNoEvents && (
<PlatformEventMonitorFetchEventStatus
serverUrl={serverUrl}
Expand All @@ -94,7 +153,7 @@ export const PlatformEventMonitor: FunctionComponent<PlatformEventMonitorProps>
<PlatformEventMonitorListenerCard
loading={loadingPlatformEvents}
picklistKey={picklistKey}
platformEventsList={platformEventsList}
platformEventsList={platformEventsListSubscriptions}
subscribedPlatformEventsList={subscribedPlatformEventsList}
selectedSubscribeEvent={selectedSubscribeEvent}
messagesByChannel={messagesByChannel}
Expand All @@ -110,7 +169,7 @@ export const PlatformEventMonitor: FunctionComponent<PlatformEventMonitorProps>
serverUrl={serverUrl}
loadingPlatformEvents={loadingPlatformEvents}
picklistKey={picklistKey}
platformEventsList={platformEventsList}
platformEventsList={platformEventsListPublisher}
selectedPublishEvent={selectedPublishEvent}
onSelectedPublishEvent={setSelectedPublishEvent}
publish={publish}
Expand Down
Loading