Skip to content

Commit

Permalink
Dont allow cards to be moved past start or end
Browse files Browse the repository at this point in the history
  • Loading branch information
timmo001 committed Jun 27, 2020
1 parent 4b81fd4 commit 423f046
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions frontend/src/Components/Cards/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export interface BaseProps extends HomeAssistantChangeProps {
config: ConfigurationProps;
editing: number;
expandable: boolean;
maxPosition: number;
position: number;
handleCloseExpand?: () => void;
handleCopy?: () => void;
handleDelete?: () => void;
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/Components/Cards/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ function Overlay(props: BaseProps): ReactElement {
<IconButton color="primary" onClick={props.handleCopy}>
<CopyIcon fontSize="small" />
</IconButton>
<IconButton color="primary" onClick={props.handleMoveUp}>
<IconButton
disabled={props.position === 0}
color="primary"
onClick={props.handleMoveUp}>
<ArrowUpwardIcon fontSize="small" />
</IconButton>
<IconButton color="primary" onClick={props.handleMoveDown}>
<IconButton
disabled={props.position === props.maxPosition}
color="primary"
onClick={props.handleMoveDown}>
<ArrowDownwardsIcon fontSize="small" />
</IconButton>
{deleteConfirm && (
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/Components/Configuration/EditCard/EditCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,14 @@ function EditCard(props: EditCardProps): ReactElement {
container
alignContent="center"
justify="space-around">
<CardBase {...props} card={card} editing={0} expandable={true} />
<CardBase
{...props}
card={card}
editing={0}
expandable={true}
maxPosition={0}
position={0}
/>
</Grid>
</Grid>
</DialogContent>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/Components/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ function Overview(props: OverviewProps): ReactElement {
card={card}
editing={props.editing}
expandable
maxPosition={cards.length - 1}
position={cardKey}
handleCopy={handleCopy(card)}
handleDelete={handleDelete(group, card)}
handleMoveUp={handleMoveUp(group, card)}
Expand Down

0 comments on commit 423f046

Please sign in to comment.