Skip to content

Commit bca2409

Browse files
Improve overall performance
1 parent a70e3b1 commit bca2409

24 files changed

+391
-373
lines changed

app/common/src/services/Backend.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,6 @@ export function isPlaceholderId(id: AssetId) {
842842
return false
843843
}
844844

845-
console.log('isPlaceholderId id', id, PLACEHOLDER_SIGNATURE in id)
846-
847845
return PLACEHOLDER_SIGNATURE in id
848846
}
849847

app/gui/src/dashboard/components/dashboard/AssetRow.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export interface AssetRowInnerProps {
8181
/** Props for an {@link AssetRow}. */
8282
export interface AssetRowProps {
8383
readonly isOpened: boolean
84+
8485
readonly isPlaceholder: boolean
8586
readonly visibility: Visibility | undefined
8687
readonly id: backendModule.AssetId
@@ -96,6 +97,7 @@ export interface AssetRowProps {
9697
readonly grabKeyboardFocus: (item: backendModule.AnyAsset) => void
9798
readonly onClick: (props: AssetRowInnerProps, event: React.MouseEvent) => void
9899
readonly select: (item: backendModule.AnyAsset) => void
100+
readonly isExpanded: boolean
99101
readonly onDragStart?: (
100102
event: React.DragEvent<HTMLTableRowElement>,
101103
item: backendModule.AnyAsset,
@@ -267,6 +269,7 @@ export function RealAssetInternalRow(props: RealAssetRowInternalProps) {
267269
columns,
268270
onClick,
269271
isPlaceholder,
272+
isExpanded,
270273
type,
271274
asset,
272275
} = props
@@ -689,7 +692,7 @@ export function RealAssetInternalRow(props: RealAssetRowInternalProps) {
689692
}
690693
}}
691694
className={tailwindMerge.twMerge(
692-
'h-table-row rounded-full transition-all ease-in-out rounded-rows-child [contain-intrinsic-size:40px] [content-visibility:auto]',
695+
'h-table-row rounded-full transition-all ease-in-out contain-strict rounded-rows-child [contain-intrinsic-size:37px] [content-visibility:auto]',
693696
visibility,
694697
(isDraggedOver || selected) && 'selected',
695698
)}
@@ -830,6 +833,7 @@ export function RealAssetInternalRow(props: RealAssetRowInternalProps) {
830833
<td key={column} className={columnUtils.COLUMN_CSS_CLASS[column]}>
831834
<Render
832835
isPlaceholder={isPlaceholder}
836+
isExpanded={isExpanded}
833837
keyProp={id}
834838
isOpened={isOpened}
835839
backendType={backend.type}

app/gui/src/dashboard/components/dashboard/DatalinkNameColumn.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import EditableSpan from '#/components/EditableSpan'
66

77
import type * as backendModule from '#/services/Backend'
88

9-
import { useSetIsAssetPanelTemporarilyVisible } from '#/providers/DriveProvider'
9+
import { useSetIsAssetPanelTemporarilyVisible } from '#/layouts/AssetPanel'
1010
import * as eventModule from '#/utilities/event'
1111
import * as indent from '#/utilities/indent'
1212
import * as object from '#/utilities/object'
@@ -43,8 +43,8 @@ export default function DatalinkNameColumn(props: DatalinkNameColumnProps) {
4343

4444
return (
4545
<div
46-
className={tailwindMerge.twMerge(
47-
'flex h-table-row min-w-max items-center gap-name-column-icon whitespace-nowrap rounded-l-full px-name-column-x py-name-column-y',
46+
className={tailwindMerge.twJoin(
47+
'flex h-table-row min-w-max items-center gap-name-column-icon whitespace-nowrap rounded-l-full px-name-column-x py-name-column-y rounded-rows-child',
4848
indent.indentClass(depth),
4949
)}
5050
onKeyDown={(event) => {

app/gui/src/dashboard/components/dashboard/DirectoryNameColumn.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ export interface DirectoryNameColumnProps extends column.AssetColumnProps {
3838
* This should never happen.
3939
*/
4040
export default function DirectoryNameColumn(props: DirectoryNameColumnProps) {
41-
const { item, selected, state, rowState, setRowState, isEditable, depth } = props
42-
const { backend, nodeMap, doToggleDirectoryExpansion, expandedDirectoryIds } = state
41+
const { item, selected, state, rowState, setRowState, isEditable, depth, isExpanded } = props
42+
const { backend, nodeMap, doToggleDirectoryExpansion } = state
4343
const { getText } = textProvider.useText()
4444
const driveStore = useDriveStore()
45-
const isExpanded = expandedDirectoryIds.includes(item.id)
4645

4746
const updateDirectoryMutation = useMutation(backendMutationOptions(backend, 'updateDirectory'))
4847

@@ -67,8 +66,8 @@ export default function DirectoryNameColumn(props: DirectoryNameColumnProps) {
6766

6867
return (
6968
<div
70-
className={tailwindMerge.twMerge(
71-
'group flex h-table-row min-w-max items-center gap-name-column-icon whitespace-nowrap rounded-l-full px-name-column-x py-name-column-y',
69+
className={tailwindMerge.twJoin(
70+
'group flex h-table-row min-w-max items-center gap-name-column-icon whitespace-nowrap rounded-l-full px-name-column-x py-name-column-y rounded-rows-child',
7271
indent.indentClass(depth),
7372
)}
7473
onKeyDown={(event) => {
@@ -93,7 +92,7 @@ export default function DirectoryNameColumn(props: DirectoryNameColumnProps) {
9392
variant="custom"
9493
aria-label={isExpanded ? getText('collapse') : getText('expand')}
9594
tooltipPlacement="left"
96-
className={tailwindMerge.twMerge(
95+
className={tailwindMerge.twJoin(
9796
'm-0 hidden cursor-pointer border-0 transition-transform duration-arrow group-hover:m-name-column-icon group-hover:inline-block',
9897
isExpanded && 'rotate-90',
9998
)}

app/gui/src/dashboard/components/dashboard/FileNameColumn.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export default function FileNameColumn(props: FileNameColumnProps) {
5959

6060
return (
6161
<div
62-
className={tailwindMerge.twMerge(
63-
'flex h-table-row min-w-max items-center gap-name-column-icon whitespace-nowrap rounded-l-full px-name-column-x py-name-column-y',
62+
className={tailwindMerge.twJoin(
63+
'flex h-table-row min-w-max items-center gap-name-column-icon whitespace-nowrap rounded-l-full px-name-column-x py-name-column-y rounded-rows-child',
6464
indent.indentClass(depth),
6565
)}
6666
onKeyDown={(event) => {

app/gui/src/dashboard/components/dashboard/ProjectNameColumn.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ export default function ProjectNameColumn(props: ProjectNameColumnProps) {
9595

9696
return (
9797
<div
98-
className={tailwindMerge.twMerge(
99-
'flex h-table-row min-w-max items-center gap-name-column-icon whitespace-nowrap rounded-l-full px-name-column-x py-name-column-y',
98+
className={tailwindMerge.twJoin(
99+
'flex h-table-row min-w-max items-center gap-name-column-icon whitespace-nowrap rounded-l-full px-name-column-x py-name-column-y rounded-rows-child',
100100
indent.indentClass(depth),
101101
)}
102102
onKeyDown={(event) => {

app/gui/src/dashboard/components/dashboard/SecretNameColumn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function SecretNameColumn(props: SecretNameColumnProps) {
5252
return (
5353
<div
5454
className={tailwindMerge.twMerge(
55-
'flex h-table-row min-w-max items-center gap-name-column-icon whitespace-nowrap rounded-l-full px-name-column-x py-name-column-y',
55+
'flex h-table-row min-w-max items-center gap-name-column-icon whitespace-nowrap rounded-l-full px-name-column-x py-name-column-y rounded-rows-child',
5656
indent.indentClass(depth),
5757
)}
5858
onKeyDown={(event) => {

app/gui/src/dashboard/components/dashboard/column.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface AssetColumnProps {
3333
readonly setRowState: Dispatch<SetStateAction<AssetRowState>>
3434
readonly isEditable: boolean
3535
readonly isPlaceholder: boolean
36+
readonly isExpanded: boolean
3637
}
3738

3839
/** Props for a {@link AssetColumn}. */

app/gui/src/dashboard/layouts/AssetContextMenu.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ import * as backendModule from '#/services/Backend'
3636
import * as localBackendModule from '#/services/LocalBackend'
3737

3838
import { useUploadFileWithToastMutation } from '#/hooks/backendHooks'
39-
import {
40-
usePasteData,
41-
useSetAssetPanelProps,
42-
useSetIsAssetPanelTemporarilyVisible,
43-
} from '#/providers/DriveProvider'
39+
import { usePasteData } from '#/providers/DriveProvider'
4440
import { normalizePath } from '#/utilities/fileInfo'
4541
import { mapNonNullish } from '#/utilities/nullable'
4642
import * as object from '#/utilities/object'
4743
import * as permissions from '#/utilities/permissions'
44+
import { useSetAssetPanelProps, useSetIsAssetPanelTemporarilyVisible } from './AssetPanel'
4845

4946
// ========================
5047
// === AssetContextMenu ===

app/gui/src/dashboard/layouts/AssetPanel/AssetPanel.tsx

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,32 @@ import versionsIcon from '#/assets/versions.svg'
1111

1212
import { useEventCallback } from '#/hooks/eventCallbackHooks'
1313
import { useBackend } from '#/providers/BackendProvider'
14-
import {
15-
useAssetPanelProps,
16-
useAssetPanelSelectedTab,
17-
useIsAssetPanelExpanded,
18-
useIsAssetPanelHidden,
19-
useSetAssetPanelSelectedTab,
20-
useSetIsAssetPanelExpanded,
21-
} from '#/providers/DriveProvider'
2214
import { useText } from '#/providers/TextProvider'
23-
import type Backend from '#/services/Backend'
2415
import LocalStorage from '#/utilities/LocalStorage'
25-
import type { AnyAsset, BackendType } from 'enso-common/src/services/Backend'
16+
import { useStore } from '#/utilities/zustand'
17+
import type { BackendType } from 'enso-common/src/services/Backend'
2618
import type { Spring } from 'framer-motion'
2719
import { AnimatePresence, motion } from 'framer-motion'
2820
import { memo, startTransition } from 'react'
2921
import { z } from 'zod'
3022
import { AssetDocs } from '../AssetDocs'
3123
import AssetProjectSessions from '../AssetProjectSessions'
32-
import type { AssetPropertiesSpotlight } from '../AssetProperties'
3324
import AssetProperties from '../AssetProperties'
3425
import AssetVersions from '../AssetVersions/AssetVersions'
3526
import type { Category } from '../CategorySwitcher/Category'
27+
import {
28+
assetPanelStore,
29+
useIsAssetPanelExpanded,
30+
useSetIsAssetPanelExpanded,
31+
} from './AssetPanelState'
3632
import { AssetPanelTabs } from './components/AssetPanelTabs'
3733
import { AssetPanelToggle } from './components/AssetPanelToggle'
34+
import { ASSET_PANEL_TABS, type AssetPanelTab } from './types'
3835

3936
const ASSET_SIDEBAR_COLLAPSED_WIDTH = 48
4037
const ASSET_PANEL_WIDTH = 480
4138
const ASSET_PANEL_TOTAL_WIDTH = ASSET_PANEL_WIDTH + ASSET_SIDEBAR_COLLAPSED_WIDTH
4239

43-
/** Determines the content of the {@link AssetPanel}. */
44-
const ASSET_PANEL_TABS = ['settings', 'versions', 'sessions', 'schedules', 'docs'] as const
45-
46-
/** Determines the content of the {@link AssetPanel}. */
47-
type AssetPanelTab = (typeof ASSET_PANEL_TABS)[number]
48-
4940
declare module '#/utilities/LocalStorage' {
5041
/** */
5142
interface LocalStorageData {
@@ -65,15 +56,6 @@ LocalStorage.register({
6556
isAssetPanelVisible: { schema: z.boolean() },
6657
})
6758

68-
/** Props supplied by the row. */
69-
export interface AssetPanelContextProps {
70-
readonly backend: Backend | null
71-
readonly selectedTab: AssetPanelTab
72-
readonly item: AnyAsset | null
73-
readonly path: string | null
74-
readonly spotlightOn: AssetPropertiesSpotlight | null
75-
}
76-
7759
/**
7860
* Props for an {@link AssetPanel}.
7961
*/
@@ -97,7 +79,9 @@ const DEFAULT_TRANSITION_OPTIONS: Spring = {
9779
* It is used to view and interact with assets in the drive.
9880
*/
9981
export function AssetPanel(props: AssetPanelProps) {
100-
const isHidden = useIsAssetPanelHidden()
82+
const isHidden = useStore(assetPanelStore, (state) => state.isAssetPanelHidden, {
83+
unsafeEnableTransition: true,
84+
})
10185
const isExpanded = useIsAssetPanelExpanded()
10286

10387
const panelWidth = isExpanded ? ASSET_PANEL_TOTAL_WIDTH : ASSET_SIDEBAR_COLLAPSED_WIDTH
@@ -137,11 +121,21 @@ export function AssetPanel(props: AssetPanelProps) {
137121
const InternalAssetPanelTabs = memo(function InternalAssetPanelTabs(props: AssetPanelProps) {
138122
const { category } = props
139123

140-
const { item, spotlightOn, path } = useAssetPanelProps()
124+
const { item, spotlightOn, path } = useStore(assetPanelStore, (state) => ({
125+
item: state.assetPanelProps.item,
126+
spotlightOn: state.assetPanelProps.spotlightOn,
127+
path: state.assetPanelProps.path,
128+
}))
141129

142-
const selectedTab = useAssetPanelSelectedTab()
143-
const setSelectedTab = useSetAssetPanelSelectedTab()
144-
const isHidden = useIsAssetPanelHidden()
130+
const selectedTab = useStore(assetPanelStore, (state) => state.selectedTab, {
131+
unsafeEnableTransition: true,
132+
})
133+
const setSelectedTab = useStore(assetPanelStore, (state) => state.setSelectedTab, {
134+
unsafeEnableTransition: true,
135+
})
136+
const isHidden = useStore(assetPanelStore, (state) => state.isAssetPanelHidden, {
137+
unsafeEnableTransition: true,
138+
})
145139

146140
const isReadonly = category.type === 'trash'
147141

0 commit comments

Comments
 (0)