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/WG-232-React-Listing-UI #268

Merged
merged 24 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
82ac31a
task/WG-232-React-Listing-UI-clean
sophia-massie Oct 3, 2024
8304f93
- Linting
sophia-massie Oct 3, 2024
b5c2a4e
- Adds better response and error handling.
sophia-massie Oct 3, 2024
e5a4817
- Linting
sophia-massie Oct 3, 2024
0ff0f14
- Addresses Type 'ReactNode' is not assignable to
sophia-massie Oct 3, 2024
d55959d
- Linting
sophia-massie Oct 3, 2024
dfa4af2
- Address changes - removed fontawesome,
sophia-massie Oct 28, 2024
50d748f
Merge branch 'main' into task/WG-232-React-Listing-UI-clean
sophia-massie Oct 30, 2024
555c8ae
- Addresses changes
sophia-massie Oct 30, 2024
16e3a3e
- Linting
sophia-massie Oct 30, 2024
ee9fc43
- Undoing unnecessary diff
sophia-massie Oct 30, 2024
99821f5
- Adds hover function
sophia-massie Oct 30, 2024
9a6dd50
- Fixes hover change to reduce diff
sophia-massie Oct 30, 2024
08c7f56
Merge branch 'main' into task/WG-232-React-Listing-UI-clean
sophia-massie Oct 30, 2024
3072b0c
- Adds placeholder for empty DS projects
sophia-massie Oct 30, 2024
dc21d68
Merge branch 'task/WG-232-React-Listing-UI-clean' of github.com:TACC-…
sophia-massie Oct 30, 2024
d9b2607
- Removes issue with width
sophia-massie Oct 30, 2024
bee9325
- Linting
sophia-massie Oct 30, 2024
9b7e5c4
Merge branch 'main' into task/WG-232-React-Listing-UI-clean
sophia-massie Nov 9, 2024
7a9db80
Merge branch 'main' into task/WG-232-React-Listing-UI-clean
sophia-massie Nov 9, 2024
ec0f60e
- Casts error message to avoid type issues
sophia-massie Nov 9, 2024
20a0b54
Merge branch 'main' into task/WG-232-React-Listing-UI-clean
sophia-massie Nov 14, 2024
fab0b14
- Ensures content fits within column containers
sophia-massie Nov 14, 2024
c90c18d
- Linting
sophia-massie Nov 14, 2024
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
9 changes: 9 additions & 0 deletions react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.0",
"@changey/react-leaflet-markercluster": "^4.0.0-rc1",
"@fortawesome/fontawesome-free": "^6.6.0",
sophia-massie marked this conversation as resolved.
Show resolved Hide resolved
"@reduxjs/toolkit": "^1.8.4",
"@tacc/core-styles": "^2.24.1",
"@testing-library/react": "^13.4.0",
Expand Down
47 changes: 47 additions & 0 deletions react/src/components/Projects/ProjectListing.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.root {
display: flex;
flex-direction: column;
width: 100%;
}
.projectList {
height: 270px;
border-collapse: collapse;
align-self: center;
overflow-y: scroll;
margin-top: 40px;
margin-bottom: 40px;
}
.projectHeader,
.projectHeader th {
background: #d0d0d0;
position: sticky;
top: 0;
z-index: 1;
}

.projectListItemButton {
cursor: pointer;
color: initial;
margin-right: 10px;
}

.projectListItemButton:hover {
color: #666;
}

.mapColumn {
width: 30%;
}
.projectColumn {
width: 60%;
}
.buttonColumn {
white-space: nowrap;
}

