-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
@@ -1,4 +1,5 @@ | |||
// Displays date bubble | |||
/* eslint-disable max-len */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to fix the error than to disable the rule.
Also this component looks like a better fit for a function rather than a class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you can fix line length with multiline strings, can you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can wrap a string over multiple lines with either +
or \
.
Also this is an expression which is easier to wrap. I think it should be built by a function rather than inline like this. Really hard to read between the template strings, use of this.props
, and the ternary operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (displayDateRange) {
return `${startDate} ${startMonth} ${startYear} - ${endDate} ${endMonth} ${endYear}`
} else {
return `${startDate} ${startMonth} ${startYear}`;
}
I think this is much clearer and breaks no linting rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could go one further and use this.props.ISODate
or whatever the field is called, along with format
and use the in-built tokens
|
||
DateBubble.propTypes = { | ||
startDateTime: PropTypes.shape(dateShape), | ||
endDateTime: PropTypes.shape(dateShape), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look required to me?
… when end date prop is specified
…nd fix Karma tests
…to try and fix Karma tests" This reverts commit 8b2c1c3.
@@ -77,7 +84,7 @@ export default class EventsController { | |||
.then((response) => response.json()) | |||
.then((events) => { | |||
res.send({ list: events.data.allEvents.sort((a, b) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could use our pathOr(['...]), that we have used in badger brain to access these nested object keys. Just thinking of a scenario where someone changes the query and doesn't actually query for the startDateTime but yet we try access the .iso key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a bit of premature optimization - this is a client and it knows what it just requested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh you mean in case startDateTime is null? Maybe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Basically whenever I see a.b.c.d.e these days I want to use pathOr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally should be built in :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm putting this one on hold for now - at the moment if startDateTime
is missing, the whole site will explode. We should handle this in a clever way, probably on BB level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be addressed as part of a separate PR.
startDateTime, | ||
endDateTime, | ||
}) => { | ||
let displayDateContent = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be cleaner if we put this in its' own function
}) => ( | ||
<div> | ||
{ | ||
event.externalLinks || event.internalLinks ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make more sense to do this inside the child component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah probably. There's also potential for refactoring in a way of only passing down elements of the event
and not the whole event
.
? <TagsList | ||
tags={event.tags} | ||
tagsLinkPath="about-us/events" /> | ||
: null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we need to update to React 15 in order to get that null
returns working without warnings.
} else { | ||
displayDateContent = | ||
`${startDateTime.date} ${startDateTime.monthSym} ${startDateTime.year}`; | ||
} else { // eslint-disable-line no-else-return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obey the style guide instead of turning off the linter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are my options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, fixed
Looks good :) |
@AndrewBestbier merge merge! |
Motivation
Currently it is only possible to specify datetime of the event. With this change we are introducing ability to specify start datetime and end datetime. Events spanning multiple days will have those days displayed in the UI (under
Today
list).