• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ProteinsWebTeam / interpro7-client / 10298555325

08 Aug 2024 08:22AM UTC coverage: 25.376% (+2.5%) from 22.889%
10298555325

Pull #641

github

web-flow
Merge 8b67ca91f into 9398226d6
Pull Request #641: Re-factory of the Search By Sequence area

521 of 2519 branches covered (20.68%)

Branch coverage included in aggregate %.

7 of 9 new or added lines in 4 files covered. (77.78%)

6 existing lines in 2 files now uncovered.

1131 of 3991 relevant lines covered (28.34%)

92.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

39.24
/src/pages/index.js
1
// @flow
2
import React, { PureComponent } from 'react';
3
import T from 'prop-types';
4
import { connect } from 'react-redux';
5
import { createSelector } from 'reselect';
6

7
import ErrorBoundary from 'wrappers/ErrorBoundary';
8
import Switch from 'components/generic/Switch';
9
import Redirect from 'components/generic/Redirect';
10
import loadable from 'higherOrder/loadable';
11

12
import BreadCrumbs from 'components/BreadCrumbs';
13
import Loading from 'components/SimpleCommonComponents/Loading';
14

15
import { stuckSelector } from 'reducers/ui/stuck';
16

17
import { foundationPartial } from 'styles/foundation';
18

19
import ebiGlobalStyles from 'ebi-framework/css/ebi-global.css';
20
import ipro from 'styles/interpro-new.css';
21
import style from './style.css';
22

23
const f = foundationPartial(ebiGlobalStyles, ipro, style);
1✔
24

25
// Main pages
26
const Home = loadable({
1✔
27
  loader: () =>
28
    import(
×
29
      /* webpackPreload: true */
30
      /* webpackChunkName: "home-page" */ './Home'
31
    ),
32
});
33
const Entry = loadable({
1✔
34
  loader: () => import(/* webpackChunkName: "entry-page" */ './Entry'),
×
35
});
36
const Protein = loadable({
1✔
37
  loader: () => import(/* webpackChunkName: "protein-page" */ './Protein'),
×
38
});
39
const Structure = loadable({
1✔
40
  loader: () => import(/* webpackChunkName: "structure-page" */ './Structure'),
×
41
});
42
const Taxonomy = loadable({
1✔
43
  // $FlowFixMe
44
  loader: () => import(/* webpackChunkName: "taxonomy-page" */ './Taxonomy'),
×
45
});
46
const Proteome = loadable({
1✔
47
  loader: () => import(/* webpackChunkName: "proteome-page" */ './Proteome'),
×
48
});
49
const EntrySet = loadable({
1✔
50
  // $FlowFixMe
51
  loader: () => import(/* webpackChunkName: "set-page" */ './Set'),
×
52
});
53

54
// Other
55
const Search = loadable({
1✔
56
  // $FlowFixMe
57
  loader: () => import(/* webpackChunkName: "search-page" */ './Search'),
×
58
});
59
const Jobs = loadable({
1✔
60
  // $FlowFixMe
UNCOV
61
  loader: () => import(/* webpackChunkName: "jobs-page" */ './Jobs'),
×
62
});
63

64
// Static pages
65
const Download = loadable({
1✔
66
  // $FlowFixMe
67
  loader: () => import(/* webpackChunkName: "about-page" */ './Download'),
×
68
});
69
const ReleaseNotes = loadable({
1✔
70
  loader: () => import(/* webpackChunkName: "about-page" */ './Release_notes'),
×
71
});
72
const About = loadable({
1✔
73
  loader: () => import(/* webpackChunkName: "about-page" */ './About'),
×
74
});
75
const Help = loadable({
1✔
76
  loader: () => import(/* webpackChunkName: "help-page" */ './Help'),
×
77
});
78
const Settings = loadable({
1✔
79
  loader: () => import(/* webpackChunkName: "settings-page" */ './Settings'),
×
80
});
81
const Contact = loadable({
1✔
82
  // $FlowFixMe
83
  loader: () => import(/* webpackChunkName: "contact-page" */ './Contact'),
×
84
});
85

86
const NotFound = loadable({
1✔
87
  loader: () =>
88
    import(/* webpackChunkName: "not-found-page" */ './error/NotFound'),
×
89
});
90
const FavouriteUpdates = loadable({
1✔
91
  loader: () => import(/* webpackChunkName: "fav-page" */ './FavouriteUpdates'),
×
92
});
93

