Skip to content

Commit

Permalink
Merge pull request #617 from osmlab/develop
Browse files Browse the repository at this point in the history
v3.1.3 release preparation
  • Loading branch information
nrotstan authored Feb 5, 2019
2 parents f1040d1 + fbf5d90 commit 7b27738
Show file tree
Hide file tree
Showing 79 changed files with 13,041 additions and 678 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react-dropzone": "^4.2.3",
"react-grid-layout": "^0.16.6",
"react-intl": "^2.3.0",
"react-intl-formatted-duration": "^3.0.0",
"react-jsonschema-form": "1.0.3",
"react-jsonschema-form-async": "^0.2.0",
"react-leaflet": "^1.8.0",
Expand Down
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import UserProfile from './components/UserProfile/UserProfile'
import Leaderboard from './components/Leaderboard/Leaderboard'
import ChallengeLeaderboard from './components/ChallengeLeaderboard/ChallengeLeaderboard'
import ProjectLeaderboard from './components/ProjectLeaderboard/ProjectLeaderboard'
import CountryLeaderboard from './components/CountryLeaderboard/CountryLeaderboard'
import ErrorModal from './components/ErrorModal/ErrorModal'
import Sprites from './components/Sprites/Sprites'
import MobileNotSupported
Expand Down Expand Up @@ -89,6 +90,7 @@ export class App extends Component {
<CachedRoute path='/leaderboard' component={Leaderboard} />
<CachedRoute path='/challenge/:challengeId/leaderboard' component={ChallengeLeaderboard} />
<CachedRoute path='/project/:projectId/leaderboard' component={ProjectLeaderboard} />
<CachedRoute path='/country/:countryCode/leaderboard' component={CountryLeaderboard} />
<CachedRoute path='/admin' component={AdminPane} />
<CachedRoute path='/error' component={ErrorPane} />
<Route component={PageNotFound} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
@import 'mixins.scss';

.admin__manage.challenge-dashboard {
.admin__manage__primary-content {
padding-top: 0;

.challenge-tasks-status {
.challenge-tasks-status {
&__building-header {
display: flex;
flex-direction: column;
justify-content: flex-start;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}

h3 {
font-size: $size-3;
margin-bottom: 20px;
h3 {
font-size: $size-3;
color: $primary;

&.is-danger {
color: $coral;
}
&.is-danger {
color: $coral;
}
}

&__status-message {
font-size: $size-6;
white-space: pre-wrap;
max-width: 100%;
border-radius: $radius-medium;
}
&__status-message {
font-size: $size-6;
white-space: pre-wrap;
max-width: 100%;
border-radius: $radius-medium;
}

&__build-status {
font-size: $size-5;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ export const uiSchema = (intl, user, challengeData) => {
description: {
"ui:field": "markdown",
},
blurb: {
"ui:emptyValue": "",
},
instruction: {
"ui:field": "markdown",
},
Expand All @@ -165,6 +168,9 @@ export const uiSchema = (intl, user, challengeData) => {
additionalKeywords: {
"ui:field": "tags",
},
checkinComment: {
"ui:emptyValue": "",
},
includeCheckinHashtag: {
"ui:widget": "radio",
},
Expand Down
10 changes: 5 additions & 5 deletions src/components/AdminPane/Manage/ViewChallengeTasks/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ export default defineMessages({

tasksCreatedCount: {
id: "Admin.Challenge.tasksCreatedCount",
defaultMessage: "{count, number} tasks created",
defaultMessage: "{count, number} tasks created so far",
},

asOf: {
id: "Admin.Challenge.status.asOf.label",
defaultMessage: "as of",
totalElapsedTime: {
id: "Admin.Challenge.totalCreationTime",
defaultMessage: "Total elapsed time:",
},

refreshStatusLabel: {
id: "Admin.Challenge.controls.refreshStatus.label",
defaultMessage: "Refresh Status",
defaultMessage: "Refreshing status in",
},

tasksHeader: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react'
import { FormattedMessage,
FormattedRelative } from 'react-intl'
import { FormattedMessage } from 'react-intl'
import FormattedDuration, { TIMER_FORMAT } from 'react-intl-formatted-duration'
import parse from 'date-fns/parse'
import _get from 'lodash/get'
import { ChallengeStatus }
from '../../../../services/Challenge/ChallengeStatus/ChallengeStatus'
Expand All @@ -18,17 +19,42 @@ const TIMER_INTERVAL = 10000 // 10 seconds
export default class TaskBuildProgress extends Component {
timerHandle = null

state = {
startTime: new Date(),
}

clearTimer = () => {
if (this.timerHandle !== null) {
clearInterval(this.timerHandle)
this.timerHandle = null
}
}

/**
* Returns the total elapsed seconds since the start time (usually the challenge
* modification date)
*/
totalElapsedSeconds = () => {
return (Date.now() - this.state.startTime) / 1000
}

/**
* Returns the number of seconds until the next status update
*/
nextUpdateSeconds = () => {
return (
new Date(this.props.challenge._meta.fetchedAt + TIMER_INTERVAL).getTime() - Date.now()
) / 1000
}

componentDidMount() {
this.clearTimer()
this.timerHandle =
setInterval(this.props.refreshChallenge, TIMER_INTERVAL)

if (this.props.challenge.modified) {
this.setState({startTime: parse(this.props.challenge.modified)})
}
}

componentWillUnmount() {
Expand All @@ -43,21 +69,37 @@ export default class TaskBuildProgress extends Component {
return (
<div>
<div className="challenge-tasks-status">
<h3><FormattedMessage {...messages.tasksBuilding} /></h3>

<div className="since-when">
<FormattedMessage {...messages.tasksCreatedCount}
values={{count: _get(this.props.challenge,
'actions.total', 0)}}
/> <FormattedMessage {...messages.asOf}
/> <FormattedRelative
value={new Date(this.props.challenge._meta.fetchedAt)}
updateInterval={1000} />
<div className="challenge-tasks-status__building-header">
<h3>
<FormattedMessage
{...messages.tasksBuilding}
/> <BusySpinner className="inline" />
</h3>

<div className="pane-loading">
<BusySpinner />
<div>
<FormattedMessage
{...messages.totalElapsedTime}
/> <FormattedDuration seconds={this.totalElapsedSeconds()} format={TIMER_FORMAT} />
</div>
</div>

<div className="challenge-tasks-status__build-status">
<p>
<FormattedMessage
{...messages.tasksCreatedCount}
values={{count: _get(this.props.challenge, 'actions.total', 0)}}
/>
</p>

<p>
<FormattedMessage
{...messages.refreshStatusLabel}
/> <FormattedDuration
seconds={this.nextUpdateSeconds()}
format={TIMER_FORMAT}
/>
</p>
</div>
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import TriStateCheckbox from '../../../Bulma/TriStateCheckbox'
import ConfirmAction from '../../../ConfirmAction/ConfirmAction'
import SvgSymbol from '../../../SvgSymbol/SvgSymbol'
import BusySpinner from '../../../BusySpinner/BusySpinner'
import IntervalRender from '../../../IntervalRender/IntervalRender'
import WithDeactivateOnOutsideClick
from '../../../HOCs/WithDeactivateOnOutsideClick/WithDeactivateOnOutsideClick'
import ChallengeTaskMap from '../ChallengeTaskMap/ChallengeTaskMap'
Expand Down Expand Up @@ -99,7 +100,7 @@ export class ViewChallengeTasks extends Component {

render() {
if (this.props.challenge.status === ChallengeStatus.building) {
return <TaskBuildProgress {...this.props} />
return <IntervalRender><TaskBuildProgress {...this.props} /></IntervalRender>
}

if (this.props.challenge.status === ChallengeStatus.failed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ ShallowWrapper {
}
/>
</MediaQuery>
<Component
<Connect(Component)
challenges={
Array [
Object {
Expand Down Expand Up @@ -448,7 +448,7 @@ ShallowWrapper {
}
/>
</MediaQuery>
<Component
<Connect(Component)
challenges={
Array [
Object {
Expand Down Expand Up @@ -665,7 +665,7 @@ ShallowWrapper {
}
/>
</MediaQuery>,
<Component
<Connect(Component)
challenges={
Array [
Object {
Expand Down Expand Up @@ -1286,7 +1286,7 @@ ShallowWrapper {
}
/>
</MediaQuery>
<Component
<Connect(Component)
challenges={
Array [
Object {
Expand Down Expand Up @@ -1506,7 +1506,7 @@ ShallowWrapper {
}
/>
</MediaQuery>
<Component
<Connect(Component)
challenges={
Array [
Object {
Expand Down Expand Up @@ -1723,7 +1723,7 @@ ShallowWrapper {
}
/>
</MediaQuery>,
<Component
<Connect(Component)
challenges={
Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import WithSortedChallenges from '../../HOCs/WithSortedChallenges/WithSortedChal
import WithPagedChallenges from '../../HOCs/WithPagedChallenges/WithPagedChallenges'
import ChallengeResultItem from '../ChallengeResultItem/ChallengeResultItem'
import SortChallengesSelector from './SortChallengesSelector'
import LoadMoreButton from './LoadMoreButton'
import PageResultsButton from './PageResultsButton'
import SvgSymbol from '../../SvgSymbol/SvgSymbol'
import BusySpinner from '../../BusySpinner/BusySpinner'
import StartVirtualChallenge from './StartVirtualChallenge'
Expand Down Expand Up @@ -123,7 +123,7 @@ export class ChallengeResultList extends Component {
{results}

<div className="after-results">
<LoadMoreButton {...this.props} />
<PageResultsButton {...this.props} />
</div>
</div>
)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import { FormattedMessage } from 'react-intl'
import _get from 'lodash/get'
import { RESULTS_PER_PAGE } from '../../../services/Search/Search'
import './LoadMoreButton.css'
import LoadMoreButton from '../../LoadMoreButton/LoadMoreButton'
import messages from './Messages'


Expand All @@ -14,31 +13,21 @@ import messages from './Messages'
*
* @author [Kelli Rotstan](https://github.com/krotstan)
*/
export default class LoadMoreButton extends Component {
export default class PageResultsButton extends Component {
render() {
if (!this.props.hasMoreResults) {
return null
}

const resultsPerPage = _get(this.props, 'searchPage.resultsPerPage', RESULTS_PER_PAGE)
const currentPage = _get(this.props, 'searchPage.currentPage', 0)

return (
<button className={classNames("button is-outlined load-more-button",
this.props.className,
{"is-loading": this.props.isLoading,
"no-focus": !this.props.isLoading})}
onClick={(e) => {
e.preventDefault()
this.props.setSearchPage({currentPage: (currentPage + 1), resultsPerPage})
}}>
<LoadMoreButton {...this.props}
loadMore={(e) => this.props.setSearchPage({currentPage: (currentPage + 1), resultsPerPage})} >
<FormattedMessage {...messages.loadMoreLabel} />
</button>
</LoadMoreButton>
)
}
}

LoadMoreButton.propTypes = {
PageResultsButton.propTypes = {
/** Invoked to page the challenges when the button is clicked */
setSearchPage: PropTypes.func.isRequired,
/** Boolean flag indicating if there are more results */
Expand Down
Loading

0 comments on commit 7b27738

Please sign in to comment.