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
55f5b9e7
Unverified
Commit
55f5b9e7
authored
3 years ago
by
Alexander Polyankin
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix whitelabling for chart colors (#17903)
parent
227a1e9c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/lib/colors.js
+7
-7
7 additions, 7 deletions
frontend/src/metabase/lib/colors.js
frontend/test/metabase/lib/colors.unit.spec.js
+20
-3
20 additions, 3 deletions
frontend/test/metabase/lib/colors.unit.spec.js
with
27 additions
and
10 deletions
frontend/src/metabase/lib/colors.js
+
7
−
7
View file @
55f5b9e7
...
...
@@ -199,7 +199,7 @@ export function lighten(
}
const
PREFERRED_COLORS
=
{
[
colors
[
"
success
"
]]
:
[
success
:
[
"
success
"
,
"
succeeded
"
,
"
pass
"
,
...
...
@@ -211,7 +211,7 @@ const PREFERRED_COLORS = {
"
active
"
,
"
profit
"
,
],
[
colors
[
"
error
"
]]
:
[
error
:
[
"
error
"
,
"
fail
"
,
"
failed
"
,
...
...
@@ -225,10 +225,10 @@ const PREFERRED_COLORS = {
"
deleted
"
,
"
pending
"
,
],
[
colors
[
"
warning
"
]]
:
[
"
warn
"
,
"
warning
"
,
"
incomplete
"
,
"
unstable
"
],
[
colors
[
"
brand
"
]]
:
[
"
count
"
],
[
colors
[
"
accent1
"
]]
:
[
"
sum
"
],
[
colors
[
"
accent2
"
]]
:
[
"
average
"
],
warning
:
[
"
warn
"
,
"
warning
"
,
"
incomplete
"
,
"
unstable
"
],
brand
:
[
"
count
"
],
accent1
:
[
"
sum
"
],
accent2
:
[
"
average
"
],
};
const
PREFERRED_COLORS_MAP
=
{};
...
...
@@ -244,7 +244,7 @@ for (const color in PREFERRED_COLORS) {
type
Key
=
string
;
function
getPreferredColor
(
key
:
Key
)
{
return
PREFERRED_COLORS_MAP
[
key
.
toLowerCase
()];
return
color
(
PREFERRED_COLORS_MAP
[
key
.
toLowerCase
()]
)
;
}
// returns a mapping of deterministically assigned colors to keys, optionally with a fixed value mapping
...
...
This diff is collapsed.
Click to expand it.
frontend/test/metabase/lib/colors.unit.spec.js
+
20
−
3
View file @
55f5b9e7
import
{
getRandomColor
,
normal
}
from
"
metabase/lib/colors
"
;
import
colors
,
{
getColorForValue
,
getRandomColor
}
from
"
metabase/lib/colors
"
;
describe
(
"
getRandomColor
"
,
()
=>
{
it
(
"
should return a color string from the proper family
"
,
()
=>
{
const
color
=
getRandomColor
(
normal
);
expect
(
Object
.
values
(
normal
)).
toContain
(
color
);
const
color
=
getRandomColor
(
colors
);
expect
(
Object
.
values
(
colors
)).
toContain
(
color
);
});
});
describe
(
"
getColorForValue
"
,
()
=>
{
it
(
"
should get a color by semantic name
"
,
()
=>
{
const
color
=
getColorForValue
(
"
sum
"
);
expect
(
color
).
toBe
(
colors
.
accent1
);
});
it
(
"
should respect changes in colors
"
,
()
=>
{
const
{
accent1
,
accent2
}
=
colors
;
colors
.
accent1
=
accent2
;
const
color
=
getColorForValue
(
"
sum
"
);
colors
.
accent1
=
accent1
;
expect
(
color
).
toBe
(
colors
.
accent2
);
});
});
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