From cf3fbd6e4f63240759a6ee813b9e7072fa7b3edc Mon Sep 17 00:00:00 2001 From: Trevor McMaster Date: Fri, 6 Dec 2024 07:58:48 -0700 Subject: [PATCH] Removed unneeded vars --- .../src/components/YamlVars/DropDown.tsx | 48 ------------------- .../src/components/YamlVars/index.tsx | 43 +++-------------- .../src/components/YamlVars/story.tsx | 5 +- .../src/util/yamlwriter.ts | 3 -- 4 files changed, 8 insertions(+), 91 deletions(-) delete mode 100644 guide/results-viewer-react/src/components/YamlVars/DropDown.tsx diff --git a/guide/results-viewer-react/src/components/YamlVars/DropDown.tsx b/guide/results-viewer-react/src/components/YamlVars/DropDown.tsx deleted file mode 100644 index 75a1f024..00000000 --- a/guide/results-viewer-react/src/components/YamlVars/DropDown.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { DEV_KEY_BETA, DEV_KEY_PROD } from "../../util/yamlwriter"; -import React from "react"; -import styled from "styled-components"; - -const DropboxLabel = styled.label` - margin-right: 5px; - margin-top: 5px; - margin-bottom: 0px; - font-size: 11px; - display: flex; - flex-direction: row; -`; - -const DropDownSelect = styled.select` - margin-top: 0px; - margin-bottom: 0px; - font-size: 10px; - display: flex; - flex-direction: row; -`; - -interface VarsDropDownProps { - onChange: (event: React.ChangeEvent) => void; - display: boolean; -} - -// Drop down window for devKey -export default function VarsDropDown (props: VarsDropDownProps) { - - const changeEnvironment = (event: React.ChangeEvent) => { - props.onChange(event); - }; - - return ( -
- {props.display && - - Enviornment:   - - - - - - - } -
- ); -} diff --git a/guide/results-viewer-react/src/components/YamlVars/index.tsx b/guide/results-viewer-react/src/components/YamlVars/index.tsx index d9822b51..e6ad7f7a 100644 --- a/guide/results-viewer-react/src/components/YamlVars/index.tsx +++ b/guide/results-viewer-react/src/components/YamlVars/index.tsx @@ -1,17 +1,14 @@ import { CSSTransition, TransitionGroup } from "react-transition-group"; import { Checkbox, Div, InputsDiv, Label, Span} from "../YamlStyles"; import { - DEV_KEY_BETA, LOAD_TIME_DEFAULT, PEAK_LOAD_DEFAULT, PewPewVars, RAMP_TIME_DEFAULT, SESSION_ID_DEFAULT } from "../../util/yamlwriter"; -import { LogLevel, log } from "../../util/log"; import React, { useEffect, useRef, useState } from "react"; import QuestionBubble from "../YamlQuestionBubble"; -import VarsDropDown from "./DropDown"; import { uniqueId } from "../../util/clientutil"; export type PewPewVarsStringType = "name" | "value"; @@ -20,20 +17,17 @@ interface DefaultVariables { rampTime: boolean; loadTime: boolean; peakLoad: boolean; - devKey: boolean; } type DefaultVariablesType = keyof DefaultVariables; // This is the default state of all checkboxes and drop downs when the UI is initially loaded const defaultUI: DefaultVariables = { - devKey: false, rampTime: true, loadTime: true, peakLoad: true, sessionId: true }; -const defaultEnvironment = DEV_KEY_BETA; export interface VarsProps { addVar: (pewpewVar: PewPewVars) => void; @@ -49,24 +43,21 @@ interface VarsState extends DefaultVariables { nameReady: boolean; valueReady: boolean; defaultVars: boolean; - environment: string; } export const VARS = "vars"; const SESSION_ID = "sessionId"; const RAMP_TIME = "rampTime"; const LOAD_TIME = "loadTime"; const PEAK_LOAD = "peakLoad"; -const DEV_KEY = "devKey"; const DEFAULT_VARS = "defaultVars"; export const emptyVar = (varId: string = uniqueId()): PewPewVars => ({ id: varId, name: "", value: "" }); -export const devKeyVar = (environment: string): PewPewVars => ({ id: DEV_KEY, name: DEV_KEY, value: environment }); export const rampTimeVar = (): PewPewVars => ({ id: RAMP_TIME, name: RAMP_TIME, value: RAMP_TIME_DEFAULT }); export const loadTimeVar = (): PewPewVars => ({ id: LOAD_TIME, name: LOAD_TIME, value: LOAD_TIME_DEFAULT }); export const peakLoadVar = (): PewPewVars => ({ id: PEAK_LOAD, name: PEAK_LOAD, value: PEAK_LOAD_DEFAULT }); export const sessionIdVar = (): PewPewVars => ({ id: SESSION_ID, name: SESSION_ID, value: SESSION_ID_DEFAULT }); -function getDefaultVar (varName: DefaultVariablesType, environment: string): PewPewVars { +function getDefaultVar (varName: DefaultVariablesType): PewPewVars { switch (varName) { case SESSION_ID: return sessionIdVar(); @@ -76,18 +67,16 @@ function getDefaultVar (varName: DefaultVariablesType, environment: string): Pew return loadTimeVar(); case PEAK_LOAD: return peakLoadVar(); - case DEV_KEY: - return devKeyVar(environment); default: throw new Error("getDefaultVar Invalid varName: " + varName); } } -export function getDefaultVars (defaultVars: DefaultVariables = defaultUI, environment: string = defaultEnvironment): PewPewVars[] { +export function getDefaultVars (defaultVars: DefaultVariables = defaultUI): PewPewVars[] { const pewpewVars: PewPewVars[] = []; for (const [varName, isEnabled] of Object.entries(defaultVars)) { if (isEnabled) { - pewpewVars.push(getDefaultVar(varName as DefaultVariablesType, environment)); + pewpewVars.push(getDefaultVar(varName as DefaultVariablesType)); } } @@ -99,8 +88,7 @@ export function Vars ({ authenticated, defaultYaml, ...props }: VarsProps) { nameReady: false, valueReady: false, defaultVars: defaultYaml, - ...defaultUI, - environment: defaultEnvironment + ...defaultUI }; /** Map to keep id's unique */ const varsMap = new Map(props.vars.map((pewpewVar) => ([pewpewVar.id, pewpewVar]))); @@ -142,7 +130,7 @@ export function Vars ({ authenticated, defaultYaml, ...props }: VarsProps) { // Add/delete from varsMap/vars if (newChecked && !varsMap.has(varsType)) { // Add it (will update the map when it comes back in via props) - const defaultVar = getDefaultVar(varsType, state.environment); + const defaultVar = getDefaultVar(varsType); props.addVar(defaultVar); } else if (!newChecked && varsMap.has(varsType)) { // Remove it (will update the map when it comes back in via props) @@ -165,21 +153,10 @@ export function Vars ({ authenticated, defaultYaml, ...props }: VarsProps) { }; const clearAllVars = () => { - updateState({ defaultVars: false, sessionId: false, rampTime: false, loadTime: false, peakLoad: false, devKey: false }); + updateState({ defaultVars: false, sessionId: false, rampTime: false, loadTime: false, peakLoad: false }); props.clearAllVars(); }; - const changeEnvironment = (event: React.ChangeEvent) => { - updateState({ environment: event.target.value }); - const devKey = varsMap.get(DEV_KEY); - if (devKey) { - devKey.value = event.target.value; - props.changeVar(devKey); - } else { - log("Environment changed without devKey variable existing", LogLevel.WARN); - } - }; - // https://github.com/reactjs/react-transition-group/issues/904 // http://reactcommunity.org/react-transition-group/transition#Transition-prop-nodeRef const nodeRef = useRef(null); @@ -219,14 +196,6 @@ export function Vars ({ authenticated, defaultYaml, ...props }: VarsProps) { ) => switchDefault(PEAK_LOAD, event.target.checked)} checked={state.peakLoad}/> -
- - - - switchDefault(DEV_KEY, event.target.checked)} checked={state.devKey}/> - - -
{Array.from(varsMap.values()).map((pewpewVar: PewPewVars) => ( diff --git a/guide/results-viewer-react/src/components/YamlVars/story.tsx b/guide/results-viewer-react/src/components/YamlVars/story.tsx index eb166a7a..4305c7c7 100644 --- a/guide/results-viewer-react/src/components/YamlVars/story.tsx +++ b/guide/results-viewer-react/src/components/YamlVars/story.tsx @@ -1,8 +1,8 @@ -import { DEV_KEY_BETA, PewPewVars } from "../../util/yamlwriter"; import { DisplayDivBody, DisplayDivMain } from "../YamlWriterForm"; import type { Meta, StoryFn } from "@storybook/react"; import { Vars, VarsProps} from "."; import { GlobalStyle } from "../Global"; +import { PewPewVars } from "../../util/yamlwriter"; import React from "react"; const props: VarsProps = { @@ -35,8 +35,7 @@ const propsLoaded: VarsProps = { ...props, { id: "sessionId", name: "sessionId", value: "${SESSIONID}" }, { id: "rampTime", name: "rampTime", value: "${RAMP_TIME}" }, { id: "loadTime", name: "loadTime", value: "${LOAD_TIME}" }, - { id: "peakLoad", name: "peakLoad", value: "${PEAK_LOAD}" }, - { id: "devKey", name: "devKey", value: DEV_KEY_BETA } + { id: "peakLoad", name: "peakLoad", value: "${PEAK_LOAD}" } ] }; diff --git a/guide/results-viewer-react/src/util/yamlwriter.ts b/guide/results-viewer-react/src/util/yamlwriter.ts index c21629f1..b83e6a1b 100644 --- a/guide/results-viewer-react/src/util/yamlwriter.ts +++ b/guide/results-viewer-react/src/util/yamlwriter.ts @@ -93,6 +93,3 @@ export const SESSION_ID_DEFAULT = "${SESSIONID}"; export const RAMP_TIME_DEFAULT = "${RAMP_TIME}"; export const LOAD_TIME_DEFAULT = "${LOAD_TIME}"; export const PEAK_LOAD_DEFAULT = "${PEAK_LOAD}"; - -export const DEV_KEY_BETA = "WCQY-7J1Q-GKVV-7DNM-SQ5M-9Q5H-JX3H-CMJK"; -export const DEV_KEY_PROD = "Q4JW-NBZX-TWHZ-ZZDJ-LSP9-G15N-NLC8-P1M3";