.projectName {
max-width: fit-content;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
118 changes: 80 additions & 38 deletions react/src/components/Projects/ProjectListing.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { useState } from 'react';
import { useProjectsWithDesignSafeInformation } from '../../hooks';
import { Button, LoadingSpinner, Icon } from '../../core-components';
import styles from './ProjectListing.module.css';
import { EmptyTablePlaceholder } from '../utils';
import CreateMapModal from '../CreateMapModal/CreateMapModal';
import { useNavigate } from 'react-router-dom';

export const ProjectListing: React.FC = () => {
const ProjectListing: React.FC = () => {
const [isModalOpen, setIsModalOpen] = useState(false);
const navigate = useNavigate();

Expand All @@ -22,45 +24,85 @@ export const ProjectListing: React.FC = () => {
return <LoadingSpinner />;
}

if (isError) {
return <h4>Unable to retrieve projects</h4>;
}

return (
<>
<table>
<thead>
<tr>
<th>Map</th>
<th>Project</th>
<th>
<CreateMapModal isOpen={isModalOpen} toggle={toggleModal} />
<Button onClick={toggleModal} size="small">
Create a New Map
</Button>
</th>
</tr>
</thead>
<tbody>
{data?.map((proj) => (
<tr key={proj.id} onClick={() => navigateToProject(proj.uuid)}>
<td>{proj.name}</td>
<td>
{proj.ds_project?.value.projectId}{' '}
{proj.ds_project?.value.title}
</td>
<td>
<Button>
<Icon name="edit-document"></Icon>
<div className={styles.root}>
<div className={styles.projectList}>
<table>
sophia-massie marked this conversation as resolved.
Show resolved Hide resolved
<thead className={styles.projectHeader}>
<tr>
sophia-massie marked this conversation as resolved.
Show resolved Hide resolved
<th className={styles.mapColumn}>Map</th>
<th className={styles.projectColumn}>Project</th>
<th className={styles.buttonColumn}>
<CreateMapModal isOpen={isModalOpen} toggle={toggleModal} />
<Button
onClick={toggleModal}
type="link"
className={styles.projectListItemButton}
>
<Icon name="add" />
sophia-massie marked this conversation as resolved.
Show resolved Hide resolved
Create a New Map
</Button>
<Button>
<Icon name="trash"></Icon>
</Button>
</td>
</th>
</tr>
))}
</tbody>
</table>
</>
</thead>
<tbody>
{isError && (
<tr>
<td colSpan={3}>
<EmptyTablePlaceholder type="error">
There was an error gathering your maps and projects. {''}
<a
href="https://www.designsafe-ci.org/help/new-ticket/"
target="_blank"
rel="noreferrer"
>
Click here to submit a ticket on DesignSafe.
</a>
</EmptyTablePlaceholder>
</td>
</tr>
)}
sophia-massie marked this conversation as resolved.
Show resolved Hide resolved
{data && data.length > 0 ? (
data?.map((proj) => (
<tr key={proj.id} onClick={() => navigateToProject(proj.uuid)}>
<td className={styles.projectName}>{proj.name}</td>
<td>
{proj.ds_project?.value.projectId}
{' - '}
{proj.ds_project?.value.title}
sophia-massie marked this conversation as resolved.
Show resolved Hide resolved
</td>
<td>
<Button
type="link"
className={styles.projectListItemButton}
>
<Icon name="edit-document" />
</Button>
<Button
type="link"
className={styles.projectListItemButton}
>
<Icon name="trash" />
</Button>
</td>
</tr>
))
) : (
<tr>
<td colSpan={3}>
<EmptyTablePlaceholder type="info">
sophia-massie marked this conversation as resolved.
Show resolved Hide resolved
No projects or maps found.
sophia-massie marked this conversation as resolved.
Show resolved Hide resolved
<br />
Click Create New Map above to get started.
</EmptyTablePlaceholder>
</td>
</tr>
)}
</tbody>
</table>
</div>
</div>
);
};

export default ProjectListing;
2 changes: 1 addition & 1 deletion react/src/components/Projects/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { ProjectListing } from './ProjectListing';
export { default } from './ProjectListing';
12 changes: 12 additions & 0 deletions react/src/components/utils/EmptyTablePlaceholder.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Table Placeholder */
.empty {
display: flex;
align-items: center;
justify-content: center;
}

.empty > :first-child {
margin-top: 10px;
padding: 50px;
border: 1px solid var(--global-color-primary--dark);
}
25 changes: 25 additions & 0 deletions react/src/components/utils/EmptyTablePlaceholder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { SectionMessage } from '../../core-components';
sophia-massie marked this conversation as resolved.
Show resolved Hide resolved
import styles from './EmptyTablePlaceholder.module.css';
import React from 'react';

interface EmptyPlaceholderProps {
children?: React.ReactNode;
type: 'error' | 'warning' | 'info' | 'success';
}

export const EmptyTablePlaceholder: React.FC<EmptyPlaceholderProps> = ({
children,
type,
}) => {
return (
<div className={styles['empty']}>
{children ? (
<SectionMessage type={type}>{children}</SectionMessage>
) : (
<SectionMessage type={type}>No data available.</SectionMessage>
)}
</div>
);
};

export default EmptyTablePlaceholder;
1 change: 1 addition & 0 deletions react/src/components/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as EmptyTablePlaceholder } from './EmptyTablePlaceholder';
21 changes: 19 additions & 2 deletions react/src/hazmapper.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import url('@tacc/core-styles/dist/core-styles.base.css');
@import url('@tacc/core-styles/dist/core-styles.portal.css');
@import 'leaflet/dist/leaflet.css';
@import '@fortawesome/fontawesome-free/css/all.css';
@import url('https://fonts.googleapis.com/css?family=Raleway');
@import url('https://unpkg.com/[email protected]/dist/mapillary.min.css');

/* for hazmapper specific overwrites of base and portal styles" like,

Expand All @@ -8,3 +10,18 @@
}

*/

/* CSS module styles taken from Angular styles.styl */
:root {
sophia-massie marked this conversation as resolved.
Show resolved Hide resolved
--global-font-family: 'Raleway', san-serif;
}
html,
body {
height: 100%;
font-family: var(--global-font-family);
}
table,
form,
button {
font-family: inherit;
}
4 changes: 2 additions & 2 deletions react/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* prettier-ignore */
@import url('https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css') layer(foundation);

@import url('@tacc/core-styles/dist/core-styles.base.css'); /* layer(base);*/
@import url('@tacc/core-styles/dist/core-styles.portal.css'); /* layer(base);*/
@import url('@tacc/core-styles/dist/core-styles.base.css') layer(base);
@import url('@tacc/core-styles/dist/core-styles.portal.css') layer(base);

@import url('./hazmapper.css') layer(project);
3 changes: 1 addition & 2 deletions react/src/pages/MainMenu/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
} from '../../core-components';
import useAuthenticatedUser from '../../hooks/user/useAuthenticatedUser';
import { SystemSelect } from '../../components/Systems';
import { ProjectListing } from '../../components/Projects/ProjectListing';

import ProjectListing from '../../components/Projects';
function MainMenu() {
const {
data: userData,
Expand Down
Loading