function sourceValidate()

in frontend/src/pages/Configure/Source.js [48:91]


function sourceValidate(suppressUpload = false) {
  let clusterName = getState(['app', 'wizard', 'clusterName']);
  let sourceClusterName = getState(['app', 'wizard', 'source', 'selectedCluster']);
  let upload = getState([...sourcePath, 'upload']);
  let source = getState([...sourcePath, 'type']);
  let valid = true;
  const loadingPath = ['app', 'wizard', 'source', 'loading'];

  setState([...sourceErrorsPath, 'validated'], true);

  if(!clusterName || clusterName === "")
  {
    setState([...sourceErrorsPath, 'clusterName'], 'Cluster name must not be blank.');
    valid = false;
  } else {
    clearState([...sourceErrorsPath, 'clusterName']);
  }

  if(source === 'cluster' && (!sourceClusterName || sourceClusterName === ''))
  {
    setState([...sourceErrorsPath, 'sourceClusterName'], 'You must select a cluster to copy from.');
    valid = false;
  } else {
    clearState([...sourceErrorsPath, 'sourceClusterName']);
  }

  // Returning false here tells the wizard not to advance
  // which allows us to explicitly control the page if the
  // user selects a file (or stay here if they do not)
  if(valid && (source === 'upload' || source === 'template') && !suppressUpload)
  {
    upload();
    return false;
  }

  if(valid && (source === 'cluster') & !suppressUpload)
  {
    setState(loadingPath, true);
    copyFrom(sourceClusterName);
    return false;
  }

  return valid;
}