Skip to content

Commit

Permalink
Merge pull request #388 from Smithsonian/develop
Browse files Browse the repository at this point in the history
v0.9.8
  • Loading branch information
jahjedtieson authored Mar 29, 2022
2 parents 69ebcca + b5ef219 commit 78a6fcd
Show file tree
Hide file tree
Showing 88 changed files with 1,971 additions and 1,156 deletions.
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dpo-packrat/client",
"version": "0.9.7",
"version": "0.9.8",
"private": true,
"license": "Apache-2.0",
"description": "Client for Packrat",
Expand Down Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@apollo/client": "3.1.5",
"@date-io/date-fns": "1.3.13",
"@dpo-packrat/common": "0.9.7",
"@dpo-packrat/common": "0.9.8",
"@material-ui/core": "4.11.0",
"@material-ui/data-grid": "4.0.0-alpha.33",
"@material-ui/icons": "4.9.1",
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/controls/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ interface InputFieldProps extends ViewableProps {
padding?: string;
inputHeight?: string;
gridGap?: string;
containerStyle?: React.CSSProperties;
}

function InputField(props: InputFieldProps): React.ReactElement {
const { label, name, value, onChange, type, required = false, viewMode = false, disabled = false, valueLeftAligned = false, gridLabel, gridValue, padding, gridGap } = props;
const { label, name, value, onChange, type, required = false, viewMode = false, disabled = false, valueLeftAligned = false, gridLabel, gridValue, padding, gridGap, containerStyle } = props;
const classes = useStyles(props);

const rowFieldProps = { alignItems: 'center', justifyContent: 'space-between', style: { borderRadius: 0 } };
const rowFieldProps = { alignItems: 'center', justifyContent: 'space-between', style: { borderRadius: 0, ...containerStyle } };

return (
<FieldType
Expand Down
10 changes: 3 additions & 7 deletions client/src/components/shared/DataGridWithPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ const useStyles = makeStyles(({ palette, typography }) => ({
flexDirection: 'column',
overflow: 'auto',
maxHeight: 'calc(100vh - 60px)',
paddingLeft: '1%',
width: '1200px',
margin: '0 auto'
width: '1200px'
},
DataGridContainer: {
marginTop: '2%',
marginTop: '20px',
width: '1000px',
padding: '20px',
height: 'calc(100% - 120px)',
Expand Down Expand Up @@ -49,11 +47,9 @@ const useStyles = makeStyles(({ palette, typography }) => ({
searchFilterContainer: {
display: 'flex',
justifyContent: 'space-around',
height: '70px',
width: 'fit-content',
backgroundColor: '#FFFCD1',
paddingLeft: '20px',
paddingRight: '20px'
padding: '15px 20px'
},
searchFilterSettingsContainer: {
display: 'flex',
Expand Down
5 changes: 5 additions & 0 deletions client/src/constants/helperfunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ export const attachSystemObjectUploadRedirect = (idSystemObject: number, ObjectT

export const truncateWithEllipses = (text: string, max: number) => text.slice(0, max - 1) + (text.length > max ? ' ...' : '');

export const truncateMiddleWithEllipses = (text: string, firstHalf: number, secondHalf: number) => {
if (firstHalf + secondHalf >= text.length) return text;
return text.slice(0, firstHalf) + '...' + text.slice(-secondHalf);
};

export function getDownloadSiteMapXMLLink(serverEndPoint: string | undefined): string {
return `${serverEndPoint}/download/sitemap.xml`;
}
2 changes: 1 addition & 1 deletion client/src/pages/Admin/components/AddProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function AddProjectForm(): React.ReactElement {
Description: description
}
},
refetchQueries: ['getProjectList', 'getIngestionProjectsForSubjects']
refetchQueries: ['getProjectList']
});
if (data?.createProject) {
toast.success('Project created successfully');
Expand Down
6 changes: 2 additions & 4 deletions client/src/pages/Admin/components/AdminProjectsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Clear from '@material-ui/icons/Clear';

const useStyles = makeStyles({
AdminListContainer: {
marginTop: '2%',
marginTop: '20px',
width: '450px',
padding: '20px',
height: 'calc(100% - 120px)',
Expand Down Expand Up @@ -71,11 +71,9 @@ const useStyles = makeStyles({
AdminSearchFilterContainer: {
display: 'flex',
justifyContent: 'space-around',
height: '70px',
width: '600px',
backgroundColor: '#FFFCD1',
paddingLeft: '20px',
paddingRight: '20px'
padding: '15px 20px'
},
AdminUsersSearchFilterSettingsContainer: {
display: 'flex',
Expand Down
6 changes: 2 additions & 4 deletions client/src/pages/Admin/components/AdminUnitsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Clear from '@material-ui/icons/Clear';

const useStyles = makeStyles({
AdminListContainer: {
marginTop: '2%',
marginTop: '20px',
width: '80%',
padding: '20px',
height: 'calc(100% - 120px)',
Expand Down Expand Up @@ -71,11 +71,9 @@ const useStyles = makeStyles({
AdminSearchFilterContainer: {
display: 'flex',
justifyContent: 'space-around',
height: '70px',
width: '600px',
backgroundColor: '#FFFCD1',
paddingLeft: '20px',
paddingRight: '20px'
padding: '15px 20px'
},
AdminUsersSearchFilterSettingsContainer: {
display: 'flex',
Expand Down
4 changes: 1 addition & 3 deletions client/src/pages/Admin/components/AdminUsersFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ const useStyles = makeStyles(({ typography, palette }) => ({
AdminUsersSearchFilterContainer: {
display: 'flex',
justifyContent: 'space-around',
height: '70px',
width: '900px',
backgroundColor: '#FFFCD1',
paddingLeft: '20px',
paddingRight: '20px'
padding: '15px 20px'
},
AdminUsersSearchFilterSettingsContainer: {
display: 'flex',
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/Admin/components/AdminUsersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { extractISOMonthDateYear } from '../../../constants/index';

const useStyles = makeStyles({
AdminUsersListContainer: {
marginTop: '2%',
marginTop: '20px',
width: '1000px',
padding: '20px',
height: 'calc(100% - 120px)',
Expand Down
6 changes: 2 additions & 4 deletions client/src/pages/Admin/components/License/LicenseView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Clear from '@material-ui/icons/Clear';

const useStyles = makeStyles({
AdminListContainer: {
marginTop: '2%',
marginTop: '20px',
width: '80%',
padding: '20px',
height: 'calc(100% - 120px)',
Expand Down Expand Up @@ -72,11 +72,9 @@ const useStyles = makeStyles({
AdminSearchFilterContainer: {
display: 'flex',
justifyContent: 'space-around',
height: '70px',
width: '600px',
backgroundColor: '#FFFCD1',
paddingLeft: '20px',
paddingRight: '20px'
padding: '15px 20px'
},
AdminUsersSearchFilterSettingsContainer: {
display: 'flex',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
import React from 'react';
import { SubtitleFields, eSubtitleOption } from '../../../../../store/metadata/metadata.types';
import { Box, makeStyles, Typography, Table, TableBody, TableCell, TableContainer, TableRow, fade } from '@material-ui/core';
import { RiCheckboxBlankCircleLine, RiRecordCircleFill } from 'react-icons/ri';
import { grey } from '@material-ui/core/colors';
import { palette } from '../../../../../theme';
import { DebounceInput } from 'react-debounce-input';
import clsx from 'clsx';

interface SubtitleControlProps {
subtitles: SubtitleFields;
objectName: string;
onSelectSubtitle: (id: number) => void;
onUpdateCustomSubtitle: (event: React.ChangeEvent<HTMLInputElement>, id: number) => void;
hasPrimaryTheme: boolean
}

const useStyles = makeStyles(({ palette, typography }) => ({
container: {
display: 'flex',
flexDirection: 'column',
backgroundColor: (hasPrimaryTheme) => hasPrimaryTheme ? palette.primary.light : palette.secondary.light,
width: 'fit-content',
minWidth: 300
},
selected: {
cursor: 'pointer',
},
cell: {
border: 'none',
padding: '1px 10px',
maxHeight: 22
},
labelCell: {
width: 30
},
optionContainer: {
display: 'flex',
padding: '0 16px 0 0',
alignItems: 'center'
},
input: {
height: 20,
border: `1px solid ${fade(palette.primary.contrastText, 0.4)}`,
fontFamily: typography.fontFamily,
fontSize: '0.8rem',
padding: '0px 10px',
borderRadius: 5,
},
text: {
fontSize: '0.8rem'
}
}));

function SubtitleControl(props: SubtitleControlProps): React.ReactElement {
const { objectName, subtitles, onUpdateCustomSubtitle, onSelectSubtitle, hasPrimaryTheme } = props;
const classes = useStyles(hasPrimaryTheme);
const selectedSubtitle = subtitles.find(subtitle => subtitle.selected === true)?.value;
const selectedSubtitlesName = selectedSubtitle ? `: ${selectedSubtitle}` : '';
const sortedSubtitles: SubtitleFields = subtitles.sort((a, b) => a.subtitleOption - b.subtitleOption);


const renderSubtitleOptions = (subtitles: SubtitleFields): React.ReactElement => {
// console.log('subtitles', subtitles,'objectName', objectName);
// Case: forced
if (subtitles.some(option => option.subtitleOption === eSubtitleOption.eForced))
return (
<TableRow>
<TableCell className={clsx(classes.labelCell, classes.cell)}>
<Typography className={classes.text}>Name:</Typography>
</TableCell>
<TableCell className={classes.cell} style={{ height: 24 }}>
<Typography className={classes.text}>{`${objectName}${selectedSubtitlesName}`}</Typography>
</TableCell>
</TableRow>
);

// Case: optional subtitle
if (objectName && subtitles.length === 1 && subtitles.find(option => option.subtitleOption === eSubtitleOption.eInput)) {
const { id, value } = subtitles[0];
return (
<>
<TableRow>
<TableCell className={clsx(classes.labelCell, classes.cell)}>
<Typography className={classes.text}>Name:</Typography>
</TableCell>
<TableCell className={classes.cell} style={{ height: 24 }}>
<Typography className={classes.text}>{`${objectName}${selectedSubtitlesName}`}</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell className={clsx(classes.labelCell, classes.cell)}>
<Typography className={classes.text}>Subtitle:</Typography>
</TableCell>
<TableCell className={classes.cell} style={{ height: 24 }}>
<DebounceInput
onChange={(e) => onUpdateCustomSubtitle(e, id)}
element='input'
value={value}
className={classes.input}
debounceTimeout={400}
title={`subtitle-input-${value}`}
/>
</TableCell>
</TableRow>
</>
);
}

// Case: mandatory name input
if (subtitles.length === 1 && subtitles.find(option => option.subtitleOption === eSubtitleOption.eInput)) {
const { id, value } = subtitles[0];
return (
<TableRow>
<TableCell className={clsx(classes.labelCell, classes.cell)}>
<Typography className={classes.text}>Name:</Typography>
</TableCell>
<TableCell className={classes.cell} style={{ height: 24 }}>
<DebounceInput
onChange={(e) => onUpdateCustomSubtitle(e, id)}
element='input'
value={value}
className={classes.input}
debounceTimeout={400}
title={`subtitle-input-${value}`}
/>
</TableCell>
</TableRow>
);
}

// Case: mixed
const options = (
<>
<TableRow>
<TableCell className={clsx(classes.labelCell, classes.cell)}>
<Typography className={classes.text}>Name:</Typography>
</TableCell>
<TableCell className={classes.cell} style={{ height: 24 }}>
<Typography className={classes.text}>{`${objectName}${selectedSubtitlesName}`}</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell className={clsx(classes.labelCell, classes.cell)}>
<Typography className={classes.text}>Subtitle:</Typography>
</TableCell>
<TableCell className={classes.cell}>
<div style={{ display: 'flex', height: 24 }}>
{
sortedSubtitles.map(({ selected, value, id, subtitleOption }, key) => (
<div className={classes.optionContainer} key={key}>
{!selected && <RiCheckboxBlankCircleLine className={classes.selected} onClick={() => onSelectSubtitle(id)} size={18} color={grey[400]} />}
{selected && <RiRecordCircleFill className={classes.selected} onClick={() => onSelectSubtitle(id)} size={18} color={palette.primary.main} />}
{subtitleOption === eSubtitleOption.eNone && <Typography className={classes.text}>None</Typography>}
{subtitleOption === eSubtitleOption.eInherit && <Typography className={classes.text}>{value.length ? value : 'None'}</Typography>}
{subtitleOption === eSubtitleOption.eInput && (
<DebounceInput
onChange={(e) => onUpdateCustomSubtitle(e, id)}
element='input'
value={value}
className={classes.input}
debounceTimeout={400}
title={`subtitle-input-${value}`}
/>
)}
</div>
))
}
</div>
</TableCell>
</TableRow>
</>
);

return <React.Fragment>{options}</React.Fragment>;
};

return (
<Box className={classes.container}>
<TableContainer>
<Table>
<TableBody>
{renderSubtitleOptions(subtitles)}
</TableBody>
</Table>
</TableContainer>
</Box>
);
}

export default SubtitleControl;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { Table, TableBody, TableCell, TableHead, TableRow, Typography, Box } fro

const useStyles = makeStyles(theme => ({
assetFilesTableContainer: {
width: 'calc(52vw + 20px)',
width: 'fit-content',
minWidth: 400,
borderRadius: 5,
padding: 1,
backgroundColor: theme.palette.secondary.light
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ function ObjectSelectModal(props: ObjectSelectModalProps): React.ReactElement {
};

const updateRepositorySearch = (): void => {
resetRepositoryBrowserRoot();
const filterState = getFilterState();
filterState.search = filterState.keyword;
resetRepositoryFilter();
Expand Down
Loading

0 comments on commit 78a6fcd

Please sign in to comment.