Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
03279f0
WIP Drag and Drop file list
mofojed Jul 9, 2021
261bb39
Fix up drag and drop functionality
mofojed Jul 12, 2021
87c16fe
A little bit of cleanup
mofojed Jul 12, 2021
4a29c6a
WIP Tried to get rid of SingleClickItemList and just used DraggableIt…
mofojed Jul 12, 2021
49b5ee6
WIP Cleaned it up more... still can't get the drag start to trigger :(
mofojed Jul 13, 2021
855caa6
WIP Using ItemList
mofojed Jul 13, 2021
90f3eeb
Fixed up the selection after doing a drag
mofojed Jul 13, 2021
c255983
Clean up some styling, allow hovering over a folder when dragging to …
mofojed Jul 13, 2021
1c9ca73
Fix up moving directories
mofojed Jul 13, 2021
4a488f7
Clean up tests, remove unused SCSS file
mofojed Jul 13, 2021
d378f6d
Convert unit tests to TypeScript and add some more
mofojed Jul 13, 2021
fdd232b
Remove the onItemDrag stuff that's no longer needed on ItemList
mofojed Jul 13, 2021
29eb51e
Fix isDoubleClickSelect on DraggableItemList
mofojed Jul 13, 2021
453ef7d
Fix the CSV overlay appearing when dragging over it
mofojed Jul 19, 2021
39c1ac0
Fix up styling for list
mofojed Jul 19, 2021
b452355
Allow dropping at the root
mofojed Jul 19, 2021
c125205
Update packages/file-explorer/src/FileList.tsx
mofojed Jul 22, 2021
2a6508c
Update packages/file-explorer/src/FileList.tsx
mofojed Jul 22, 2021
81dbd57
Remove all the UpdateableComponent wiring
mofojed Jul 22, 2021
bf647f0
Fix issue with dragging into a directory deleting itself
mofojed Jul 23, 2021
ef073e5
Fix Ctrl+Click to not trigger select
mofojed Jul 23, 2021
9698ded
Fix up shift/ctrl+click triggering a 'onSelect' change
mofojed Jul 23, 2021
fa0df80
Add styling to FileList to match CommandHistory more closely
mofojed Jul 23, 2021
118f09d
Don't reset the background if dragging
mofojed Jul 23, 2021
cb84910
Fix cursor style on Chrome on Mac when dragging item
mofojed Jul 23, 2021
7b4d6b3
Clean up linting errors
mofojed Jul 23, 2021
66efb9a
Update styling for when item is selected but focus is not within the …
mofojed Jul 23, 2021
2af0426
Change the effectAllowed to "move" instead of copy
mofojed Jul 23, 2021
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
17 changes: 3 additions & 14 deletions packages/code-studio/src/dashboard/panels/FileExplorerPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import Log from '@deephaven/log';
import { getFileStorage } from '@deephaven/redux';
import FileExplorer, {
FileExplorerToolbar,
FileListItem,
FileStorage,
FileStorageItem,
NewItemModal,
UpdateableComponent,
} from '@deephaven/file-explorer';
import GoldenLayout from 'golden-layout';
import React, { ReactNode } from 'react';
Expand Down Expand Up @@ -65,7 +64,6 @@ export class FileExplorerPanel extends React.Component<
);
this.handleDelete = this.handleDelete.bind(this);
this.handleRename = this.handleRename.bind(this);
this.handleResize = this.handleResize.bind(this);
this.handleSessionOpened = this.handleSessionOpened.bind(this);
this.handleSessionClosed = this.handleSessionClosed.bind(this);
this.handleShow = this.handleShow.bind(this);
Expand All @@ -85,8 +83,6 @@ export class FileExplorerPanel extends React.Component<
}
}

private fileExplorer = React.createRef<UpdateableComponent>();

handleCreateFile(): void {
const { glEventHub } = this.props;
const { session, language } = this.state;
Expand Down Expand Up @@ -121,7 +117,7 @@ export class FileExplorerPanel extends React.Component<
fileStorage.createDirectory(path).catch(FileExplorerPanel.handleError);
}

