Skip to content
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/WP-65-DropdownViewFullPath #866

Merged
merged 24 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
11f5121
task/WP-65-DropdownViewFullPath
Sep 29, 2023
d566301
task/WP-65-DropdownViewFullPath-v2
Oct 2, 2023
ad75f18
task/WP-65-DropdownViewFullPath-v3
Oct 2, 2023
123a766
task/WP-65-DropdownViewFullPath-v4
Oct 2, 2023
2d446c1
task/WP-65-DropdownViewFullPath-v5
Oct 2, 2023
3c0ca4a
Merge branch 'main' into task/WP-65-DropdownViewFullPath
rstijerina Oct 3, 2023
c531d37
task/WP-65-DropdownViewFullPathv6
Oct 3, 2023
f9605ac
Merge branch 'task/WP-65-DropdownViewFullPath' of github.com:TACC/Cor…
Oct 3, 2023
1fb6ab8
Merge branch 'main' into task/WP-65-DropdownViewFullPath
wesleyboar Oct 4, 2023
d20f4cb
task/WP-65-DropdownViewFullPath-v7
Oct 4, 2023
a72b22c
task/WP-65-DropdownViewFullPath - dropdown-menu css component (#875)
wesleyboar Oct 4, 2023
41b0f80
task/WP-65-DropdownViewFullPath-v8
Oct 5, 2023
00f4c5c
task/WP-65-DropdownViewFullPath-v9
Oct 5, 2023
8d3b8ab
task/WP-65-DropdownViewFullPath-v10
Oct 5, 2023
e4b6329
Merge branch 'main' into task/WP-65-DropdownViewFullPath
tjgrafft Oct 10, 2023
00a1ce0
task/WP-65-DropdownViewFullPath-v11
Oct 10, 2023
488f169
task/WP-65-DropdownViewFullPath-v12
Oct 10, 2023
78e0cc4
Merge branch 'main' into task/WP-65-DropdownViewFullPath
tjgrafft Oct 20, 2023
2ea3b0f
task/WP-65-DropdownViewFullPath-v13
Oct 24, 2023
c41e082
task/WP-65-DropdownViewFullPath-v14
Oct 24, 2023
0f002c1
task/WP-65-DropdownViewFullPath-v15
Oct 25, 2023
1e5d30c
Merge branch 'main' into task/WP-65-DropdownViewFullPath
rstijerina Oct 27, 2023
d72ae52
Update client/src/components/DataFiles/DataFilesModals/DataFilesShowP…
chandra-tacc Oct 27, 2023
d01917f
prettier fix
chandra-tacc Oct 27, 2023
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
wesleyboar marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import React from 'react';
import { useState } from 'react';
import { useDispatch } from 'react-redux';
import { Button } from '_common';
import {
DropdownToggle,
DropdownMenu,
DropdownItem,
ButtonDropdown,
} from 'reactstrap';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { v4 as uuidv4 } from 'uuid';
import './DataFilesBreadcrumbs.scss';
import '../DataFilesModals/DataFilesShowPathModal.jsx';
import {
useSystemDisplayName,
useFileListing,
Expand Down Expand Up @@ -35,7 +45,7 @@ const BreadcrumbLink = ({
case 'FilesListing':
return (
<Link
className="breadcrumb-link"
className="breadcrumb-link truncate"
to={`${basePath}/${api}/${scheme}/${system}${path}/`}
>
{children}
Expand All @@ -46,7 +56,7 @@ const BreadcrumbLink = ({
return (
<span>
<a
className="breadcrumb-link"
className="breadcrumb-link truncate"
href={`/workbench/data/${api}/${scheme}/${system}${path}/`}
onClick={onClick}
>
Expand Down Expand Up @@ -120,6 +130,45 @@ const DataFilesBreadcrumbs = ({
const paths = [];
const pathComps = [];

const [dropdownOpen, setDropdownOpen] = useState(false);
const toggleDropdown = () => setDropdownOpen(!dropdownOpen);

const handleNavigation = (targetPath) => {
const basePath = isPublic ? '/public-data' : '/workbench/data';
let url;

if (scheme === 'projects' && !targetPath) {
url = `${basePath}/${api}/projects/`;
} else if (api === 'googledrive' && !targetPath) {
url = `${basePath}/${api}/${scheme}/${system}/`;
} else {
url = `${basePath}/${api}/${scheme}/${system}${targetPath}/`;
}

if (!url) {
console.error('URL is not defined');
return;
}

return url;
};

const dispatch = useDispatch();

const fileData = {
system: system,
path: path,
};

const openFullPathModal = (e) => {
e.stopPropagation();
e.preventDefault();
dispatch({
type: 'DATA_FILES_TOGGLE_MODAL',
payload: { operation: 'showpath', props: { file: fileData } },
});
};
rstijerina marked this conversation as resolved.
Show resolved Hide resolved

const { fetchSelectedSystem } = useSystems();

const selectedSystem = fetchSelectedSystem({ scheme, system, path });
Expand Down Expand Up @@ -155,52 +204,88 @@ const DataFilesBreadcrumbs = ({
}
}, '');

const lastTwoPaths = paths.slice(-1);
const lastTwoPathComps = pathComps.slice(-1);
const reversedPath = paths.reverse();

return (
<div className={`breadcrumbs ${className}`}>
{scheme === 'projects' && (
<>
<RootProjectsLink
api={api}
section={section}
operation={operation}
label="Shared Workspaces"
/>{' '}
{system && `/ `}
</>
Comment on lines -159 to -169
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we had the "Shared Workspaces" root in the breadcrumb path. Do we want to include that with this feature as well?
Screenshot 2023-10-18 at 12 16 08 PM

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SharedProjects What do you think of this? I'll fix the folder icon alignment, but do you like this idea for Shared Workspaces?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

<div className="breadcrumb-container">
<div id="path-button-wrapper">
<ButtonDropdown
isOpen={dropdownOpen}
toggle={toggleDropdown}
className="go-to-button-dropdown"
>
<DropdownToggle tag={Button}>Go to ...</DropdownToggle>
<DropdownMenu>
{reversedPath.slice(1, reversedPath.length).map((path, index) => {
const folderName = path.split('/').pop();
return (
<>
<Link key={index} to={handleNavigation(path)}>
<DropdownItem>
<i className="icon-folder" />
{folderName.length > 20
? folderName.substring(0, 20)
: folderName}
</DropdownItem>
</Link>
</>
);
})}
<DropdownItem divider />
<Link to={handleNavigation(homeDir)}>
<DropdownItem>
<i className="icon-my-data" />
<span className="multiline-menu-item-wrapper">
{systemName || 'Shared Workspaces'}
<small>Root</small>
</span>
rstijerina marked this conversation as resolved.
Show resolved Hide resolved
</DropdownItem>
</Link>
</DropdownMenu>
</ButtonDropdown>
</div>
<div className={`breadcrumbs ${className}`}>
{lastTwoPathComps.length === 0 ? (
<span className="system-name truncate">
{systemName || 'Shared Workspaces'}
</span>
) : (
lastTwoPathComps.map((pathComp, i) => {
if (i === lastTwoPaths.length - 1) {
return (
<span key={uuidv4()} className="truncate">
{pathComp}
</span>
);
}
rstijerina marked this conversation as resolved.
Show resolved Hide resolved
return (
<React.Fragment key={uuidv4()}>
<span className="vertical-align-separator">/</span>
<BreadcrumbLink
api={api}
scheme={scheme}
system={system}
path={lastTwoPaths[i]}
section={section}
>
<>{pathComp}</>
rstijerina marked this conversation as resolved.
Show resolved Hide resolved
</BreadcrumbLink>
</React.Fragment>
);
})
)}
</div>
{systemName && api !== 'googledrive' ? (
rstijerina marked this conversation as resolved.
Show resolved Hide resolved
<Button type="link" onClick={openFullPathModal}>
View Full Path
</Button>
) : (
<Button type="link" disabled={true} onClick={openFullPathModal}>
View Full Path
</Button>
rstijerina marked this conversation as resolved.
Show resolved Hide resolved
)}
<BreadcrumbLink
api={api}
scheme={scheme}
system={system}
path={startingPath}
section={section}
isPublic={isPublic}
>
<>{systemName}</>
</BreadcrumbLink>
{pathComps.map((pathComp, i) => {
if (i < paths.length - 2) {
return ' /... ';
}
if (i === paths.length - 1) {
return <span key={uuidv4()}> / {pathComp}</span>;
}
return (
<React.Fragment key={uuidv4()}>
{' '}
/{' '}
<BreadcrumbLink
api={api}
scheme={scheme}
system={system}
path={paths[i]}
section={section}
>
<>{pathComp}</>
</BreadcrumbLink>
</React.Fragment>
);
})}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/* ... */
@include truncate-with-ellipsis;
margin-right: 2em;
display: flex;
align-items: center;
}
.breadcrumb-link,
.breadcrumb-link:hover {
Expand Down Expand Up @@ -34,3 +36,84 @@
max-width: 700px;
}
}

#path-button-wrapper {
padding-left: var(--horizontal-buffer);
}

/* HACK: Quick solution to prevent styles from cascading into header dropdown */
.go-to-button-dropdown {
.dropdown-menu {
wesleyboar marked this conversation as resolved.
Show resolved Hide resolved
opacity: 1 !important;
border-color: var(--global-color-accent--normal);
border-radius: 0;
margin-top: 34px;
padding: 0;
width: 200px;
vertical-align: top;
pointer-events: auto !important;
}
.dropdown-menu::before,
.dropdown-menu::after {
position: absolute;
top: -10px;
left: 23px;
border-right: 10px solid transparent;
border-bottom: 10px solid var(--global-color-accent--normal);
border-left: 10px solid transparent;
content: '';
}
.dropdown-menu::after {
top: -9px;
left: 23px;
border-bottom: 10px solid #ffffff;
}

.dropdown-item {
display: inline-block;
padding: 10px 6px;
color: var(--global-color-primary--x-dark);
font-size: 14px;
i {
padding-right: 19px;
font-size: 20px;
vertical-align: top;
}
&:hover {
color: var(--global-color-primary--x-dark);
}
}
.dropdown-item:focus,
.dropdown-item:hover {
background-color: var(--global-color-accent--weak);
}
}

.breadcrumb-container {
display: flex;
align-items: center;
}

.truncate {
display: inline-block;
max-width: 600px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding-left: 20px;
}

.multiline-menu-item-wrapper {
display: inline-block;
padding-left: 5px;
line-height: 1.1em;
small {
display: block;
color: var(--global-color-primary--x-dark);
}
}

.breadcrumbs .vertical-align-separator {
margin-right: 2px;
margin-left: 10px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('DataFilesBreadcrumbs', () => {
systems: systemsFixture,
});
const history = createMemoryHistory();
const { getByText, debug } = renderComponent(
const { getAllByText, debug } = renderComponent(
<DataFilesBreadcrumbs
api="tapis"
scheme="private"
Expand All @@ -60,36 +60,7 @@ describe('DataFilesBreadcrumbs', () => {
createMemoryHistory()
);

expect(getByText('Frontera')).toBeDefined();
expect(getByText('Frontera').closest('a').getAttribute('href')).toEqual(
'/workbench/data/tapis/private/frontera.home.username/'
);
});

it('render breadcrumbs with initial empty systems', () => {
const store = mockStore({
systems: initialSystemState,
projects: projectsFixture,
});
const history = createMemoryHistory();
const { getByText, debug } = renderComponent(
<DataFilesBreadcrumbs
api="tapis"
scheme="private"
system="frontera.home.username"
path="/path/to/the/files"
section="FilesListing"
/>,
store,
createMemoryHistory()
);

expect(getByText(/Frontera/)).toBeDefined();
expect(
getByText(/Frontera/)
.closest('a')
.getAttribute('href')
).toEqual('/workbench/data/tapis/private/frontera.home.username/');
expect(getAllByText('Frontera')).toBeDefined();
});

it('render breadcrumbs for projects', () => {
Expand Down
Loading