From e1db9dbbeb90224ee4308bdda938b1000565b5f4 Mon Sep 17 00:00:00 2001 From: Michelle Bergquist Date: Thu, 8 Feb 2024 11:28:29 -0700 Subject: [PATCH] Add bot permissions and turn on feature --- web/packages/teleport/src/Bots/List/ActionCell.tsx | 5 ++++- web/packages/teleport/src/Bots/List/BotList.test.tsx | 1 + web/packages/teleport/src/Bots/List/BotList.tsx | 2 ++ web/packages/teleport/src/Bots/List/Bots.story.tsx | 1 + web/packages/teleport/src/Bots/List/Bots.tsx | 3 ++- web/packages/teleport/src/Bots/types.ts | 2 ++ web/packages/teleport/src/features.tsx | 5 ++--- web/packages/teleport/src/services/bot/bot.ts | 6 +++--- web/packages/teleport/src/teleportContext.tsx | 4 ++++ web/packages/teleport/src/types.ts | 2 ++ 10 files changed, 23 insertions(+), 8 deletions(-) diff --git a/web/packages/teleport/src/Bots/List/ActionCell.tsx b/web/packages/teleport/src/Bots/List/ActionCell.tsx index 6c67fa739173e..ec98394a9d0a6 100644 --- a/web/packages/teleport/src/Bots/List/ActionCell.tsx +++ b/web/packages/teleport/src/Bots/List/ActionCell.tsx @@ -28,6 +28,7 @@ export function BotOptionsCell({ onClickView, bot, disabledEdit, + disabledDelete, onClickEdit, }: BotOptionsCellProps) { return ( @@ -36,7 +37,9 @@ export function BotOptionsCell({ Edit... - Delete... + + Delete... + {bot.type === BotUiFlow.GitHubActionsSsh && ( View... )} diff --git a/web/packages/teleport/src/Bots/List/BotList.test.tsx b/web/packages/teleport/src/Bots/List/BotList.test.tsx index 9192e65d52092..02b281c37f59f 100644 --- a/web/packages/teleport/src/Bots/List/BotList.test.tsx +++ b/web/packages/teleport/src/Bots/List/BotList.test.tsx @@ -27,6 +27,7 @@ const makeProps = (): BotListProps => ({ attempt: { status: '' }, bots: botsFixture, disabledEdit: false, + disabledDelete: false, onClose: () => {}, onDelete: () => {}, onEdit: () => {}, diff --git a/web/packages/teleport/src/Bots/List/BotList.tsx b/web/packages/teleport/src/Bots/List/BotList.tsx index 231b2fe9e693a..bd1449e009bca 100644 --- a/web/packages/teleport/src/Bots/List/BotList.tsx +++ b/web/packages/teleport/src/Bots/List/BotList.tsx @@ -39,6 +39,7 @@ export function BotList({ attempt, bots, disabledEdit, + disabledDelete, roles, onClose, onDelete, @@ -78,6 +79,7 @@ export function BotList({ setInteraction(Interaction.VIEW); }} disabledEdit={disabledEdit} + disabledDelete={disabledDelete} onClickEdit={() => { setSelectedBot(bot); setSelectedRoles(bot.roles); diff --git a/web/packages/teleport/src/Bots/List/Bots.story.tsx b/web/packages/teleport/src/Bots/List/Bots.story.tsx index 8d12d0c30f902..0d4b6287d4f1b 100644 --- a/web/packages/teleport/src/Bots/List/Bots.story.tsx +++ b/web/packages/teleport/src/Bots/List/Bots.story.tsx @@ -31,6 +31,7 @@ export const List = () => { attempt={{ status: '' }} bots={botsFixture} disabledEdit={false} + disabledDelete={false} onClose={() => {}} onDelete={() => {}} onEdit={() => {}} diff --git a/web/packages/teleport/src/Bots/List/Bots.tsx b/web/packages/teleport/src/Bots/List/Bots.tsx index 2f445df9098a6..7c57c8b3f0328 100644 --- a/web/packages/teleport/src/Bots/List/Bots.tsx +++ b/web/packages/teleport/src/Bots/List/Bots.tsx @@ -146,7 +146,8 @@ export function Bots() { void; onClickDelete: (bot: FlatBot) => void; onClickView: (bot: FlatBot) => void; @@ -32,6 +33,7 @@ export type BotListProps = { attempt: Attempt; bots: FlatBot[]; disabledEdit: boolean; + disabledDelete: boolean; roles: string[]; onClose: () => void; onDelete: () => void; diff --git a/web/packages/teleport/src/features.tsx b/web/packages/teleport/src/features.tsx index 2fbbb551ea187..0e65ececf1985 100644 --- a/web/packages/teleport/src/features.tsx +++ b/web/packages/teleport/src/features.tsx @@ -222,9 +222,8 @@ export class FeatureBots implements TeleportFeature { component: Bots, }; - // todo (michellescripts) return flags.Users once integrated with mcbattirola and feature is ready - hasAccess() { - return false; + hasAccess(flags: FeatureFlags) { + return flags.listBots; } navigationItem = { diff --git a/web/packages/teleport/src/services/bot/bot.ts b/web/packages/teleport/src/services/bot/bot.ts index 17ecfad4d766f..9db10d4d93b1f 100644 --- a/web/packages/teleport/src/services/bot/bot.ts +++ b/web/packages/teleport/src/services/bot/bot.ts @@ -61,7 +61,7 @@ export function fetchBots( signal: AbortSignal, flags: FeatureFlags ): Promise { - if (!flags.users) { + if (!flags.listBots) { return; } @@ -89,7 +89,7 @@ export function editBot( name: string, req: EditBotRequest ): Promise { - if (!flags.users || !flags.roles) { + if (!flags.editBots || !flags.roles) { return; } @@ -99,7 +99,7 @@ export function editBot( } export function deleteBot(flags: FeatureFlags, name: string) { - if (!flags.users) { + if (!flags.removeBots) { return; } diff --git a/web/packages/teleport/src/teleportContext.tsx b/web/packages/teleport/src/teleportContext.tsx index 31ffda295d1f6..7c001ef474efa 100644 --- a/web/packages/teleport/src/teleportContext.tsx +++ b/web/packages/teleport/src/teleportContext.tsx @@ -216,6 +216,8 @@ class TeleportContext implements types.Context { externalAuditStorage: userContext.getExternalAuditStorageAccess().list, listBots: userContext.getBotsAccess().list, addBots: userContext.getBotsAccess().create, + editBots: userContext.getBotsAccess().edit, + removeBots: userContext.getBotsAccess().remove, }; } } @@ -253,6 +255,8 @@ export const disabledFeatureFlags: types.FeatureFlags = { externalAuditStorage: false, addBots: false, listBots: false, + editBots: false, + removeBots: false, }; export default TeleportContext; diff --git a/web/packages/teleport/src/types.ts b/web/packages/teleport/src/types.ts index 5cd081e8a3a82..31191840b04c3 100644 --- a/web/packages/teleport/src/types.ts +++ b/web/packages/teleport/src/types.ts @@ -179,6 +179,8 @@ export interface FeatureFlags { externalAuditStorage: boolean; listBots: boolean; addBots: boolean; + editBots: boolean; + removeBots: boolean; } // LockedFeatures are used for determining which features are disabled in the user's cluster.