-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[NEW] Enterprise tags #18276
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
[NEW] Enterprise tags #18276
Changes from 7 commits
20794fa
10bc6f0
99d6589
8abf038
c11f513
2c201c1
fb443fe
8a2b0f0
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import React, { useMemo, useState } from 'react'; | ||
| import { Tag, Box } from '@rocket.chat/fuselage'; | ||
|
|
||
| import { useMethod } from '../../contexts/ServerContext'; | ||
|
|
||
| function PlanTag() { | ||
| const [plans, setPlans] = useState([]); | ||
| const [background, setBackground] = useState([]); | ||
|
|
||
| const getTags = useMethod('license:getTags'); | ||
|
|
||
| useMemo(() => { | ||
|
ggazzo marked this conversation as resolved.
Outdated
|
||
| const loadTags = async () => { | ||
| setPlans(await getTags()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a catch here: import { useSafely } from '@rocket.chat/fuselage-hooks';
const [plans, setPlans] = useSafely(useState([]));So N.B.: Pay attention to possible memory leaks, tough. If the promise never resolves, |
||
| }; | ||
| loadTags(); | ||
| }, [getTags]); | ||
|
|
||
| useMemo(() => { | ||
| const currBg = []; | ||
| plans.forEach((plan, i) => { | ||
| switch (plan) { | ||
| case 'bronze': | ||
| currBg[i] = '#BD5A0B'; | ||
| break; | ||
| case 'silver': | ||
| currBg[i] = '#9EA2A8'; | ||
| break; | ||
| case 'gold': | ||
| currBg[i] = '#F3BE08'; | ||
| break; | ||
| default: | ||
| currBg[i] = '#2F343D'; | ||
| break; | ||
| } | ||
| }); | ||
| setBackground(currBg); | ||
| }, [plans]); | ||
|
ggazzo marked this conversation as resolved.
Outdated
|
||
|
|
||
| return <Box> | ||
| {plans.map((plan, i) => <Tag key={plan} backgroundColor={background[i]} marginInlineStart='x8' color='#fff' textTransform='capitalize' >{plan}</Tag>) } | ||
|
MartinSchoeler marked this conversation as resolved.
Outdated
|
||
| </Box>; | ||
| } | ||
|
|
||
| export default PlanTag; | ||
Uh oh!
There was an error while loading. Please reload this page.