@@ -375,7 +400,7 @@ const RolePage = ({
-
+
{dataChanged ? (
@@ -402,7 +427,16 @@ const RolePage = ({
)}
- {body}
+
)
}
diff --git a/ui/src/admin/containers/influxdb/UserPage.tsx b/ui/src/admin/containers/influxdb/UserPage.tsx
index b84b4bec90..0febe2b023 100644
--- a/ui/src/admin/containers/influxdb/UserPage.tsx
+++ b/ui/src/admin/containers/influxdb/UserPage.tsx
@@ -3,7 +3,11 @@ import {connect, ResolveThunks} from 'react-redux'
import {withSource} from 'src/CheckSources'
import {Source} from 'src/types'
import {Database, User, UserPermission, UserRole} from 'src/types/influxAdmin'
-import {hasRoleManagement, isConnectedToLDAP} from './AdminInfluxDBTabbedPage'
+import {
+ AdminTabs,
+ hasRoleManagement,
+ isConnectedToLDAP,
+} from './AdminInfluxDBTabbedPage'
import {withRouter, WithRouterProps} from 'react-router'
import {useMemo} from 'react'
import ConfirmButton from 'src/shared/components/ConfirmButton'
@@ -24,6 +28,7 @@ import {
computePermissionsChange,
toUserPermissions,
} from '../../util/permissions'
+import ConfirmDiscardDialog from 'src/admin/components/influxdb/ConfirmDiscardDialog'
const FAKE_USER: User = {
name: '',
@@ -179,7 +184,7 @@ const UserPage = ({
const changePermissions = useMemo(
() => async () => {
if (Object.entries(changedPermissions).length === 0) {
- return
+ return true
}
setRunning(true)
try {
@@ -189,7 +194,7 @@ const UserPage = ({
changedPermissions,
isEnterprise ? [] : user.permissions.filter(x => x.scope === 'all')
)
- await updatePermissionsAsync(user, permissions)
+ return await updatePermissionsAsync(user, permissions)
} finally {
setRunning(false)
}
@@ -236,7 +241,7 @@ const UserPage = ({
const changeRoles = useMemo(
() => async () => {
if (Object.entries(changedRolesRecord).length === 0) {
- return
+ return true
}
setRunning(true)
try {
@@ -251,7 +256,7 @@ const UserPage = ({
}
return acc
}, [])
- await updateRolesAsync(user, newRoles)
+ return await updateRolesAsync(user, newRoles)
} finally {
setRunning(false)
}
@@ -263,13 +268,14 @@ const UserPage = ({
permissionsChanged,
rolesChanged,
])
- const changeData = useCallback(async () => {
- await changeRoles()
- await changePermissions()
- }, [changePermissions, changeRoles])
const exitHandler = useCallback(() => {
router.push(`/sources/${sourceID}/admin-influxdb/users`)
}, [router, source])
+ const changeData = useCallback(async () => {
+ if ((await changeRoles()) && (await changePermissions())) {
+ exitHandler()
+ }
+ }, [changePermissions, changeRoles, exitHandler])
const databaseNames = useMemo
(
() =>
databases.reduce(
@@ -281,6 +287,24 @@ const UserPage = ({
),
[isEnterprise, databases]
)
+
+ const [exitUrl, setExitUrl] = useState('')
+ const onTabChange = useCallback(
+ (_section, url) => {
+ if (dataChanged) {
+ setExitUrl(url)
+ return
+ }
+ router.push(url)
+ },
+ [router, dataChanged]
+ )
+ const onExitCancel = useCallback(() => {
+ setExitUrl('')
+ }, [])
+ const onExitConfirm = useCallback(() => {
+ router.push(exitUrl)
+ }, [router, exitUrl])
const body =
user === FAKE_USER ? (
@@ -480,7 +504,7 @@ const UserPage = ({
-
+
{dataChanged ? (
@@ -489,7 +513,7 @@ const UserPage = ({
confirmText="Discard unsaved changes?"
confirmAction={exitHandler}
position="left"
- testId="exit--button"
+ testId="discard-changes--exit--button"
/>
) : (
@@ -507,7 +531,16 @@ const UserPage = ({
)}
- {body}
+
)
}
diff --git a/ui/src/reusable_ui/components/overlays/Overlay.scss b/ui/src/reusable_ui/components/overlays/Overlay.scss
index 4426173dd6..8a31a44a32 100644
--- a/ui/src/reusable_ui/components/overlays/Overlay.scss
+++ b/ui/src/reusable_ui/components/overlays/Overlay.scss
@@ -25,7 +25,7 @@ $overlay-min-height: 150px;
@extend %overlay-styles;
z-index: 1;
opacity: 0;
- transition: opacity 0.25s ease;
+ // transition: opacity 1.25s ease; // some defect in Chrome causes to randomly go to opacity 1 (ConfirmDiscardDialog)
@include gradient-diag-down($c-pool,$c-comet);
}
diff --git a/ui/src/shared/components/SubSections.tsx b/ui/src/shared/components/SubSections.tsx
index 344f629f80..8d200a5fb7 100644
--- a/ui/src/shared/components/SubSections.tsx
+++ b/ui/src/shared/components/SubSections.tsx
@@ -33,6 +33,7 @@ interface Props extends WithRouterProps {
parentUrl: string
children?: ReactNode
position?: 'left' | 'top'
+ onTabChange?: (section: PageSection, url: string) => void
}
@ErrorHandling
@@ -55,7 +56,7 @@ class SubSections extends Component
{
)
@@ -75,9 +76,14 @@ class SubSections extends Component {
return found?.component || children ||
}
- public handleTabClick = (url: string) => () => {
- const {router, sourceID, parentUrl} = this.props
- router.push(`/sources/${sourceID}/${parentUrl}/${url}`)
+ public handleTabClick = (section: PageSection) => () => {
+ const {router, sourceID, parentUrl, onTabChange} = this.props
+ const url = `/sources/${sourceID}/${parentUrl}/${section.url}`
+ if (onTabChange) {
+ onTabChange(section, url)
+ return
+ }
+ router.push(url)
}
}
diff --git a/ui/src/style/pages/admin.scss b/ui/src/style/pages/admin.scss
index ef5b93753d..d080d297ba 100644
--- a/ui/src/style/pages/admin.scss
+++ b/ui/src/style/pages/admin.scss
@@ -265,7 +265,7 @@ pre.admin-table--query {
height: calc(100vh - 150px);
min-height: 10px;
&.influxdb-admin--detail{
- height: calc(100vh - 120px);
+ height: calc(100vh - 150px);
padding: 10px 0 0;
background-color: $g1-raven;
}