handleDelete(files: FileListItem[]): void {
handleDelete(files: FileStorageItem[]): void {
const { glEventHub } = this.props;
files.forEach(file => {
glEventHub.emit(NotebookEvent.CLOSE_FILE, {
Expand All @@ -131,7 +127,7 @@ export class FileExplorerPanel extends React.Component<
});
}

handleFileSelect(file: FileListItem): void {
handleFileSelect(file: FileStorageItem): void {
log.debug('fileSelect', file);
if (file.type === 'directory') {
return;
Expand Down Expand Up @@ -159,10 +155,6 @@ export class FileExplorerPanel extends React.Component<
glEventHub.emit(NotebookEvent.RENAME_FILE, oldName, newName);
}

handleResize(): void {
this.fileExplorer.current?.updateDimensions();
}

handleSessionOpened(
session: DhSession,
{ language }: { language: string }
Expand All @@ -182,7 +174,6 @@ export class FileExplorerPanel extends React.Component<

handleShow(): void {
this.setState({ isShown: true });
this.fileExplorer.current?.updateDimensions();
}

isHidden(): boolean {
Expand All @@ -202,7 +193,6 @@ export class FileExplorerPanel extends React.Component<
glEventHub={glEventHub}
onSessionOpen={this.handleSessionOpened}
onSessionClose={this.handleSessionClosed}
onResize={this.handleResize}
onShow={this.handleShow}
>
<FileExplorerToolbar
Expand All @@ -212,7 +202,6 @@ export class FileExplorerPanel extends React.Component<
{isShown && (
<FileExplorer
isMultiSelect
ref={this.fileExplorer}
storage={fileStorage}
onDelete={this.handleDelete}
onRename={this.handleRename}
Expand Down
7 changes: 6 additions & 1 deletion packages/code-studio/src/dashboard/panels/NotebookPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ class NotebookPanel extends Component {
const { fileMetadata } = this.state;
if (fileMetadata.id === oldName) {
this.setState({ fileMetadata: { id: newName, itemName: newName } });
this.debouncedSavePanelState();
}
}

Expand Down Expand Up @@ -715,13 +716,17 @@ class NotebookPanel extends Component {
isDashboardActive,
isLoaded,
isLoading,
isPreview,
fileMetadata,
session,
sessionLanguage,
settings: initialSettings,
showCloseModal,
showSaveAsModal,
} = this.state;
// We don't want to steal focus if this isn't shown or it's just a preview
const focusOnMount =
isDashboardActive && !glContainer.isHidden && !isPreview;
const itemName = fileMetadata?.itemName ?? NotebookPanel.DEFAULT_NAME;
const isExistingItem = fileMetadata?.id != null;
const overflowActions = this.getOverflowActions();
Expand Down Expand Up @@ -859,7 +864,7 @@ class NotebookPanel extends Component {
session={session}
sessionLanguage={sessionLanguage}
settings={settings}
focusOnMount={isDashboardActive && !glContainer.isHidden}
focusOnMount={focusOnMount}
ref={notebook => {
this.notebook = notebook;
}}
Expand Down
2 changes: 1 addition & 1 deletion packages/code-studio/src/styleguide/Grids.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import { Grid, MockGridModel, MockTreeGridModel } from '@deephaven/grid';
import { IrisGrid } from '@deephaven/iris-grid/dist/IrisGrid';
import IrisGrid from '@deephaven/iris-grid/dist/IrisGrid';
import MockIrisGridTreeModel from './MockIrisGridTreeModel';

class Grids extends PureComponent {
Expand Down
12 changes: 12 additions & 0 deletions packages/code-studio/src/styleguide/MockIrisGridTreeModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ class MockIrisGridTreeModel extends IrisGridModel {
return true;
}

get pendingRowCount() {
return 0;
}

set pendingRowCount(count) {}

get pendingDataMap() {
return new Map();
}

set pendingDataMap(value) {}

textForCell(column, row) {
return (
this.editedData[column]?.[row] ?? this.model.textForCell(column, row)
Expand Down
4 changes: 2 additions & 2 deletions packages/code-studio/src/styleguide/StyleGuideInit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
setWorkspace as setWorkspaceAction,
} from '@deephaven/redux';
import StyleGuide from './StyleGuide';
import WorkspaceStorage from '../dashboard/WorkspaceStorage';
import LocalWorkspaceStorage from '../dashboard/LocalWorkspaceStorage';

/**
* Initialize data needed for the styleguide
Expand All @@ -15,7 +15,7 @@ const StyleGuideInit = props => {
const { workspace, setWorkspace } = props;

useEffect(() => {
setWorkspace(WorkspaceStorage.makeDefaultWorkspace());
setWorkspace(LocalWorkspaceStorage.makeDefaultWorkspace());
}, [setWorkspace]);

return <>{workspace && <StyleGuide />}</>;
Expand Down
66 changes: 32 additions & 34 deletions packages/components/src/DraggableItemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { Draggable, Droppable, DraggableChildrenFn } from 'react-beautiful-dnd';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { vsGripper } from '@deephaven/icons';
import { RangeUtils, Range } from '@deephaven/utils';
import ItemList, { RenderItemProps, DefaultListItem } from './ItemList';
import ItemList, {
RenderItemProps,
DefaultListItem,
ItemListProps,
} from './ItemList';
import { Tooltip } from './popper';
import './DraggableItemList.scss';

Expand All @@ -18,33 +22,19 @@ type DraggableRenderItemFn<T> = (
props: DraggableRenderItemProps<T>
) => React.ReactNode;

type DraggableItemListProps<T> = {
type DraggableItemListProps<T> = Omit<
ItemListProps<T>,
'overscanCount' | 'focusSelector' | 'isDragSelect'
> & {
className: string;
draggingItemClassName: string;
// Total item count
itemCount: number;
rowHeight: number;
// Offset of the top item in the items array
offset: number;
// Item object format expected by the default renderItem function
// Can be anything as long as it's supported by the renderItem
items: T[];
// Whether to allow dropping items in this list
isDropDisabled: boolean;
// Whether to allow dragging items from this list
isDragDisabled: boolean;
// Whether to allow multiple selections in this item list
isMultiSelect: boolean;
// Set to true if you want the list to scroll when new items are added and it's already at the bottom
isStickyBottom: boolean;
// Fired when an item is clicked. With multiple selection, fired on double click.
onSelect(index: number): void;
onSelectionChange(ranges: Range[]): void;
onViewportChange(): void;
selectedRanges: Range[];
disableSelect: boolean;

renderItem: DraggableRenderItemFn<T>;
style: React.CSSProperties;

// The prefix to add to all draggable item IDs
draggablePrefix: string;
// The ID to give the droppable list
Expand Down Expand Up @@ -74,12 +64,16 @@ class DraggableItemList<T> extends PureComponent<
offset: 0,
items: [],
rowHeight: DraggableItemList.DEFAULT_ROW_HEIGHT,
isDoubleClickSelect: true,
isDropDisabled: false,
isDragDisabled: false,
isMultiSelect: false,
isStickyBottom: false,
disableSelect: false,
style: null,
onFocusChange(): void {
// no-op
},
onSelect(): void {
// no-op
},
Expand Down Expand Up @@ -165,16 +159,16 @@ class DraggableItemList<T> extends PureComponent<

itemList: React.RefObject<ItemList<T>>;

selectItem(itemIndex: number): void {
this.itemList.current?.selectItem(itemIndex);
}

focusItem(itemIndex: number): void {
if (this.itemList.current) {
this.itemList.current.focusItem(itemIndex);
}
this.itemList.current?.focusItem(itemIndex);
}

scrollToItem(itemIndex: number): void {
if (this.itemList.current) {
this.itemList.current.scrollToItem(itemIndex);
}
this.itemList.current?.scrollToItem(itemIndex);
}

getCachedDraggableItem = memoize(
Expand All @@ -183,7 +177,7 @@ class DraggableItemList<T> extends PureComponent<
renderItem: DraggableRenderItemFn<T>,
item: T,
itemIndex: number,
isKeyboardSelected: boolean,
isFocused: boolean,
isSelected: boolean,
isDragDisabled: boolean,
style: React.CSSProperties
Expand Down Expand Up @@ -211,7 +205,7 @@ class DraggableItemList<T> extends PureComponent<
{renderItem({
item,
itemIndex,
isKeyboardSelected,
isFocused,
isSelected,
style,
isClone: false,
Expand All @@ -238,7 +232,7 @@ class DraggableItemList<T> extends PureComponent<
) => ({
item,
itemIndex,
isKeyboardSelected,
isFocused,
isSelected,
style,
}: RenderItemProps<T>) =>
Expand All @@ -247,7 +241,7 @@ class DraggableItemList<T> extends PureComponent<
renderItem,
item,
itemIndex,
isKeyboardSelected,
isFocused,
isSelected,
isDragDisabled,
style
Expand Down Expand Up @@ -287,7 +281,7 @@ class DraggableItemList<T> extends PureComponent<
{renderItem({
item,
itemIndex,
isKeyboardSelected: false,
isFocused: false,
isSelected: true,
style: {},
isClone: true,
Expand All @@ -306,18 +300,20 @@ class DraggableItemList<T> extends PureComponent<
draggablePrefix,
draggingItemClassName,
droppableId,
isDoubleClickSelect,
isDragDisabled,
isDropDisabled,
isMultiSelect,
isStickyBottom,
itemCount,
items,
onViewportChange,
offset,
onFocusChange,
onSelect,
onViewportChange,
renderItem,
rowHeight,
selectedRanges,
onSelect,
style,
} = this.props;
return (
Expand Down Expand Up @@ -349,11 +345,13 @@ class DraggableItemList<T> extends PureComponent<
>
<ItemList
focusSelector=".draggable-item-list-item"
isDoubleClickSelect={isDoubleClickSelect}
isDragSelect={false}
isMultiSelect={isMultiSelect}
isStickyBottom={isStickyBottom}
itemCount={itemCount}
items={items}
onFocusChange={onFocusChange}
onSelect={onSelect}
onSelectionChange={this.handleSelectionChange}
onViewportChange={onViewportChange}
Expand Down
Loading