-
Notifications
You must be signed in to change notification settings - Fork 2
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
Task/WG-238 panel assets listing #261
Merged
Merged
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
4fcb8c1
Add initial feature file tree
nathanfranklin fc2abec
Additional work on assets list
nathanfranklin ff4c6c9
Add sorting
nathanfranklin 2f4123f
Improve doc
nathanfranklin 9216df1
Improve styling and fix nodes of tree
nathanfranklin 3fdc671
Add todo
nathanfranklin f16352b
Refactor and add test
nathanfranklin 2f305e2
Refactor into new files
nathanfranklin 2b05b08
Move FeatureFileNode into types
nathanfranklin 1c00bfe
Use font awesome for folder icon
nathanfranklin b05a0c4
Fix spelling error
nathanfranklin 2eeef58
Rework importing
nathanfranklin 95175c4
Expand rows
nathanfranklin 67c8351
Set witch of panel as 230px
nathanfranklin 241cd2e
Remove todos
nathanfranklin 44e1250
Ensure nodes are expanded at start
nathanfranklin 3a87f28
Fix selection/hover and height of rows
nathanfranklin 0333927
Fix expanding rows on refresh
nathanfranklin e66ebf3
Add selected feature to route and fix row spacing
nathanfranklin 1f58828
Merge branch 'main' into task/WG-238-panel-assets-listing
nathanfranklin 76d23a7
Add useDelete
sophia-massie 244aa45
Add functionality for feature deletion
nathanfranklin 70134f6
Refactor MapProject
nathanfranklin 80c23b2
Fix todos
nathanfranklin 8ea8522
Add isLoading to button
nathanfranklin c19870f
Allow user to export feature geojson to file
nathanfranklin 5737561
Add feature icon in asset listing
nathanfranklin 998e6bf
Refactor types related to feature icon
nathanfranklin e58e743
Add missing useDeleteFeature
nathanfranklin efa76b4
Add unit testing of getFeatureType
nathanfranklin ea5b2c9
Fix linting
nathanfranklin ab0e68e
Add AssetsPanel test
nathanfranklin a82eb91
Add FeatureFileTree unit test
nathanfranklin 29b4d75
Bump testing-library/react to get rid of act warnings
nathanfranklin b4e8c91
Removed unused
nathanfranklin 3d121ce
Add antd
nathanfranklin fba6261
Merge branch 'main' into task/WG-238-panel-assets-listing
nathanfranklin c3724f0
Switch to antd tree instead of react-table
nathanfranklin 6bbcf71
Merge branch 'main' into task/WG-238-panel-assets-listing
nathanfranklin 632d393
Fix accessibility-related warnings and fix unit tests
nathanfranklin d537889
Adjust width and overflow
nathanfranklin 6aa69ca
Fix height issues
nathanfranklin 29180da
Improve navbar
nathanfranklin 5c10f64
Remove deprecated typs/antd.
nathanfranklin 98b348a
Limit getting features to a single time
nathanfranklin bfd6a6f
Fix scaling of panel container
nathanfranklin f9bebe9
Rework tree to deal with virtual rendering issues
nathanfranklin 6df48bf
Make nav bar scrolling when y overflows
nathanfranklin b5c7176
Make contents of project view take up space below nav/control bar
nathanfranklin feae104
Removed unneeded config and styles
nathanfranklin cf6123b
Move hazmapper globals to hazmapper.css
nathanfranklin 7f79136
Add missing file
nathanfranklin 4246b60
Merge branch 'main' into task/WG-238-panel-assets-listing
nathanfranklin 64c9f48
Merge branch 'main' into task/WG-238-panel-assets-listing
nathanfranklin fdfa3dd
Update act import
nathanfranklin 9e3c9e0
Merge branch 'task/WG-238-panel-assets-listing' of github.com:TACC-Cl…
nathanfranklin 84f34a7
Fix bad merge
nathanfranklin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { act } from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import AssetsPanel from './AssetsPanel'; | ||
import { featureCollection } from '@hazmapper/__fixtures__/featuresFixture'; | ||
import { useFeatures } from '@hazmapper/hooks'; | ||
|
||
jest.mock('@hazmapper/hooks', () => ({ | ||
useFeatures: jest.fn(), | ||
})); | ||
|
||
// Mock FeatureFileTree component since it's a complex component and tested elswhere | ||
jest.mock('@hazmapper/components/FeatureFileTree', () => { | ||
return function MockFeatureFileTree() { | ||
return <div data-testid="feature-file-tree">FeatureFileTree Component</div>; | ||
}; | ||
}); | ||
|
||
describe('AssetsPanel', () => { | ||
const defaultProps = { | ||
featureCollection, | ||
projectId: 1, | ||
isPublic: false, | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
|
||
// Setup default mock implementation for useFeatures which is used for downloading geojson | ||
(useFeatures as jest.Mock).mockReturnValue({ | ||
isLoading: false, | ||
refetch: jest.fn(), | ||
}); | ||
}); | ||
|
||
it('renders all main components', () => { | ||
const { getByText } = render(<AssetsPanel {...defaultProps} />); | ||
|
||
// Check for the presence of buttons | ||
expect(getByText('Import from DesignSafe TODO/WG-387')).toBeDefined(); | ||
expect(getByText('Export to GeoJSON')).toBeDefined(); | ||
}); | ||
|
||
it('handles GeoJSON export correctly', async () => { | ||
// Mock the useFeatures hook for download scenario | ||
const mockRefetch = jest.fn(); | ||
(useFeatures as jest.Mock).mockReturnValue({ | ||
isLoading: false, | ||
refetch: mockRefetch, | ||
}); | ||
|
||
render(<AssetsPanel {...defaultProps} />); | ||
|
||
// Click export button | ||
await act(async () => { | ||
fireEvent.click(screen.getByText('Export to GeoJSON')); | ||
}); | ||
// Verify refetch was called | ||
expect(mockRefetch).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
react/src/components/FeatureFileTree/FeatureFileTree.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
.root { | ||
width: 100%; | ||
overflow: visible; | ||
|
||
:global(.ant-tree .ant-tree-treenode) { | ||
margin-bottom: 0px !important; /*needed to ensure calculation of row hight is right */ | ||
} | ||
|
||
/* Remove switcher space */ | ||
:global(.ant-tree-switcher) { | ||
display: none; | ||
} | ||
|
||
/* Hovering over non-selected items */ | ||
:global(.ant-tree-node-content-wrapper:hover:not(.ant-tree-node-selected)) { | ||
background-color: var(--global-color-accent--weak) !important; | ||
} | ||
|
||
/* Selected items (both normal and hover state) */ /*TODO*/ | ||
:global(.ant-tree-node-content-wrapper.ant-tree-node-selected) { | ||
background-color: var(--global-color-accent--weak) !important; | ||
} | ||
} | ||
|
||
.featureFileTree { | ||
height: 100%; | ||
|
||
:global(.ant-tree-node-content-wrapper) { | ||
/*https://tacc-main.atlassian.net/browse/WG-390*/ | ||
font-size: var(--global-font-family--small); | ||
font-family: var(--global-font-family--sans); | ||
max-width: var(--hazmapper-panel-width); /* fixed width of panel*/ | ||
padding-left: 5px; | ||
padding-right: 5px; | ||
overflow: hidden; | ||
} | ||
|
||
/* Adjust indent size */ | ||
:global(.ant-tree-indent-unit) { | ||
width: 8px; | ||
} | ||
} | ||
|
||
.treeNode { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
} | ||
|
||
.fileName { | ||
flex: 1; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
margin-left: 0.25em; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the name of the download reflect the project name so that the user can differentiate downloads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea 👍 Doing this in a follow on PR