Update more stuff #9

Merged
PouuleT merged 1 commits from updatePackages into master 2020-02-27 12:49:31 +00:00
6 changed files with 136 additions and 127 deletions

View File

@ -1,65 +1,52 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { Form, FormGroup, FormControl, FormLabel } from "react-bootstrap"; import { Form, FormGroup, FormControl, FormLabel } from "react-bootstrap";
class ExplorerOptions extends React.PureComponent { const ExplorerOptions = ({ display, params, options, type, history }) => {
constructor(props) { // Should this componennt be displayed
super(props); if (!display) {
this.handleSourceChange = this.handleSourceChange.bind(this); return null;
this.handleCategoryChange = this.handleCategoryChange.bind(this);
} }
handleSourceChange(event) {
let source = event.target.value;
let category = this.props.options.get(event.target.value).first();
this.props.history.push(
`/${this.props.type}/explore/${source}/${category}`
);
}
handleCategoryChange(event) {
let source = this.props.params.source;
let category = event.target.value;
this.props.history.push(
`/${this.props.type}/explore/${source}/${category}`
);
}
propsValid(props) {
if ( if (
!props.params || !params ||
!props.params.source || !params.source ||
!props.params.category || !params.category ||
props.params.source === "" || params.source === "" ||
props.params.category === "" params.category === ""
) { ) {
return false; return null;
} }
return true;
} const handleSourceChange = event => {
prettyName(name) { let source = event.target.value;
let category = options.get(event.target.value).first();
history.push(`/${type}/explore/${source}/${category}`);
};
const handleCategoryChange = event => {
let source = params.source;
let category = event.target.value;
history.push(`/${type}/explore/${source}/${category}`);
};
const prettyName = name => {
return name return name
.replace("_", " ") .replace("_", " ")
.split(" ") .split(" ")
.map(w => w[0].toUpperCase() + w.substr(1)) .map(w => w[0].toUpperCase() + w.substr(1))
.join(" "); .join(" ");
} };
render() {
// Should this componennt be displayed
if (!this.props.display) {
return null;
}
// Options are not yet fetched // Options are not yet fetched
if (this.props.options.size === 0) { if (options.size === 0) {
return null; return null;
} }
// Invalid props let source = params.source;
if (!this.propsValid(this.props)) { let category = params.category;
return; let categories = options.get(params.source);
}
let source = this.props.params.source;
let category = this.props.params.category;
let categories = this.props.options.get(this.props.params.source);
return ( return (
<div className="row"> <div className="row">
@ -72,16 +59,16 @@ class ExplorerOptions extends React.PureComponent {
<FormControl <FormControl
bsPrefix="form-control input-sm" bsPrefix="form-control input-sm"
as="select" as="select"
onChange={this.handleSourceChange} onChange={handleSourceChange}
value={source} value={source}
> >
{this.props.options.keySeq().map(function(source) { {options.keySeq().map(function(source) {
return ( return (
<option key={source} value={source}> <option key={source} value={source}>
{this.prettyName(source)} {prettyName(source)}
</option> </option>
); );
}, this)} })}
</FormControl> </FormControl>
</FormGroup> </FormGroup>
</div> </div>
@ -91,16 +78,16 @@ class ExplorerOptions extends React.PureComponent {
<FormControl <FormControl
bsPrefix="form-control input-sm" bsPrefix="form-control input-sm"
as="select" as="select"
onChange={this.handleCategoryChange} onChange={handleCategoryChange}
value={category} value={category}
> >
{categories.map(function(category) { {categories.map(function(category) {
return ( return (
<option key={category} value={category}> <option key={category} value={category}>
{this.prettyName(category)} {prettyName(category)}
</option> </option>
); );
}, this)} })}
</FormControl> </FormControl>
</FormGroup> </FormGroup>
</div> </div>
@ -109,7 +96,13 @@ class ExplorerOptions extends React.PureComponent {
</div> </div>
</div> </div>
); );
} };
} ExplorerOptions.propTypes = {
params: PropTypes.object,
history: PropTypes.object,
type: PropTypes.string,
options: PropTypes.object,
display: PropTypes.bool
};
export default withRouter(ExplorerOptions); export default withRouter(ExplorerOptions);

View File

@ -48,8 +48,8 @@ const UserEditConnect = ({
ev.preventDefault(); ev.preventDefault();
updateUser({ updateUser({
password: password, password: password,
password_confirm: passwordConfirm, password_confirm: passwordConfirm, // eslint-disable-line camelcase
polochon_id: id polochon_id: id // eslint-disable-line camelcase
}); });
}; };

View File

@ -13,20 +13,20 @@ const mapStateToProps = state => ({
const mapDispatchToProps = { userSignUp }; const mapDispatchToProps = { userSignUp };
const UserSignUp = props => { const UserSignUp = props => {
if (props.isLogged) {
return <Redirect to="/" />;
}
const [username, setUsername] = useState(""); const [username, setUsername] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [passwordConfirm, setPasswordConfirm] = useState(""); const [passwordConfirm, setPasswordConfirm] = useState("");
if (props.isLogged) {
return <Redirect to="/" />;
}
const handleSubmit = e => { const handleSubmit = e => {
e.preventDefault(); e.preventDefault();
props.userSignUp({ props.userSignUp({
username: username, username: username,
password: password, password: password,
password_confirm: passwordConfirm password_confirm: passwordConfirm // eslint-disable-line camelcase
}); });
}; };

View File

@ -31,7 +31,7 @@ const UserTokens = props => {
}; };
UserTokens.propTypes = { UserTokens.propTypes = {
tokens: PropTypes.instanceOf(List), tokens: PropTypes.instanceOf(List),
isLoading: PropTypes.bool.isRequired, isLoading: PropTypes.bool,
getUserTokens: PropTypes.func.isRequired, getUserTokens: PropTypes.func.isRequired,
deleteUserToken: PropTypes.func.isRequired deleteUserToken: PropTypes.func.isRequired
}; };
@ -89,14 +89,14 @@ Actions.propTypes = {
deleteToken: PropTypes.func.isRequired deleteToken: PropTypes.func.isRequired
}; };
const Logo = props => { const Logo = ({ ua, device, browser }) => {
var className; var className;
if (props.ua === "canape-cli") { if (ua === "canape-cli") {
className = "terminal"; className = "terminal";
} else if (props.device.type == "mobile") { } else if (device.type == "mobile") {
className = "mobile"; className = "mobile";
} else { } else {
switch (props.browser.name) { switch (browser.name) {
case "Chrome": case "Chrome":
case "chrome": case "chrome":
className = "chrome"; className = "chrome";
@ -117,42 +117,58 @@ const Logo = props => {
return <span className={`fa fa-${className}`}></span>; return <span className={`fa fa-${className}`}></span>;
}; };
Logo.propTypes = {
ua: PropTypes.string,
device: PropTypes.object,
browser: PropTypes.object
};
const OS = props => { const OS = ({ name, version }) => {
var osName = "-"; var osName = "-";
if (props.name !== undefined) { if (name !== undefined) {
osName = props.name; osName = name;
if (props.version !== undefined) { if (version !== undefined) {
osName += " " + props.version; osName += " " + version;
} }
} }
return <span> {osName}</span>; return <span> {osName}</span>;
}; };
OS.propTypes = {
name: PropTypes.string,
version: PropTypes.string
};
const Device = props => { const Device = ({ model }) => {
var deviceName = "-"; var deviceName = "-";
if (props.model !== undefined) { if (model !== undefined) {
deviceName = props.model; deviceName = model;
} }
return <span> {deviceName}</span>; return <span> {deviceName}</span>;
}; };
Device.propTypes = {
model: PropTypes.string
};
const Browser = props => { const Browser = ({ name, version }) => {
var browserName = "-"; var browserName = "-";
if (props.name !== undefined) { if (name !== undefined) {
browserName = props.name; browserName = name;
if (props.version !== undefined) { if (version !== undefined) {
browserName += " - " + props.version; browserName += " - " + version;
} }
} }
return <span> {browserName}</span>; return <span> {browserName}</span>;
}; };
Browser.propTypes = {
name: PropTypes.string,
version: PropTypes.string
};
export default connect(mapStateToProps, mapDispatchToProps)(UserTokens); export default connect(mapStateToProps, mapDispatchToProps)(UserTokens);

View File

@ -15,8 +15,8 @@ const handlers = {
return state.mergeDeep( return state.mergeDeep(
fromJS({ fromJS({
show: { show: {
tracked_season: action.payload.season, tracked_season: action.payload.season, // eslint-disable-line camelcase
tracked_episode: action.payload.episode tracked_episode: action.payload.episode // eslint-disable-line camelcase
} }
}) })
); );

View File

@ -82,13 +82,13 @@ const config = {
"apple-mobile-web-app-title": "Canapé" "apple-mobile-web-app-title": "Canapé"
}, },
name: "Canapé", name: "Canapé",
short_name: "Canapé", short_name: "Canapé", // eslint-disable-line camelcase
background_color: "#4e5d6c", background_color: "#4e5d6c", // eslint-disable-line camelcase
theme_color: "#4e5d6c", theme_color: "#4e5d6c", // eslint-disable-line camelcase
display: "standalone", display: "standalone",
orientation: "omit", orientation: "omit",
scope: "/", scope: "/",
start_url: "/", start_url: "/", // eslint-disable-line camelcase
icons: [ icons: [
{ {
src: path.resolve(__dirname, "img/android-chrome-512x512.png"), src: path.resolve(__dirname, "img/android-chrome-512x512.png"),