import { isEmpty } from 'lodash'; import * as React from 'react'; export interface IServerGroupNamePreviewProps { createsNewCluster: boolean; latestServerGroupName: string; mode: string; namePreview: string; navigateToLatestServerGroup: () => void; } const SPEL_EXPRESSION_REGEX = /\${[^}]+}/g; const SPEL_WITH_DEFAULT_AND_ALPHANUMERICAL_REGEX = /^\${\s*#alphanumerical\(.*\)\s*\?:\s*[^\s]+\s*}$/; export const ServerGroupNamePreview = ({ createsNewCluster, latestServerGroupName, mode, namePreview, navigateToLatestServerGroup, }: IServerGroupNamePreviewProps) => { const spelMatches = namePreview.match(SPEL_EXPRESSION_REGEX); if (!isEmpty(spelMatches)) { const anyInvalidSpel = [...spelMatches].some((match) => !SPEL_WITH_DEFAULT_AND_ALPHANUMERICAL_REGEX.test(match)); return (
Your server group cluster will be determined by evaluating the expressions dynamically
{anyInvalidSpel && (Your server group will be in the cluster:
{namePreview} {createsNewCluster && (new cluster)}
{!createsNewCluster && mode === 'create' && latestServerGroupName && (There is already a server group in this cluster. Do you want to clone it?
Cloning copies the entire configuration from the selected server group, allowing you to modify whichever fields (e.g. image) you need to change in the new server group.
To clone a server group, select "Clone" from the "Server Group Actions" menu in the details view of the server group.