Skip to content

Commit

Permalink
fix(ui): Fix inconsistency in UI and improve UX (#314)
Browse files Browse the repository at this point in the history
* fix(ui): Fix inconsistency in UI and improve UX

* fix(ui): Make text clickable again

* fix(ui): Remove unused component

* fix(ui): Change page titles to Title Case, Fix and optimize searchbar, adjust height of headers in console pages
  • Loading branch information
Mrkazik99 authored Sep 7, 2024
1 parent ab84620 commit 5a465ec
Show file tree
Hide file tree
Showing 15 changed files with 569 additions and 499 deletions.
28 changes: 6 additions & 22 deletions ui/src/components/app-bar/app-bar-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,27 +269,7 @@ const AppBarSearch = () => {

const handleClear = useCallback(() => {
setBuffer('')
if (isFiles) {
navigate(`/workspace/${workspaceId}/file/${fileId}`)
} else if (isWorkspaces) {
navigate(`/workspace`)
} else if (isGroups) {
navigate(`/group`)
} else if (isOrgs) {
navigate(`/organization`)
} else if (isOrgMembers) {
navigate(`/organization/${workspaceId}/member`)
} else if (isGroupMembers) {
navigate(`/group/${workspaceId}/member`)
} else if (isConsoleUsers) {
navigate(`/console/users`)
} else if (isConsoleOrganizations) {
navigate(`/console/organization`)
} else if (isConsoleGroups) {
navigate(`/console/groups`)
} else if (isConsoleWorkspaces) {
navigate(`/console/workspaces`)
}
handleSearch('')
}, [
workspaceId,
fileId,
Expand All @@ -299,12 +279,16 @@ const AppBarSearch = () => {
isOrgs,
isOrgMembers,
isGroupMembers,
isConsoleUsers,
isConsoleOrganizations,
isConsoleGroups,
isConsoleWorkspaces,
navigate,
])

const handleKeyDown = useCallback(
(event: KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Enter' && buffer.length >= 3) {
if (event.key === 'Enter' && buffer.trim().length >= 3) {
handleSearch(buffer.trim())
} else if (
event.key === 'Enter' &&
Expand Down
47 changes: 25 additions & 22 deletions ui/src/components/console/console-confirmation-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
ModalHeader,
ModalOverlay,
} from '@chakra-ui/react'
import cx from 'classnames'

interface ConsoleConfirmationModalProps {
action: string | undefined
Expand Down Expand Up @@ -66,28 +67,30 @@ const ConsoleConfirmationModal = (props: ConsoleConfirmationModalProps) => {
Please confirm this action
</ModalBody>
<ModalFooter>
<Button
type="button"
variant="outline"
colorScheme="blue"
disabled={props.isSubmitting}
onClick={() => {
props.closeConfirmationWindow()
}}
>
Cancel
</Button>
<Button
type="button"
variant="solid"
colorScheme="blue"
isLoading={props.isSubmitting}
onClick={async () => {
await props.request(null, null, null, true)
}}
>
Confirm
</Button>
<div className={cx('flex', 'flex-row', 'items-center', 'gap-1')}>
<Button
type="button"
variant="outline"
colorScheme="blue"
disabled={props.isSubmitting}
onClick={() => {
props.closeConfirmationWindow()
}}
>
Cancel
</Button>
<Button
type="button"
variant="solid"
colorScheme="blue"
isLoading={props.isSubmitting}
onClick={async () => {
await props.request(null, null, null, true)
}}
>
Confirm
</Button>
</div>
</ModalFooter>
</ModalContent>
</Modal>
Expand Down
36 changes: 0 additions & 36 deletions ui/src/components/console/console-highlightable-tr.tsx

This file was deleted.

45 changes: 25 additions & 20 deletions ui/src/components/console/console-rename-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import {
} from '@chakra-ui/react'
import { Field, FieldAttributes, FieldProps, Form, Formik } from 'formik'
import * as Yup from 'yup'
import cx from 'classnames'

interface ConsoleRenameModalProps {
closeConfirmationWindow: () => void
isOpen: boolean
isSubmitting: boolean
previousName: string | undefined
previousName: string
object: string
formSchema: Yup.ObjectSchema<
{ name: string },
Expand Down Expand Up @@ -69,7 +70,7 @@ const ConsoleRenameModal = (props: ConsoleRenameModalProps) => {
<ModalCloseButton />
<Formik
enableReinitialize={true}
initialValues={{ name: '' }}
initialValues={{ name: props.previousName }}
validationSchema={props.formSchema}
validateOnBlur={false}
onSubmit={async (event) => {
Expand Down Expand Up @@ -98,25 +99,29 @@ const ConsoleRenameModal = (props: ConsoleRenameModalProps) => {
</Field>
</ModalBody>
<ModalFooter>
<Button
type="button"
variant="outline"
colorScheme="blue"
disabled={isSubmitting}
onClick={() => {
props.closeConfirmationWindow()
}}
<div
className={cx('flex', 'flex-row', 'items-center', 'gap-1')}
>
Cancel
</Button>
<Button
type="submit"
variant="solid"
colorScheme="blue"
isLoading={isSubmitting}
>
Confirm
</Button>
<Button
type="button"
variant="outline"
colorScheme="blue"
disabled={isSubmitting}
onClick={() => {
props.closeConfirmationWindow()
}}
>
Cancel
</Button>
<Button
type="submit"
variant="solid"
colorScheme="blue"
isLoading={isSubmitting}
>
Confirm
</Button>
</div>
</ModalFooter>
</Form>
)}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/pages/console/console-panel-database-indexes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const ConsolePanelDatabaseIndexes = () => {
</ModalContent>
</Modal>
<Helmet>
<title>Index management</title>
<title>Index Management</title>
</Helmet>
<div className={cx('flex', 'flex-col', 'gap-3.5', 'pb-3.5')}>
{list && list.data.length > 0 ? (
Expand All @@ -156,7 +156,7 @@ const ConsolePanelDatabaseIndexes = () => {
<Th>Name</Th>
<Th>Table</Th>
<Th>Syntax</Th>
<Th>Actions</Th>
<Th></Th>
</Tr>
</Thead>
<Tbody>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/console/console-panel-database-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ConsolePanelDatabaseOverview = () => {
return (
<>
<Helmet>
<title>Database management</title>
<title>Database Management</title>
</Helmet>
<div className={cx('flex', 'flex-col', 'gap-3.5', 'pb-3.5')}></div>
</>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/pages/console/console-panel-database.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const ConsolePanelDatabase = () => {
const location = useLocation()
const navigate = useNavigate()
const [tabIndex, setTabIndex] = useState(0)
const [indexesAvailable, setIndexesAvailable] = useState(true)
const [indexesAvailable, setIndexesAvailable] = useState(false)

useEffect(() => {
const segments = location.pathname.split('/')
Expand All @@ -38,7 +38,7 @@ const ConsolePanelDatabase = () => {
return (
<div className={cx('flex', 'flex-col', 'gap-3.5', 'pb-3.5')}>
<Heading className={cx('text-heading', 'shrink-0')} noOfLines={1}>
Database management
Database Management
</Heading>
<Tabs variant="solid-rounded" colorScheme="gray" index={tabIndex}>
<TabList>
Expand Down
45 changes: 32 additions & 13 deletions ui/src/pages/console/console-panel-groups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ import { useEffect, useState } from 'react'
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'
import {
Button,
Center,
Heading,
IconButton,
Menu,
MenuButton,
MenuItem,
MenuList,
Stack,
Table,
Tbody,
Expand All @@ -27,6 +33,7 @@ import { Helmet } from 'react-helmet-async'
import ConsoleApi, { GroupManagementList } from '@/client/console/console'
import ConsoleRenameModal from '@/components/console/console-rename-modal'
import { consoleGroupsPaginationStorage } from '@/infra/pagination'
import { IconMoreVert } from '@/lib/components/icons'
import PagePagination from '@/lib/components/page-pagination'
import SectionSpinner from '@/lib/components/section-spinner'
import { decodeQuery } from '@/lib/helpers/query'
Expand All @@ -45,7 +52,7 @@ const ConsolePanelGroups = () => {
})
const [confirmRenameWindowOpen, setConfirmRenameWindowOpen] = useState(false)
const [isSubmitting, setSubmitting] = useState(false)
const [currentName, setCurrentName] = useState<string>()
const [currentName, setCurrentName] = useState<string>('')
const [groupId, setGroupId] = useState<string>()
const formSchema = Yup.object().shape({
name: Yup.string().required('Name is required').max(255),
Expand All @@ -64,7 +71,7 @@ const ConsolePanelGroups = () => {
} finally {
closeConfirmationWindow()
}
} else if (id !== null && currentName !== null) {
} else if (id !== null && currentName !== null && currentName !== '') {
setConfirmRenameWindowOpen(true)
setCurrentName(currentName)
setGroupId(id)
Expand All @@ -74,7 +81,7 @@ const ConsolePanelGroups = () => {
const closeConfirmationWindow = () => {
setConfirmRenameWindowOpen(false)
setSubmitting(false)
setCurrentName(undefined)
setCurrentName('')
setGroupId(undefined)
}

Expand Down Expand Up @@ -108,10 +115,10 @@ const ConsolePanelGroups = () => {
request={renameGroup}
/>
<Helmet>
<title>Group management</title>
<title>Group Management</title>
</Helmet>
<div className={cx('flex', 'flex-col', 'gap-3.5', 'pb-3.5')}>
<Heading className={cx('text-heading')}>Group management</Heading>
<Heading className={cx('text-heading')}>Group Management</Heading>
{list && list.data.length > 0 ? (
<Stack direction="column" spacing={2}>
<Table variant="simple">
Expand All @@ -121,7 +128,7 @@ const ConsolePanelGroups = () => {
<Th>Organization</Th>
<Th>Create time</Th>
<Th>Update time</Th>
<Th>Actions</Th>
<Th></Th>
</Tr>
</Thead>
<Tbody>
Expand Down Expand Up @@ -150,13 +157,25 @@ const ConsolePanelGroups = () => {
<Text>{new Date(group.updateTime).toLocaleString()}</Text>
</Td>
<Td>
<Button
onClick={async () => {
await renameGroup(group.id, group.name, null)
}}
>
Rename
</Button>
<Center>
<Menu>
<MenuButton
as={IconButton}
icon={<IconMoreVert />}
variant="ghost"
aria-label=""
/>
<MenuList>
<MenuItem
onClick={async () => {
await renameGroup(group.id, group.name, null)
}}
>
Rename
</MenuItem>
</MenuList>
</Menu>
</Center>
</Td>
</Tr>
))}
Expand Down
Loading

0 comments on commit 5a465ec

Please sign in to comment.