Skip to content

Commit

Permalink
Revert "Merge branch 'master' into LIBSEARCH-901-priority-figure-out-…
Browse files Browse the repository at this point in the history
…what-is-going-on-with-authentication-and-get-this"

This reverts commit 3811567, reversing
changes made to ca90abf.
  • Loading branch information
erinesullivan committed Aug 30, 2023
1 parent 3811567 commit d90dbb2
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 68 deletions.
4 changes: 2 additions & 2 deletions src/modules/affiliation/reducer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const affiliationReducer = (state = initialState, action) => {
case actions.SET_DEFAULT_AFFILIATION:
return {
...state,
defaultAffiliation: action.payload || initialAffiliationState.defaultAffiliation
defaultAffiliation: action.payload
};
case actions.SET_ACTIVE_AFFILIATION:
return {
...state,
active: action.payload || initialAffiliationState.active
active: action.payload
};
default:
return state;
Expand Down
61 changes: 0 additions & 61 deletions src/modules/datastores/components/FlintAlerts/index.js

This file was deleted.

4 changes: 1 addition & 3 deletions src/modules/datastores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import DatastoreNavigation from './components/DatastoreNavigation';
import Landing from './components/Landing';
import DatastoreInfo from './components/DatastoreInfo';
import DatastoreAlerts from './components/DatastoreAlerts';
import FlintAlerts from './components/FlintAlerts';
import datastoresReducer from './reducer/';

import { addDatastore, changeActiveDatastore } from './actions';
Expand All @@ -14,6 +13,5 @@ export {
changeActiveDatastore,
Landing,
DatastoreInfo,
DatastoreAlerts,
FlintAlerts
DatastoreAlerts
};
60 changes: 60 additions & 0 deletions src/modules/flint/components/FlintAlerts/index.js
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 src/modules/flint/components/UserIsFlintAffiliated/index.js
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);
7 changes: 7 additions & 0 deletions src/modules/flint/index.js
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
};
17 changes: 15 additions & 2 deletions src/modules/pages/components/DatastorePage/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { AdvancedSearch } from '../../../advanced';
import {
DatastoreNavigation,
DatastoreInfo,
FlintAlerts,
Landing
} from '../../../datastores';
import { Filters } from '../../../filters';
Expand All @@ -25,6 +24,7 @@ import { switchPrideToDatastore } from '../../../pride';
import { InstitutionSelect, InstitutionWrapper } from '../../../institution';
import { List } from '../../../lists';
import { setDocumentTitle } from '../../../a11y';
import { FlintAlerts } from '../../../flint';
import PropTypes from 'prop-types';
import { Icon } from '../../../reusable';

Expand Down Expand Up @@ -101,7 +101,20 @@ class DatastorePageContainer extends React.Component {
<>
<SearchBox />
<DatastoreNavigation />
<FlintAlerts />
<div
css={{
marginTop: '-0.75rem',
'.alert-inner': {
display: 'flex',
justifyContent: 'center'
},
':empty': {
display: 'none'
}
}}
>
<FlintAlerts />
</div>
<ConnectedSwitch>
<Route
path={match.url + '/record/:recordUid/get-this/:barcode'}
Expand Down

0 comments on commit d90dbb2

Please sign in to comment.