1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-13 13:48:59 +02:00

remove some now-redundant code

This commit is contained in:
Thomas Heartman 2025-05-07 10:16:44 +02:00
parent 544072e40d
commit 47843b3c52
3 changed files with 3 additions and 80 deletions

View File

@ -179,35 +179,17 @@ type ConstraintUpdateAction =
type Props = {
localConstraint: IConstraint;
// setContextName: (contextName: string) => void;
// setOperator: (operator: Operator) => void;
// setLocalConstraint: React.Dispatch<React.SetStateAction<IConstraint>>;
onDelete?: () => void;
// toggleInvertedOperator: () => void;
// toggleCaseSensitivity: () => void;
contextDefinition: Pick<IUnleashContextDefinition, 'legalValues'>;
constraintValues: string[];
constraintValue: string;
// setValue: (value: string) => void;
// setValues: (values: string[]) => void;
// removeValue: (index: number) => void;
updateConstraint: (action: ConstraintUpdateAction) => void;
};
export const EditableConstraint: FC<Props> = ({
localConstraint,
// setLocalConstraint,
// setContextName,
// setOperator,
onDelete,
// toggleInvertedOperator,
// toggleCaseSensitivity,
contextDefinition,
constraintValues,
constraintValue,
// setValue,
// setValues,
// removeValue,
updateConstraint,
}) => {
const { input } = useConstraintInput({
@ -222,34 +204,6 @@ export const EditableConstraint: FC<Props> = ({
const addValuesButtonRef = useRef<HTMLButtonElement>(null);
const inputType = getInputType(input);
/* We need a special case to handle the currentTime context field. Since
this field will be the only one to allow DATE_BEFORE and DATE_AFTER operators
this will check if the context field is the current time context field AND check
if it is not already using one of the date operators (to not overwrite if there is existing
data). */
// useEffect(() => {
// if (
// contextName === CURRENT_TIME_CONTEXT_FIELD &&
// !oneOf(dateOperators, operator)
// ) {
// setLocalConstraint((prev) => ({
// ...prev,
// operator: DATE_AFTER,
// value: new Date().toISOString(),
// }));
// } else if (
// contextName !== CURRENT_TIME_CONTEXT_FIELD &&
// oneOf(dateOperators, operator)
// ) {
// setOperator(IN);
// }
// if (oneOf(stringOperators, operator)) {
// setShowCaseSensitiveButton(true);
// } else {
// setShowCaseSensitiveButton(false);
// }
// }, [contextName, setOperator, operator, setLocalConstraint]);
if (!context) {
return null;
}
@ -260,20 +214,6 @@ export const EditableConstraint: FC<Props> = ({
const onOperatorChange = (operator: Operator) => {
updateConstraint({ type: 'set operator', payload: operator });
// if (oneOf(stringOperators, operator)) {
// setShowCaseSensitiveButton(true);
// } else {
// setShowCaseSensitiveButton(false);
// }
// if (oneOf(dateOperators, operator)) {
// setLocalConstraint((prev) => ({
// ...prev,
// operator: operator,
// value: new Date().toISOString(),
// }));
// } else {
// setOperator(operator);
// }
};
const validator = useMemo(() => constraintValidator(input), [input]);

View File

@ -121,11 +121,6 @@ export const EditableConstraintWrapper = ({
}
};
// const [state, dispatch] = useReducer(
// constraintReducer,
// cleanConstraint(constraint),
// );
const [localConstraint, setLocalConstraint] = useState(
cleanConstraint(constraint),
);
@ -152,7 +147,6 @@ export const EditableConstraintWrapper = ({
localConstraint={localConstraint}
onDelete={onDelete}
constraintValues={constraint?.values || []}
constraintValue={constraint?.value || ''}
contextDefinition={contextDefinition}
updateConstraint={updateConstraint}
/>

View File

@ -73,11 +73,9 @@ const LegalValuesSelectorWidget = styled('article')(({ theme }) => ({
export const LegalValuesSelector = ({
data,
values,
// setValues,
addValues,
removeValue,
clearAll,
// setValuesWithRecord,
constraintValues,
}: IRestrictiveLegalValuesProps) => {
const [filter, setFilter] = useState('');
@ -107,6 +105,7 @@ export const LegalValuesSelector = ({
useEffect(() => {
if (illegalValues.length > 0) {
// todo: impl this
console.log('would clean deleted values here');
// setValues(cleanDeletedLegalValues(values));
}
@ -115,15 +114,9 @@ export const LegalValuesSelector = ({
const onChange = (legalValue: string) => {
if (valuesMap[legalValue]) {
removeValue(legalValue);
// const index = values.findIndex((value) => value === legalValue);
// const newValues = [...values];
// newValues.splice(index, 1);
// setValuesWithRecord(newValues);
return;
} else {
addValues([legalValue]);
}
addValues([legalValue]);
// setValuesWithRecord([...cleanDeletedLegalValues(values), legalValue]);
};
const isAllSelected = legalValues.every((value) =>
@ -134,13 +127,9 @@ export const LegalValuesSelector = ({
if (isAllSelected) {
clearAll();
return;
// return setValuesWithRecord([]);
} else {
addValues(legalValues.map(({ value }) => value));
}
// setValuesWithRecord([
// ...legalValues.map((legalValue) => legalValue.value),
// ]);
};
const handleSearchKeyDown = (event: React.KeyboardEvent) => {