Skip to content
Snippets Groups Projects
Commit 54d49544 authored by Jure's avatar Jure
Browse files

style(client): fixing linting issues

parent 045ac0c2
No related branches found
No related tags found
No related merge requests found
......@@ -32,11 +32,13 @@ export function stripTypenames(obj) {
})
return obj
}
// Construct an ApolloClient. If a function is passed as the first argument,
// it will be called with the default client config as an argument, and should
// return the desired config.
const makeApolloClient = (makeConfig, connectToWebSocket) => {
const uploadLink = createUploadLink()
const authLink = setContext((_, { headers }) => {
const token = localStorage.getItem('token')
return {
......@@ -51,6 +53,7 @@ const makeApolloClient = (makeConfig, connectToWebSocket) => {
if (operation.variables) {
operation.variables = stripTypenames(operation.variables)
}
return forward(operation)
})
......@@ -58,6 +61,7 @@ const makeApolloClient = (makeConfig, connectToWebSocket) => {
if (connectToWebSocket) {
const wsProtocol = window.location.protocol === 'https:' ? 'wss' : 'ws'
const wsLink = new WebSocketLink({
uri: `${wsProtocol}://${window.location.host}/subscriptions`,
options: {
......@@ -65,6 +69,7 @@ const makeApolloClient = (makeConfig, connectToWebSocket) => {
connectionParams: () => ({ authToken: localStorage.getItem('token') }),
},
})
link = split(
({ query }) => {
const { kind, operation } = getMainDefinition(query)
......@@ -74,6 +79,7 @@ const makeApolloClient = (makeConfig, connectToWebSocket) => {
link,
)
}
const config = {
link,
cache: new InMemoryCache({
......@@ -87,7 +93,7 @@ const makeApolloClient = (makeConfig, connectToWebSocket) => {
read(existing, { cache, args, readField }) {
const currentRoles = currentRolesVar()
const currentId = readField('id')
const r = currentRoles.find(r => r.id === currentId)
const r = currentRoles.find(ro => ro.id === currentId)
return (r && r.roles) || []
},
},
......@@ -99,7 +105,7 @@ const makeApolloClient = (makeConfig, connectToWebSocket) => {
read(existing, { cache, args, readField }) {
const currentRoles = currentRolesVar()
const currentId = readField('id')
const r = currentRoles.find(r => r.id === currentId)
const r = currentRoles.find(ro => ro.id === currentId)
return (r && r.roles) || []
},
},
......@@ -108,6 +114,7 @@ const makeApolloClient = (makeConfig, connectToWebSocket) => {
},
}),
}
return new ApolloClient(makeConfig ? makeConfig(config) : config)
}
......
import VisibilitySensor from 'react-visibility-sensor'
import { Link } from 'react-router-dom'
import React from 'react'
// import PropTypes from 'prop-types'
import PropTypes from 'prop-types'
import { Spinner } from '../shared'
import { HasNextPage, NextPageButton } from './style'
......@@ -11,14 +11,16 @@ const NextPageButtonWrapper = props => {
fetchMore,
href,
children,
automatic = true,
topOffset = -250,
bottomOffset = -250,
automatic,
topOffset,
bottomOffset,
} = props
const onChange = isVisible => {
if (isFetchingMore || !isVisible) return undefined
return fetchMore()
}
return (
<HasNextPage
as={href ? Link : 'div'}
......@@ -54,14 +56,23 @@ const NextPageButtonWrapper = props => {
}
// TODO: Set default props
// NextPageButtonWrapper.propTypes = {
// isFetchingMore: PropTypes.bool,
// href: PropTypes.object,
// fetchMore: PropTypes.func.isRequired,
// children: PropTypes.string,
// automatic: PropTypes.bool,
// topOffset: PropTypes.number,
// bottomOffset: PropTypes.number,
// }
NextPageButtonWrapper.propTypes = {
isFetchingMore: PropTypes.bool,
href: PropTypes.string,
fetchMore: PropTypes.func.isRequired,
children: PropTypes.string,
automatic: PropTypes.bool,
topOffset: PropTypes.number,
bottomOffset: PropTypes.number,
}
NextPageButtonWrapper.defaultProps = {
isFetchingMore: false,
href: undefined,
children: undefined,
automatic: true,
topOffset: -250,
bottomOffset: -250,
}
export default NextPageButtonWrapper
......@@ -6,18 +6,21 @@ import currentRolesVar from '../shared/currentRolesVar'
const updateStuff = data => {
if (data?.currentUser) {
// eslint-disable-next-line no-underscore-dangle
return currentRolesVar(data.currentUser._currentRoles)
}
return null
}
const RolesUpdater = ({ children, history, match }) => {
const RolesUpdater = ({ children }) => {
// This updates the current roles app-wide using Apollo's makeVar
const { data, error, loading } = useQuery(GET_CURRENT_USER, {
pollInterval: 5000,
notifyOnNetworkStatusChange: true,
fetchPolicy: 'network-only',
// TODO: useCallback used because of bug: https://github.com/apollographql/apollo-client/issues/6301
onCompleted: useCallback(data => updateStuff(data), []),
onCompleted: useCallback(dataCompleted => updateStuff(dataCompleted), []),
})
if ((error && !error.networkError) || (!loading && !data?.currentUser)) {
......
import React from 'react'
import { Link } from '@pubsweet/ui'
import PropTypes from 'prop-types'
const projectUrl = ({ version, page, id }) => {
const projectUrl = (version, page, id) => {
const parts = []
if (version) {
......@@ -20,10 +21,23 @@ const projectUrl = ({ version, page, id }) => {
return parts.join('/')
}
const JournalLink = props => (
<Link className={props.className} to={projectUrl(props)}>
{props.children}
const JournalLink = ({ className, children, version, page, id }) => (
<Link className={className} to={projectUrl(version, page, id)}>
{children}
</Link>
)
JournalLink.propTypes = {
version: PropTypes.shape({
id: PropTypes.string,
}),
page: PropTypes.string,
id: PropTypes.string,
}
JournalLink.defaultProps = {
version: undefined,
page: undefined,
id: undefined,
}
export default JournalLink
......@@ -408,5 +408,5 @@
"description": "<p>Aperture is now accepting Research Object Submissions. Please fill out the form below to complete your submission.</p>",
"haspopup": "true",
"popuptitle": "By submitting the manuscript, you agree to the following statements.",
"popupdescription": "<p>The corresponding author confirms that all co-authors are included, and that everyone listed as a co-author agrees to that role and all the following requirements and acknowledgements.</p><p></p><p>The submission represents original work and that sources are given proper attribution. The journal employs CrossCheck to compare submissions against a large and growing database of published scholarly content. If in the judgment of a senior editor a submission is genuinely suspected of plagiarism, it will be returned to the author(s) with a request for explanation.</p><p></p><p>The research was conducted in accordance with ethical principles.</p><p></p><p>There is a Data Accessibility Statement, containing information about the location of open data and materials, in the manuscript.</p><p></p><p>A conflict of interest statement is present in the manuscript, even if to state no conflicts of interest.</p>"
}
"popupdescription": "<p>The corresponding author confirms that all co-authors are included, and that everyone listed as a co-author agrees to that role and all the following requirements and acknowledgements.</p><p></p><p>The submission represents original work and that sources are given proper attribution. The journal employs CrossCheck to compare submissions against a large and growing database of published scholarly content. If in the judgment of a senior editor a submission is genuinely suspected of plagiarism, it will be returned to the author(s) with a request for explanation.</p><p></p><p>The research was conducted in accordance with ethical principles.</p><p></p><p>There is a Data Accessibility Statement, containing information about the location of open data and materials, in the manuscript.</p><p>n</p><p>A conflict of interest statement is present in the manuscript, even if to state no conflicts of interest.</p>"
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment