Skip to content

Commit 80ad39e

Browse files
committed
refactor: move the abortPreviousRequest func and SortingOrder enum to common lib + code cleanup
1 parent 2601821 commit 80ad39e

File tree

14 files changed

+139
-120
lines changed

14 files changed

+139
-120
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": "0.0.58-beta-6",
7+
"@devtron-labs/devtron-fe-common-lib": "0.0.58-beta-9",
88
"@rjsf/core": "^5.13.3",
99
"@rjsf/utils": "^5.13.3",
1010
"@rjsf/validator-ajv8": "^5.13.3",

src/Pages/GlobalConfigurations/Authorization/PermissionGroups/List/NoPermissionGroups.tsx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,27 @@ import { ReactComponent as AddIcon } from '../../../../../assets/icons/ic-add.sv
66
import { EMPTY_STATE_STATUS } from '../../../../../config/constantMessaging'
77
import { URLS } from '../../../../../config'
88

9-
const NoPermissionGroups = () => {
10-
const renderAddGroupButton = () => (
11-
<Link
12-
type="button"
13-
to={`${URLS.GLOBAL_CONFIG_AUTH_PERMISSION_GROUPS}/add`}
14-
role="button"
15-
className="cta dc__gap-4 flex h-32 anchor"
16-
>
17-
<AddIcon />
18-
Add group
19-
</Link>
20-
)
9+
const renderAddGroupButton = () => (
10+
<Link
11+
type="button"
12+
to={`${URLS.GLOBAL_CONFIG_AUTH_PERMISSION_GROUPS}/add`}
13+
role="button"
14+
className="cta dc__gap-4 flex h-32 anchor"
15+
>
16+
<AddIcon />
17+
Add group
18+
</Link>
19+
)
2120

22-
return (
23-
<GenericEmptyState
24-
image={nullStateImage}
25-
title={EMPTY_STATE_STATUS.NO_GROUPS.TITLE}
26-
subTitle={EMPTY_STATE_STATUS.NO_GROUPS.SUBTITLE}
27-
isButtonAvailable
28-
renderButton={renderAddGroupButton}
29-
classname="flex-grow-1"
30-
/>
31-
)
32-
}
21+
const NoPermissionGroups = () => (
22+
<GenericEmptyState
23+
image={nullStateImage}
24+
title={EMPTY_STATE_STATUS.NO_GROUPS.TITLE}
25+
subTitle={EMPTY_STATE_STATUS.NO_GROUPS.SUBTITLE}
26+
isButtonAvailable
27+
renderButton={renderAddGroupButton}
28+
classname="flex-grow-1"
29+
/>
30+
)
3331

3432
export default NoPermissionGroups

src/Pages/GlobalConfigurations/Authorization/PermissionGroups/List/PermissionGroupList.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
useAsync,
1212
DEFAULT_BASE_PAGE_SIZE,
1313
useUrlFilters,
14+
abortPreviousRequests,
15+
getIsRequestAborted,
1416
} from '@devtron-labs/devtron-fe-common-lib'
1517
import { API_STATUS_CODES } from '../../../../../config'
1618

@@ -22,7 +24,6 @@ import { useAuthorizationContext } from '../../AuthorizationProvider'
2224
import { importComponentFromFELibrary } from '../../../../../components/common'
2325
import FiltersEmptyState from '../../shared/components/FilterEmptyState/FilterEmptyState.component'
2426
import NoPermissionGroups from './NoPermissionGroups'
25-
import { abortPreviousRequests, getIsRequestAborted } from '../../utils'
2627

2728
const PermissionGroupInfoBar = importComponentFromFELibrary('PermissionGroupInfoBar', noop, 'function')
2829

