1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-28 17:55:15 +02:00
unleash.unleash/frontend/src/component/common/ConstraintAccordion/ConstraintAccordion.tsx
Tymoteusz Czech 23a874d051 Refactor: convert jsx files to typescript (#881)
* refactor: convert remaining js files to typescript

* refactor: conditionally render remove index

* refactor: dialog component to tsx

* refactor: migrate some files from jsx to tsx

* refactor: convert dropdown element to tsx

* refactor: feature toggle list to tsx

* refactor: update context name in use overrides

* refactor: variant overrides to tsx

refactor: remove unused strategy constraint file

* fix: tsx imports

* fix: update refectored components after rebase

* refactor: rename report list files to tsx

* fix: project health list types

* refactor: addon form - add types

* refactor: copy feature component types

* fix: projects toggle style after tsx refactor

* refactor: update ts types from openapi

* fix: ts refactor changes after review

* fix: header title prop

* fix: update after PR comments

* add test to useoverrides hook

* fix conditionally render time ago

* fix: toggle list empty tooltip

* fix: remove unused variable

* remove unused variable

* fix: remove faulty snapshot
2022-05-02 12:52:33 +02:00

50 lines
1.4 KiB
TypeScript

import { IConstraint } from 'interfaces/strategy';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { ConstraintAccordionEdit } from './ConstraintAccordionEdit/ConstraintAccordionEdit';
import { ConstraintAccordionView } from './ConstraintAccordionView/ConstraintAccordionView';
interface IConstraintAccordionProps {
compact: boolean;
editing: boolean;
constraint: IConstraint;
onCancel: () => void;
onEdit?: () => void;
onDelete?: () => void;
onSave?: (constraint: IConstraint) => void;
}
export const ConstraintAccordion = ({
constraint,
compact = false,
editing,
onEdit,
onCancel,
onDelete,
onSave,
}: IConstraintAccordionProps) => {
if (!constraint) return null;
return (
<ConditionallyRender
condition={Boolean(editing && onSave)}
show={
<ConstraintAccordionEdit
constraint={constraint}
onCancel={onCancel}
onSave={onSave!}
compact={compact}
/>
}
elseShow={
<ConstraintAccordionView
constraint={constraint}
onEdit={onEdit}
onDelete={onDelete}
compact={compact}
/>
}
/>
);
};