-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Web: Add MarkInverse and ResourceLabelTooltip contents (#50532)
* Add a inverse Mark version inside tooltips * Add tooltip contents for resource labels * Fix spacing for ButtonTextWithAddIcon * Add index file for export * Rename MarkForTooltip to MarkInverse * Address CRs
- Loading branch information
Showing
11 changed files
with
225 additions
and
3 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
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
29 changes: 29 additions & 0 deletions
29
...packages/teleport/src/Discover/Shared/ResourceLabelTooltip/ResourceLabelTooltip.story.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,29 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { ResourceLabelTooltip } from './ResourceLabelTooltip'; | ||
|
||
export default { | ||
title: 'Teleport/Discover/Shared/ResourceLabelTooltip', | ||
}; | ||
|
||
export const RDS = () => <ResourceLabelTooltip resourceKind="rds" />; | ||
export const EKS = () => <ResourceLabelTooltip resourceKind="eks" />; | ||
export const Server = () => <ResourceLabelTooltip resourceKind="server" />; | ||
export const Database = () => <ResourceLabelTooltip resourceKind="db" />; | ||
export const Kube = () => <ResourceLabelTooltip resourceKind="kube" />; |
147 changes: 147 additions & 0 deletions
147
web/packages/teleport/src/Discover/Shared/ResourceLabelTooltip/ResourceLabelTooltip.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,147 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import Link from 'design/Link'; | ||
import { MarkInverse } from 'design/Mark'; | ||
import { Position } from 'design/Popover/Popover'; | ||
import { IconTooltip } from 'design/Tooltip'; | ||
import styled from 'styled-components'; | ||
|
||
/** | ||
* Returns a IconTooltip component with its tip contents | ||
* set to the requested resource kind. | ||
* | ||
* @param resourceKind - the tip contents differ slightly depending | ||
* on the resource kind | ||
* @param toolTipPosition (opt) - the position which the tooltip should | ||
* render (see type Position) | ||
* @returns JSX Element | ||
*/ | ||
export function ResourceLabelTooltip({ | ||
resourceKind, | ||
toolTipPosition, | ||
}: { | ||
resourceKind: 'server' | 'eks' | 'rds' | 'kube' | 'db'; | ||
toolTipPosition?: Position; | ||
}) { | ||
let tip; | ||
|
||
switch (resourceKind) { | ||
case 'server': { | ||
tip = ( | ||
<> | ||
Labels allow you to do the following: | ||
<Ul> | ||
<li> | ||
Filter servers by labels when using tsh, tctl, or the web UI. | ||
</li> | ||
<li> | ||
Restrict access to this server with{' '} | ||
<Link | ||
target="_blank" | ||
href="https://goteleport.com/docs/enroll-resources/server-access/rbac/" | ||
> | ||
Teleport RBAC | ||
</Link> | ||
. Only roles with <MarkInverse>node_labels</MarkInverse> that | ||
match these labels will be allowed to access this server. | ||
</li> | ||
</Ul> | ||
</> | ||
); | ||
break; | ||
} | ||
case 'kube': | ||
case 'eks': { | ||
tip = ( | ||
<> | ||
Labels allow you to do the following: | ||
<Ul> | ||
<li> | ||
Filter Kubernetes clusters by labels when using tsh, tctl, or the | ||
web UI. | ||
</li> | ||
<li> | ||
Restrict access to this Kubernetes cluster with{' '} | ||
<Link | ||
target="_blank" | ||
href="https://goteleport.com/docs/enroll-resources/kubernetes-access/controls/" | ||
> | ||
Teleport RBAC | ||
</Link> | ||
. Only roles with <MarkInverse>kubernetes_labels</MarkInverse>{' '} | ||
that match these labels will be allowed to access this Kubernetes | ||
cluster. | ||
</li> | ||
{resourceKind === 'eks' && ( | ||
<li> | ||
All the AWS tags from the selected EKS will be included upon | ||
enrollment. | ||
</li> | ||
)} | ||
</Ul> | ||
</> | ||
); | ||
break; | ||
} | ||
case 'rds': | ||
case 'db': { | ||
tip = ( | ||
<> | ||
Labels allow you to do the following: | ||
<Ul> | ||
<li> | ||
Filter databases by labels when using tsh, tctl, or the web UI. | ||
</li> | ||
<li> | ||
Restrict access to this database with{' '} | ||
<Link | ||
target="_blank" | ||
href="https://goteleport.com/docs/enroll-resources/database-access/rbac/" | ||
> | ||
Teleport RBAC | ||
</Link> | ||
. Only roles with <MarkInverse>db_labels</MarkInverse> that match | ||
these labels will be allowed to access this database. | ||
</li> | ||
{resourceKind === 'rds' && ( | ||
<li> | ||
All the AWS tags from the selected RDS will be included upon | ||
enrollment. | ||
</li> | ||
)} | ||
</Ul> | ||
</> | ||
); | ||
break; | ||
} | ||
default: | ||
resourceKind satisfies never; | ||
} | ||
|
||
return ( | ||
<IconTooltip sticky={true} position={toolTipPosition}> | ||
{tip} | ||
</IconTooltip> | ||
); | ||
} | ||
|
||
const Ul = styled.ul` | ||
margin: 0; | ||
padding-left: ${p => p.theme.space[4]}px; | ||
`; |
19 changes: 19 additions & 0 deletions
19
web/packages/teleport/src/Discover/Shared/ResourceLabelTooltip/index.ts
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,19 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
export { ResourceLabelTooltip } from './ResourceLabelTooltip'; |