Skip to content

Commit

Permalink
supportsEvaluationHitsCount
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Dec 10, 2024
1 parent 6e4ea9b commit 19e8b23
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/boxed-expression-component/src/api/BeeTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export interface BeeTableProps<R extends object> {
/** Index of the column, where the evaluation hits count should be displayed. If not set, evaluation hits count number is not shown. */
evaluationHitsCountColumnIndex?: number;
/** Method should return true for table rows, that can display evaluation hits count, false otherwise. If not set, BeeTableBody defaults to false. */
getEvaluationHitsCountSupportedByRow?: (row: ReactTable.Row<R>) => boolean;
supportsEvaluationHitsCount?: (row: ReactTable.Row<R>) => boolean;
}

/** Possible status for the visibility of the Table's Header */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export function ConditionalExpression({
return row.original.part["@_id"];
}, []);

const getEvaluationHitsCountSupportedByRow = useCallback((row: ReactTable.Row<ROWTYPE>) => {
const supportsEvaluationHitsCount = useCallback((row: ReactTable.Row<ROWTYPE>) => {
return row.original.label !== "if";
}, []);

Expand All @@ -257,7 +257,7 @@ export function ConditionalExpression({
shouldShowRowsInlineControls={false}
shouldShowColumnsInlineControls={false}
evaluationHitsCountColumnIndex={1}
getEvaluationHitsCountSupportedByRow={getEvaluationHitsCountSupportedByRow}
supportsEvaluationHitsCount={supportsEvaluationHitsCount}
/>
</div>
</NestedExpressionContainerContext.Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ export function DecisionTableExpression({
[beeTableRows.length]
);

const getEvaluationHitsCountSupportedByRow = useCallback((row: ReactTable.Row<ROWTYPE>) => {
const supportsEvaluationHitsCount = useCallback((row: ReactTable.Row<ROWTYPE>) => {
return true;
}, []);

Expand Down Expand Up @@ -1078,7 +1078,7 @@ export function DecisionTableExpression({
shouldShowRowsInlineControls={true}
shouldShowColumnsInlineControls={true}
evaluationHitsCountColumnIndex={0}
getEvaluationHitsCountSupportedByRow={getEvaluationHitsCountSupportedByRow}
supportsEvaluationHitsCount={supportsEvaluationHitsCount}
// lastColumnMinWidth={lastColumnMinWidth} // FIXME: Check if this is a good strategy or not when doing https://github.com/apache/incubator-kie-issues/issues/181
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function BeeTableInternal<R extends object>({
lastColumnMinWidth,
rowWrapper,
evaluationHitsCountColumnIndex,
getEvaluationHitsCountSupportedByRow,
supportsEvaluationHitsCount,
}: BeeTableProps<R> & {
selectionRef?: React.RefObject<BeeTableSelectionRef>;
}) {
Expand Down Expand Up @@ -660,7 +660,7 @@ export function BeeTableInternal<R extends object>({
lastColumnMinWidth={lastColumnMinWidth}
isReadOnly={isReadOnly}
evaluationHitsCountColumnIndex={evaluationHitsCountColumnIndex}
getEvaluationHitsCountSupportedByRow={getEvaluationHitsCountSupportedByRow}
supportsEvaluationHitsCount={supportsEvaluationHitsCount}
/>
</table>
<BeeTableContextMenuHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface BeeTableBodyProps<R extends object> {
/** See BeeTable.ts */
evaluationHitsCountColumnIndex?: number;
/** See BeeTable.ts */
getEvaluationHitsCountSupportedByRow?: (row: ReactTable.Row<R>) => boolean;
supportsEvaluationHitsCount?: (row: ReactTable.Row<R>) => boolean;
}

export function BeeTableBody<R extends object>({
Expand All @@ -78,7 +78,7 @@ export function BeeTableBody<R extends object>({
rowWrapper,
isReadOnly,
evaluationHitsCountColumnIndex,
getEvaluationHitsCountSupportedByRow,
supportsEvaluationHitsCount,
}: BeeTableBodyProps<R>) {
const { evaluationHitsCountById } = useBoxedExpressionEditor();

Expand All @@ -87,7 +87,7 @@ export function BeeTableBody<R extends object>({
reactTableInstance.prepareRow(row);

const rowKey = getRowKey(row);
const isEvalationHitsCountSupportedByRow: boolean = getEvaluationHitsCountSupportedByRow?.(row) ?? false;
const isEvalationHitsCountSupportedByRow: boolean = supportsEvaluationHitsCount?.(row) ?? false;
const rowEvaluationHitsCount = evaluationHitsCountById ? evaluationHitsCountById?.get(rowKey) ?? 0 : undefined;
const canDisplayEvaluationHitsCountRowOverlay =
rowEvaluationHitsCount !== undefined && isEvalationHitsCountSupportedByRow === true;
Expand Down

0 comments on commit 19e8b23

Please sign in to comment.