Skip to content

Commit

Permalink
Allow user to add a name to a deployment so that in history it can be…
Browse files Browse the repository at this point in the history
… more easily identified v2

Adding new functionality that will allow users to save deployments. This should be accessible from all deployment options

resolves #331
  • Loading branch information
joiecosby committed Jun 4, 2023
1 parent 1b4585d commit c31ab05
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ const COLUMNS: ColumnWithFilter<SalesforceDeployHistoryItem>[] = [
key: 'start',
width: 200,
},
{
...setColumnFromType('name', 'text'),
name: 'Deployment History Name',
key: 'deploymentHistoryName',
width: 165,
},
{
...setColumnFromType('type', 'text'),
name: 'Type',
Expand Down Expand Up @@ -84,6 +90,7 @@ export const DeployMetadataHistoryTable: FunctionComponent<DeployMetadataHistory
onView,
onDownload,
}) => {
console.log('items:', items);
const context: DeployHistoryTableContext = useMemo(
() => ({ orgsById, portalRefForFilters: modalRef, onView, onDownload }),
[orgsById, modalRef, onView, onDownload]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css } from '@emotion/react';
import { useNonInitialEffect } from '@jetstream/shared/ui-utils';
import { DeployOptions, DeployOptionsTestLevel } from '@jetstream/types';
import { Checkbox, Icon, Radio, RadioGroup, Textarea, Tooltip } from '@jetstream/ui';
import { Checkbox, Icon, Input, Radio, RadioGroup, Textarea, Tooltip } from '@jetstream/ui';
import { Fragment, FunctionComponent, useState } from 'react';

const SPLIT_LINE_COMMA = /(\n|, |,)/g;
Expand All @@ -20,6 +20,7 @@ export interface DeployMetadataOptionsProps {
disabledOptions?: Set<keyof DeployOptions>;
isSinglePackage?: boolean;
onChange: (deployOptions: DeployOptions) => void;
setDeploymentHistoryName?: (deploymentHistoryName: string | undefined) => void;
}

export const DeployMetadataOptions: FunctionComponent<DeployMetadataOptionsProps> = ({
Expand All @@ -28,6 +29,7 @@ export const DeployMetadataOptions: FunctionComponent<DeployMetadataOptionsProps
disabledOptions = new Set(),
isSinglePackage,
onChange,
setDeploymentHistoryName,
}) => {
const [allowMissingFiles, setAllowMissingFiles] = useState(deployOptions.allowMissingFiles ?? false);
const [autoUpdatePackage, setAutoUpdatePackage] = useState(deployOptions.autoUpdatePackage ?? false);
Expand Down Expand Up @@ -83,6 +85,18 @@ export const DeployMetadataOptions: FunctionComponent<DeployMetadataOptionsProps

return (
<Fragment>
<hr className="slds-m-vertical_x-small" />
<Tooltip content="This name will show up in the metadata history within Jetstream and will not be sent to Salesforce">
<Input label="Deployment History Name" className="slds-grow">
<input
className="slds-input"
value={undefined}
placeholder="Choose a deployment name"
onChange={(event) => setDeploymentHistoryName(event.target.value)}
autoComplete="off"
/>
</Input>
</Tooltip>
<fieldset className="slds-form-element slds-m-top_small">
<legend className="slds-form-element__legend slds-form-element__label">Deployment Options</legend>
<div className="slds-form-element__icon">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export async function getHistoryItemFile(item: SalesforceDeployHistoryItem) {
export async function saveHistory({
sourceOrg,
destinationOrg,
deploymentHistoryName,
type,
start,
metadata,
Expand All @@ -77,13 +78,15 @@ export async function saveHistory({
}: {
sourceOrg?: SalesforceOrgUi;
destinationOrg: SalesforceOrgUi;
deploymentHistoryName?: string | undefined;
type: SalesforceDeployHistoryType;
start: Date;
metadata?: MapOf<ListMetadataResult[]>;
deployOptions: DeployOptions;
results?: DeployResult;
file?: ArrayBuffer | string | null;
}) {
console.log('deploymentHistoryName:', deploymentHistoryName);
try {
if (file && isString(file)) {
try {
Expand All @@ -108,6 +111,7 @@ export async function saveHistory({
label: destinationOrg.label,
orgName: destinationOrg.orgName || '',
},
deploymentHistoryName: deploymentHistoryName,
start,
finish: new Date(),
url: results?.id ? getDeploymentStatusUrl(results.id) : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export function useDeployMetadataBetweenOrgs(
saveHistory({
sourceOrg,
destinationOrg,
deploymentHistoryName: 'test 2',
type: 'orgToOrg',
start,
metadata: selectedMetadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function useDeployMetadataPackage(destinationOrg: SalesforceOrgUi, deploy
},
});
dispatch({ type: 'SUCCESS', payload: { results } });
saveHistory({ destinationOrg, type: deployType, start, deployOptions, results, file });
saveHistory({ destinationOrg, deploymentHistoryName: 'test3', type: deployType, start, deployOptions, results, file });
if (results.success) {
notifyUser(`Deployment finished successfully`, {
body: getNotificationMessageBody(results),
Expand Down
1 change: 1 addition & 0 deletions libs/types/src/lib/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ export interface SalesforceDeployHistoryItem {
key: string; // org:type:timestamp
fileKey?: string;
destinationOrg: SalesforceDeploymentHistoryOrg;
deploymentHistoryName?: string | undefined;
sourceOrg?: SalesforceDeploymentHistoryOrg;
start: Date;
finish: Date;
Expand Down

0 comments on commit c31ab05

Please sign in to comment.