-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge branch 'master' into LIBSEARCH-901-priority-figure-out-…
…what-is-going-on-with-authentication-and-get-this" This reverts commit 3811567, reversing changes made to ca90abf.
- Loading branch information
1 parent
3811567
commit d90dbb2
Showing
7 changed files
with
115 additions
and
68 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react'; | ||
import { Alert, Button } from '../../../reusable'; | ||
import { connect } from 'react-redux'; | ||
import { UserIsFlintAffiliated } from '../../../flint'; | ||
import PropTypes from 'prop-types'; | ||
|
||
class FlintAlerts extends React.Component { | ||
state = { | ||
closed: false | ||
}; | ||
|
||
handleCloseButtonClick = () => { | ||
this.setState({ closed: true }); | ||
}; | ||
|
||
render () { | ||
const { datastore } = this.props; | ||
|
||
const alertMessages = { | ||
primo: 'U-M Flint users: You may not be able to access U-M Ann Arbor resources. For the best results use <a href="https://umich.primo.exlibrisgroup.com/discovery/search?vid=01UMICH_INST:FLINT">Thompson Library’s Search All</a> to search for articles.', | ||
databases: 'We noticed you are affiliated with U-M Flint. For the best results use the <a href="https://libguides.umflint.edu/az.php?a=all">Thompson Library’s database listing</a>.', | ||
onlinejournals: 'We noticed you are affiliated with U-M Flint. For the best results use the <a href="https://umich.primo.exlibrisgroup.com/discovery/jsearch?vid=01UMICH_INST:FLINT">Thompson Library’s Search All</a> to search for articles.', | ||
website: 'We noticed you are affiliated with U-M Flint. For the best results use the <a href="https://libguides.umflint.edu/library">Thompson Library website</a>.' | ||
}; | ||
|
||
if (this.state.closed || !Object.keys(alertMessages).includes(datastore)) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<UserIsFlintAffiliated> | ||
<Alert type='warning'> | ||
<span dangerouslySetInnerHTML={{ __html: alertMessages[datastore] }} /> | ||
<Button | ||
kind='secondary' | ||
small | ||
onClick={() => { | ||
return this.handleCloseButtonClick(); | ||
}} | ||
> | ||
Dismiss | ||
</Button> | ||
</Alert> | ||
</UserIsFlintAffiliated> | ||
); | ||
} | ||
} | ||
|
||
FlintAlerts.propTypes = { | ||
datastore: PropTypes.string | ||
}; | ||
|
||
function mapStateToProps (state) { | ||
return { | ||
query: state.search.query, | ||
datastore: state.datastores.active | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(FlintAlerts); |
30 changes: 30 additions & 0 deletions
30
src/modules/flint/components/UserIsFlintAffiliated/index.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,30 @@ | ||
import _ from 'underscore'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const UserIsFlintAffiliated = ({ | ||
isFlintAffiliated, | ||
children | ||
}) => { | ||
if (isFlintAffiliated) { | ||
return children; | ||
} else { | ||
return null; | ||
} | ||
}; | ||
|
||
UserIsFlintAffiliated.propTypes = { | ||
isFlintAffiliated: PropTypes.bool, | ||
children: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.node), | ||
PropTypes.node | ||
]) | ||
}; | ||
|
||
function mapStateToProps (state) { | ||
return { | ||
isFlintAffiliated: _.contains(state.profile.institutions, 'Flint') | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(UserIsFlintAffiliated); |
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,7 @@ | ||
import FlintAlerts from './components/FlintAlerts'; | ||
import UserIsFlintAffiliated from './components/UserIsFlintAffiliated'; | ||
|
||
export { | ||
FlintAlerts, | ||
UserIsFlintAffiliated | ||
}; |
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