-
-
Save mahileeb/1ce0c625634d10595351c1110711901f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum EnvironmentMode { | |
UNKNOWN_MODE = 1; | |
DEMO = 2; | |
LIVE = 3; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
import { enumToString } from "helpers/enum"; | |
import { EnvironmentMode } from "protobuf/generated/com/mahifx/model/echo_protomap_pb"; | |
type OwnProps = { | |
name?: string; | |
mode?: EnvironmentMode; | |
version?: string; | |
build?: string; | |
className?: string; | |
} | |
const EnvLabel: React.FC<OwnProps> = props => { | |
const {name, mode, version, build} = props; | |
const hasBuild: boolean = !!build; | |
const [showBuild, setShowBuild] = useState(false); | |
const modeName: string = enumToString(mode, EnvironmentMode); | |
const onClick = () => { | |
setShowBuild(!showBuild); | |
}; | |
return <span | |
className={props.className} | |
onClick={onClick} | |
> | |
<b>{name} {mode !== EnvironmentMode.LIVE ? modeName : ""}</b> | |
{" "} | |
v{version} | |
{hasBuild && showBuild && `-${build}`} | |
</span>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment