-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #850 from osmlab/prerelease
Prepare for v3.3.4 release
- Loading branch information
Showing
20 changed files
with
347 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,3 +243,10 @@ | |
} | ||
} | ||
} | ||
|
||
.ChallengeTasksWidget { | ||
.modal.is-active { | ||
display: block; | ||
padding-top: 500px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/components/HOCs/WithSystemNotices/WithSystemNotices.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React, { Component } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { fetchActiveSystemNotices } | ||
from '../../../services/SystemNotices/SystemNotices' | ||
|
||
const ACKNOWLEDGED_SETTING = 'acknowledgedNotices' | ||
|
||
/** | ||
* WithSystemNotices provides the WrappedComponent with an array of active, | ||
* unacknowledged system notices along with methods for acknowledging them | ||
* | ||
* @author [Neil Rotstan](https://github.com/nrotstan) | ||
*/ | ||
export const WithSystemNotices = function(WrappedComponent) { | ||
class _WithSystemNotices extends Component { | ||
state = { | ||
systemNotices: null, | ||
unacknowledgedNotices: [], | ||
} | ||
|
||
async componentDidMount() { | ||
if (!this.state.systemNotices) { | ||
const activeNotices = await fetchActiveSystemNotices() | ||
|
||
this.setState({systemNotices: activeNotices}) | ||
} | ||
} | ||
|
||
/** | ||
* Retrieves all acknowledged notices from the user's app settings | ||
* | ||
* @private | ||
*/ | ||
allAcknowledgedNotices = () => { | ||
if (!this.props.user) { | ||
return [] | ||
} | ||
|
||
return this.props.getUserAppSetting(this.props.user, ACKNOWLEDGED_SETTING) || [] | ||
} | ||
|
||
/** | ||
* Retrieves array of notices that have not yet been acknowledged by the | ||
* user | ||
* | ||
* @private | ||
*/ | ||
unacknowledgedNotices = () => { | ||
if (!this.state.systemNotices) { | ||
return [] | ||
} | ||
|
||
const acknowledged = this.allAcknowledgedNotices() | ||
return this.state.systemNotices.filter( | ||
notice => acknowledged.indexOf(notice.uuid) === -1 | ||
) | ||
} | ||
|
||
/** | ||
* Acknowledges the given notice | ||
*/ | ||
acknowledgeNotice = async (notice) => { | ||
if (!this.props.user || !notice.uuid) { | ||
return | ||
} | ||
|
||
const updatedAcknowledgements = this.allAcknowledgedNotices().slice() | ||
updatedAcknowledgements.push(notice.uuid) | ||
await this.props.updateUserAppSetting(this.props.user.id, { | ||
[ACKNOWLEDGED_SETTING]: updatedAcknowledgements, | ||
}) | ||
} | ||
|
||
render() { | ||
const remainingNotices = this.unacknowledgedNotices(this.state.systemNotices) | ||
return <WrappedComponent | ||
{...this.props} | ||
allSystemNotices={this.state.systemNotices} | ||
newSystemNotices={remainingNotices} | ||
acknowledgeNotice={notice => this.acknowledgeNotice(notice)} | ||
/> | ||
} | ||
} | ||
|
||
_WithSystemNotices.propTypes = { | ||
user: PropTypes.object, | ||
getUserAppSetting: PropTypes.func.isRequired, | ||
updateUserAppSetting: PropTypes.func.isRequired, | ||
} | ||
|
||
return _WithSystemNotices | ||
} | ||
|
||
export default WrappedComponent => WithSystemNotices(WrappedComponent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.