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

[WIP] Allow user to add a name to a deployment so that in history it can be… #359

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from '@emotion/react';
import { useNonInitialEffect, useRollbar } from '@jetstream/shared/ui-utils';
import { DeployOptions, ListMetadataResult, MapOf, SalesforceOrgUi } from '@jetstream/types';
import { DeployOptions, ListMetadataResult, MapOf, Maybe, SalesforceOrgUi } from '@jetstream/types';
import { Grid, GridCol, Icon, Modal } from '@jetstream/ui';
import JSZip from 'jszip';
import { Fragment, FunctionComponent, useEffect, useRef, useState } from 'react';
Expand All @@ -17,6 +17,7 @@ export interface DeleteMetadataConfigModalProps {
onSelection?: (deployOptions: DeployOptions) => void;
onClose: () => void;
onDeploy: (file: ArrayBuffer, deployOptions: DeployOptions) => void;
setDeploymentHistoryName?: (deploymentHistoryName: Maybe<string>) => void;
}

export const DeleteMetadataConfigModal: FunctionComponent<DeleteMetadataConfigModalProps> = ({
Expand All @@ -27,6 +28,7 @@ export const DeleteMetadataConfigModal: FunctionComponent<DeleteMetadataConfigMo
onSelection,
onClose,
onDeploy,
setDeploymentHistoryName,
}) => {
const rollbar = useRollbar();
const modalBodyRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -141,7 +143,12 @@ export const DeleteMetadataConfigModal: FunctionComponent<DeleteMetadataConfigMo
</div>
<div>
{/* OPTIONS */}
<DeployMetadataOptions deployOptions={deployOptions} hiddenOptions={hiddenOptions} onChange={setDeployOptions} />
<DeployMetadataOptions
deployOptions={deployOptions}
hiddenOptions={hiddenOptions}
onChange={setDeployOptions}
setDeploymentHistoryName={setDeploymentHistoryName}
/>
</div>
</div>
</GridCol>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ANALYTICS_KEYS } from '@jetstream/shared/constants';
import { DeployOptions, DeployResult, ListMetadataResult, MapOf, SalesforceOrgUi } from '@jetstream/types';
import { DeployOptions, DeployResult, ListMetadataResult, MapOf, Maybe, SalesforceOrgUi } from '@jetstream/types';
import { FileDownloadModal } from '@jetstream/ui';
import { Fragment, FunctionComponent, useState } from 'react';
import { useRecoilState } from 'recoil';
Expand All @@ -25,6 +25,7 @@ export const DeleteMetadataModal: FunctionComponent<DeleteMetadataModalProps> =
const [file, setFile] = useState<ArrayBuffer>();
const [deployOptions, setDeployOptions] = useState<DeployOptions>();
const [deployResultsData, setDeployResultsData] = useState<MapOf<any[]>>();
const [deploymentHistoryName, setDeploymentHistoryName] = useState<Maybe<string>>(undefined);

