Skip to content

Commit

Permalink
Merge branch 'task/WP-724' of github.com:TACC/Core-Portal into task/W…
Browse files Browse the repository at this point in the history
…P-724
  • Loading branch information
Jeff McMillen authored and Jeff McMillen committed Dec 6, 2024
2 parents b7f8389 + d4ad0b1 commit f5e6bb4
Show file tree
Hide file tree
Showing 21 changed files with 642 additions and 159 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.10.1]

### Fixed

- WP-778: Fix infinite loop for state update in useEffect (#1019)
- Quick: CSS regression fixes- testing session (#1018)

## [3.10.0]

### Added
Expand Down Expand Up @@ -1134,7 +1141,8 @@ WP-306: Fix target path regression (#871)
## [1.0.0] - 2020-02-28
v1.0.0 Production release as of Feb 28, 2020.

[unreleased]: https://github.com/TACC/Core-Portal/compare/v3.10.0...HEAD
[unreleased]: https://github.com/TACC/Core-Portal/compare/v3.10.1...HEAD
[3.10.1]: https://github.com/TACC/Core-Portal/releases/tag/v3.10.1
[3.10.0]: https://github.com/TACC/Core-Portal/releases/tag/v3.10.0
[3.9.0]: https://github.com/TACC/Core-Portal/releases/tag/v3.9.0
[3.8.2]: https://github.com/TACC/Core-Portal/releases/tag/v3.8.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,102 @@ describe('DataFilesListing - Section Name Determination', () => {
).toBeInTheDocument();
});
});
describe('DataFilesListing - showViewPath', () => {
afterEach(() => {
vi.restoreAllMocks();
});
it('renders the "Path" column when showViewPath is true', () => {
const testfile = {
system: 'test.system',
path: '/path/to/file',
name: 'testfile',
format: 'file',
length: 4096,
lastModified: '2019-06-17T15:49:53-05:00',
_links: { self: { href: 'href.test' } },
};
const history = createMemoryHistory();
history.push('/workbench/data/tapis/private/test.system/');
const store = mockStore({
...initialMockState,
files: {
...initialMockState.files,
listing: { FilesListing: [testfile] },
},
workbench: {
config: {
viewPath: true,
},
},
});
// Spy on useMemo to capture the cells array
const useMemoSpy = vi
.spyOn(React, 'useMemo')
.mockImplementation((fn) => fn());
const { getByText } = renderComponent(
<DataFilesListing
api="tapis"
scheme="private"
system="test.system"
resultCount={4}
path="/"
/>,
store,
history
);
// Path cell is added
expect(getByText('Path')).toBeDefined();
// Check the length of the cells array
const cellsArray = useMemoSpy.mock.results.find((result) =>
Array.isArray(result.value)
).value;
expect(cellsArray.length).toBe(6);
});
it('does not render the "Path" column when showViewPath is false', () => {
const testfile = {
system: 'test.system',
path: '/path/to/file',
name: 'testfile',
format: 'file',
length: 4096,
lastModified: '2019-06-17T15:49:53-05:00',
_links: { self: { href: 'href.test' } },
};
const history = createMemoryHistory();
history.push('/workbench/data/tapis/private/test.system/');
const store = mockStore({
...initialMockState,
files: {
...initialMockState.files,
listing: { FilesListing: [testfile] },
},
workbench: {
config: {
viewPath: false,
},
},
});
// Spy on useMemo to capture the cells array
const useMemoSpy = vi
.spyOn(React, 'useMemo')
.mockImplementation((fn) => fn());
const { queryByText } = renderComponent(
<DataFilesListing
api="tapis"
scheme="private"
system="test.system"
resultCount={4}
path="/"
/>,
store,
history
);
// Path should not exist as a new cell
expect(queryByText('Path')).toBeNull();
// Check the length of the cells array
const cellsArray = useMemoSpy.mock.results.find((result) =>
Array.isArray(result.value)
).value;
expect(cellsArray.length).toBe(5);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,7 @@ describe('DataFilesCopyModal', () => {
const submitButton = getByText('Create Folder');
fireEvent.click(submitButton);
});

expect(store.getActions()).toEqual([
{
type: 'DATA_FILES_MKDIR',
payload: {
api: 'tapis',
scheme: 'private',
system: 'test.system',
path: '/',
dirname: 'abc123',
reloadCallback: expect.any(Function),
},
},
]);
// TODO: New test needed for react redux call for mkdir
});

it('Error message on invalid input', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
}

.member-search {
margin-bottom: 1em;
font-size: 12px !important;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('DataFilesSidebar', () => {
).toEqual(
'/workbench/data/tapis/private/longhorn.home.username/home/username/'
);
expect(queryByText(/My Data \(Work\)/)).toBeNull();
expect(queryByText(/My Data \(Work\)/)).toBeDefined();
});

it('disables creating new shared workspaces in read only shared workspaces', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('DataFilesSystemSelector', () => {
store,
history
);
expect(queryByText(/My Data \(Work\)/)).toBeNull();
expect(queryByText(/My Data \(Work\)/)).toBeDefined();
expect(queryByText(/My Data \(Frontera\)/)).toBeDefined();
expect(queryByText(/My Data \(Longhorn\)/)).toBeDefined();
expect(queryByText(/Google Drive/)).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* TODOv3 update this fixture https://jira.tacc.utexas.edu/browse/WP-68*/

// Updated fixture changes from endpoint https://cep.test/api/datafiles/systems/list/
// Removed from configuration: hidden, keyservice
// Removed from storage and defintions array: errorMessage, loading
const systemsFixture = {
storage: {
configuration: [
Expand All @@ -9,10 +11,8 @@ const systemsFixture = {
scheme: 'private',
api: 'tapis',
icon: null,
hidden: true,
homeDir: '/home/username',
default: true,
keyservice: true,
},
{
name: 'My Data (Frontera)',
Expand Down Expand Up @@ -65,13 +65,30 @@ const systemsFixture = {
integration: 'portal.apps.googledrive_integration',
},
],
error: false,
errorMessage: null,
loading: false,
/*
* The following needs to be mirrored for the storage and definitions
These are included in the datafiles reducers but pass tests without these
This means that tests need to be more comprehensive to catch this or removed
Definitions that use variables other than list are used in:
- DataFilesTable.jsx:45 for error
state.systems.definitions.* is not called for anything else other than error
These would need to be removed then
- errorMessage
- loading
*/

//error: false,
//errorMessage: null,
//loading: false,
defaultHost: 'frontera.tacc.utexas.edu',
defaultSystem: 'frontera',
},
// This definitions is required for the tests, some can be removed. Referencing datafiles.reducers.js
definitions: {
// For DataFilesTable and DataFilesShowPathModal it requires the id from this list
list: [
{
id: 'frontera.home.username',
Expand All @@ -90,9 +107,9 @@ const systemsFixture = {
effectiveUserId: 'username',
},
],
error: false,
errorMessage: null,
loading: false,
error: false, // Commenting this out results in an error
//errorMessage: null,
//loading: false,
},
};

Expand Down
3 changes: 2 additions & 1 deletion client/src/components/DataFiles/tests/DataFiles.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('DataFiles', () => {
//);
expect(getAllByText(/My Data \(Frontera\)/)).toBeDefined();
expect(getByText(/My Data \(Longhorn\)/)).toBeDefined();
expect(queryByText(/My Data \(Work\)/)).toBeNull();
expect(queryByText(/My Data \(Work\)/)).toBeDefined(); // Changed to defined, hidden attribute removed and would be defined by default
});

it('should not render Data Files with no systems', () => {
Expand All @@ -68,6 +68,7 @@ describe('DataFiles', () => {
},
},
systems: {
// TODO: Remove rest of unused variables
storage: {
configuration: [
{
Expand Down
1 change: 1 addition & 0 deletions client/src/components/PublicData/PublicData.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/* FAQ: Public pages, like `PublicData` and `SiteSearch`, have no sidebar */
/* padding-left: 1.5em; /* ~24px (20px * design * 1.2 design-to-app ratio) */
}

34 changes: 0 additions & 34 deletions client/src/hooks/datafiles/mutations/useMkdir.js

This file was deleted.

89 changes: 89 additions & 0 deletions client/src/hooks/datafiles/mutations/useMkdir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { useSelector, useDispatch, shallowEqual } from 'react-redux';
import { useMutation } from '@tanstack/react-query';
import { apiClient } from 'utils/apiClient';

export async function mkdirUtil({
api,
scheme,
system,
path,
dirname,
}: {
api: string;
scheme: string;
system: string;
path: string;
dirname: string;
}): Promise<{ name: string; path: string }> {
let apiPath = !path || path[0] === '/' ? path : `/${path}`;
if (apiPath === '/') {
apiPath = '';
}
let url = `/api/datafiles/${api}/mkdir/${scheme}/${system}/${apiPath}/`;
url = url.replace(/\/{2,}/g, '/');
const response = await apiClient.put<{ name: string; path: string }>(url, {
dir_name: dirname,
});

return response.data;
}

function useMkdir() {
const dispatch = useDispatch();
const status = useSelector(
(state: any) => state.files.operationStatus.mkdir,
shallowEqual
);

const setStatus = (newStatus: any) => {
dispatch({
type: 'DATA_FILES_SET_OPERATION_STATUS',
payload: { status: newStatus, operation: 'mkdir' },
});
};

const { mutate } = useMutation({ mutationFn: mkdirUtil });

const mkdir = ({
api,
scheme,
system,
path,
dirname,
reloadCallback,
}: {
api: string;
scheme: string;
system: string;
path: string;
dirname: string;
reloadCallback: any;
}) => {
mutate(
{
api,
scheme,
system,
path,
dirname,
},
{
onSuccess: () => {
dispatch({
type: 'DATA_FILES_TOGGLE_MODAL',
payload: {
operation: 'mkdir',
props: {},
},
});
reloadCallback();
},
onError: () => {},
}
);
};

return { mkdir, status, setStatus };
}

export default useMkdir;
Loading

0 comments on commit f5e6bb4

Please sign in to comment.