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

web.lib.components.header.stream-picker.tsx Maven / Gradle / Ivy

There is a newer version: 37
Show newest version
import React from 'react';
import './stream-picker.scss';
import { Platform, Stream } from '../api/model';
import { getRecommendedStream, getProjectStream } from '../api/quarkus-project-utils';
import { Dropdown } from 'react-bootstrap';
import { FaAngleDown, FaCheck, FaStar } from 'react-icons/fa';
import { useAnalytics } from '../../core/analytics';
import classNames from 'classnames';



function formatStreamStatus(status?: string, quarkusCoreVersion?: string) {
  let s = status?.toLowerCase();
  if (s === 'final') {
    return null;
  }
  return  s;
}

function parseStreamKey(key: string) {
  const streamKey = key.split(':');
  const platformKey = streamKey[0];
  const streamId = streamKey[1];

  return {
    platformKey, streamId
  }
}

export interface StreamPickerProps {
  platform: Platform;
  streamKey?: string;
  platformOnly?: boolean;
  setStreamKey: (string?, boolean?) => void;
}

const SelectedStream = (props: {stream: Stream}) => {
  const platformVersion = props.stream.platformVersion;
  const recommended = props.stream.recommended;
  
  const status = formatStreamStatus(props.stream.status, props.stream.quarkusCoreVersion);
  const { platformKey, streamId} = parseStreamKey(props.stream.key);
  
  return (
    
{streamId} { (status && !recommended) && {status} } {platformKey}
); } function StreamItem(props: { streamKey: string; quarkusCoreVersion?: string; platformVersion?: string; recommended: boolean; selected?: boolean; status?: string; lts?: boolean }) { const status = formatStreamStatus(props.status, props.quarkusCoreVersion); const { platformKey, streamId} = parseStreamKey(props.streamKey); return (
{props.selected ? : } {platformKey} {streamId} {props.lts && !status && (lts)} {status && ({status})} {props.recommended && }
); } export function StreamPicker(props: StreamPickerProps) { const analytics = useAnalytics(); const recommendedStream = getRecommendedStream(props.platform); const stream = getProjectStream(props.platform, props.streamKey); function setStreamKey(s: Stream) { props.setStreamKey(s.key, props.platformOnly); analytics.event('Switch stream', { stream: s.key, element: 'stream-picker' }); } return ( <> { props.platform.streams.length > 1 && } {props.platform.streams.map((s, i) => ( s !== stream && setStreamKey(s)}> ))} ); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy