Skip to content

Commit 2e66cd0

Browse files
committed
Merge branch 'develop' of github.com:devtron-labs/dashboard into feat/react-query-setup
2 parents af0779f + ae36df1 commit 2e66cd0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+555
-764
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.17.0-pre-12",
7+
"@devtron-labs/devtron-fe-common-lib": "1.17.0-pre-15",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/App.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ const App = () => {
168168
<Route path="/" render={() => <NavigationRoutes reloadVersionConfig={reloadVersionConfig} />} />
169169
<Redirect to={window._env_.K8S_CLIENT ? '/' : `${URLS.LOGIN_SSO}${location.search}`} />
170170
</Switch>
171-
<div id="visible-modal" />
172-
<div id="visible-modal-2" />
173171
</BreadcrumbStore>
174172
</ErrorBoundary>
175173
)

src/Pages/App/CreateAppModal/CreateAppModal.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { getHostURLConfiguration } from '@Services/service'
3636

3737
import ApplicationInfoForm from './ApplicationInfoForm'
3838
import { CloneApplicationSelectionList } from './CloneApplicationSelectionList'
39-
import { createAppInitialFormErrorState, createAppInitialFormState } from './constants'
39+
import { createAppInitialFormErrorState, createAppInitialFormState, PROJECT_SELECT_INPUT_ID } from './constants'
4040
import HeaderSection from './HeaderSection'
4141
import { createApp } from './service'
4242
import Sidebar from './Sidebar'
@@ -374,7 +374,7 @@ const CreateAppModal = ({ isJobView, handleClose }: CreateAppModalProps) => {
374374
}
375375