src/Pages/GlobalConfigurations/Authorization/PermissionGroups/PermissionGroups.component.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ const PermissionGroups = () => {
1313
<Route
1414
path={`${path}/:groupId`}
1515
render={({ match }) => (
16-
<section className="flexbox-col flex-grow-1 h-100" key={match.params.groupId}>
17-
<PermissionGroupAddEdit />
16+
<section className="flexbox-col flex-grow-1 h-100">
17+
{/* Passing the groupId as key to re-mount the component on its change */}
18+
<PermissionGroupAddEdit key={match.params.groupId} />
1819
</section>
1920
)}
2021
/>

src/Pages/GlobalConfigurations/Authorization/SSOLoginServices/service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export function getSSOConfigList(): Promise<any> {
66
return get(Routes.SSO_LIST)
77
}
88

9-
// Use the common function for search params
109
export function getSSOConfig(name: string): Promise<any> {
1110
return get(getUrlWithSearchParams(Routes.SSO, { name }))
1211
}

src/Pages/GlobalConfigurations/Authorization/UserPermissions/AddEdit/UserForm.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -389,17 +389,15 @@ const UserForm = ({ isAddMode, userData = null }: { isAddMode: boolean; userData
389389
</div>
390390
{!isAddMode && (
391391
<div className="flex dc__content-start dc__gap-12">
392-
{!isAddMode && (
393-
<button
394-
disabled={submitting}
395-
type="button"
396-
className="cta delete override-button flex dc__gap-6 h-32"
397-
onClick={toggleDeleteConfirmationModal}
398-
>
399-
<PlusIcon className="icon-dim-14 mw-14" />
400-
Delete
401-
</button>
402-
)}
392+
<button
393+
disabled={submitting}
394+
type="button"
395+
className="cta delete override-button flex dc__gap-6 h-32"
396+
onClick={toggleDeleteConfirmationModal}
397+
>
398+
<PlusIcon className="icon-dim-14 mw-14" />
399+
Delete
400+
</button>
403401
</div>
404402
)}
405403
</div>

src/Pages/GlobalConfigurations/Authorization/UserPermissions/List/NoUsers.tsx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,27 @@ import { ReactComponent as AddIcon } from '../../../../../assets/icons/ic-add.sv
66
import { EMPTY_STATE_STATUS } from '../../../../../config/constantMessaging'
77
import { URLS } from '../../../../../config'
88

9-
const NoUsers = () => {
10-
const renderAddUserButton = () => (
11-
<Link
12-
type="button"
13-
to={`${URLS.GLOBAL_CONFIG_AUTH_USER_PERMISSION}/add`}
14-
role="button"
15-
className="cta dc__gap-4 flex h-32 anchor"
16-
>
17-
<AddIcon />
18-
Add user
19-
</Link>
20-
)
9+
const renderAddUserButton = () => (
10+
<Link
11+
type="button"
12+
to={`${URLS.GLOBAL_CONFIG_AUTH_USER_PERMISSION}/add`}
13+
role="button"
14+
className="cta dc__gap-4 flex h-32 anchor"
15+
>
16+
<AddIcon />
17+
Add user
18+
</Link>
19+
)
2120

22-
return (
23-
<GenericEmptyState
24-
image={nullStateImage}
25-
title={EMPTY_STATE_STATUS.NO_USER.TITLE}
26-
subTitle={EMPTY_STATE_STATUS.NO_USER.SUBTITLE}
27-
isButtonAvailable
28-
renderButton={renderAddUserButton}
29-
classname="flex-grow-1"
30-
/>
31-
)
32-
}
21+
const NoUsers = () => (
22+
<GenericEmptyState
23+
image={nullStateImage}
24+
title={EMPTY_STATE_STATUS.NO_USER.TITLE}
25+
subTitle={EMPTY_STATE_STATUS.NO_USER.SUBTITLE}
26+
isButtonAvailable
27+
renderButton={renderAddUserButton}
28+
classname="flex-grow-1"
29+
/>
30+
)
3331

3432
export default NoUsers

src/Pages/GlobalConfigurations/Authorization/UserPermissions/List/UserPermissionList.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
useAsync,
1111
DEFAULT_BASE_PAGE_SIZE,
1212
useUrlFilters,
13+
abortPreviousRequests,
14+
getIsRequestAborted,
1315
} from '@devtron-labs/devtron-fe-common-lib'
1416
import { API_STATUS_CODES } from '../../../../../config'
1517

@@ -20,7 +22,6 @@ import UserPermissionRow from './UserPermissionRow'
2022
import FiltersEmptyState from '../../shared/components/FilterEmptyState/FilterEmptyState.component'
2123
import NoUsers from './NoUsers'
2224
import { importComponentFromFELibrary } from '../../../../../components/common'
23-
import { abortPreviousRequests, getIsRequestAborted } from '../../utils'
2425

2526
const StatusHeaderCell = importComponentFromFELibrary('StatusHeaderCell', null, 'function')
2627

src/Pages/GlobalConfigurations/Authorization/UserPermissions/UserPermissions.component.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const UserPermissions = () => {
3737

3838
const isSSOConfigured = ssoConfig?.result?.some((sso) => sso.active) || false
3939

40+
// The users can only be configured if SSO is configured
4041
if (!isSSOConfigured) {
4142
return <SSONotConfiguredState />
4243
}
@@ -48,6 +49,7 @@ const UserPermissions = () => {
4849
path={`${path}/:userId`}
4950
render={({ match }) => (
5051
<section className="flexbox-col flex-grow-1 h-100 dc__content-center">
52+
{/* Passing the userId as key to re-mount the component on its change */}
5153
<UserPermissionAddEdit key={match.params.userId} />
5254
</section>
5355
)}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
export interface FilterEmptyStateProps {
2+
/**
3+
* Click handler for clearing the applied filters
4+
*/
25
clearFilters: () => void
36
}

0 commit comments

Comments
 (0)