rfellows opened a new pull request, #11685: URL: https://github.com/apache/nifi/pull/11685
# NIFI-16352: Disable Component State single-entry clear when the listing is partial ## Description The Component State dialog caps the entries it retrieves from `GET /state` (5000). When a component holds more entries than that, the dialog already renders a "Showing partial results" note, but it still offers the per-entry delete action. Clearing a single entry is not a "delete this key" call — the UI POSTs back the remainder of the state map it currently has in memory, and the server requires that payload to be the full live map minus exactly one key. On a truncated listing that payload is missing thousands of keys, so the request always fails with `Unable to remove a state key... Exactly one key removal is supported.` The user is offered an action that cannot succeed. This change removes the per-entry clear affordance whenever the listing is partial and explains why in the existing partial-results message. Clearing the entire state map is unaffected — that operation does not depend on the visible entries and remains available. ## What's Changed - Hide the `actions` column and its per-entry clear buttons while `partialResults` is true, so a truncated listing never offers an entry delete. - Guard `clearComponentStateEntry()` to return without dispatching when `partialResults` is true, closing the path for any caller that reaches the handler outside the template. - Expand the partial-results message to `Showing partial results.` plus, when the component supports dropping individual keys, `Individual entries cannot be cleared while only partial results are shown.` Components that only support whole-map clear do not get the second sentence, since nothing was taken away from them. - Reset `partialResults` at the start of each component-state emission so a subsequent complete listing restores the actions column. - Replace the three separate column-mutating subscriptions with a single `syncDisplayedColumns()` that rebuilds the column list from scratch. - Convert `dropStateKeySupported`, `canClear`, and the cluster summary to store signals; drop the now-unused `concatLatestFrom` import. - Add `data-qa` hooks for the per-entry clear button and the partial-results message. - Add unit tests covering the partial-listing behavior and column ordering. ## Key Features - **Single source of truth for columns**: `syncDisplayedColumns()` rebuilds `['key', 'value']` and then conditionally appends `scope` (when connected to a cluster) and `actions` (when `canClear`, `dropStateKeySupported`, and not partial). Previously three independent subscriptions spliced into a shared array, which made ordering dependent on emission order; `actions` is now always last. An `effect()` plus the state subscription keep the list in sync as either signal or the state map changes. - **Partial detection covers both maps**: `partialResults` is set when either the local or the cluster state map reports a `totalEntryCount` greater than the number of returned entries. A truncated cluster map disables entry clearing even when the local map is complete, because the POST payload spans both. - **Whole-map clear preserved**: `clearState()` is untouched and still renders for `canClear() && totalEntries > 0`, so users retain a working escape hatch on very large state maps. - **Defense in depth**: the template no longer renders the button and the handler no-ops, so the invalid request cannot be issued from either layer. ## Testing Added to `component-state.component.spec.ts`: - Actions column and delete buttons are hidden when the local map is truncated. - Actions column is hidden when only the cluster map is truncated (columns resolve to `['key', 'value', 'scope']`). - Actions column and buttons are restored after a complete listing replaces a truncated one. - Banner copy includes the individual-entry sentence when `dropStateKeySupported` is true and omits it when false; no banner on a complete listing. - `clearState()` still dispatches `clearComponentState` while the listing is partial. - `clearComponentStateEntry()` dispatches nothing when `partialResults` is true. - Column ordering places `scope` before `actions` when connected to a cluster. A `renderVirtualRows()` helper stubs the virtual-scroll viewport dimensions so row-level assertions can run against rendered cells. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
