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

web.lib.components.code-quarkus.tsx Maven / Gradle / Ivy

There is a newer version: 37
Show newest version
import * as React from 'react';
import { Analytics, AnalyticsContext, SegmentAnalyticsImpl, useAnalytics } from '../core/analytics';
import './bootstrap-reboot.css';
import './bootstrap-base.css';
import './code-quarkus.scss';
import { QuarkusProjectFlow } from './quarkus-project/quarkus-project-flow';
import { Config, QuarkusProject } from './api/model';
import { QuarkusBlurb } from './layout/quarkus-blurb';
import { Api, ConfigApi, PlatformApi } from './api/code-quarkus-api';
import { DataLoader, SentryBoundary } from '../core/components';
import { getQueryParams, resolveInitialFilterQueryParam, resolveInitialProject } from './api/quarkus-project-utils';
import { CodeQuarkusIoHeader } from './header/code-quarkus-io-header';
import { CodeQuarkusHeaderProps } from './header/code-quarkus-header';

export interface ConfiguredCodeQuarkusProps {
  config: Config;
  platformApi: PlatformApi;
  header?: React.FC;
  api: Api;
}

const queryParams = getQueryParams();

const initialFilterQueryParam = resolveInitialFilterQueryParam();

const initialProject = resolveInitialProject(queryParams);

export function ConfiguredCodeQuarkus(props: ConfiguredCodeQuarkusProps) {
  const [ analytics, setAnalytics ] = React.useState(useAnalytics());
  const [ filter, setFilter ] = React.useState(initialFilterQueryParam);
  const [ project, setProject ] = React.useState(initialProject);

  React.useEffect(() => {
    setAnalytics((prev) => {
      const newAnalytics = props.config.segmentWriteKey ? new SegmentAnalyticsImpl(props.config.segmentWriteKey) : prev;
      newAnalytics.init();
      return newAnalytics;
    });
  }, [ props.config.segmentWriteKey ]);
  const Header: React.FC = props.header || CodeQuarkusIoHeader;
  const platformLoader = () => props.platformApi(props.api, project.streamKey, project.platformOnly);
  function setStreamKey(streamKey: string, platformOnly: boolean) {
    setProject((prev) => ({ ...prev, streamKey, platformOnly }));
  }
  return (
    
      
{platform => ( <>
)}
); } export interface CodeQuarkusProps { configApi: ConfigApi; platformApi: PlatformApi; api: Api; header?: React.FC; } export function CodeQuarkus(props: CodeQuarkusProps) { const configLoader = () => props.configApi(props.api); return ( {config => ( )} ); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy