Skip to content

Self service permissions > 'Settings' page - #1164

Open
carma12 wants to merge 2 commits into
freeipa:mainfrom
carma12:self-service-permissions-settings
Open

Self service permissions > 'Settings' page#1164
carma12 wants to merge 2 commits into
freeipa:mainfrom
carma12:self-service-permissions-settings

Conversation

@carma12

@carma12 carma12 commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

This PR depends on this one to be merged: #1153

Summary by Sourcery

Provide end-to-end self-service permission management, including a Settings page for viewing and updating permission attributes.

New Features:

  • Add a self-service permissions management page with listing, search, pagination, creation, deletion, and contextual help.
  • Add a self-service permission Settings view for editing permitted attributes with save and revert actions.
  • Add a reusable checkbox-enabled typeahead control for selecting and filtering multiple values.

Enhancements:

  • Add API integration and data handling for self-service permission discovery, display, creation, modification, and deletion.
  • Expose self-service permissions through application navigation and detail routes.

Documentation:

  • Update documentation links for self-service permissions.

Tests:

  • Add component coverage for multi-select typeahead behavior, filtering, selection, and read-only handling.

@carma12 carma12 self-assigned this Aug 18, 2026
@carma12 carma12 added the needs-review This PR is waiting on a review label Aug 18, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In TypeAheadWithCheckbox, the previousTarget/localOptions reset logic calls setState directly during render when creationProps.onChangeTarget changes; this should be moved into a useEffect on creationProps?.onChangeTarget to avoid React warnings and unnecessary re-renders.
  • The TypeAheadWithCheckbox component mutates localOptions and availableOptions in the same render cycle and uses eslint-disable to work around useEffect behavior; consider refactoring the options filtering/creation logic into pure derivations from props and input state to make the component easier to reason about and avoid reliance on side effects for basic data shaping.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `TypeAheadWithCheckbox`, the `previousTarget`/`localOptions` reset logic calls `setState` directly during render when `creationProps.onChangeTarget` changes; this should be moved into a `useEffect` on `creationProps?.onChangeTarget` to avoid React warnings and unnecessary re-renders.
- The `TypeAheadWithCheckbox` component mutates `localOptions` and `availableOptions` in the same render cycle and uses `eslint-disable` to work around `useEffect` behavior; consider refactoring the options filtering/creation logic into pure derivations from props and input state to make the component easier to reason about and avoid reliance on side effects for basic data shaping.

## Individual Comments

### Comment 1
<location path="src/components/TypeAheadWithCheckbox.tsx" line_range="54-57" />
<code_context>
+  const [activeItemId, setActiveItemId] = useState<string | null>(null);
+  const textInputRef = useRef<HTMLInputElement>(undefined);
+
+  const [previousTarget, setPreviousTarget] = useState<T | null>(null);
+  const allowCreation = creationProps !== undefined;
+
+  if (allowCreation && previousTarget !== creationProps?.onChangeTarget) {
+    setPreviousTarget(creationProps.onChangeTarget);
+    setLocalOptions(
</code_context>
<issue_to_address>
**issue (bug_risk):** Avoid calling setState during render when creationProps.onChangeTarget changes

This logic runs during render and triggers `setPreviousTarget`/`setLocalOptions`, introducing side effects in the render phase. In React (especially under StrictMode), this can cause repeated renders and unpredictable behavior. Move this into a `useEffect` that depends on `creationProps?.onChangeTarget` (and `allowCreation`/`options` as needed) so `previousTarget` and `localOptions` are updated after render.

```ts
useEffect(() => {
  if (!allowCreation || !creationProps) return;
  setPreviousTarget(creationProps.onChangeTarget);
  setLocalOptions(
    [...options].sort((a, b) => String(a.value).localeCompare(String(b.value)))
  );
  setInputValue("");
}, [allowCreation, creationProps?.onChangeTarget, options]);
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/components/TypeAheadWithCheckbox.tsx

@duzda duzda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On save please clear the attributes box.

Screencast.From.2026-08-19.10-50-04.mp4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add the barrel file without unit tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can create a unit test for that component.

Comment on lines +32 to +36
const selectedValues = React.useMemo(() => {
return toArray(rawValue).filter(
(val): val is string => typeof val === "string" && val !== ""
);
}, [rawValue]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange piece of code but fine with keeping it in. The BasicType is way too broad.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, this is my attempt to normalize the values here and preventing undesired values. But now I'm thinking that maybe this can be simplified to something like:

const selectedValues = React.useMemo(() => {
  return toArray(rawValue) as string[];
}, [rawValue]);

Not sure if the casting here will be a bad practice though...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically as is a bad practice, but I'd use as here, you're not really narrowing here - the variable is incorrectly typed, you know it's a string, also value "" is still a valid string.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will change it then.

@carma12
carma12 force-pushed the self-service-permissions-settings branch 2 times, most recently from ce0b6af to 61aeb1d Compare August 19, 2026 14:01
@carma12

carma12 commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

On save please clear the attributes box.
Screencast.From.2026-08-19.10-50-04.mp4

I have modified the original TypeAheadWithCheckbox component to clear the textinput when the 'X' button is clicked.

@carma12
carma12 requested a review from duzda August 19, 2026 14:03
@carma12
carma12 force-pushed the self-service-permissions-settings branch from 61aeb1d to f97b9fc Compare August 20, 2026 08:01
@carma12

carma12 commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

Just amended the code mentioned in this comment.

const result = data.result;

if (result) {
if ("error" in result.results[0] && result.results[0].error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

batch delete only inspects results[0] ? What if first delete succeeds and a later one fails?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same: it belongs to PR #1153 and should be fixed there.


// If no option matches the filter exactly, display creation option
if (allowCreation) {
if (!localOptions.some((option) => option.value === inputValue)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPA stores attrs lowercase, but this comparison is case-sensitive typing Mail can show “Create new” next to mail. Lowercase on create and match case-insensitively.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, will fix....

Comment thread src/components/Form/IpaTypeAheadWithCheckbox/IpaTypeAheadWithCheckbox.tsx Outdated
id: "modal-form-self-service-name",
name: "Self-service name",
pfComponent: (
<InputRequiredText

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also validate aciname against ^[-_ a-zA-Z0-9]+$ and reject leading/trailing spaces, this currently only checks that the name is non-empty.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was introduced in the original PR (#1153) from which belongs the first commit of this PR, so maybe should be fixed there.

@carma12
carma12 force-pushed the self-service-permissions-settings branch from f97b9fc to 811cbef Compare August 20, 2026 12:24
@carma12

carma12 commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@pranav210798 - I have amended some of your suggestions, specifically the ones that belong to the current PR / last commit, as it has been built on the top of #1153 and the first commit belong to this one and should be fix there.

The 'Self service permissions' page
must show a table with all the entries
from `selfservice_find` API command and
allow refresh, add, and delete operations.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Carla Martinez <carlmart@redhat.com>
The 'Settings' page must show information
about a specific self-service permission and
allow further modifications.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Carla Martinez <carlmart@redhat.com>
@carma12
carma12 force-pushed the self-service-permissions-settings branch from 811cbef to 2266860 Compare August 20, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review This PR is waiting on a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants