- {(explorerStore.layoutMode === 'grid' || explorerStore.layoutMode === 'media') && (
+ {(settings.layoutMode === 'grid' || settings.layoutMode === 'media') && (
Item size
- {explorerStore.layoutMode === 'grid' ? (
+ {settings.layoutMode === 'grid' ? (
{
- getExplorerStore().gridItemSize = value[0] || 100;
+ explorer.settingsStore.gridItemSize = value[0] || 100;
}}
- defaultValue={[explorerStore.gridItemSize]}
+ defaultValue={[settings.gridItemSize]}
max={200}
step={10}
min={60}
/>
) : (
{
- if (val !== undefined) {
- getExplorerStore().mediaColumns = 10 - val;
- }
+ if (val !== undefined)
+ explorer.settingsStore.mediaColumns = 10 - val;
}}
/>
)}
)}
- {explorerStore.layoutMode === 'grid' && (
+ {settings.layoutMode === 'grid' && (
Gap
{
)}
- {(explorerStore.layoutMode === 'grid' || explorerStore.layoutMode === 'media') && (
+ {(settings.layoutMode === 'grid' || settings.layoutMode === 'media') && (
Sort by
@@ -88,12 +93,18 @@ export default () => {
Direction
)}
- {explorerStore.layoutMode === 'grid' && (
+ {settings.layoutMode === 'grid' && (
{
- if (typeof value === 'boolean') {
- getExplorerStore().showBytesInGridView = value;
- }
+ if (typeof value !== 'boolean') return;
+
+ explorer.settingsStore.showBytesInGridView = value;
}}
className="mt-1"
/>
)}
- {explorerStore.layoutMode === 'media' && (
+ {settings.layoutMode === 'media' && (
{
- if (typeof value === 'boolean') {
- getExplorerStore().mediaAspectSquare = value;
- }
+ if (typeof value !== 'boolean') return;
+
+ explorer.settingsStore.mediaAspectSquare = value;
}}
className="mt-1"
/>
@@ -136,15 +147,23 @@ export default () => {
Double click action
);
};
+
+const doubleClickActions = z.union([
+ z.literal('openFile').describe('Open File'),
+ z.literal('quickPreview').describe('Quick Preview')
+]);
diff --git a/interface/app/$libraryId/Explorer/TopBarOptions.tsx b/interface/app/$libraryId/Explorer/TopBarOptions.tsx
index ad6df4b01157..9b63b0963ede 100644
--- a/interface/app/$libraryId/Explorer/TopBarOptions.tsx
+++ b/interface/app/$libraryId/Explorer/TopBarOptions.tsx
@@ -20,20 +20,23 @@ import { useExplorerSearchParams } from './util';
export const useExplorerTopBarOptions = () => {
const explorerStore = useExplorerStore();
+ const explorer = useExplorerContext();
+
+ const settings = explorer.useSettingsSnapshot();
const viewOptions: ToolOption[] = [
{
toolTipLabel: 'Grid view',
icon:
,
- topBarActive: explorerStore.layoutMode === 'grid',
- onClick: () => (getExplorerStore().layoutMode = 'grid'),
+ topBarActive: settings.layoutMode === 'grid',
+ onClick: () => (explorer.settingsStore.layoutMode = 'grid'),
showAtResolution: 'sm:flex'
},
{
toolTipLabel: 'List view',
icon:
,
- topBarActive: explorerStore.layoutMode === 'rows',
- onClick: () => (getExplorerStore().layoutMode = 'rows'),
+ topBarActive: settings.layoutMode === 'list',
+ onClick: () => (explorer.settingsStore.layoutMode = 'list'),
showAtResolution: 'sm:flex'
},
// {
@@ -46,8 +49,8 @@ export const useExplorerTopBarOptions = () => {
{
toolTipLabel: 'Media view',
icon:
,
- topBarActive: explorerStore.layoutMode === 'media',
- onClick: () => (getExplorerStore().layoutMode = 'media'),
+ topBarActive: settings.layoutMode === 'media',
+ onClick: () => (explorer.settingsStore.layoutMode = 'media'),
showAtResolution: 'sm:flex'
}
];
diff --git a/interface/app/$libraryId/Explorer/View/GridList.tsx b/interface/app/$libraryId/Explorer/View/GridList.tsx
index b8250580c35b..3764919ff1b1 100644
--- a/interface/app/$libraryId/Explorer/View/GridList.tsx
+++ b/interface/app/$libraryId/Explorer/View/GridList.tsx
@@ -98,6 +98,7 @@ export default ({ children }: { children: RenderItem }) => {
const isChrome = CHROME_REGEX.test(navigator.userAgent);
const explorer = useExplorerContext();
+ const settings = explorer.useSettingsSnapshot();
const explorerStore = useExplorerStore();
const explorerView = useExplorerViewContext();
@@ -108,9 +109,8 @@ export default ({ children }: { children: RenderItem }) => {
const [dragFromThumbnail, setDragFromThumbnail] = useState(false);
- const itemDetailsHeight =
- explorerStore.gridItemSize / 4 + (explorerStore.showBytesInGridView ? 20 : 0);
- const itemHeight = explorerStore.gridItemSize + itemDetailsHeight;
+ const itemDetailsHeight = settings.gridItemSize / 4 + (settings.showBytesInGridView ? 20 : 0);
+ const itemHeight = settings.gridItemSize + itemDetailsHeight;
const grid = useGridList({
ref: explorerView.ref,
@@ -119,19 +119,19 @@ export default ({ children }: { children: RenderItem }) => {
onLoadMore: explorer.loadMore,
rowsBeforeLoadMore: explorer.rowsBeforeLoadMore,
size:
- explorerStore.layoutMode === 'grid'
- ? { width: explorerStore.gridItemSize, height: itemHeight }
+ settings.layoutMode === 'grid'
+ ? { width: settings.gridItemSize, height: itemHeight }
: undefined,
- columns: explorerStore.layoutMode === 'media' ? explorerStore.mediaColumns : undefined,
+ columns: settings.layoutMode === 'media' ? settings.mediaColumns : undefined,
getItemId: (index) => {
const item = explorer.items?.[index];
return item ? explorerItemHash(item) : undefined;
},
getItemData: (index) => explorer.items?.[index],
- padding: explorerView.padding || explorerStore.layoutMode === 'grid' ? 12 : undefined,
+ padding: explorerView.padding || settings.layoutMode === 'grid' ? 12 : undefined,
gap:
explorerView.gap ||
- (explorerStore.layoutMode === 'grid' ? explorerStore.gridGap : undefined),
+ (settings.layoutMode === 'grid' ? explorerStore.gridGap : undefined),
top: explorerView.top
});
diff --git a/interface/app/$libraryId/Explorer/View/GridView.tsx b/interface/app/$libraryId/Explorer/View/GridView.tsx
index 6fb01c9ceee3..b2b85aa1ed67 100644
--- a/interface/app/$libraryId/Explorer/View/GridView.tsx
+++ b/interface/app/$libraryId/Explorer/View/GridView.tsx
@@ -18,9 +18,11 @@ interface GridViewItemProps {
}
const GridViewItem = memo(({ data, selected, cut, isRenaming, renamable }: GridViewItemProps) => {
+ const explorer = useExplorerContext();
+ const { showBytesInGridView, gridItemSize } = explorer.useSettingsSnapshot();
+
const filePathData = getItemFilePath(data);
const location = getItemLocation(data);
- const { showBytesInGridView, gridItemSize } = useExplorerStore();
const showSize =
!filePathData?.is_dir &&
@@ -33,7 +35,13 @@ const GridViewItem = memo(({ data, selected, cut, isRenaming, renamable }: GridV
-
+
diff --git a/interface/app/$libraryId/Explorer/View/ListView.tsx b/interface/app/$libraryId/Explorer/View/ListView.tsx
index 22f49bb46b48..a848c3b705f9 100644
--- a/interface/app/$libraryId/Explorer/View/ListView.tsx
+++ b/interface/app/$libraryId/Explorer/View/ListView.tsx
@@ -16,6 +16,7 @@ import { useKey, useMutationObserver, useWindowEventListener } from 'rooks';
import useResizeObserver from 'use-resize-observer';
import {
ExplorerItem,
+ ExplorerSettings,
FilePath,
ObjectKind,
byteSize,
@@ -34,7 +35,8 @@ import { useExplorerContext } from '../Context';
import { FileThumb } from '../FilePath/Thumb';
import { InfoPill } from '../Inspector';
import { useExplorerViewContext } from '../ViewContext';
-import { FilePathSearchOrderingKeys, getExplorerStore, isCut, useExplorerStore } from '../store';
+import { createOrdering, getOrderingDirection, orderingKey } from '../store';
+import { isCut } from '../store';
import { ExplorerItemHash } from '../useExplorer';
import { explorerItemHash } from '../util';
import RenamableItemText from './RenamableItemText';
@@ -91,7 +93,7 @@ type Range = [ExplorerItemHash, ExplorerItemHash];
export default () => {
const explorer = useExplorerContext();
- const explorerStore = useExplorerStore();
+ const settings = explorer.useSettingsSnapshot();
const explorerView = useExplorerViewContext();
const layout = useLayoutContext();
@@ -126,19 +128,25 @@ export default () => {
const scrollBarWidth = 8;
const rowHeight = 45;
-
const { width: tableWidth = 0 } = useResizeObserver({ ref: tableRef });
const { width: headerWidth = 0 } = useResizeObserver({ ref: tableHeaderRef });
const getFileName = (path: FilePath) => `${path.name}${path.extension && `.${path.extension}`}`;
+ useEffect(() => {
+ //we need this to trigger a re-render with the updated column sizes from the store
+ if (!resizing) {
+ setColumnSizing(explorer.settingsStore.colSizes);
+ }
+ }, [resizing, explorer.settingsStore.colSizes]);
+
const columns = useMemo[]>(
() => [
{
id: 'name',
header: 'Name',
minSize: 200,
- size: 350,
+ size: settings.colSizes['name'],
maxSize: undefined,
meta: { className: '!overflow-visible !text-ink' },
accessorFn: (file) => {
@@ -161,6 +169,7 @@ export default () => {
@@ -178,6 +187,7 @@ export default () => {
{
id: 'kind',
header: 'Type',
+ size: settings.colSizes['kind'],
enableSorting: false,
accessorFn: (file) => {
return isPath(file) && file.item.is_dir
@@ -198,7 +208,7 @@ export default () => {
{
id: 'sizeInBytes',
header: 'Size',
- size: 100,
+ size: settings.colSizes['sizeInBytes'],
accessorFn: (file) => {
const file_path = getItemFilePath(file);
if (!file_path || !file_path.size_in_bytes_bytes) return;
@@ -209,11 +219,13 @@ export default () => {
{
id: 'dateCreated',
header: 'Date Created',
+ size: settings.colSizes['dateCreated'],
accessorFn: (file) => dayjs(file.item.date_created).format('MMM Do YYYY')
},
{
id: 'dateModified',
header: 'Date Modified',
+ size: settings.colSizes['dateModified'],
accessorFn: (file) =>
dayjs(getItemFilePath(file)?.date_modified).format('MMM Do YYYY')
},
@@ -226,17 +238,20 @@ export default () => {
{
id: 'dateAccessed',
header: 'Date Accessed',
+ size: settings.colSizes['dateAccessed'],
accessorFn: (file) =>
getItemObject(file)?.date_accessed &&
dayjs(getItemObject(file)?.date_accessed).format('MMM Do YYYY')
},
{
+ id: 'contentId',
header: 'Content ID',
enableSorting: false,
- size: 180,
+ size: settings.colSizes['contentId'],
accessorFn: (file) => getExplorerItemData(file).casId
},
{
+ id: 'objectId',
header: 'Object ID',
enableSorting: false,
size: 180,
@@ -247,7 +262,7 @@ export default () => {
}
}
],
- [explorer.selectedItems]
+ [explorer.selectedItems, settings.colSizes]
);
const table = useReactTable({
@@ -710,7 +725,6 @@ export default () => {
const nameColumnMinSize = table.getColumn('name')?.columnDef.minSize;
const newNameSize =
(nameSize || 0) + tableWidth - paddingX * 2 - scrollBarWidth - tableLength;
-
return {
...sizing,
...(nameSize !== undefined && nameColumnMinSize !== undefined
@@ -751,7 +765,6 @@ export default () => {
table.setColumnSizing({ ...sizings, name: nameWidth });
setLocked(true);
} else table.setColumnSizing(sizings);
-
setSized(true);
}
}, []);
@@ -973,6 +986,9 @@ export default () => {
useWindowEventListener('mouseup', () => {
if (resizing) {
setTimeout(() => {
+ //we need to update the store to trigger a DB update
+ explorer.settingsStore.colSizes =
+ columnSizing as typeof explorer.settingsStore.colSizes;
setResizing(false);
if (layout?.ref.current) {
layout.ref.current.style.cursor = '';
@@ -1012,8 +1028,11 @@ export default () => {
{headerGroup.headers.map((header, i) => {
const size = header.column.getSize();
- const isSorted =
- explorerStore.orderBy === header.id;
+ const orderingDirection =
+ settings.order &&
+ orderingKey(settings.order) === header.id
+ ? getOrderingDirection(settings.order)
+ : null;
const cellContent = flexRender(
header.column.columnDef.header,
@@ -1039,15 +1058,21 @@ export default () => {
if (resizing) return;
if (header.column.getCanSort()) {
- if (isSorted) {
- getExplorerStore().orderByDirection =
- explorerStore.orderByDirection ===
- 'Asc'
- ? 'Desc'
- : 'Asc';
+ if (orderingDirection) {
+ explorer.settingsStore.order =
+ createOrdering(
+ header.id,
+ orderingDirection ===
+ 'Asc'
+ ? 'Desc'
+ : 'Asc'
+ );
} else {
- getExplorerStore().orderBy =
- header.id as FilePathSearchOrderingKeys;
+ explorer.settingsStore.order =
+ createOrdering(
+ header.id,
+ 'Asc'
+ );
}
}
}}
@@ -1056,7 +1081,7 @@ export default () => {
{
/>
)}
- {isSorted ? (
- explorerStore.orderByDirection ===
- 'Asc' ? (
-
- ) : (
-
- )
- ) : null}
+ {orderingDirection === 'Asc' && (
+
+ )}
+ {orderingDirection === 'Desc' && (
+
+ )}
@@ -1085,7 +1108,6 @@ export default () => {
header.getResizeHandler()(
e
);
-
setResizing(true);
setLocked(false);
diff --git a/interface/app/$libraryId/Explorer/View/MediaView.tsx b/interface/app/$libraryId/Explorer/View/MediaView.tsx
index c9fb61c6db6a..346773a4dcae 100644
--- a/interface/app/$libraryId/Explorer/View/MediaView.tsx
+++ b/interface/app/$libraryId/Explorer/View/MediaView.tsx
@@ -4,6 +4,7 @@ import { memo } from 'react';
import { ExplorerItem } from '@sd/client';
import { Button } from '@sd/ui';
import { ViewItem } from '.';
+import { useExplorerContext } from '../Context';
import { FileThumb } from '../FilePath/Thumb';
import { getExplorerStore, useExplorerStore } from '../store';
import GridList from './GridList';
@@ -15,7 +16,7 @@ interface MediaViewItemProps {
}
const MediaViewItem = memo(({ data, selected, cut }: MediaViewItemProps) => {
- const explorerStore = useExplorerStore();
+ const settings = useExplorerContext().useSettingsSnapshot();
return (
{
>