Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
e4eb3f99
Unverified
Commit
e4eb3f99
authored
3 years ago
by
Ariya Hidayat
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Custom expression editor: don't suggest a unique matching function (#20485)
parent
db531274
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/lib/expressions/suggest.js
+18
-7
18 additions, 7 deletions
frontend/src/metabase/lib/expressions/suggest.js
frontend/test/metabase/lib/expressions/suggest.unit.spec.js
+10
-0
10 additions, 0 deletions
frontend/test/metabase/lib/expressions/suggest.unit.spec.js
with
28 additions
and
7 deletions
frontend/src/metabase/lib/expressions/suggest.js
+
18
−
7
View file @
e4eb3f99
...
...
@@ -151,11 +151,22 @@ export function suggest({
suggestions
=
suggestions
.
filter
(
suggestion
=>
suggestion
.
range
);
// deduplicate suggestions and sort by type then name
return
{
suggestions
:
_
.
chain
(
suggestions
)
.
uniq
(
suggestion
=>
suggestion
.
text
)
.
sortBy
(
"
text
"
)
.
sortBy
(
"
order
"
)
.
value
(),
};
suggestions
=
_
.
chain
(
suggestions
)
.
uniq
(
suggestion
=>
suggestion
.
text
)
.
sortBy
(
"
text
"
)
.
sortBy
(
"
order
"
)
.
value
();
// the only suggested function equals the prefix match?
if
(
suggestions
.
length
===
1
&&
matchPrefix
)
{
const
{
icon
}
=
suggestions
[
0
];
if
(
icon
===
"
function
"
)
{
const
helpText
=
getHelpText
(
getMBQLName
(
matchPrefix
));
if
(
helpText
)
{
return
{
helpText
};
}
}
}
return
{
suggestions
};
}
This diff is collapsed.
Click to expand it.
frontend/test/metabase/lib/expressions/suggest.unit.spec.js
+
10
−
0
View file @
e4eb3f99
...
...
@@ -161,6 +161,16 @@ describe("metabase/lib/expression/suggest", () => {
expect
(
args
).
toHaveLength
(
3
);
});
it
(
"
should provide help text for the unique match
"
,
()
=>
{
const
{
structure
,
args
}
=
helpText
({
source
:
"
lower
"
,
// doesn't need to be "lower(" since it's a unique match
query
:
ORDERS
.
query
(),
startRule
:
"
expression
"
,
});
expect
(
structure
).
toEqual
(
"
lower(text)
"
);
expect
(
args
).
toHaveLength
(
1
);
});
it
(
"
should provide help text after first argument if there's only one argument
"
,
()
=>
{
expect
(
helpText
({
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment