From ff33308d8e044d036391a893b92cca471f6ba4c5 Mon Sep 17 00:00:00 2001
From: andreas-unleash <104830839+andreas-unleash@users.noreply.github.com>
Date: Mon, 8 Aug 2022 10:42:45 +0300
Subject: [PATCH] Parameters Bug fix
---
.../PlaygroundParameterItem.tsx} | 10 +-
.../PlaygroundParametertem.styles.ts} | 0
.../PlaygroundResultConstraintExecution.tsx | 2 +-
.../PlaygroundResultStrategyExecution.tsx | 3 +-
...tStrategyExecutionCustomStrategyParams.tsx | 126 ++++++------------
...roundResultStrategyExecutionParameters.tsx | 10 +-
.../{helepers.ts => helpers.ts} | 0
7 files changed, 55 insertions(+), 96 deletions(-)
rename frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/{PlaygroundConstraintItem/PlaygroundConstraintItem.tsx => PlaygroundParamteterItem/PlaygroundParameterItem.tsx} (91%)
rename frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/{PlaygroundConstraintItem/PlaygroundConstraintItem.styles.ts => PlaygroundParamteterItem/PlaygroundParametertem.styles.ts} (100%)
rename frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/{helepers.ts => helpers.ts} (100%)
diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundConstraintItem/PlaygroundConstraintItem.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundParamteterItem/PlaygroundParameterItem.tsx
similarity index 91%
rename from frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundConstraintItem/PlaygroundConstraintItem.tsx
rename to frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundParamteterItem/PlaygroundParameterItem.tsx
index d1f6d90399..eddd9b67c9 100644
--- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundConstraintItem/PlaygroundConstraintItem.tsx
+++ b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundParamteterItem/PlaygroundParameterItem.tsx
@@ -1,18 +1,18 @@
import { Chip, Typography, useTheme } from '@mui/material';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
-import { useStyles } from './PlaygroundConstraintItem.styles';
+import { useStyles } from './PlaygroundParametertem.styles';
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
import { CancelOutlined } from '@mui/icons-material';
import classnames from 'classnames';
interface IConstraintItemProps {
- value: string[];
+ value: Array;
text: string;
input?: string | number | boolean | 'no value';
showReason?: boolean;
}
-export const PlaygroundConstraintItem = ({
+export const PlaygroundParameterItem = ({
value,
text,
input,
@@ -56,13 +56,13 @@ export const PlaygroundConstraintItem = ({
{value.length > 1 ? `${text}s` : text} will get
access.
- {value.map((v: string) => (
+ {value.map((v: string | number) => (
}
diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundConstraintItem/PlaygroundConstraintItem.styles.ts b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundParamteterItem/PlaygroundParametertem.styles.ts
similarity index 100%
rename from frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundConstraintItem/PlaygroundConstraintItem.styles.ts
rename to frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundParamteterItem/PlaygroundParametertem.styles.ts
diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultConstraintExecution/PlaygroundResultConstraintExecution.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultConstraintExecution/PlaygroundResultConstraintExecution.tsx
index cbfdcd486d..3e4b7c71a8 100644
--- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultConstraintExecution/PlaygroundResultConstraintExecution.tsx
+++ b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultConstraintExecution/PlaygroundResultConstraintExecution.tsx
@@ -33,7 +33,7 @@ export const PlaygroundResultConstraintExecution = ({
{constraints?.map((constraint, index) => (
0}
+ condition={index > 0 && constraints?.length > 1}
show={}
/>
0);
+ const hasParameters = Object.keys(parameters).length === 0;
if (!parameters) {
return null;
@@ -68,7 +69,7 @@ export const PlaygroundResultStrategyExecution = ({
/>
0
+ constraints && constraints.length > 0 && !hasParameters
)}
show={}
/>
diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultStrategyExecutionCustomStrategyParams./PlaygroundResultStrategyExecutionCustomStrategyParams.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultStrategyExecutionCustomStrategyParams./PlaygroundResultStrategyExecutionCustomStrategyParams.tsx
index da1a731c01..08670d8872 100644
--- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultStrategyExecutionCustomStrategyParams./PlaygroundResultStrategyExecutionCustomStrategyParams.tsx
+++ b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultStrategyExecutionCustomStrategyParams./PlaygroundResultStrategyExecutionCustomStrategyParams.tsx
@@ -4,14 +4,12 @@ import {
parseParameterStrings,
} from 'utils/parseParameter';
import React, { Fragment } from 'react';
-import { PlaygroundConstraintItem } from '../PlaygroundConstraintItem/PlaygroundConstraintItem';
+import { PlaygroundParameterItem } from '../PlaygroundParamteterItem/PlaygroundParameterItem';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator';
-import { Chip } from '@mui/material';
+import {Chip} from '@mui/material';
import PercentageCircle from 'component/common/PercentageCircle/PercentageCircle';
-import StringTruncator from 'component/common/StringTruncator/StringTruncator';
import { PlaygroundConstraintSchema } from 'hooks/api/actions/usePlayground/playground.model';
-import { useStyles } from '../PlaygroundResultStrategyExecution.styles';
import { useStrategies } from 'hooks/api/getters/useStrategies/useStrategies';
interface PlaygroundResultStrategyExecutionCustomStrategyProps {
@@ -25,15 +23,16 @@ export const PlaygroundResultStrategyExecutionCustomStrategyParams = ({
constraints,
parameters,
}: PlaygroundResultStrategyExecutionCustomStrategyProps) => {
- const { classes: styles } = useStyles();
const { strategies } = useStrategies();
-
const definition = strategies.find(strategyDefinition => {
return strategyDefinition.name === strategyName;
});
+ if (!definition?.editable) {
+ return null;
+ }
+
const renderCustomStrategyParameters = () => {
- if (!definition?.editable) return null;
return definition?.parameters.map((param: any, index: number) => {
const notLastItem = index !== definition?.parameters?.length - 1;
switch (param?.type) {
@@ -43,7 +42,7 @@ export const PlaygroundResultStrategyExecutionCustomStrategyParams = ({
);
return (
-
@@ -81,93 +80,52 @@ export const PlaygroundResultStrategyExecutionCustomStrategyParams = ({
);
case 'boolean':
+ const bool = Boolean(parameters[param?.name]);
return (
-
-
- {' '}
- {parameters[param.name]}
-
+
+
}
- />
- }
+ condition={notLastItem}
+ show={}
/>
);
case 'string':
- const value = parseParameterString(parameters[param.name]);
+ const value = parseParameterString(parameters[param.name]) ?? 'no value';
return (
-
-
-
-
- is set to
-
-
-
- }
- />
- >
- }
- />
+
+
+ }
+ />
+
);
case 'number':
const number = parseParameterNumber(parameters[param.name]);
return (
-
-
-
-
- is set to
-
-
-
- }
- />
- >
- }
- />
+
+
+ }
+ />
+
);
case 'default':
return null;
diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultStrategyExecutionParameters/PlaygroundResultStrategyExecutionParameters.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultStrategyExecutionParameters/PlaygroundResultStrategyExecutionParameters.tsx
index 0f85b338b0..a0582fa107 100644
--- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultStrategyExecutionParameters/PlaygroundResultStrategyExecutionParameters.tsx
+++ b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/PlaygroundResultFeatureStrategyList/PlaygroundResultStrategyList/PlaygroundResultFeatureStrategyItem/PlaygroundResultStrategyExecution/PlaygroundResultStrategyExecutionParameters/PlaygroundResultStrategyExecutionParameters.tsx
@@ -4,14 +4,14 @@ import {
} from 'utils/parseParameter';
import { Box, Chip } from '@mui/material';
import PercentageCircle from 'component/common/PercentageCircle/PercentageCircle';
-import { PlaygroundConstraintItem } from '../PlaygroundConstraintItem/PlaygroundConstraintItem';
+import { PlaygroundParameterItem } from '../PlaygroundParamteterItem/PlaygroundParameterItem';
import React from 'react';
import { useStyles } from '../PlaygroundResultStrategyExecution.styles';
import {
PlaygroundConstraintSchema,
PlaygroundRequestSchema,
} from 'hooks/api/actions/usePlayground/playground.model';
-import { getMappedParam } from '../helepers';
+import { getMappedParam } from '../helpers';
export interface PlaygroundResultStrategyExecutionParametersProps {
parameters: { [key: string]: string };
@@ -62,7 +62,7 @@ export const PlaygroundResultStrategyExecutionParameters = ({
case 'UserIds':
const users = parseParameterStrings(parameters[key]);
return (
-