Skip to content

Commit

Permalink
Merge 685b997 into d53e1df
Browse files Browse the repository at this point in the history
  • Loading branch information
negreirosleo committed Nov 20, 2018
2 parents d53e1df + 685b997 commit ce2a24c
Show file tree
Hide file tree
Showing 31 changed files with 689 additions and 559 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Imports/exports of stories
- Documents
- Tasks
- Added Popover when Story is collapsed in board V2

## [1.21.1] 2018-10-18
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/stories/Stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Stories = ({ stories }) => {
return (
<div>
{stories.map(story => (
<StoryItem key={story.id} {...story} />
<StoryItem key={story.id} story={story} />
))}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import PropTypes from 'prop-types';

const estimateRule = (estimate) => estimate > 0 ? estimate : '-';

const CollapsedStoryEstimate = ({ estimate }) => (
<span className='Story__estimated'>{estimateRule(estimate)}</span>
);

CollapsedStoryEstimate.propTypes = {
estimate: PropTypes.number,
};

CollapsedStoryEstimate.defaultProp = {
estimate: '-',
};

export default CollapsedStoryEstimate;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import CollapsedStoryTitle from './CollapsedStoryTitle'
import CollapsedStoryLabels from './CollapsedStoryLabels'

const CollapsedStoryInfo = ({ story }) => (
<div className="Story__info">
<CollapsedStoryLabels story={story} />
<CollapsedStoryTitle story={story} />
</div>
);

CollapsedStoryInfo.propTypes = {
story: PropTypes.object.isRequired
};

export default CollapsedStoryInfo;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react'
import PropTypes from 'prop-types'

const labelSplit = (labels) => labels.split(',');

const StoryLabel = ( { label } ) => (
<a href="#" className="Story__label" title={label}>{label}</a>
);

StoryLabel.propTypes = {
label: PropTypes.string.isRequired,
};

const CollapsedStoryLabels = ({ story }) => {
if (!story.labels) {
return null
}

return (
<span className='Story__labels'>
{labelSplit(story.labels).map(label => (
<StoryLabel key={label} label={label} />
))}
</span>
);
};

CollapsedStoryLabels.propTypes = {
story: PropTypes.object.isRequired,
};

export default CollapsedStoryLabels;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

const CollapsedStoryPoints = () => (
<div>
<span className="Story__estimate">1</span>
<span className="Story__estimate">2</span>
<span className="Story__estimate">3</span>
<span className="Story__estimate">5</span>
<span className="Story__estimate">8</span>
</div>
);

export default CollapsedStoryPoints;
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import PropTypes from 'prop-types';
import CollapsedStoryPoints from './CollapsedStoryPoints';
import CollapsedStoryStateButton from './CollapsedStoryStateButton';
import { isStoryNotEstimated } from '../../../models/beta/story';

const StoryActionFor = (state) => StateAction[state] || StateAction.unstarted;

const StateAction = {
started: ["finish"],
finished: ["deliver"],
delivered: ["accept", "reject"],
rejected: ["restart"],
accepted: [],
unstarted: ["start"]
};

const CollapsedStoryStateActions = ({ story }) => (
<div className='Story__actions'>
{
isStoryNotEstimated(story.storyType, story.estimate) ?
<CollapsedStoryPoints />
: StoryActionFor(story.state).map((stateAction) =>
<CollapsedStoryStateButton action={stateAction} key={stateAction} />
)
}
</div>
);

CollapsedStoryStateActions.propTypes = {
story: PropTypes.object.isRequired,
};


export default CollapsedStoryStateActions;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import PropTypes from 'prop-types';

const CollapsedStoryStateButton = ({ action }) => (
<button type="button" className={`Story__btn Story__btn--${action}`}>
{ I18n.translate(`story.events.${action}`) }
</button>
);

CollapsedStoryStateButton.propTypes = {
action: PropTypes.string.isRequired
};

export default CollapsedStoryStateButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import PropTypes from 'prop-types'

const CollapsedStoryTitle = ({ story }) => (
<div className="Story__title">
{story.title}
<abbr
className="Story__initials"
title={story.ownedByName}
>
{story.ownedByInitials}
</abbr>
</div>
);

CollapsedStoryTitle.propTypes = {
story: PropTypes.object.isRequired,
};


export default CollapsedStoryTitle
44 changes: 44 additions & 0 deletions app/assets/javascripts/components/story/CollapsedStory/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import classname from 'classnames';
import PropTypes from 'prop-types';
import StoryPopover from '../StoryPopover';
import StoryDescriptionIcon from '../StoryDescriptionIcon';
import CollapsedStoryEstimate from './CollapsedStoryEstimate';
import CollapsedStoryStateActions from './CollapsedStoryStateActions';
import CollapsedStoryInfo from './CollapsedStoryInfo';
import StoryIcon from '../StoryIcon';
import * as StoryModel from '../../../models/beta/story';

const classNameStory = (storyType, estimate) => {

const isStoryNotEstimated = StoryModel.isStoryNotEstimated(storyType, estimate);
const isRelease = StoryModel.isRelease(storyType);

return classname('Story', {
'Story--unestimated': isStoryNotEstimated,
'Story--estimated': !isStoryNotEstimated,
'Story--release': isRelease
});
};

const CollapsedStory = ({ story }) => (
<div className={classNameStory(story.storyType, story.estimate)}>
<StoryPopover story={story}>
<div className='Story__icons-block'>
<StoryIcon storyType={story.storyType} />
<CollapsedStoryEstimate estimate={story.estimate} />
<StoryDescriptionIcon description={story.description} />
</div>
</StoryPopover>

<CollapsedStoryInfo story={story}/>

<CollapsedStoryStateActions story={story}/>
</div>
);

CollapsedStory.propTypes = {
story: PropTypes.object.isRequired
};

export default CollapsedStory;
28 changes: 28 additions & 0 deletions app/assets/javascripts/components/story/StoryIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import PropTypes from 'prop-types';
import _ from 'underscore';

const iconRules = {
feature: { icon: 'start', className: 'star' },
bug: { icon: 'bug_report', className: 'bug' },
chore: { icon: 'settings', className: 'dark' },
release: { icon: 'bookmark', className: 'bookmark' }
};

const iconRuleFor = _.propertyOf(iconRules);

const iconRule = (storyType) => iconRuleFor([storyType, 'icon']);

const classIconRule = (storyType) => iconRuleFor([storyType, 'className']);

const CollapsedStoryIcon = ({ storyType }) => (
<span className='Story__icon'>
<i className={`mi md-${classIconRule(storyType)} md-16`}>{iconRule(storyType)}</i>
</span>
);

CollapsedStoryIcon.propTypes = {
storyType: PropTypes.string.isRequired,
};

export default CollapsedStoryIcon;
Loading

0 comments on commit ce2a24c

Please sign in to comment.