Skip to content

Commit

Permalink
Allow any users to drag ideas in 'grouping' stage on desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderhoop committed Feb 8, 2019
1 parent d7509ca commit 2bf4c6f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
25 changes: 24 additions & 1 deletion test/components/conditionally_draggable_idea_content_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { spy } from "sinon"
import ConditionallyDraggableIdeaContent from "../../web/static/js/components/conditionally_draggable_idea_content"
import STAGES from "../../web/static/js/configs/stages"

const { IDEA_GENERATION } = STAGES
const { IDEA_GENERATION, GROUPING } = STAGES

describe("<ConditionallyDraggableIdeaContent />", () => {
let wrapper
Expand Down Expand Up @@ -189,6 +189,29 @@ describe("<ConditionallyDraggableIdeaContent />", () => {
})
})

context("when the stage is grouping", () => {
context("and the user is neither the facilitator", () => {
context("nor the author of the idea", () => {
beforeEach(() => {
wrapper = mountWithConnectedSubcomponents(
<ConditionallyDraggableIdeaContent
{...defaultProps}
currentUser={{
is_facilitator: false,
id: 393939393939,
}}
stage={GROUPING}
/>
)
})

it("sets draggable=true", () => {
expect(wrapper.html()).to.match(/draggable="true"/)
})
})
})
})

context("when the idea is being dragged", () => {
const idea = { id: 1, body: "yo sup" }
const props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import StageAwareIdeaControls from "./stage_aware_idea_controls"

import * as AppPropTypes from "../prop_types"
import { MIN_TABLET_WIDTH } from "../configs/responsive"
import STAGES from "../configs/stages"
import styles from "./css_modules/conditionally_draggable_idea_content.css"

const { IDEA_GENERATION, GROUPING } = STAGES

const handleDragStart = props => event => {
const { idea } = props
event.dataTransfer.dropEffect = "move"
Expand All @@ -18,15 +21,18 @@ const ConditionallyDraggableIdeaContent = props => {
const { idea, currentUser, retroChannel, stage, assignee } = props
const isEdited = (+new Date(idea.updated_at) - +new Date(idea.inserted_at)) > 100

const canUserEditIdea = currentUser.is_facilitator || (currentUser.id === idea.user_id)
const isIdeaEditableInCurrentStage = stage === "idea-generation"
const userHasContentEditPermissions =
currentUser.is_facilitator || (currentUser.id === idea.user_id)

const isIdeaDragEligible =
(stage === GROUPING || (stage === IDEA_GENERATION && userHasContentEditPermissions))

return (
<MediaQuery minWidth={MIN_TABLET_WIDTH}>
{isTabletOrAbove => (
<div
className={styles.ideaWrapper}
draggable={canUserEditIdea && isIdeaEditableInCurrentStage && isTabletOrAbove}
draggable={isIdeaDragEligible && isTabletOrAbove}
onDragStart={handleDragStart(props)}
>
<StageAwareIdeaControls
Expand Down

0 comments on commit 2bf4c6f

Please sign in to comment.