web.lib.components.header.stream-picker.tsx Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code-quarkus Show documentation
Show all versions of code-quarkus Show documentation
Customize a Web Interface to generate Quarkus starter projects.
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 } 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 }) {
const status = formatStreamStatus(props.status, props.quarkusCoreVersion);
const { platformKey, streamId} = parseStreamKey(props.streamKey);
return (
{props.selected ? : }
{platformKey}
{streamId}
{props.recommended && (recommended)}
{status && ({status})}
);
}
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