Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(console): multi optimizations of ui and interactive #1262

Merged
merged 5 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions console/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@ import { mergeOverrides } from '@/utils/baseui'
import { useStyletron } from 'baseui'

export interface IButtonProps extends ButtonProps {
as?: 'link' | 'button' | 'transparent'
as?: 'link' | 'button' | 'transparent' | withIcon
kind?: KIND[keyof KIND]
isFull?: boolean
className?: string
}

// const useStyles = createUseStyles({
// baseButton: {
// style: {
// borderRadius: theme.borders.radius100,
// }
// }
// })

/* eslint-disable react/jsx-props-no-spreading */
export default function Button({
isFull = false,
Expand Down Expand Up @@ -106,6 +98,31 @@ export default function Button({
},
props.overrides
)
} else if (as === 'withIcon') {
overrides = mergeOverrides(
{
BaseButton: {
style: {
'borderTopLeftRadius': theme.borders.radius200,
'borderTopRightRadius': theme.borders.radius200,
'borderBottomLeftRadius': theme.borders.radius200,
'borderBottomRightRadius': theme.borders.radius200,
'width': isFull ? '100%' : 'auto',
'backgroundColor': '#F4F5F7',
'color': 'rgba(2,16,43,0.60)',
':hover': {
backgroundColor: '#F0F4FF',
color: '#5181E0',
},
':active': {
backgroundColor: '#F0F4FF',
color: '#1C4CAD',
},
},
},
},
props.overrides
)
}

return (
Expand Down
2 changes: 1 addition & 1 deletion console/src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function Input({ size = 'compact', ...props }: IInputProps) {
overrides.MaskToggleShowIcon = () => <IconFont type='eye' kind='gray' />
overrides.MaskToggleHideIcon = () => <IconFont type='eye_off' kind='gray' />
overrides.MaskToggleButton = {
props: { tabindex: -1 },
props: { tabIndex: -1 },
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const ConfigManageColumns = React.forwardRef<{ getConfig: () => any }, PropsT>((
onClick={() => setIsOpen(!isOpen)}
shape={SHAPE.pill}
size={SIZE.compact}
as='link'
as='withIcon'
startEnhancer={() => (
<IconFont
type='setting'
Expand Down
16 changes: 10 additions & 6 deletions console/src/components/data-table/config-views.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ function ConfigViews(props: PropsT) {
onChange={(params) => {
const id = params.option?.id as string
if (id === ALLRUNS) {
store.onCurrentViewColumnsChange(
props.columns.map((v) => v.key),
[],
[]
)
store.onCurrentViewFiltersChange([])
useStore.setState({
currentView: {
filters: [],
selectedIds: props.columns.map((v) => v.key),
pinnedIds: [],
sortedIds: [],
sortBy: '',
id: ALLRUNS,
},
})
return
}

Expand Down
13 changes: 0 additions & 13 deletions console/src/components/data-table/filter-operate-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,6 @@ function FilterOperateMenu(props: PropsT) {
borderRight: 0,
},
},
// Action: {
// style: {
// background: 'rgba(2,16,43,0.20)',
// borderRadius: '50%',
// color: '#fff',
// },
// },
// ActionIcon: {
// style: {
// width: 8,
// height: 8,
// },
// },
}}
onActionClick={handleSelectNone}
>
Expand Down
7 changes: 1 addition & 6 deletions console/src/domain/dataset/schemas/dataset.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IResourceSchema } from '@/domain/base/schemas/resource'
import { IUserSchema } from '@user/schemas/user'
import { IDatasetVersionSchema } from './datasetVersion'
import { IDatasetFileSchema, IDatasetVersionSchema } from './datasetVersion'

export interface IDatasetSchema extends IResourceSchema {
name: string
Expand All @@ -19,11 +19,6 @@ export interface IDatasetDetailSchema {
indexTable?: string
}

export interface IDatasetFileSchema {
name: string
size: string
}

export interface IUpdateDatasetSchema {
description?: string
}
Expand Down
15 changes: 13 additions & 2 deletions console/src/domain/dataset/schemas/datasetVersion.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import { IResourceSchema } from '@/domain/base/schemas/resource'
import { IUserSchema } from '@user/schemas/user'

export interface IDatasetFileSchema {
name: string
size: string
}
export interface IDatasetVersionSchema extends IResourceSchema {
name: string
tag: string
meta: string
owner?: IUserSchema
}

export interface IDatasetVersionDetailSchema extends IDatasetVersionSchema {
datasetName?: string
export interface IDatasetVersionDetailSchema {
id?: string
name?: string
createdTime?: number
versionMeta?: string
versionName?: string
versionTag?: string
files?: Array<IDatasetFileSchema>
indexTable?: string
}

export interface IUpdateDatasetVersionSchema {
Expand Down
47 changes: 23 additions & 24 deletions console/src/pages/Dataset/DatasetOverviewLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import _ from 'lodash'
import Button from '@/components/Button'
import IconFont from '@/components/IconFont'
import { Panel } from 'baseui/accordion'
import { useDatasetVersion } from '@/domain/dataset/hooks/useDatasetVersion'
import qs from 'qs'
import { usePage } from '@/hooks/usePage'

export interface IDatasetLayoutProps {
children: React.ReactNode
Expand All @@ -28,7 +31,8 @@ export default function DatasetOverviewLayout({ children }: IDatasetLayoutProps)
const datasetInfo = useFetchDataset(projectId, datasetId)
const datasetVersionInfo = useFetchDatasetVersion(projectId, datasetId, datasetVersionId)
const { dataset, setDataset } = useDataset()

const { setDatasetVersion } = useDatasetVersion()
const [page] = usePage()
const { setDatasetLoading } = useDatasetLoading()
const history = useHistory()
const [t] = useTranslation()
Expand All @@ -45,21 +49,10 @@ export default function DatasetOverviewLayout({ children }: IDatasetLayoutProps)
}, [dataset?.versionName, datasetInfo, setDataset, setDatasetLoading])

useEffect(() => {
setDatasetLoading(datasetVersionInfo.isLoading)
if (datasetVersionInfo.isSuccess) {
if (datasetVersionInfo.data) {
setDataset(datasetVersionInfo.data)
}
} else if (datasetVersionInfo.isLoading) {
setDataset(undefined)
if (datasetVersionInfo.data) {
setDatasetVersion(datasetVersionInfo.data)
}
}, [
datasetVersionInfo.data,
datasetVersionInfo.isLoading,
datasetVersionInfo.isSuccess,
setDataset,
setDatasetLoading,
])
}, [datasetVersionInfo.data, setDatasetVersion])

const breadcrumbItems: INavItem[] = useMemo(() => {
const items = [
Expand Down Expand Up @@ -184,19 +177,25 @@ export default function DatasetOverviewLayout({ children }: IDatasetLayoutProps)
value={datasetVersionId}
onChange={(v) =>
history.push(
`/projects/${projectId}/datasets/${datasetId}/versions/${v}/${activeItemId}`
`/projects/${projectId}/datasets/${datasetId}/versions/${v}/${activeItemId}?${qs.stringify(
page
)}`
)
}
/>
</div>
<Button
size='compact'
kind='secondary'
startEnhancer={() => <IconFont type='runtime' />}
onClick={() => history.push(`/projects/${projectId}/datasets/${datasetId}/versions`)}
>
{t('History')}
</Button>
{datasetVersionId && (
<Button
size='compact'
as='withIcon'
startEnhancer={() => <IconFont type='runtime' />}
onClick={() =>
history.push(`/projects/${projectId}/datasets/${datasetId}/versions`)
}
>
{t('History')}
</Button>
)}
</div>
{datasetVersionId && <BaseNavTabs navItems={navItems} />}
<div style={{ paddingTop: '12px', flex: '1', display: 'flex', flexDirection: 'column' }}>
Expand Down
10 changes: 6 additions & 4 deletions console/src/pages/Dataset/DatasetVersionOverviewFiles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import { useDataset } from '@dataset/hooks/useDataset'
import { useQueryDatasetList } from '@/domain/datastore/hooks/useFetchDatastore'
import { useHistory, useParams } from 'react-router-dom'
import { TableBuilder, TableBuilderColumn } from 'baseui/table-semantic'
Expand All @@ -16,6 +15,7 @@ import IconFont from '@/components/IconFont/index'
import { createUseStyles } from 'react-jss'
import qs from 'qs'
import { DatasetObject } from '@/domain/dataset/sdk'
import { useDatasetVersion } from '@/domain/dataset/hooks/useDatasetVersion'
import DatasetVersionFilePreview from './DatasetVersionOverviewFilePreview'

const useCardStyles = createUseStyles({
Expand Down Expand Up @@ -139,10 +139,10 @@ export default function DatasetVersionFiles() {
fileId: string
}>()
const [page, setPage] = usePage()
const { dataset: datasetVersion } = useDataset()
const { token } = useAuth()
const history = useHistory()
const styles = useCardStyles()
const { datasetVersion } = useDatasetVersion()

const tables = useQueryDatasetList(datasetVersion?.indexTable, page, true)

Expand Down Expand Up @@ -323,11 +323,13 @@ export default function DatasetVersionFiles() {
value={layoutKey}
onChange={(key) => {
setLayoutKey(key)
const newSize = key === '1' ? PAGE_TABLE_SIZE : PAGE_CARD_SIZE

history.push(
`/projects/${projectId}/datasets/${datasetId}/versions/${datasetVersionId}/files/?${qs.stringify(
{
...page,
pageSize: key === '1' ? PAGE_TABLE_SIZE : PAGE_CARD_SIZE,
pageNum: Math.floor((page.pageSize * page.pageNum) / newSize),
pageSize: newSize,
}
)}`
)
Expand Down
4 changes: 2 additions & 2 deletions console/src/pages/Evaluation/EvaluationResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const PlotlyVisualizer = React.lazy(
() => import(/* webpackChunkName: "PlotlyVisualizer" */ '../../components/Indicator/PlotlyVisualizer')
)

const PAGE_TABLE_SIZE = 10
const PAGE_TABLE_SIZE = 100

function ConfusionMatrix({ fetch }: any) {
const { labels, binarylabel } = useParseConfusionMatrix(fetch?.data)
Expand Down Expand Up @@ -65,7 +65,7 @@ function EvaluationViewer({ table }: { table: string }) {
return info.data?.columnTypes ?? {}
}, [info])
const columns = React.useMemo(() => {
return Object.keys(columnTypes) ?? []
return Object.keys(columnTypes).sort((a) => (a === 'id' ? -1 : 1)) ?? []
}, [columnTypes])
const data = React.useMemo(() => {
if (!info.data) return []
Expand Down
6 changes: 3 additions & 3 deletions console/src/pages/Project/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useHistory } from 'react-router-dom'
import { IProjectSchema } from '@/domain/project/schemas/project'
import { createUseStyles } from 'react-jss'
import { useFetchProjectMembers } from '@/domain/project/hooks/useFetchProjectMembers'
import Button from '@/components/Button/Button'
import Button from '@/components/Button'
import { useQuery } from 'react-query'
import Avatar from '@/components/Avatar'
import WithAuth from '@/api/WithAuth'
Expand Down Expand Up @@ -90,7 +90,7 @@ const ProjectCard = ({ project, onEdit }: IProjectCardProps) => {
<Button
onClick={() => onEdit?.()}
size='compact'
kind='secondary'
as='withIcon'
startEnhancer={() => <IconFont type='edit' size={13} />}
>
{t('Edit')}
Expand Down Expand Up @@ -128,7 +128,7 @@ const ProjectCard = ({ project, onEdit }: IProjectCardProps) => {
<Button
onClick={() => history.push(`/projects/${project.id}/members`)}
size='compact'
kind='secondary'
as='withIcon'
startEnhancer={() => <IconFont type='a-managemember' size={13} />}
>
{t('Manage Member')}
Expand Down
6 changes: 6 additions & 0 deletions console/src/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ const overrides = {
buttonPrimaryFill: customPrimaryColors.primary,
buttonPrimaryHover: customPrimaryColors.primaryHover,
buttonPrimaryActive: customPrimaryColors.primaryPressed,
buttonSecondaryFill: '#F4F5F7',
buttonSecondaryText: 'rgba(2,16,43,0.60)',
buttonSecondarySelectedText: '#1C4CAD',
buttonSecondarySelectedFill: '#1C4CAD',
buttonSecondaryHover: '#F0F4FF',
buttonSecondaryActive: '#F0F4FF;',
borderSelected: customPrimaryColors.primary,
tickFillSelected: customPrimaryColors.primary,
tickFillSelectedHover: customPrimaryColors.primary,
Expand Down