Skip to content

Commit 91b5f64

Browse files
committed
feat: rename useSuperAdmin hook
1 parent 6707124 commit 91b5f64

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ src/Common/Drawer/Drawer.tsx
3030
src/Common/Grid/Grid.tsx
3131
src/Common/Helper.tsx
3232
src/Common/Hooks/UseClickOutside/UseClickOutside.tsx
33-
src/Common/Hooks/UseSuperAdmin/UseSuperAdmin.tsx
3433
src/Common/Hooks/UseWindowSize/UseWindowSize.tsx
3534
src/Common/ImageTags.tsx
3635
src/Common/InfoColorBar/InfoColourbar.tsx

src/Common/Hooks/UseSuperAdmin/UseSuperAdmin.tsx renamed to src/Common/Hooks/UseGetUserRoles/UseGetUserRoles.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React, { useEffect, useState } from 'react'
17+
import { useEffect, useState } from 'react'
1818
import { getUserRole } from '../../Common.service'
19-
import { useSuperAdminType } from './types'
19+
import { useGetUserRolesType } from './types'
2020
import { showError } from '../../Helper'
2121

2222
/**
2323
* @description It will return isSuperAdmin and would be set to false by default, might need few optimizations like dep, etc
24-
* @returns {useSuperAdminType} isSuperAdmin, canManageAllAccess
24+
* @returns {useGetUserRolesType} isSuperAdmin, canManageAllAccess
2525
*/
26-
export const useSuperAdmin = (): useSuperAdminType => {
27-
const [result, setResult] = useState<useSuperAdminType>({ isSuperAdmin: false, canManageAllAccess: false })
26+
const useGetUserRoles = (): useGetUserRolesType => {
27+
const [result, setResult] = useState<useGetUserRolesType>({ isSuperAdmin: false, canManageAllAccess: false })
2828

2929
useEffect(() => {
3030
getUserRole()
31-
.then(({ result }) => {
31+
.then(({ result: apiResult }) => {
3232
setResult({
33-
isSuperAdmin: result.superAdmin ?? false,
34-
canManageAllAccess: result.canManageAllAccess ?? false,
33+
isSuperAdmin: apiResult.superAdmin ?? false,
34+
canManageAllAccess: apiResult.canManageAllAccess ?? false,
3535
})
3636
})
3737
.catch((error) => {
@@ -41,3 +41,5 @@ export const useSuperAdmin = (): useSuperAdminType => {
4141

4242
return result
4343
}
44+
45+
export default useGetUserRoles
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as useGetUserRoles } from './UseGetUserRoles'

src/Common/Hooks/UseSuperAdmin/types.ts renamed to src/Common/Hooks/UseGetUserRoles/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
export interface useSuperAdminType {
17+
export interface useGetUserRolesType {
1818
isSuperAdmin: boolean
1919
/**
2020
* User can give access to all other users

src/Common/Hooks/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
export { useSuperAdmin } from './UseSuperAdmin/UseSuperAdmin'
17+
export { useGetUserRoles } from './UseGetUserRoles'
1818
export { useClickOutside } from './UseClickOutside/UseClickOutside'
1919
export { useWindowSize } from './UseWindowSize/UseWindowSize'
2020
export * from './useUrlFilters'

src/Shared/Components/CICDHistory/Artifacts.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
ClipboardButton,
3333
extractImage,
3434
DOCUMENTATION,
35-
useSuperAdmin,
35+
useGetUserRoles,
3636
} from '../../../Common'
3737
import { ArtifactType, CIListItemType } from './types'
3838
import { TERMINAL_STATUS_MAP } from './constants'
@@ -148,7 +148,7 @@ const Artifacts = ({
148148
renderCIListHeader,
149149
targetPlatforms,
150150
}: ArtifactType) => {
151-
const { isSuperAdmin } = useSuperAdmin()
151+
const { isSuperAdmin } = useGetUserRoles()
152152
const { handleDownload } = useDownload()
153153

154154
const { triggerId, buildId } = useParams<{

src/Shared/Components/CICDHistory/History.components.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
GenericEmptyState,
2323
Tooltip,
2424
extractImage,
25-
useSuperAdmin,
25+
useGetUserRoles,
2626
useRegisterShortcut,
2727
} from '../../../Common'
2828
import { EMPTY_STATE_STATUS } from '../../constants'
@@ -136,7 +136,7 @@ export const GitChanges = ({
136136
renderCIListHeader,
137137
targetPlatforms,
138138
}: GitChangesType) => {
139-
const { isSuperAdmin } = useSuperAdmin()
139+
const { isSuperAdmin } = useGetUserRoles()
140140

141141
if (!ciMaterials?.length || !Object.keys(gitTriggers ?? {}).length) {
142142
return (

0 commit comments

Comments
 (0)