Skip to content

Commit

Permalink
feat: add item settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Jun 29, 2021
1 parent 8861e65 commit 82069ed
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/item/header/ItemHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ItemHeader = ({ onClick }) => {
return (
<div className={classes.root}>
<Navigation item={item} user={user} />
<ItemHeaderActions item={item} onClick={onClick} />
{item && <ItemHeaderActions item={item} onClick={onClick} />}
</div>
);
};
Expand Down
15 changes: 12 additions & 3 deletions src/components/item/header/ItemHeaderActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import IconButton from '@material-ui/core/IconButton';
import PropTypes from 'prop-types';
import EditIcon from '@material-ui/icons/Edit';
import { Map } from 'immutable';
import SettingsIcon from '@material-ui/icons/Settings';
import { useHistory } from 'react-router';
import InfoIcon from '@material-ui/icons/Info';
import { makeStyles } from '@material-ui/core/styles';
import ModeButton from './ModeButton';
import { ITEM_TYPES } from '../../../enums';
import DeleteButton from '../../common/DeleteButton';
import { ItemLayoutModeContext } from '../../context/ItemLayoutModeContext';
import { VIEW_ITEM_EDIT_ITEM_BUTTON_ID } from '../../../config/selectors';
import ShareButton from '../../common/ShareButton';
import { ITEM_TYPES_WITH_CAPTIONS } from '../../../config/constants';
import { buildItemSettingsPath } from '../../../config/paths';

const useStyles = makeStyles((theme) => ({
root: {
Expand All @@ -26,6 +28,7 @@ const useStyles = makeStyles((theme) => ({
}));
const ItemHeaderActions = ({ onClick, item }) => {
const classes = useStyles();
const { push } = useHistory();
const type = item?.get('type');
const isFile = type && type !== ITEM_TYPES.FOLDER;
const id = item?.get('id');
Expand All @@ -45,17 +48,23 @@ const ItemHeaderActions = ({ onClick, item }) => {
</IconButton>
);

const onClickSettings = () => {
push(buildItemSettingsPath(id));
};

return (
<div className={classes.buttons}>
{actions}
{!isFile && <ModeButton />}
{id && (
<>
<ShareButton itemId={id} />
<DeleteButton itemIds={[id]} />
<IconButton onClick={onClick} color="primary">
<InfoIcon color="primary" />
</IconButton>
<ShareButton itemId={id} />
<IconButton onClick={onClickSettings} color="primary">
<SettingsIcon />
</IconButton>
</>
)}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/item/settings/ItemLoginSetting.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const ItemLoginSwitch = () => {
>
{Object.values(SETTINGS.ITEM_LOGIN.OPTIONS).map((value) => (
<MenuItem
key={value}
value={value}
id={buildItemLoginSettingModeSelectOption(value)}
>
Expand Down
2 changes: 2 additions & 0 deletions src/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export const ITEMS_PATH = '/items';
export const buildItemPath = (id = ':itemId') => `${ITEMS_PATH}/${id}`;
export const REDIRECT_PATH = '/redirect';
export const MEMBER_PROFILE_PATH = '/profile';
export const buildItemSettingsPath = (id = ':itemId') =>
`${ITEMS_PATH}/${id}/settings`;
3 changes: 2 additions & 1 deletion src/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"Storage Used": "Storage Used",
"Member Since": "Member Since",
"Profile": "Profile",
"Member ID": "Member ID"
"Member ID": "Member ID",
"Size": "Size"
}
}
3 changes: 2 additions & 1 deletion src/langs/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"Storage Used": "Mémoire utilisée",
"Member Since": "Membre depuis",
"Profile": "Profil",
"Member ID": "ID de Membre"
"Member ID": "ID de Membre",
"Size": "Taille"
}
}

0 comments on commit 82069ed

Please sign in to comment.