function handleDeploy(file: ArrayBuffer, deployOptions: DeployOptions) {
setFile(file);
Expand Down Expand Up @@ -55,6 +56,7 @@ export const DeleteMetadataModal: FunctionComponent<DeleteMetadataModalProps> =
initialOptions={deployOptions}
onClose={() => onClose()}
onDeploy={handleDeploy}
setDeploymentHistoryName={setDeploymentHistoryName}
/>
)}
{deployStatusModalOpen && deployOptions && file && (
Expand All @@ -66,6 +68,7 @@ export const DeleteMetadataModal: FunctionComponent<DeleteMetadataModalProps> =
onGoBack={handleGoBackFromDeploy}
onClose={onClose}
onDownload={handleDeployResultsDownload}
deploymentHistoryName={deploymentHistoryName}
/>
)}
{downloadResultsModalOpen && deployResultsData && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useNonInitialEffect } from '@jetstream/shared/ui-utils';
import { DeployOptions, DeployResult, SalesforceOrgUi } from '@jetstream/types';
import { DeployOptions, DeployResult, Maybe, SalesforceOrgUi } from '@jetstream/types';
import { SalesforceLogin } from '@jetstream/ui';
import { Fragment, FunctionComponent, useEffect, useState } from 'react';
import { useRecoilValue } from 'recoil';
Expand All @@ -11,6 +11,7 @@ import { getStatusValue, useDeployMetadataPackage } from '../utils/useDeployMeta
export interface DeployMetadataPackageStatusModalProps {
destinationOrg: SalesforceOrgUi;
deployOptions: DeployOptions;
deploymentHistoryName?: Maybe<string>;
file: ArrayBuffer;
// used to hide while download window is open
hideModal: boolean;
Expand All @@ -22,6 +23,7 @@ export interface DeployMetadataPackageStatusModalProps {
export const DeployMetadataPackageStatusModal: FunctionComponent<DeployMetadataPackageStatusModalProps> = ({
destinationOrg,
deployOptions,
deploymentHistoryName,
file,
hideModal,
onGoBack,
Expand All @@ -34,7 +36,8 @@ export const DeployMetadataPackageStatusModal: FunctionComponent<DeployMetadataP
const { deployMetadata, results, deployId, loading, status, lastChecked, hasError, errorMessage } = useDeployMetadataPackage(
destinationOrg,
deployOptions,
file
file,
deploymentHistoryName
);

useEffect(() => {
Expand Down Expand Up @@ -86,6 +89,7 @@ export const DeployMetadataPackageStatusModal: FunctionComponent<DeployMetadataP
onGoBack={onGoBack}
onClose={onClose}
onDownload={onDownload}
deploymentHistoryName={deploymentHistoryName}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ const TYPE_MAP = {
};

const COLUMNS: ColumnWithFilter<SalesforceDeployHistoryItem>[] = [
{
...setColumnFromType('name', 'text'),
name: 'Name',
key: 'deploymentHistoryName',
width: 165,
},
{
...setColumnFromType('start', 'date'),
name: 'Started',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ANALYTICS_KEYS } from '@jetstream/shared/constants';
import { DeployOptions, DeployResult, MapOf, SalesforceOrgUi } from '@jetstream/types';
import { DeployOptions, DeployResult, MapOf, Maybe, SalesforceOrgUi } from '@jetstream/types';
import { FileDownloadModal, Icon } from '@jetstream/ui';
import classNames from 'classnames';
import { Fragment, FunctionComponent, useState } from 'react';
Expand Down Expand Up @@ -28,6 +28,7 @@ export const DeployMetadataPackage: FunctionComponent<DeployMetadataPackageProps
);
const [deployOptions, setDeployOptions] = useState<DeployOptions>();
const [deployResultsData, setDeployResultsData] = useState<MapOf<any[]>>();
const [deploymentHistoryName, setDeploymentHistoryName] = useState<Maybe<string>>(undefined);

function handleClick() {
setDestinationOrg(initialSelectedOrg);
Expand Down Expand Up @@ -79,6 +80,7 @@ export const DeployMetadataPackage: FunctionComponent<DeployMetadataPackageProps
initialIsSinglePackage={fileInfo.isSinglePackage}
onClose={() => setConfigModalOpen(false)}
onDeploy={handleDeploy}
setDeploymentHistoryName={setDeploymentHistoryName}
/>
)}
{deployStatusModalOpen && deployOptions && fileInfo.file && (
Expand All @@ -90,6 +92,7 @@ export const DeployMetadataPackage: FunctionComponent<DeployMetadataPackageProps
onGoBack={handleGoBackFromDeploy}
onClose={handleCloseDeploymentModal}
onDownload={handleDeployResultsDownload}
deploymentHistoryName={deploymentHistoryName}
/>
)}
{downloadResultsModalOpen && deployResultsData && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface DeployMetadataPackageConfigModalProps {
destinationOrg: SalesforceOrgUi,
deployOptions: DeployOptions
) => void;
setDeploymentHistoryName?: (deploymentHistoryName: Maybe<string>) => void;
}

export const DeployMetadataPackageConfigModal: FunctionComponent<DeployMetadataPackageConfigModalProps> = ({
Expand All @@ -41,6 +42,7 @@ export const DeployMetadataPackageConfigModal: FunctionComponent<DeployMetadataP
onSelection,
onClose,
onDeploy,
setDeploymentHistoryName,
}) => {
const rollbar = useRollbar();
const orgs = useRecoilValue<SalesforceOrgUi[]>(salesforceOrgsState);
Expand Down Expand Up @@ -175,7 +177,12 @@ export const DeployMetadataPackageConfigModal: FunctionComponent<DeployMetadataP
</div>
<div>
{/* OPTIONS */}
<DeployMetadataOptions deployOptions={deployOptions} isSinglePackage={isSinglePackage} onChange={setDeployOptions} />
<DeployMetadataOptions
deployOptions={deployOptions}
isSinglePackage={isSinglePackage}
onChange={setDeployOptions}
setDeploymentHistoryName={setDeploymentHistoryName}
/>
</div>
</div>
</GridCol>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useNonInitialEffect } from '@jetstream/shared/ui-utils';
import { DeployOptions, DeployResult, SalesforceOrgUi } from '@jetstream/types';
import { DeployOptions, DeployResult, Maybe, SalesforceOrgUi } from '@jetstream/types';
import { SalesforceLogin } from '@jetstream/ui';
import { Fragment, FunctionComponent, useEffect, useState } from 'react';
import { useRecoilValue } from 'recoil';
Expand All @@ -11,6 +11,7 @@ import { getStatusValue, useDeployMetadataPackage } from '../utils/useDeployMeta
export interface DeployMetadataPackageStatusModalProps {
destinationOrg: SalesforceOrgUi;
deployOptions: DeployOptions;
deploymentHistoryName?: Maybe<string>;
file: ArrayBuffer;
// used to hide while download window is open
hideModal: boolean;
Expand All @@ -22,6 +23,7 @@ export interface DeployMetadataPackageStatusModalProps {
export const DeployMetadataPackageStatusModal: FunctionComponent<DeployMetadataPackageStatusModalProps> = ({
destinationOrg,
deployOptions,
deploymentHistoryName,
file,
hideModal,
onGoBack,
Expand All @@ -34,6 +36,7 @@ export const DeployMetadataPackageStatusModal: FunctionComponent<DeployMetadataP
const { deployMetadata, results, deployId, loading, status, lastChecked, hasError, errorMessage } = useDeployMetadataPackage(
destinationOrg,
deployOptions,
deploymentHistoryName,
file
);

Expand Down Expand Up @@ -81,6 +84,7 @@ export const DeployMetadataPackageStatusModal: FunctionComponent<DeployMetadataP
onGoBack={onGoBack}
onClose={onClose}
onDownload={onDownload}
deploymentHistoryName={deploymentHistoryName}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ANALYTICS_KEYS } from '@jetstream/shared/constants';
import { DeployOptions, DeployResult, ListMetadataResult, MapOf, SalesforceOrgUi } from '@jetstream/types';
import { DeployOptions, DeployResult, ListMetadataResult, MapOf, Maybe, SalesforceOrgUi } from '@jetstream/types';
import { FileDownloadModal, Icon } from '@jetstream/ui';
import { Fragment, FunctionComponent, useState } from 'react';
import { useRecoilState } from 'recoil';
Expand Down Expand Up @@ -29,6 +29,7 @@ export const DeployMetadataToOrg: FunctionComponent<DeployMetadataToOrgProps> =
const [deployMetadataOptions, setDeployMetadataOptions] = useState<DeployOptions | null>(null);

const [selectedMetadata, setSelectedMetadata] = useState<MapOf<ListMetadataResult[]>>();
const [deploymentHistoryName, setDeploymentHistoryName] = useState<Maybe<string>>(undefined);

function handleClick() {
setConfigModalOpen(true);
Expand Down Expand Up @@ -78,6 +79,7 @@ export const DeployMetadataToOrg: FunctionComponent<DeployMetadataToOrgProps> =
selectedMetadata={selectedMetadata}
onClose={handleCloseConfigModal}
onDeploy={handleDeployMetadata}
setDeploymentHistoryName={setDeploymentHistoryName}
/>
)}
{deployStatusModalOpen && destinationOrg && selectedMetadata && (
Expand All @@ -90,6 +92,7 @@ export const DeployMetadataToOrg: FunctionComponent<DeployMetadataToOrgProps> =
onGoBack={handleGoBackFromDeploy}
onClose={() => setDeployStatusModalOpen(false)}
onDownload={handleDeployResultsDownload}
deploymentHistoryName={deploymentHistoryName}
/>
)}
{downloadResultsModalOpen && deployResultsData && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface DeployMetadataToOrgConfigModalProps {
onSelection?: (deployOptions: DeployOptions) => void;
onClose: () => void;
onDeploy: (destinationOrg: SalesforceOrgUi, deployOptions: DeployOptions) => void;
setDeploymentHistoryName?: (deploymentHistoryName: Maybe<string>) => void;
}

export const DeployMetadataToOrgConfigModal: FunctionComponent<DeployMetadataToOrgConfigModalProps> = ({
Expand All @@ -29,6 +30,7 @@ export const DeployMetadataToOrgConfigModal: FunctionComponent<DeployMetadataToO
onSelection,
onClose,
onDeploy,
setDeploymentHistoryName,
}) => {
const modalBodyRef = useRef<HTMLDivElement>(null);
const [selectedMetadataList, setSelectedMetadataList] = useState<string[]>();
Expand Down Expand Up @@ -118,7 +120,12 @@ export const DeployMetadataToOrgConfigModal: FunctionComponent<DeployMetadataToO
/>
<div>
{/* OPTIONS */}
<DeployMetadataOptions deployOptions={deployOptions} hiddenOptions={DISABLED_OPTIONS} onChange={setDeployOptions} />
<DeployMetadataOptions
deployOptions={deployOptions}
hiddenOptions={DISABLED_OPTIONS}
onChange={setDeployOptions}
setDeploymentHistoryName={setDeploymentHistoryName}
/>
</div>
</div>
</GridCol>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useNonInitialEffect } from '@jetstream/shared/ui-utils';
import { DeployOptions, DeployResult, ListMetadataResult, MapOf, SalesforceOrgUi } from '@jetstream/types';
import { DeployOptions, DeployResult, ListMetadataResult, MapOf, Maybe, SalesforceOrgUi } from '@jetstream/types';
import { SalesforceLogin } from '@jetstream/ui';
import { Fragment, FunctionComponent, useEffect, useState } from 'react';
import { useRecoilValue } from 'recoil';
Expand All @@ -11,6 +11,7 @@ import { getStatusValue, useDeployMetadataBetweenOrgs } from '../utils/useDeploy
export interface DeployMetadataToOrgStatusModalProps {
sourceOrg: SalesforceOrgUi;
destinationOrg: SalesforceOrgUi;
deploymentHistoryName?: Maybe<string>;
selectedMetadata: MapOf<ListMetadataResult[]>;
deployOptions: DeployOptions;
// used to hide while download window is open
Expand All @@ -23,6 +24,7 @@ export interface DeployMetadataToOrgStatusModalProps {
export const DeployMetadataToOrgStatusModal: FunctionComponent<DeployMetadataToOrgStatusModalProps> = ({
sourceOrg,
destinationOrg,
deploymentHistoryName,
selectedMetadata,
deployOptions,
hideModal,
Expand All @@ -37,7 +39,8 @@ export const DeployMetadataToOrgStatusModal: FunctionComponent<DeployMetadataToO
sourceOrg,
destinationOrg,
selectedMetadata,
deployOptions
deployOptions,
deploymentHistoryName
);

useEffect(() => {
Expand Down Expand Up @@ -84,6 +87,7 @@ export const DeployMetadataToOrgStatusModal: FunctionComponent<DeployMetadataToO
onGoBack={onGoBack}
onClose={onClose}
onDownload={onDownload}
deploymentHistoryName={deploymentHistoryName}
/>
);
};
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 { DeployOptions, DeployOptionsTestLevel, Maybe } from '@jetstream/types';
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: Maybe<string>) => 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 All @@ -38,6 +40,7 @@ export const DeployMetadataOptions: FunctionComponent<DeployMetadataOptionsProps
const [singlePackage, setSinglePackage] = useState(deployOptions.singlePackage ?? true);
const [testLevel, setTestLevel] = useState<DeployOptionsTestLevel | undefined>(deployOptions.testLevel ?? undefined);
const [runTests, setRunTests] = useState<string[]>(deployOptions.runTests ?? []);
// const [deployName, setDeployName] = useState<Maybe<string>>();

const [runSpecifiedTestsVisible, setRunSpecifiedTestsVisible] = useState(testLevel === 'RunSpecifiedTests');
const [runTestsStr, setRunTestsStr] = useState<string>(deployOptions.runTests?.join('\n') ?? '');
Expand Down Expand Up @@ -83,6 +86,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}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paustint do you have a suggestion on how to not automatically pass this as undefined?

When I navigate away from the modal and back, I ideally want to have the name the user inputted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(unrelated) for an input, you never want the value to start as undefined otherwise you will get an error saying "input is changing from uncontrolled to controlled"

Just like you are passing in setDeploymentHistoryName, you also need to pass in the value you want to use as the initial state (and this should start as empty string, not 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
Loading
Loading