Skip to content

AB#129192-apply-user-context-filter-to-grid#2856

Open
GhaziAlibi wants to merge 1 commit intonextfrom
AB#129192-apply-user-context-filter-to-grid
Open

AB#129192-apply-user-context-filter-to-grid#2856
GhaziAlibi wants to merge 1 commit intonextfrom
AB#129192-apply-user-context-filter-to-grid

Conversation

@GhaziAlibi
Copy link
Copy Markdown

@GhaziAlibi GhaziAlibi commented Apr 21, 2026

Description

Adds support for {{user.*}} placeholders in dashboard/grid context filters, so filters can be scoped to the current logged-in user.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Automated

npx nx test shared --testFile=context.service.spec.ts

Manual

  • Open a dashboard containing a grid widget → edit the widget → open Context filter.
  • Add a filter , e.g.:
{
  "field": "region",
  "operator": "eq",
  "value": "{{user.region}}"
}
  • Save and reload → grid returns only records matching the logged-in user's attribute.

Screenshots

without filter : 8408 lines

image

with filter: 2016

image image

Checklist:

( * == Mandatory )

  • * I have set myself as assignee of the pull request
  • * My code follows the style guidelines of this project
  • * Linting does not generate new warnings
  • * I have performed a self-review of my own code
  • * I have put the ticket for review, adding the oort-frontend team to the list of reviewers
  • * I have commented my code, particularly in hard-to-understand areas
  • * I have put JSDoc comment in all required places
  • * My changes generate no new warnings
  • * I have included screenshots describing my changes if relevant
  • * I have selected labels in the Pull Request, according to the changes with code brings
  • I have made corresponding changes to the documentation ( if required )
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

More explanation

https://www.loom.com/share/05a716d61b9744faaf51fb304c21d1e5?sid=f87cf896-582a-4f76-93ae-8ceed801b145

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for {{user.*}} placeholders in dashboard/grid context filters so filter values can be resolved from the currently logged-in user (including shortcuts to user attributes).

Changes:

  • Extend ContextService to resolve {{user.*}} placeholders in both replaceFilter() and injectContext().
  • Update filter-row editor selection logic to treat {{user.*}} (and other placeholders) as “dynamic placeholder” values.
  • Update EN/FR tooltip copy and add unit tests covering user placeholder replacement.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
libs/shared/src/lib/services/context/context.service.ts Adds user placeholder parsing/resolution and applies it during filter/context injection.
libs/shared/src/lib/services/context/context.service.spec.ts Adds unit tests verifying user placeholder replacement for replaceFilter() and injectContext().
libs/shared/src/lib/components/filter/filter-row/filter-row.component.ts Ensures dynamic editor is used for {{user.*}} placeholder values.
libs/shared/src/i18n/fr.json Updates tooltip text to document new {{user.*}} placeholders (FR).
libs/shared/src/i18n/en.json Updates tooltip text to document new {{user.*}} placeholders (EN).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

} else {
const userName = obj[prop]?.match(userRegex)?.[0];
if (userName) {
obj[prop] = this.getUserPlaceholderValue(userName);
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

injectContext currently assigns undefined when a {{user.*}} placeholder can’t be resolved (e.g., user not loaded yet or attribute missing). Because composite filters later drop descriptors with nil values, this can silently remove the intended user-scoping filter and broaden the query results. Consider only overwriting the property when the resolved user value is non-nil (otherwise leave the placeholder string intact), or map missing user fields to an explicit “no match” sentinel rather than removing the filter.

Suggested change
obj[prop] = this.getUserPlaceholderValue(userName);
const userValue = this.getUserPlaceholderValue(userName);
if (!isNil(userValue)) {
obj[prop] = userValue;
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants