-
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.
Add GitHub Actions bot view (#37852)
* add bots UI, disabled - in original data table view * Add bot creation UI * Remove duplicated types * add bots UI, disabled - in original data table view * Fix types and tests * Use bot join token api endpoint * Fix tests * Linting and small fixes * Fix tests * Add missing licenses * Improve styles, error messages, etc * Remove clusterId from bot routes * Undo enabling feature * Remove unused join role bot * Rename var * Reuse makeListBot * Add missing type * Revert MachineIDIntegrationSection for now * Lint * Apply suggestions from code review - fix typos Co-authored-by: Noah Stride <[email protected]> * Remove kubernetes section fromm example yaml * Remove border color from reftype selector * Small changes to address code review * Use setAttempt * add try/catch block when parsing repo addresses * Improve tests;remove unecessary fragment * Use gap in flex. Fix typo * Lint fix * Drop "ex" from input placeholders * Add stories for no perm and bot picker * Add copy to explain wrkflow name limits * fix setCurentStep * Fix invalid host error rendering * Use PascalCase for error components * Improve field name validation * Remove unecessary comments * Add bot type by label * Add bot view... * Show view gh actions yaml only for gh bots * Use existing pattern for operations * Add story and missing license * Fix typos Co-authored-by: Michelle Bergquist <[email protected]> --------- Co-authored-by: Michelle Bergquist <[email protected]> Co-authored-by: Noah Stride <[email protected]> Co-authored-by: Michelle Bergquist <[email protected]>
- Loading branch information
1 parent
ebaf393
commit ef1463e
Showing
15 changed files
with
293 additions
and
15 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
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,59 @@ | ||
/** | ||
* 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 React from 'react'; | ||
|
||
import { BotUiFlow } from 'teleport/services/bot/types'; | ||
|
||
import { ContextProvider } from 'teleport'; | ||
import { createTeleportContext } from 'teleport/mocks/contexts'; | ||
|
||
import { ViewBot } from './ViewBot'; | ||
import { ViewBotProps } from './types'; | ||
|
||
export default { | ||
title: 'Teleport/Bots/Add/ViewBot', | ||
}; | ||
|
||
export const GitHubActionsSsh = () => { | ||
const ctx = createTeleportContext(); | ||
|
||
return ( | ||
<ContextProvider ctx={ctx}> | ||
<ViewBot {...props} /> | ||
</ContextProvider> | ||
); | ||
}; | ||
|
||
const props: ViewBotProps = { | ||
bot: { | ||
name: 'my-github-bot', | ||
type: BotUiFlow.GitHubActionsSsh, | ||
namespace: '', | ||
description: '', | ||
labels: null, | ||
revision: '', | ||
traits: [], | ||
status: '', | ||
subKind: '', | ||
version: '', | ||
kind: '', | ||
roles: [], | ||
}, | ||
onClose: () => {}, | ||
}; |
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,74 @@ | ||
/** | ||
* 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 React from 'react'; | ||
import { ButtonSecondary, Flex, Text } from 'design'; | ||
import Dialog, { | ||
DialogContent, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
} from 'design/DialogConfirmation'; | ||
|
||
import TextEditor from 'shared/components/TextEditor'; | ||
|
||
import { ViewBotProps } from 'teleport/Bots/types'; | ||
|
||
import useTeleport from 'teleport/useTeleport'; | ||
|
||
import { getWorkflowExampleYaml } from './Add/GitHubActions/AddBotToWorkflow'; | ||
|
||
export function ViewBot({ bot, onClose }: ViewBotProps) { | ||
const ctx = useTeleport(); | ||
const cluster = ctx.storeUser.state.cluster; | ||
|
||
const yaml = getWorkflowExampleYaml( | ||
bot.name, | ||
cluster.authVersion, | ||
cluster.publicURL, | ||
bot.name, | ||
false | ||
); | ||
|
||
return ( | ||
<Dialog disableEscapeKeyDown={false} onClose={onClose} open={true}> | ||
<DialogHeader> | ||
<DialogTitle>{bot.name}</DialogTitle> | ||
</DialogHeader> | ||
<DialogContent width="640px"> | ||
<Text mb="4"> | ||
Below is an example GitHub Actions workflow to help you get started. | ||
You can find this again from the bot’s options dropdown. | ||
</Text> | ||
<Flex height="500px" pt="3" pr="3" bg="levels.deep" borderRadius={3}> | ||
<TextEditor | ||
readOnly={true} | ||
bg="levels.deep" | ||
data={[{ content: yaml, type: 'yaml' }]} | ||
copyButton={true} | ||
downloadButton={true} | ||
downloadFileName={`${bot.name}-githubactions.yaml`} | ||
/> | ||
</Flex> | ||
</DialogContent> | ||
<DialogFooter> | ||
<ButtonSecondary onClick={onClose}>Close</ButtonSecondary> | ||
</DialogFooter> | ||
</Dialog> | ||
); | ||
} |
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
Oops, something went wrong.