Skip to content
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

Add bot permissions and turn on feature #37943

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion web/packages/teleport/src/Bots/List/ActionCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function BotOptionsCell({
onClickView,
bot,
disabledEdit,
disabledDelete,
onClickEdit,
}: BotOptionsCellProps) {
return (
Expand All @@ -36,7 +37,9 @@ export function BotOptionsCell({
<MenuItem onClick={onClickEdit} disabled={disabledEdit}>
Edit...
</MenuItem>
<MenuItem onClick={onClickDelete}>Delete...</MenuItem>
<MenuItem onClick={onClickDelete} disabled={disabledDelete}>
Delete...
</MenuItem>
{bot.type === BotUiFlow.GitHubActionsSsh && (
<MenuItem onClick={onClickView}>View...</MenuItem>
)}
Expand Down
1 change: 1 addition & 0 deletions web/packages/teleport/src/Bots/List/BotList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const makeProps = (): BotListProps => ({
attempt: { status: '' },
bots: botsFixture,
disabledEdit: false,
disabledDelete: false,
onClose: () => {},
onDelete: () => {},
onEdit: () => {},
Expand Down
2 changes: 2 additions & 0 deletions web/packages/teleport/src/Bots/List/BotList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function BotList({
attempt,
bots,
disabledEdit,
disabledDelete,
roles,
onClose,
onDelete,
Expand Down Expand Up @@ -78,6 +79,7 @@ export function BotList({
setInteraction(Interaction.VIEW);
}}
disabledEdit={disabledEdit}
disabledDelete={disabledDelete}
onClickEdit={() => {
setSelectedBot(bot);
setSelectedRoles(bot.roles);
Expand Down
1 change: 1 addition & 0 deletions web/packages/teleport/src/Bots/List/Bots.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const List = () => {
attempt={{ status: '' }}
bots={botsFixture}
disabledEdit={false}
disabledDelete={false}
onClose={() => {}}
onDelete={() => {}}
onEdit={() => {}}
Expand Down
3 changes: 2 additions & 1 deletion web/packages/teleport/src/Bots/List/Bots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ export function Bots() {
<BotList
attempt={crudAttempt}
bots={bots}
disabledEdit={!flags.roles}
disabledEdit={!flags.roles || !flags.editBots}
disabledDelete={!flags.removeBots}
roles={roles}
onClose={onClose}
onDelete={onDelete}
Expand Down
2 changes: 2 additions & 0 deletions web/packages/teleport/src/Bots/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { FlatBot } from 'teleport/services/bot/types';
export type BotOptionsCellProps = {
bot: FlatBot;
disabledEdit: boolean;
disabledDelete: boolean;
onClickEdit: (bot: FlatBot) => void;
onClickDelete: (bot: FlatBot) => void;
onClickView: (bot: FlatBot) => void;
Expand All @@ -32,6 +33,7 @@ export type BotListProps = {
attempt: Attempt;
bots: FlatBot[];
disabledEdit: boolean;
disabledDelete: boolean;
roles: string[];
onClose: () => void;
onDelete: () => void;
Expand Down
5 changes: 2 additions & 3 deletions web/packages/teleport/src/features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions web/packages/teleport/src/services/bot/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function fetchBots(
signal: AbortSignal,
flags: FeatureFlags
): Promise<BotList> {
if (!flags.users) {
if (!flags.listBots) {
return;
}

Expand Down Expand Up @@ -89,7 +89,7 @@ export function editBot(
name: string,
req: EditBotRequest
): Promise<FlatBot> {
if (!flags.users || !flags.roles) {
if (!flags.editBots || !flags.roles) {
return;
}

Expand All @@ -99,7 +99,7 @@ export function editBot(
}

export function deleteBot(flags: FeatureFlags, name: string) {
if (!flags.users) {
if (!flags.removeBots) {
return;
}

Expand Down
4 changes: 4 additions & 0 deletions web/packages/teleport/src/teleportContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
}
Expand Down Expand Up @@ -253,6 +255,8 @@ export const disabledFeatureFlags: types.FeatureFlags = {
externalAuditStorage: false,
addBots: false,
listBots: false,
editBots: false,
removeBots: false,
};

export default TeleportContext;
2 changes: 2 additions & 0 deletions web/packages/teleport/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading