-
Notifications
You must be signed in to change notification settings - Fork 2
allow multiple page rules #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -81,3 +81,11 @@ export const checkPageFilter = (currentUrl, pageFilter, pageFilterType) => { | |||||
|
|
||||||
| return matched; | ||||||
| }; | ||||||
|
|
||||||
| export const checkPageRules = (currentUrl, action) => { | ||||||
| const rules = action.pageRules && action.pageRules.length > 0 | ||||||
| ? action.pageRules | ||||||
| : (action.pageFilter ? [{ pageFilter: action.pageFilter, pageFilterType: action.pageFilterType }] : []); | ||||||
| if (rules.length === 0) return true; | ||||||
| return rules.every(r => checkPageFilter(currentUrl, r.pageFilter, r.pageFilterType)); | ||||||
|
||||||
| return rules.every(r => checkPageFilter(currentUrl, r.pageFilter, r.pageFilterType)); | |
| return rules.every((r) => checkPageFilter(currentUrl, r.pageFilter, r.pageFilterType)); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { arrow, autoUpdate, computePosition, flip, offset, shift } from '@floating-ui/dom'; | ||
| import { GleapSession } from './Gleap'; | ||
| import { loadIcon } from './UI'; | ||
| import { checkPageFilter } from './GleapPageFilter'; | ||
| import { checkPageFilter, checkPageRules } from './GleapPageFilter'; | ||
|
|
||
| export default class GleapTooltipManager { | ||
| tooltips = []; | ||
|
|
@@ -427,6 +427,10 @@ export default class GleapTooltipManager { | |
| const currentUrl = window.location.href; | ||
|
|
||
| return this.tooltips.filter((tooltip) => { | ||
| if (tooltip.pageRules && tooltip.pageRules.length > 0) { | ||
| return checkPageRules(currentUrl, { pageRules: tooltip.pageRules }); | ||
| } | ||
|
Comment on lines
+430
to
+432
|
||
|
|
||
| if (!tooltip.page || tooltip.page.length === 0) { | ||
| return true; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rules.every(...)requires all rules to match the samecurrentUrl, which will make many realistic multi-rule configurations impossible (e.g., two'is'rules for different pages can never both be true). If the intent of “multiple page rules” is “match any of these rules”, switch torules.some(...), or add an explicit operator (e.g.,match: 'any' | 'all') to avoid locking in the wrong semantics.