376376
return (
377-
<Drawer position="right" width="1024px" onEscape={handleClose}>
377+
<Drawer position="right" width="1024px" onEscape={handleClose} initialFocus={`#${PROJECT_SELECT_INPUT_ID}`}>
378378
<div className="h-100 bg__modal--primary flexbox-col dc__overflow-hidden">
379379
<HeaderSection isJobView={isJobView} handleClose={handleClose} isCloseDisabled={isSubmitting} />
380380
<div className="flexbox flex-grow-1 dc__overflow-hidden">

src/Pages/App/CreateAppModal/ProjectSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424

2525
import { ReactComponent as ICFolderColor } from '@Icons/ic-folder-color.svg'
2626

27+
import { PROJECT_SELECT_INPUT_ID } from './constants'
2728
import { CreateAppFormStateType, ProjectSelectorProps } from './types'
2829

2930
const ProjectSelector = ({ selectedProjectId, handleProjectIdChange, error }: ProjectSelectorProps) => {
@@ -47,7 +48,7 @@ const ProjectSelector = ({ selectedProjectId, handleProjectIdChange, error }: Pr
4748
<div className="w-300">
4849
<SelectPicker
4950
icon={<ICFolderColor />}
50-
inputId="project"
51+
inputId={PROJECT_SELECT_INPUT_ID}
5152
options={projectOptions}
5253
label="Project"
5354
required
@@ -60,7 +61,6 @@ const ProjectSelector = ({ selectedProjectId, handleProjectIdChange, error }: Pr
6061
value={selectedProject}
6162
onChange={handleChange}
6263
error={error}
63-
autoFocus
6464
/>
6565
</div>
6666
)

src/Pages/App/CreateAppModal/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ export const createAppInitialFormErrorState: CreateAppFormErrorStateType = {
3939
gitMaterials: null,
4040
workflowConfig: null,
4141
}
42+
43+
export const PROJECT_SELECT_INPUT_ID = 'project'

src/Pages/GlobalConfigurations/Authorization/APITokens/ApiTokens.component.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
import emptyGeneratToken from '@Images/ic-empty-generate-token.png'
2929
import { EMPTY_STATE_STATUS } from '@Config/constantMessaging'
3030

31-
import { TokenListType, TokenResponseType } from './apiToken.type'
31+
import { TokenListType } from './apiToken.type'
3232
import APITokenList from './APITokenList'
3333
import CreateAPIToken from './CreateAPIToken'
3434
import EditAPIToken from './EditAPIToken'
@@ -90,13 +90,6 @@ const ApiTokens = () => {
9090
handleFilterChanges(_searchText)
9191
}
9292

93-
const [tokenResponse, setTokenResponse] = useState<TokenResponseType>({
94-
success: false,
95-
token: '',
96-
userId: 0,
97-
userIdentifier: 'API-TOKEN:test',
98-
})
99-
10093
const renderSearchToken = () => (
10194
<SearchBar
10295
initialSearchText={searchText}
@@ -131,8 +124,6 @@ const ApiTokens = () => {
131124
handleGenerateTokenActionButton={handleActionButton}
132125
setSelectedExpirationDate={setSelectedExpirationDate}
133126
selectedExpirationDate={selectedExpirationDate}
134-
tokenResponse={tokenResponse}
135-
setTokenResponse={setTokenResponse}
136127
reload={getData}
137128
/>
138129
</Route>

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {
4343
usePermissionConfiguration,
4444
} from '../Shared/components/PermissionConfigurationForm'
4545
import { createUserPermissionPayload, validateDirectPermissionForm } from '../utils'
46-
import { FormType, GenerateTokenType } from './apiToken.type'
46+
import { FormType, GenerateTokenType, TokenResponseType } from './apiToken.type'
4747
import { getDateInMilliseconds } from './apiToken.utils'
4848
import ExpirationDate from './ExpirationDate'
4949
import GenerateActionButton from './GenerateActionButton'
@@ -69,8 +69,6 @@ const CreateAPIToken = ({
6969
handleGenerateTokenActionButton,
7070
setSelectedExpirationDate,
7171
selectedExpirationDate,
72-
tokenResponse,
73-
setTokenResponse,
7472
reload,
7573
}: GenerateTokenType) => {
7674
const history = useHistory()
@@ -106,6 +104,13 @@ const CreateAPIToken = ({
106104
allowManageAllAccess,
107105
} = usePermissionConfiguration()
108106
const [customDate, setCustomDate] = useState<Moment>(null)
107+
const [tokenResponse, setTokenResponse] = useState<TokenResponseType>({
108+
success: false,
109+
token: '',
110+
userId: 0,
111+
userIdentifier: 'API-TOKEN:test',
112+
hideApiToken: false,
113+
})
109114
const validationRules = new ValidationRules()
110115

111116
// Reset selected expiration date to 30 days on unmount
@@ -210,6 +215,7 @@ const CreateAPIToken = ({
210215
const userPermissionPayload = createUserPermissionPayload({
211216
id: result.userId,
212217
userIdentifier: result.userIdentifier,
218+
hideApiToken: result.hideApiToken,
213219
userRoleGroups,
214220
serverMode,
215221
directPermission,
@@ -308,13 +314,13 @@ const CreateAPIToken = ({
308314
buttonText="Generate token"
309315
disabled={isSaveDisabled}
310316
/>
311-
312317
<GenerateModal
313318
close={handleGenerateTokenActionButton}
314319
token={tokenResponse.token}
315320
reload={reload}
316321
redirectToTokenList={redirectToTokenList}
317322
open={showGenerateModal}
323+
hideApiToken={tokenResponse.hideApiToken}
318324
/>
319325
</div>
320326
)

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
Button,
2424
ButtonStyleType,
2525
ButtonVariantType,
26+
ClipboardButton,
2627
CustomInput,
2728
Icon,
2829
InfoBlock,
@@ -243,6 +244,19 @@ const EditAPIToken = ({
243244
placeholder="Enter a description to remember where you have used this token"
244245
error={invalidDescription ? 'Max 350 characters allowed.' : null}
245246
/>
247+
{!!editData?.token?.length && (
248+
<label className="form__row">
249+
<span className="form__label">Token</span>
250+
<div className="flex dc__content-space top cn-9">
251+
<span data-testid="api-token-string" className="mono fs-14 dc__word-break">
252+
{editData.token}
253+
</span>
254+
<div className="icon-dim-16 ml-8">
255+
<ClipboardButton content={editData.token} />
256+
</div>
257+
</div>
258+
</label>
259+
)}
246260
<div className="dc__border-top" />
247261
<PermissionConfigurationForm showUserPermissionGroupSelector isAddMode={false} />
248262
</div>

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ import {
2626
} from '@devtron-labs/devtron-fe-common-lib'
2727

2828
import { GenerateTokenModalType } from './apiToken.type'
29+
import { getApiTokenHeader } from './apiToken.utils'
2930

3031
const GenerateModal = ({
3132
close,
32-
token,
33+
token = '',
3334
reload,
3435
redirectToTokenList,
3536
isRegenerationModal,
3637
open,
38+
hideApiToken = false,
3739
}: GenerateTokenModalType) => {
3840
const [copyToClipboardPromise, setCopyToClipboardPromise] = useState<ReturnType<typeof copyToClipboard>>(null)
3941
const modelType = isRegenerationModal ? 'Regenerated' : 'Generated'
@@ -60,9 +62,7 @@ const GenerateModal = ({
6062
<GenericModal.Body>
6163
<div className="flexbox-col dc__gap-20 p-20">
6264
<div className="flexbox-col dc__gap-4">
63-
<h5 className="m-0 cn-9 lh-1-5 fw-6">
64-
Copy and store this token safely, you won’t be able to view it again.
65-
</h5>
65+
<h5 className="m-0 cn-9 lh-1-5 fw-6">{getApiTokenHeader(hideApiToken)}</h5>
6666
<p className="cn-7 fs-12 lh-1-5 m-0">
6767
You can regenerate a token anytime. If you do, remember to update any scripts or
6868
applications using the old token.
@@ -71,7 +71,11 @@ const GenerateModal = ({
7171

7272
<InfoBlock
7373
heading="API Token"
74-
description={token}
74+
description={
75+
<div className="fs-13 font-roboto flexbox dc__word-break" data-testid="generated-token">
76+
{token}
77+
</div>
78+
}
7579
variant="success"
7680
customIcon={<Icon name="ic-key" color="G500" />}
7781
/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const RegeneratedModal = ({
117117
redirectToTokenList={redirectToTokenList}
118118
isRegenerationModal
119119
open={showGenerateModal}
120+
hideApiToken={tokenResponse.hideApiToken}
120121
/>
121122
) : (
122123
<VisibleModal className="regenerate-token-modal">

0 commit comments

Comments
 (0)