Skip to content

Commit 524d922

Browse files
committed
Allow 'Language genetic proximity map' tool for registered users
1 parent f5e7118 commit 524d922

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

src/pages/DistanceMap/index.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useContext, useEffect } from "react";
22
import { connect } from "react-redux";
3-
import { Label } from "semantic-ui-react";
3+
import { Message } from "semantic-ui-react";
44
import { graphql } from "@apollo/client/react/hoc";
55
import PropTypes from "prop-types";
66
import { compose } from "recompose";
@@ -117,15 +117,20 @@ const DistanceMapC = compose(
117117
graphql(allFieldQuery, { name: "allField" })
118118
)(DistanceMap);
119119

120-
const Wrapper = ({ user }) => {
120+
const Wrapper = ({ user, loading }) => {
121121
const getTranslation = useContext(TranslationContext);
122122

123-
if (!user || user.id !== 1) {
123+
if (loading) {
124+
return <Placeholder />;
125+
}
126+
127+
if (!user || !user.id) {
124128
return (
125-
<div style={{ marginTop: "1em" }}>
126-
<Label>
127-
{getTranslation("For the time being Distance Map functionality is available only for the administrator.")}
128-
</Label>
129+
<div className="background-content">
130+
<Message compact>
131+
<Message.Header>{getTranslation("Please sign in")}</Message.Header>
132+
<p>{getTranslation("Only registered users can work with distance map.")}</p>
133+
</Message>
129134
</div>
130135
);
131136
}

src/pages/DistanceMap/map.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { PureComponent } from "react";
22
import { connect } from "react-redux";
33
import { useLocation, useNavigate } from "react-router-dom";
4-
import { Button, Container, Label, Segment } from "semantic-ui-react";
4+
import { Button, Container, Segment, Message } from "semantic-ui-react";
55
import { gql } from "@apollo/client";
66
import { graphql, withApollo } from "@apollo/client/react/hoc";
77
import L from "leaflet";
@@ -202,20 +202,25 @@ class MapAreas extends PureComponent {
202202
}
203203

204204
render() {
205-
const { location, user } = this.props;
205+
const { location, user, loading } = this.props;
206206

207207
const { mainDictionary } = location.state;
208208

209209
if (!location.state) {
210210
return null;
211211
}
212212

213-
if (!user || user.id !== 1) {
213+
if (loading) {
214+
return <Placeholder />;
215+
}
216+
217+
if (!user || !user.id) {
214218
return (
215-
<div style={{ marginTop: "1em" }}>
216-
<Label>
217-
{this.context("For the time being Distance Map functionality is available only for the administrator.")}
218-
</Label>
219+
<div className="background-content">
220+
<Message compact>
221+
<Message.Header>{this.context("Please sign in")}</Message.Header>
222+
<p>{this.context("Only registered users can work with distance map.")}</p>
223+
</Message>
219224
</div>
220225
);
221226
}

src/pages/DistanceMap/selectorLangGroup.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useContext, useEffect, useState } from "react";
22
import { connect } from "react-redux";
33
import { Link, useLocation, useNavigate } from "react-router-dom";
4-
import { Button, Container, Label } from "semantic-ui-react";
4+
import { Button, Container, Message } from "semantic-ui-react";
55
import { withApollo } from "@apollo/client/react/hoc";
66
import { fromJS } from "immutable";
77
import PropTypes from "prop-types";
@@ -160,7 +160,7 @@ const SelectorLangGroup = ((props) => {
160160

161161
/* Initializing here due to eact-hooks/rules-of-hooks, exact same hook order. */
162162

163-
const { actions, dataForTree, client, mainGroupDictionaresAndLanguages, selected, user } = props;
163+
const { actions, dataForTree, client, mainGroupDictionaresAndLanguages, selected, user, loading } = props;
164164

165165
const [mainGroupDictsAndLangs, setMainGroupDictsAndLangs] = useState(mainGroupDictionaresAndLanguages);
166166
const [mainDictionary, setMainDictionary] = useState(null);
@@ -179,16 +179,21 @@ const SelectorLangGroup = ((props) => {
179179
return null;
180180
}
181181

182-
if (!user || user.id !== 1) {
182+
if (loading) {
183+
return <Placeholder />;
184+
}
185+
186+
if (!user || !user.id) {
183187
return (
184-
<div style={{ marginTop: "1em" }}>
185-
<Label>
186-
{getTranslation("For the time being Distance Map functionality is available only for the administrator.")}
187-
</Label>
188+
<div className="background-content">
189+
<Message compact>
190+
<Message.Header>{getTranslation("Please sign in")}</Message.Header>
191+
<p>{getTranslation("Only registered users can work with distance map.")}</p>
192+
</Message>
188193
</div>
189194
);
190195
}
191-
196+
192197
const { mainPerspectives } = location.state;
193198
let selectedLanguagesChecken = [];
194199
let rootLanguage = {};

src/pages/ToolsRoute/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function ToolsRoute(props) {
4242
<label className="card-item__label">{getTranslation("Library of linguistic maps")}</label>
4343
<img className="card-item__img" src={imageStorage} />
4444
</a>
45-
{props.user && props.user.id == 1 && (
45+
{props.user && props.user.id && (
4646
<Link className="card-item" to="/distance_map">
4747
<label className="card-item__label">{getTranslation("Language genetic proximity map")}</label>
4848
<img className="card-item__img card-item__img_distance-map" src={imageDistanceMap} />

0 commit comments

Comments
 (0)