All Downloads are FREE. Search and download functionalities are using the official Maven repository.

web.lib.components.quarkus-project.quarkus-project-edition-form.tsx Maven / Gradle / Ivy

There is a newer version: 37
Show newest version
import * as React from 'react';
import './quarkus-project-edition-form.scss';
import { ExtensionEntry, ExtensionsPicker } from '../extensions-picker/extensions-picker';
import { getProjectStream } from '../api/quarkus-project-utils';
import { InfoPicker, isValidInfo } from '../info-picker/info-picker';
import { GenerateButton } from '../generate-project/generate-button';
import { Config, Extension, Platform, QuarkusProject } from '../api/model';
import {
  debouncedSyncParamsQuery,
  Target,
  saveProjectToLocalStorage,
  resetProjectToDefault
} from '../api/quarkus-project-utils';
import { ExtensionsCart } from '../generate-project/extensions-cart';
import { Api } from '../api/code-quarkus-api';

interface CodeQuarkusFormProps {
  project: QuarkusProject;
  selectedExtensions: Extension[];
  platform: Platform;
  setProject: React.Dispatch>;
  filter: string;
  setFilter: React.Dispatch>;
  config: Config;
  api: Api;
  onSave: (target?: Target) => void;
}

export function CodeQuarkusForm(props: CodeQuarkusFormProps) {
  const [ isProjectValid, setIsProjectValid ] = React.useState(isValidInfo(props.project.metadata));
  const { setProject, filter, setFilter } = props;
  const [ isConfigSaved, setConfigSaved ] = React.useState(false);

  const setMetadata = (metadata: any) => {
    setIsProjectValid(isValidInfo(metadata));
    setProject((prev) => ({ ...prev, metadata }));
    setConfigSaved(false);
  };
  const setExtensions = (value: { extensions: ExtensionEntry[] }) => {
    setProject((prev) => ({ ...prev, extensions: value.extensions.map(e => e.id) }));
    setConfigSaved(false);
  }

  const save = (target?: Target) => {
    if (isProjectValid) {
      props.onSave(target);
    }
  };

  const storeAppConfig = () => {
    if(isProjectValid) {
      saveProjectToLocalStorage(props.project);
      setConfigSaved(true);
    }
  };

  const resetAppConfig = () => {
    resetProjectToDefault();
    setConfigSaved(false);
  };

  React.useEffect(() => {
    debouncedSyncParamsQuery(props.api, props.project, filter);
  }, [ filter, props.project ]);
  
  const currentStream = getProjectStream(props.platform, props.project.streamKey);
  return (
    

Configure your application

); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy