-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(capman): Change allocation policy table color based on active/en…
…forced (#5593) In order to make it more clear the state of the policy (active, enforced, inactive) change the color of the table to make it more obvious to the user what is happening * make table component styles configurable, change allocation policy table colors as example * make the policy table color change based on the active/enforced characteristics * fix annoying text wrapping * add a test * actually add the test
- Loading branch information
Showing
6 changed files
with
162 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
snuba/admin/static/tests/capacity_management/allocation_policies.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
snuba/admin/static/tests/capacity_management/table_color.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import {getTableColor} from "../../capacity_management/allocation_policy"; | ||
import { AllocationPolicy, AllocationPolicyConfig } from "../../capacity_management/types"; | ||
import { COLORS } from "../../theme"; | ||
import { it, expect } from "@jest/globals"; | ||
|
||
let bonus_configs = [{ | ||
name: "key1", | ||
value: "10", | ||
description: "something", | ||
type: "int", | ||
params: {}, | ||
}, | ||
{ | ||
name: "key2", | ||
value: "20", | ||
description: "something params", | ||
type: "int", | ||
params: { a: "1", b: "2" }, | ||
}, | ||
] | ||
|
||
|
||
|
||
it("should be gray when the policy is inactive", () => { | ||
let configs = [ | ||
{ | ||
name: "is_active", | ||
value: "0", | ||
description: "", | ||
type: "int", | ||
params: {}, | ||
}, | ||
{ | ||
name: "is_enforced", | ||
value: "1", | ||
description: "", | ||
type: "int", | ||
params: {}, | ||
}, | ||
].concat(bonus_configs); | ||
expect(getTableColor(configs)).toBe("gray") | ||
}) | ||
|
||
|
||
it("should be blue when the policy is active and enforced", () => { | ||
let configs = [ | ||
{ | ||
name: "is_active", | ||
value: "1", | ||
description: "", | ||
type: "int", | ||
params: {}, | ||
}, | ||
{ | ||
name: "is_enforced", | ||
value: "1", | ||
description: "", | ||
type: "int", | ||
params: {}, | ||
} | ||
].concat(bonus_configs); | ||
expect(getTableColor(configs)).toBe(COLORS.SNUBA_BLUE); | ||
}) | ||
|
||
|
||
it("should be orange when the policy is active and enforced", () => { | ||
let configs = [ | ||
{ | ||
name: "is_active", | ||
value: "1", | ||
description: "", | ||
type: "int", | ||
params: {}, | ||
}, | ||
{ | ||
name: "is_enforced", | ||
value: "0", | ||
description: "", | ||
type: "int", | ||
params: {}, | ||
} | ||
].concat(bonus_configs); | ||
expect(getTableColor(configs)).toBe("orange") | ||
}) |