Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
8838e5e2
Unverified
Commit
8838e5e2
authored
2 years ago
by
gabriellsh
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Chore: Plan tag (#26224)
parent
9975a8b2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/meteor/client/components/PlanTag.tsx
+12
-30
12 additions, 30 deletions
apps/meteor/client/components/PlanTag.tsx
apps/meteor/lib/isTruthy.ts
+1
-0
1 addition, 0 deletions
apps/meteor/lib/isTruthy.ts
with
13 additions
and
30 deletions
apps/meteor/client/components/PlanTag.tsx
+
12
−
30
View file @
8838e5e2
import
{
Box
,
Tag
}
from
'
@rocket.chat/fuselage
'
;
import
{
useSafely
}
from
'
@rocket.chat/fuselage-hooks
'
;
import
{
useMethod
}
from
'
@rocket.chat/ui-contexts
'
;
import
{
useEndpoint
}
from
'
@rocket.chat/ui-contexts
'
;
import
React
,
{
ReactElement
,
useEffect
,
useState
}
from
'
react
'
;
import
{
useQuery
}
from
'
react-query
'
;
import
{
ILicenseTag
}
from
'
../../
ee/app/license/definitions/ILicenseTag
'
;
import
{
isTruthy
}
from
'
../../
lib/isTruthy
'
;
function
PlanTag
():
ReactElement
{
const
[
plans
,
setPlans
]
=
useSafely
(
useState
<
{
name
:
string
;
color
:
string
;
}[]
>
([]),
);
const
[
plans
,
setPlans
]
=
useState
<
string
[]
>
([]);
const
getTags
=
useMethod
(
'
license:getTags
'
);
const
isEnterpriseEdition
=
useEndpoint
(
'
GET
'
,
'
/v1/licenses.isEnterprise
'
);
const
{
data
}
=
useQuery
([
'
licenses.isEnterprise
'
],
()
=>
isEnterpriseEdition
());
useEffect
(()
=>
{
const
developmentTag
=
process
.
env
.
NODE_ENV
===
'
development
'
?
{
name
:
'
development
'
,
color
:
'
#095ad2
'
}
:
null
;
const
fetchTags
=
async
():
Promise
<
void
>
=>
{
const
tags
=
await
getTags
();
setPlans
([
developmentTag
,
...
tags
].
filter
(
Boolean
)
as
ILicenseTag
[]);
};
const
developmentTag
=
process
.
env
.
NODE_ENV
===
'
development
'
?
'
Development
'
:
null
;
const
enterpriseTag
=
data
?.
isEnterprise
?
'
Enterprise
'
:
null
;
fetchTags
(
);
},
[
g
et
Tags
,
setPlans
]);
setPlans
([
developmentTag
,
enterpriseTag
].
filter
(
isTruthy
)
);
},
[
s
et
Plans
,
data
?.
isEnterprise
]);
return
(
<>
{
plans
.
map
((
{
name
,
color
}
)
=>
(
{
plans
.
map
((
name
)
=>
(
<
Box
marginInline
=
'x4'
display
=
'inline-block'
verticalAlign
=
'middle'
key
=
{
name
}
>
<
Tag
style
=
{
{
color
:
'
#fff
'
,
backgroundColor
:
color
,
textTransform
:
'
capitalize
'
,
}
}
>
{
name
}
</
Tag
>
<
Tag
variant
=
'primary'
>
{
name
}
</
Tag
>
</
Box
>
))
}
</>
...
...
This diff is collapsed.
Click to expand it.
apps/meteor/lib/isTruthy.ts
0 → 100644
+
1
−
0
View file @
8838e5e2
export
const
isTruthy
=
<
T
>
(
x
:
T
|
null
|
undefined
|
0
|
false
|
''
):
x
is
T
=>
Boolean
(
x
);
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