94
const RedirectToBlog = ({
1✔
95
  customLocation: {
96
    description: { other },
97
  },
98
}) => {
99
  const href = 'https://proteinswebteam.github.io/interpro-blog/';
×
100
  const archive =
101
    'https://proteinswebteam.github.io/interpro-blog/2013/09/01/Previous-InterPro-protein-focus-articles/';
×
102
  if (other?.[0] === 'potm') {
×
103
    if ((other?.[1] || '').toLowerCase() === 'archive.html') {
×
104
      window.location.replace(archive);
×
105
      return null;
×
106
    }
107
    window.location.replace(`${href}/${other.join('/')}`);
×
108
  } else if ((other?.[2] || '').endsWith('.pdf')) {
×
109
    const parts = other[2].replace('.pdf', '').split('_');
×
110
    const path = `potm/20${parts[2]}_${parts[3]}/${other[2]}`;
×
111
    window.location.replace(`${href}/${path}`);
×
112
  }
113
  return null;
×
114
};
115
RedirectToBlog.propTypes = {
1✔
116
  customLocation: T.shape({
117
    description: T.shape({
118
      other: T.arrayOf(T.string),
119
    }),
120
  }),
121
};
122

123
const pages = new Map([
1✔
124
  // pages with data from API
125
  ['entry', Entry],
126
  ['protein', Protein],
127
  ['structure', Structure],
128
  ['taxonomy', Taxonomy],
129
  ['proteome', Proteome],
130
  ['set', EntrySet],
131
  // other
132
  ['search', Search],
133
  ['result', Jobs],
134
]);
135

136
// Everything which ends up in the 'other' array of the location description
137
const otherPages = new Map([
1✔
138
  // static pages
139
  ['release_notes', ReleaseNotes],
140
  ['download', Download],
141
  ['about', About],
142
  ['contact', Contact],
143
  ['help', Help],
144
  ['settings', Settings],
145
  ['fav-updates', FavouriteUpdates],
146
  ['potm', RedirectToBlog],
147
  ['downloads', RedirectToBlog],
148
  ['loading', Loading],
149
]);
150

151
/*:: type Props = {
152
  stuck: boolean,
153
  top: number,
154
}; */
155

156
const locationSelector2 = (customLocation) =>
1✔
157
  customLocation.description.main.key;
×
158
const locationSelectorForOther = (customLocation) =>
1✔
159
  customLocation.description.other[0];
×
160

161
class HomeOrOther extends PureComponent /*:: <Props> */ {
162
  render() {
163
    return (
×
164
      <Switch
165
        {...this.props}
166
        locationSelector={locationSelectorForOther}
167
        indexRoute={Home}
168
        childRoutes={otherPages}
169
        catchAll={NotFound}
170
      />
171
    );
172
  }
173
}
174

175
const locationSelectorForEntryDB = createSelector(
1✔
176
  (state) => state?.customLocation?.description?.entry?.db,
×
177
  (entryDB) => ({ entryDB }),
×
178
);
179

180
const TigrfamsRedirectConnected = ({ entryDB }) => {
1✔
181
  return entryDB === 'tigrfams' ? (
×
182
    <Redirect
183
      to={(customLocation) => ({
×
184
        ...customLocation,
185
        description: {
186
          ...customLocation.description,
187
          entry: { ...customLocation.description.entry, db: 'ncbifam' },
188
        },
189
      })}
190
    />
191
  ) : null;
192
};
193

194
const TigrfamsRedirect = connect(locationSelectorForEntryDB)(
1✔
195
  TigrfamsRedirectConnected,
196
);
197

198
export class Pages extends PureComponent /*:: <Props> */ {
199
  static propTypes = {
1✔
200
    stuck: T.bool.isRequired,
201
    top: T.number.isRequired,
202
  };
203

204
  render() {
205
    const { stuck } = this.props;
1✔
206
    return (
1✔
207
      <div className={f('main', { stuck })}>
208
        <div className={f('row', 'large-12', 'columns')}>
209
          <TigrfamsRedirect />
210
          <ErrorBoundary>
211
            <div className={f('row', 'large-12', 'columns', 'breadcrumb')}>
212
              <BreadCrumbs />
213
            </div>
214
          </ErrorBoundary>
215
          <ErrorBoundary>
216
            <Switch
217
              locationSelector={locationSelector2}
218
              indexRoute={HomeOrOther}
219
              childRoutes={pages}
220
              catchAll={NotFound}
221
            />
222
          </ErrorBoundary>
223
        </div>
224
      </div>
225
    );
226
  }
227
}
228

229
const mapStateToProps = createSelector(stuckSelector, (stuck) => ({ stuck }));
1✔
230

231
export default connect(mapStateToProps)(Pages);
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc