mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-20 03:30:13 +02:00
Use library query-string to parse query parameters
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
"moment": "^2.22.2",
|
||||
"node-sass": "^4.9.3",
|
||||
"postcss-easy-import": "^3.0.0",
|
||||
"query-string": "5",
|
||||
"react": "^16.4.2",
|
||||
"react-diff-view": "^1.8.1",
|
||||
"react-dom": "^16.4.2",
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { ErrorNotification, Loading, Subtitle } from "@scm-manager/ui-components";
|
||||
import {
|
||||
ErrorNotification,
|
||||
Loading,
|
||||
Subtitle
|
||||
} from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
import BranchForm from "../components/BranchForm";
|
||||
import type { Repository, Branch } from "@scm-manager/ui-types";
|
||||
@@ -10,11 +14,14 @@ import {
|
||||
createBranch,
|
||||
createBranchReset,
|
||||
isCreateBranchPending,
|
||||
getCreateBranchFailure, isFetchBranchesPending, getFetchBranchesFailure
|
||||
getCreateBranchFailure,
|
||||
isFetchBranchesPending,
|
||||
getFetchBranchesFailure
|
||||
} from "../modules/branches";
|
||||
import type { History } from "history";
|
||||
import { connect } from "react-redux";
|
||||
import {withRouter} from "react-router-dom";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import queryString from "query-string";
|
||||
|
||||
type Props = {
|
||||
loading?: boolean,
|
||||
@@ -49,10 +56,9 @@ class CreateBranch extends React.Component<Props> {
|
||||
this.props.createBranch(branch, () => this.branchCreated(branch));
|
||||
};
|
||||
|
||||
matchesTransmittedName = (search: string) => {
|
||||
const regex = new RegExp("\\?name=.+");
|
||||
const match = search.match(regex);
|
||||
return match ? match[0].substring(6, 0): null;
|
||||
matchesTransmittedName = (url: string) => {
|
||||
const params = queryString.parse(url);
|
||||
return params.name;
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -62,8 +68,8 @@ class CreateBranch extends React.Component<Props> {
|
||||
return <ErrorNotification error={error} />;
|
||||
}
|
||||
|
||||
if(!branches) {
|
||||
return <Loading/>;
|
||||
if (!branches) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -101,8 +107,10 @@ const mapDispatchToProps = dispatch => {
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const { repository } = ownProps;
|
||||
const loading = isFetchBranchesPending(state, repository) || isCreateBranchPending(state);
|
||||
const error = getFetchBranchesFailure(state, repository) || getCreateBranchFailure(state);
|
||||
const loading =
|
||||
isFetchBranchesPending(state, repository) || isCreateBranchPending(state);
|
||||
const error =
|
||||
getFetchBranchesFailure(state, repository) || getCreateBranchFailure(state);
|
||||
const branches = getBranches(state, repository);
|
||||
return {
|
||||
repository,
|
||||
@@ -112,7 +120,9 @@ const mapStateToProps = (state, ownProps) => {
|
||||
};
|
||||
};
|
||||
|
||||
export default withRouter(connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(translate("repos")(CreateBranch)));
|
||||
export default withRouter(
|
||||
connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(translate("repos")(CreateBranch))
|
||||
);
|
||||
|
||||
@@ -701,7 +701,6 @@
|
||||
"@scm-manager/ui-bundler@^0.0.27":
|
||||
version "0.0.27"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.27.tgz#3ed2c7826780b9a1a9ea90464332640cfb5d54b5"
|
||||
integrity sha512-cBU1xq6gDy1Vw9AGOzsR763+JmBeraTaC/KQfxT3I6XyZJ2brIfG1m5QYcAcHWvDxq3mYMogpI5rfShw14L4/w==
|
||||
dependencies:
|
||||
"@babel/core" "^7.0.0"
|
||||
"@babel/plugin-proposal-class-properties" "^7.0.0"
|
||||
@@ -6832,6 +6831,14 @@ qs@~6.5.1, qs@~6.5.2:
|
||||
version "6.5.2"
|
||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
|
||||
|
||||
query-string@5:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb"
|
||||
dependencies:
|
||||
decode-uri-component "^0.2.0"
|
||||
object-assign "^4.1.0"
|
||||
strict-uri-encode "^1.0.0"
|
||||
|
||||
querystring-es3@~0.2.0:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
|
||||
@@ -7991,6 +7998,10 @@ stream-throttle@^0.1.3:
|
||||
commander "^2.2.0"
|
||||
limiter "^1.0.5"
|
||||
|
||||
strict-uri-encode@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
|
||||
|
||||
string-length@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed"
|
||||
|
||||
Reference in New Issue
Block a user