Skip to content

Commit 9db17b8

Browse files
committed
fixes: generate modal types and removed unused code
1 parent 171eb5d commit 9db17b8

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

src/Pages/GlobalConfigurations/Authorization/APITokens/GenerateModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const GenerateModal = ({
6060
<GenericModal.Body>
6161
<div className="flexbox-col dc__gap-20 p-20">
6262
<div className="flexbox-col dc__gap-4">
63-
<h5 className="m-0 cn-9 lh-1-5">
63+
<h5 className="m-0 cn-9 lh-1-5 fw-6">
6464
Copy and store this token safely, you won’t be able to view it again.
6565
</h5>
6666
<p className="cn-7 fs-12 lh-1-5 m-0">

src/Pages/GlobalConfigurations/Authorization/APITokens/apiToken.type.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import React from 'react'
1818

19+
import { GenericModalProps } from '@devtron-labs/devtron-fe-common-lib'
20+
1921
export interface FormType {
2022
name: string
2123
description: string
@@ -79,7 +81,7 @@ export interface GenerateTokenModalType {
7981
reload: () => void
8082
redirectToTokenList: () => void
8183
isRegenerationModal?: boolean
82-
open: boolean
84+
open: GenericModalProps['open']
8385
}
8486

8587
export interface APITokenListType {

src/components/ciPipeline/Webhook/WebhookDetailsModal.tsx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import './webhookDetails.scss'
5050
import { getUserRole, createOrUpdateUser } from '@Pages/GlobalConfigurations/Authorization/authorization.service'
5151
import { MODES, SERVER_MODE, WEBHOOK_NO_API_TOKEN_ERROR } from '../../../config'
5252
import { createGeneratedAPIToken } from '@Pages/GlobalConfigurations/Authorization/APITokens/service'
53-
import { CURL_PREFIX, PLAYGROUND_TAB_LIST, REQUEST_BODY_TAB_LIST, RESPONSE_TAB_LIST } from './webhook.utils'
53+
import { CURL_PREFIX, GENERATE_TOKEN_WITH_REQUIRED_PERMISSIONS, PLAYGROUND_TAB_LIST, REQUEST_BODY_TAB_LIST, RESPONSE_TAB_LIST } from './webhook.utils'
5454
import { SchemaType, TabDetailsType, WebhookDetailsType, WebhookDetailType } from './types'
5555
import { executeWebhookAPI, getExternalCIConfig, getWebhookAPITokenList } from './webhook.service'
5656
import { GENERATE_TOKEN_NAME_VALIDATION } from '../../../config/constantMessaging'
@@ -178,19 +178,6 @@ export const WebhookDetailsModal = ({ close, isTemplateView }: WebhookDetailType
178178
setSampleCURL(
179179
CURL_PREFIX.replace('{webhookURL}', _webhookDetails.webhookUrl).replace('{data}', modifiedJSONString),
180180
)
181-
if (_isSuperAdmin) {
182-
const { result } = await getWebhookAPITokenList(
183-
_webhookDetails.projectName,
184-
_webhookDetails.environmentIdentifier,
185-
_webhookDetails.appName,
186-
)
187-
const sortedResult =
188-
result
189-
?.sort((a, b) => a['name'].localeCompare(b['name']))
190-
.map((tokenData) => {
191-
return { label: tokenData.name, value: tokenData.id, ...tokenData }
192-
}) || []
193-
}
194181
setLoader(false)
195182
} catch (error) {
196183
setIsSuperAdmin(false)
@@ -412,7 +399,7 @@ export const WebhookDetailsModal = ({ close, isTemplateView }: WebhookDetailType
412399
onChange={handleTokenNameChange}
413400
disabled={!!generatedAPIToken}
414401
error={showTokenNameError && GENERATE_TOKEN_NAME_VALIDATION}
415-
helperText="An API token with the required permissions will be auto-generated."
402+
helperText="An API token with the required permissions will be generated."
416403
required
417404
/>
418405
{generatedAPIToken && renderSelectedToken(generatedAPIToken)}
@@ -447,11 +434,11 @@ export const WebhookDetailsModal = ({ close, isTemplateView }: WebhookDetailType
447434
dataTestId="select-or-generate-token"
448435
variant={ButtonVariantType.text}
449436
onClick={toggleTokenSection}
450-
text="Auto-generate token with required permissions"
437+
text={GENERATE_TOKEN_WITH_REQUIRED_PERMISSIONS}
451438
/>
452439
) : (
453440
<div className="cn-9 fs-13 mb-8">
454-
<span className="fs-13 lh-1-5 fw-6">Generate token with required permissions</span>
441+
<span className="fs-13 lh-1-5 fw-6">{GENERATE_TOKEN_WITH_REQUIRED_PERMISSIONS}</span>
455442
{renderGenerateTokenSection()}
456443
</div>
457444
)

src/components/ciPipeline/Webhook/webhook.utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ export const CURL_PREFIX = `curl --location --request POST \\
3535
--header 'Content-Type: application/json' \\
3636
--header 'api-token: {token}' \\
3737
--data-raw '{data}'`
38+
39+
export const GENERATE_TOKEN_WITH_REQUIRED_PERMISSIONS = 'Generate token with required permissions'

0 commit comments

Comments
 (0)