Skip to content

Commit

Permalink
Testing Session UI/UX fixes (#333)
Browse files Browse the repository at this point in the history
* improve login callback layout

* WG-441: fix public link overflow

* WG-457: fix close icon; refactor questionnaire modal to antd

* WG-457: fix close icon; refactor delete map modal to antd

* WG-445: filter panel tooltip; refactor datepicker to antd

* no longer re-render map on filter change

* WG-443: add more bottom margin to show leaflet zoom when asset detail open

* fix tests

* remove react-datepicker
  • Loading branch information
rstijerina authored Feb 20, 2025
1 parent 7670789 commit f96b7aa
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 212 deletions.
50 changes: 7 additions & 43 deletions react/package-lock.json

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

1 change: 0 additions & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"leaflet": "^1.9.4",
"leaflet.markercluster": "^1.5.3",
"react": "^18.3.1",
"react-datepicker": "^7.6.0",
"react-dom": "^18.3.1",
"react-esri-leaflet": "^2.0.1",
"react-hook-form": "^7.54.2",
Expand Down
8 changes: 6 additions & 2 deletions react/src/components/DeleteMapModal/DeleteMapModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ describe('DeleteMapModal', () => {

it('should disable delete button for non-deletable projects', async () => {
await renderComponent(nonDeletableProjectMock);
const deleteButton = screen.getByText('Delete') as HTMLButtonElement;
const deleteButton = screen.getByTestId(
'delete-map-button'
) as HTMLButtonElement;
expect(deleteButton.disabled).toBe(true);
});

it('should enable delete button for deletable projects', async () => {
await renderComponent();
const deleteButton = screen.getByText('Delete') as HTMLButtonElement;
const deleteButton = screen.getByTestId(
'delete-map-button'
) as HTMLButtonElement;
expect(deleteButton.disabled).toBe(false);
});

Expand Down
85 changes: 49 additions & 36 deletions react/src/components/DeleteMapModal/DeleteMapModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, SectionMessage } from '@tacc/core-components';
import { Modal, Layout, Flex, Alert } from 'antd';
import { useNavigate } from 'react-router-dom';
import { Project } from '@hazmapper/types';
import { useDeleteProject } from '@hazmapper/hooks/projects/';
Expand All @@ -26,6 +25,9 @@ const DeleteMapModal = ({
isError,
isSuccess,
} = useDeleteProject();

const { Header } = Layout;

const handleClose = () => {
parentToggle();
};
Expand All @@ -46,45 +48,56 @@ const DeleteMapModal = ({
};

return (
<Modal size="lg" isOpen={isOpen} toggle={handleClose}>
<ModalHeader toggle={handleClose}>
Delete Map: {project?.name}{' '}
</ModalHeader>
<ModalBody>
<Modal
open={isOpen}
onCancel={handleClose}
title={<Header>Delete Map: {project?.name}</Header>}
onOk={handleDeleteProject}
okText="Delete"
cancelText={isSuccess ? 'Close' : 'Cancel'}
okButtonProps={{
loading: isDeletingProject,
disabled: isSuccess || !project?.deletable,
'data-testid': 'delete-map-button',
}}
>
<Flex vertical style={{ paddingBottom: 20 }}>
{project?.deletable ? (
<>
Are you sure you want to delete this map? All associated features,
metadata, and saved files will be deleted.
{project?.public && <b> Note that this is a public map. </b>}
<br />
<b>
<u>This cannot be undone.</u>
</b>
</>
<Alert
type="warning"
message={
<span>
Are you sure you want to delete this map? All associated
features, metadata, and saved files will be deleted.
<br />
<br />
{project?.public && (
<b>
{' '}
Note that this is a public map.
<br />
<br />
</b>
)}
<b>
<u>This cannot be undone.</u>
</b>
</span>
}
/>
) : (
'You dont have permission to delete this map.'
"You don't have permission to delete this map."
)}
</ModalBody>
<ModalFooter className="justify-content-start">
<Button size="short" type="secondary" onClick={handleClose}>
{isSuccess ? 'Close' : 'Cancel'}
</Button>
<Button
size="short"
type="primary"
attr="submit"
isLoading={isDeletingProject}
onClick={handleDeleteProject}
disabled={isSuccess || !project?.deletable}
>
Delete
</Button>

{isError && (
<SectionMessage type="error">
{'There was an error deleting your map.'}
</SectionMessage>
<Flex justify="center" align="center" style={{ paddingTop: 20 }}>
<Alert
type="error"
message="There was an error deleting your map."
/>
</Flex>
)}
</ModalFooter>
</Flex>
</Modal>
);
};
Expand Down
88 changes: 33 additions & 55 deletions react/src/components/FiltersPanel/Filter.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import React from 'react';
import styles from './Filters.module.css';
import DatePicker from 'react-datepicker';
import { Button, Flex } from 'antd';
import 'react-datepicker/dist/react-datepicker.css';
import { DatePicker } from 'antd';
import { Button, Flex, Tooltip } from 'antd';
import type { Dayjs } from 'dayjs';
import { QuestionCircleOutlined } from '@ant-design/icons';

interface FiltersProps {
selectedAssetTypes: string[];
onFiltersChange: (selectedAssetTypes: string[]) => void;
startDate: Date;
setStartDate: (date: Date) => void;
endDate: Date;
setEndDate: (date: Date) => void;
startDate: Dayjs;
setStartDate: (date: Dayjs) => void;
endDate: Dayjs;
setEndDate: (date: Dayjs) => void;
toggleDateFilter: boolean;
setToggleDateFilter: (toggleDateFilter: boolean) => void;
}

interface CustomInputProps {
value?: string;
onClick?: () => void;
}

export const assetTypeOptions = {
Image: 'Image',
Video: 'Video',
Expand Down Expand Up @@ -47,56 +43,38 @@ const Filters: React.FC<FiltersProps> = ({
}
};

const CustomInputWithTooltip = React.forwardRef<
HTMLInputElement,
CustomInputProps
>(({ value, onClick }, ref) => (
<div className={styles.customInputContainer}>
<input
className={styles.customInput}
value={value}
onClick={onClick}
ref={ref}
readOnly
/>
<span
className={styles.tooltip}
title="Choose the date(s) corresponding to when the data collection occurred in the field, not when the data was uploaded to the map project."
>
?
</span>
</div>
));

CustomInputWithTooltip.displayName = 'CustomInputWithTooltip';

return (
<Flex vertical className={styles.root}>
{toggleDateFilter ? (
<>
<Button onClick={() => setToggleDateFilter(false)}>
Disable Date Range Filter
</Button>
<h2>Date Range</h2>
<h5>Start Date</h5>
<DatePicker
selected={startDate}
onChange={(date: Date | null) => setStartDate(date as Date)}
selectsStart
startDate={startDate}
endDate={endDate}
customInput={<CustomInputWithTooltip />}
/>
<h5>End Date</h5>
<DatePicker
selected={endDate}
onChange={(date: Date | null) => setEndDate(date as Date)}
selectsEnd
startDate={startDate}
endDate={endDate}
minDate={startDate}
customInput={<CustomInputWithTooltip />}
/>
<Flex vertical>
<h2>
<Flex align="center" justify="space-between">
Date Range
<Tooltip
title="Choose the date(s) corresponding to when the data collection occurred in the field, not when the data was uploaded to the map project."
placement="right"
>
<Button type="link" icon={<QuestionCircleOutlined />} />
</Tooltip>
</Flex>
</h2>
<h5>Start Date</h5>
<DatePicker
defaultValue={startDate}
onChange={setStartDate}
allowClear={false}
/>
<h5>End Date</h5>
<DatePicker
defaultValue={endDate}
onChange={setEndDate}
allowClear={false}
/>
</Flex>
</>
) : (
<Button type="primary" onClick={() => setToggleDateFilter(true)}>
Expand Down
10 changes: 7 additions & 3 deletions react/src/components/ManageMapProjectPanel/PublicTabContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const PublicTabContent: React.FC<PublicTabProps> = ({
};
const [isModalOpen, setIsModalOpen] = useState(false);

const publicPath = window.location.href.replace(
const publicPath = `${window.location.origin}${window.location.pathname.replace(
'/project/',
'/project-public/'
);
)}`;

const { Paragraph } = Typography;
return (
Expand All @@ -47,7 +47,11 @@ const PublicTabContent: React.FC<PublicTabProps> = ({
>
<Button
type="link"
style={{ textWrap: 'wrap', textAlign: 'justify' }}
style={{
textWrap: 'wrap',
textAlign: 'justify',
display: 'contents',
}}
href={`${publicPath}`}
target="_blank"
rel="noreferrer"
Expand Down
Loading

0 comments on commit f96b7aa

Please sign in to comment.