import React, {FC} from "react"; import {EmulatedButton} from "./EmulatedButton"; import {__} from "../globals"; import {useOpenTestablesPopupWindow} from "./useOpenTestablesPopupWindow"; import {convertTestableData, useNodesStore} from "./store"; import {PopupWindowStateContext, TreeContextData} from "./atoms"; import {wrapTestablesInDefaultGroup} from "./NodeHelpers"; import {TestableFormat} from "./testables"; export type NoPreconditionsProps = {} export const NoPreconditions: FC = ({}) => { const openTestablesPopup = useOpenTestablesPopupWindow() const addTestables = useNodesStore(store => store.addTestables) const openConditionsPanel = () => { // @ts-ignore const context = { id: 'preconditions-new', scope: 'preconditions', data: { componentType: 'condition', targetType: 'ghost', // root | testableComposite targetId: null, // string id if testableComposite, index if root (eg: 0 for the first root, 1 for the second root, etc) showTabs: false } } as PopupWindowStateContext openTestablesPopup({ // @ts-ignore context, onClose: (data) => { if (data.status !== 'success' || !data.components) { return } addTestables([ [wrapTestablesInDefaultGroup(convertTestableData(data.components), undefined, 'OR')], TestableFormat.Nested ], (addedIds, testablesManager, writeableStore) => { // set the created testable group id as the preconditionsID const rootGroupID = addedIds?.[0] as string | undefined if (!rootGroupID) { return } writeableStore.preconditionsID = rootGroupID }) } }) } return

{__('No preconditions')} {__('Add preconditions')}

Any date, cart subtotal, role, etc.

}