diff --git a/src/Explorer/ContainerCopy/CopyJobUtils.ts b/src/Explorer/ContainerCopy/CopyJobUtils.ts index f69c7f91e..eb37f8b92 100644 --- a/src/Explorer/ContainerCopy/CopyJobUtils.ts +++ b/src/Explorer/ContainerCopy/CopyJobUtils.ts @@ -144,3 +144,27 @@ export function isEqual(prevJobs: CopyJobType[], newJobs: CopyJobType[]): boolea return prevJob.Status === newJob.Status; }); } + +const truncateLength = 5; +const truncateName = (name: string, length: number = truncateLength): string => { + return name.length <= length ? name : name.slice(0, length); +}; + +export function getDefaultJobName( + selectedDatabaseAndContainers: { + sourceDatabaseName?: string; + sourceContainerName?: string; + targetDatabaseName?: string; + targetContainerName?: string; + }[], +): string { + if (selectedDatabaseAndContainers.length === 1) { + const { sourceDatabaseName, sourceContainerName, targetDatabaseName, targetContainerName } = + selectedDatabaseAndContainers[0]; + const timestamp = new Date().getTime().toString(); + const sourcePart = `${truncateName(sourceDatabaseName)}.${truncateName(sourceContainerName)}`; + const targetPart = `${truncateName(targetDatabaseName)}.${truncateName(targetContainerName)}`; + return `${sourcePart}_${targetPart}_${timestamp}`; + } + return ""; +} diff --git a/src/Explorer/ContainerCopy/CreateCopyJob/Screens/PreviewCopyJob/PreviewCopyJob.tsx b/src/Explorer/ContainerCopy/CreateCopyJob/Screens/PreviewCopyJob/PreviewCopyJob.tsx index c270ccdf5..050d696e9 100644 --- a/src/Explorer/ContainerCopy/CreateCopyJob/Screens/PreviewCopyJob/PreviewCopyJob.tsx +++ b/src/Explorer/ContainerCopy/CreateCopyJob/Screens/PreviewCopyJob/PreviewCopyJob.tsx @@ -1,8 +1,9 @@ import { DetailsList, DetailsListLayoutMode, Stack, Text, TextField } from "@fluentui/react"; -import FieldRow from "Explorer/ContainerCopy/CreateCopyJob/Screens/Components/FieldRow"; -import React from "react"; +import React, { useEffect } from "react"; import ContainerCopyMessages from "../../../ContainerCopyMessages"; import { useCopyJobContext } from "../../../Context/CopyJobContext"; +import { getDefaultJobName } from "../../../CopyJobUtils"; +import FieldRow from "../Components/FieldRow"; import { getPreviewCopyJobDetailsListColumns } from "./Utils/PreviewCopyJobUtils"; const PreviewCopyJob: React.FC = () => { @@ -16,6 +17,11 @@ const PreviewCopyJob: React.FC = () => { targetContainerName: copyJobState.target?.containerId, }, ]; + + useEffect(() => { + onJobNameChange(undefined, getDefaultJobName(selectedDatabaseAndContainers)); + }, []); + const jobName = copyJobState.jobName; const onJobNameChange = (_ev?: React.FormEvent, newValue?: string) => { diff --git a/src/Explorer/ContainerCopy/CreateCopyJob/Utils/useCreateCopyJobScreensList.tsx b/src/Explorer/ContainerCopy/CreateCopyJob/Utils/useCreateCopyJobScreensList.tsx index 1fcfd4976..acb17f602 100644 --- a/src/Explorer/ContainerCopy/CreateCopyJob/Utils/useCreateCopyJobScreensList.tsx +++ b/src/Explorer/ContainerCopy/CreateCopyJob/Utils/useCreateCopyJobScreensList.tsx @@ -66,7 +66,7 @@ function useCreateCopyJobScreensList(goBack: () => void): Screen[] { validations: [ { validate: (state: CopyJobContextState) => - !!(typeof state?.jobName === "string" && state?.jobName && /^[a-zA-Z0-9-.]+$/.test(state?.jobName)), + !!(typeof state?.jobName === "string" && state?.jobName && /^[a-zA-Z0-9-._]+$/.test(state?.jobName)), message: "Please enter a job name to proceed", }, ], diff --git a/src/Explorer/ContainerCopy/containerCopyStyles.less b/src/Explorer/ContainerCopy/containerCopyStyles.less index 9b995b3ad..05d9facec 100644 --- a/src/Explorer/ContainerCopy/containerCopyStyles.less +++ b/src/Explorer/ContainerCopy/containerCopyStyles.less @@ -141,8 +141,9 @@ .jobNameLink { color: @LinkColor; - text-decoration: underline; - cursor: pointer; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; } } }