Skip to content

Commit

Permalink
Merge branch 'main' into feat/330
Browse files Browse the repository at this point in the history
  • Loading branch information
paustint committed Aug 20, 2023
2 parents c0af0a2 + 45fd903 commit a4ce4db
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SFDC_CONSUMER_KEY='3MVG9tSqyyAXNH5ItQtuplEg40Ks_MLSG37L1PV.TLDjsCbdp7EDonFUW0csS
SFDC_CONSUMER_SECRET='F77C1B4AF03CF51B290A591766F4C430E3136949A636D4AA5339F8EB6A40052A'

# API VERSION TO USE
NX_SFDC_API_VERSION='55.0'
NX_SFDC_API_VERSION='58.0'

# If set to true, then authentication will be bypassed
# You will use a test account instead of a real account - only works if running locally
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
SFDC_CONSUMER_KEY: ${{ secrets.SFDC_CONSUMER_KEY }}
SFDC_CONSUMER_SECRET: ${{ secrets.SFDC_CONSUMER_SECRET }}
SFDC_ENC_KEY: ${{ secrets.SFDC_ENC_KEY }}
SFDC_API_VERSION: '57.0'
SFDC_API_VERSION: '58.0'

services:
postgres:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function getFieldMetadata(org: SalesforceOrgUi, sobject: string): P
// related records
if (relatedObjects.size > 0) {
const relatedEntities = (
await queryWithCache<EntityParticleRecord>(org, getExternalIdFieldsForSobjectsQuery(Array.from(relatedObjects)), true)
await queryWithCache<EntityParticleRecord>(org, getExternalIdFieldsForSobjectsQuery(Array.from(relatedObjects)))
).data;
const relatedEntitiesByObj = groupBy(relatedEntities.queryResults.records, 'EntityDefinition.QualifiedApiName');
fieldsWithRelationships.forEach((field) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,17 @@ function getColumnForProfileOrPermSet<T extends PermissionType>({
filters: ['BOOLEAN_SET'],
cellClass: (row) => {
const permission = row.permissions[id];
if (permissionType === 'object') {
const permission = row.permissions[id] as PermissionTableObjectCellPermission;
if (
(actionKey === 'create' && permission.createIsDirty) ||
(actionKey === 'delete' && permission.deleteIsDirty) ||
(actionKey === 'viewAll' && permission.viewAllIsDirty) ||
(actionKey === 'modifyAll' && permission.modifyAllIsDirty)
) {
return 'active-item-yellow-bg';
}
}
if ((actionKey === 'read' && permission.readIsDirty) || (actionKey === 'edit' && permission.editIsDirty)) {
return 'active-item-yellow-bg';
}
Expand Down Expand Up @@ -777,6 +788,58 @@ export function updateRowsFromRowAction<TRows extends PermissionTableObjectCell
});
}

export function resetRow<TRows extends PermissionTableObjectCell | PermissionTableFieldCell>(type: PermissionType, rows: TRows[]): TRows[] {
const newRows = [...rows];
return newRows.map((row) => {
row = { ...row };
row.permissions = { ...row.permissions };
for (const permissionId in row.permissions) {
row.permissions = { ...row.permissions, [permissionId]: { ...row.permissions[permissionId] } } as any;
if (type === 'object') {
const permission = row.permissions[permissionId] as PermissionTableObjectCellPermission;

if (permission.createIsDirty) {
permission.create = !permission.create;
}
if (permission.readIsDirty) {
permission.read = !permission.read;
}
if (permission.editIsDirty) {
permission.edit = !permission.edit;
}
if (permission.deleteIsDirty) {
permission.delete = !permission.delete;
}
if (permission.viewAllIsDirty) {
permission.viewAll = !permission.viewAll;
}
if (permission.modifyAllIsDirty) {
permission.modifyAll = !permission.modifyAll;
}

permission.createIsDirty = false;
permission.readIsDirty = false;
permission.editIsDirty = false;
permission.deleteIsDirty = false;
permission.viewAllIsDirty = false;
permission.modifyAllIsDirty = false;
} else {
const permission = row.permissions[permissionId] as PermissionTableFieldCellPermission;
if (permission.readIsDirty) {
permission.read = !permission.read;
}
if (permission.editIsDirty) {
permission.edit = !permission.edit;
}

permission.readIsDirty = false;
permission.editIsDirty = false;
}
}
return row;
});
}

/**
* Pinned row selection renderer
*/
Expand Down Expand Up @@ -980,12 +1043,13 @@ export const RowActionRenderer: FunctionComponent<RenderCellProps<PermissionTabl
const checkboxesById = getMapOf(checkboxes, 'id');
const [updatedRow] = updateRowsFromRowAction(type, checkboxesById, [row]);
onRowChange(updatedRow);
setDirtyItemCount(getDirtyCount({ row, type }));
setDirtyItemCount(getDirtyCount({ row: updatedRow, type }));
}

// TODO: honor which rows to apply to
function handleReset() {
setDirtyItemCount(getDirtyCount({ row, type }));
const [updatedRow] = resetRow(type, [row]);
onRowChange(updatedRow);
setDirtyItemCount(getDirtyCount({ row: updatedRow, type }));
}

function handlePopoverChange(isOpen: boolean) {
Expand Down Expand Up @@ -1015,7 +1079,7 @@ export const RowActionRenderer: FunctionComponent<RenderCellProps<PermissionTabl
}
footer={
<footer className="slds-popover__footer slds-grid slds-grid_align-center">
<button className="slds-button slds-button_neutral" onClick={handleReset} disabled={dirtyItemCount === 0}>
<button className="slds-button slds-button_neutral" onClick={handleReset}>
Reset Row
</button>
<button className="slds-button slds-button_brand" onClick={handleSave}>
Expand Down
2 changes: 1 addition & 1 deletion libs/api-config/src/lib/env-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const ENV = {
MAILGUN_PUBLIC_KEY: process.env.MAILGUN_PUBLIC_KEY,
MAILGUN_WEBHOOK_KEY: process.env.MAILGUN_WEBHOOK_KEY,
// SFDC
SFDC_API_VERSION: process.env.NX_SFDC_API_VERSION || process.env.SFDC_API_VERSION || '57.0',
SFDC_API_VERSION: process.env.NX_SFDC_API_VERSION || process.env.SFDC_API_VERSION || '58.0',
SFDC_CONSUMER_SECRET: process.env.SFDC_CONSUMER_SECRET,
SFDC_CONSUMER_KEY: process.env.SFDC_CONSUMER_KEY,
SFDC_CALLBACK_URL: process.env.SFDC_CALLBACK_URL,
Expand Down
62 changes: 39 additions & 23 deletions libs/ui/src/lib/sobject-field-list/SobjectExpandChildrenBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { formatNumber } from '@jetstream/shared/ui-utils';
import { pluralizeFromNumber } from '@jetstream/shared/utils';
import { FieldWrapper, MapOf, Maybe, QueryFields } from '@jetstream/types';
import { orderStringsBy, pluralizeFromNumber } from '@jetstream/shared/utils';
import { FieldWrapper, ListItem, MapOf, Maybe, QueryFields } from '@jetstream/types';
import { Fragment, FunctionComponent, useEffect, useState } from 'react';
import Select from '../form/select/Select';
import ComboboxWithItems from '../form/combobox/ComboboxWithItems';
import Icon from '../widgets/Icon';

const relationshipHelpText =
Expand Down Expand Up @@ -40,13 +40,25 @@ export const SobjectExpandChildrenBtn: FunctionComponent<SobjectExpandChildrenBt
const [selectedSObject, setSelectedSObject] = useState<Maybe<string>>(
() => initialSelectedSObject || (hasMultiple ? field.relatedSobject?.[0] : (field.relatedSobject as string))
);
const [selectId] = useState(() => `select-${parentKey}-${field.name}`);
// const [selectId] = useState(() => `select-${parentKey}-${field.name}`);
const [relatedObjects, setRelatedObjects] = useState<ListItem[]>([]);

useEffect(() => {
if (initialSelectedSObject && initialSelectedSObject !== selectedSObject) {
setSelectedSObject(initialSelectedSObject);
if (Array.isArray(field.relatedSobject)) {
setRelatedObjects(
orderStringsBy(field.relatedSobject).map(
(relationship): ListItem => ({
id: relationship,
label: relationship,
value: relationship,
})
)
);
} else {
setRelatedObjects([]);
}
}, [initialSelectedSObject]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hasMultiple]);

function handleExpand(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) {
event.preventDefault();
Expand All @@ -58,22 +70,26 @@ export const SobjectExpandChildrenBtn: FunctionComponent<SobjectExpandChildrenBt
<Fragment>
{showWhich === 'multiple' && (
<Fragment>
<Select id={selectId} label="Which Related Object" labelHelp={relationshipHelpText}>
<select
className="slds-select"
id={selectId}
value={selectedSObject || undefined}
onChange={(event) => setSelectedSObject(event.target.value)}
disabled={isExpanded}
title={isExpanded ? 'Hide fields to enable this element' : ''}
>
{(field.relatedSobject as string[]).map((relationship) => (
<option key={relationship} value={relationship}>
{relationship}
</option>
))}
</select>
</Select>
<div
onClick={(ev) => {
ev.stopPropagation();
ev.preventDefault();
}}
>
<ComboboxWithItems
comboboxProps={{
isRequired: true,
label: 'Which Related Object',
labelHelp: relationshipHelpText,
helpText: isExpanded ? 'Hide fields to to change objects' : '',
placeholder: 'Select an Option',
disabled: isExpanded,
}}
items={relatedObjects}
selectedItemId={selectedSObject}
onSelected={(item) => setSelectedSObject(item.id)}
/>
</div>
<button className="slds-button" onClick={handleExpand}>
<Icon type="utility" icon={isExpanded ? 'dash' : 'add'} className="slds-button__icon slds-button__icon_left" />
{isExpanded ? 'Hide' : 'View'} {selectedSObject} Fields
Expand Down
7 changes: 4 additions & 3 deletions libs/ui/src/lib/sobject-field-list/SobjectFieldListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { css } from '@emotion/react';
import { getFieldKey } from '@jetstream/shared/ui-utils';
import { FieldWrapper, MapOf, QueryFields, SalesforceOrgUi } from '@jetstream/types';
import { useHighlightedText } from 'libs/ui/src/lib/hooks/useHighlightedText';
import Icon from 'libs/ui/src/lib/widgets/Icon';
import Tooltip from 'libs/ui/src/lib/widgets/Tooltip';
import { Fragment, FunctionComponent, useEffect, useState } from 'react';
import Grid from '../grid/Grid';
import { useHighlightedText } from '../hooks/useHighlightedText';
import Icon from '../widgets/Icon';
import Tooltip from '../widgets/Tooltip';
import SobjectExpandChildrenBtn from './SobjectExpandChildrenBtn';
import SobjectFieldList from './SobjectFieldList';
import SobjectFieldListMetadataWarning from './SobjectFieldListMetadataWarning';
Expand Down Expand Up @@ -131,6 +131,7 @@ export const SobjectFieldListItem: FunctionComponent<SobjectFieldListItemProps>
{isExpanded && selectedSObject && (
<div>
<SobjectFieldList
key={selectedSObject}
org={org}
serverUrl={serverUrl}
isTooling={isTooling}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/jetstreamapp/jetstream"
},
"author": "Jetstream",
"version": "2.36.1",
"version": "2.37.2",
"license": "GNU Lesser General Public License v3.0",
"engines": {
"node": ">=16 <=18"
Expand Down

0 comments on commit a4ce4db

Please sign in to comment.