mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Merged 2.0.0-m3
This commit is contained in:
@@ -398,6 +398,11 @@ public final class LogCommandBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogCommandBuilder setAncestorChangeset(String ancestorChangeset) {
|
||||
request.setAncestorChangeset(ancestorChangeset);
|
||||
return this;
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -109,7 +109,10 @@ public final class DiffCommandRequest extends FileBaseCommandRequest
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
public void setAncestorChangeset(String ancestorChangeset) {
|
||||
this.ancestorChangeset = ancestorChangeset;
|
||||
}
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return the output format of the diff command.
|
||||
@@ -124,8 +127,13 @@ public final class DiffCommandRequest extends FileBaseCommandRequest
|
||||
return format;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
public String getAncestorChangeset() {
|
||||
return ancestorChangeset;
|
||||
}
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** diff format */
|
||||
private DiffFormat format = DiffFormat.NATIVE;
|
||||
|
||||
private String ancestorChangeset;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,8 @@ public final class LogCommandRequest implements Serializable, Resetable
|
||||
&& Objects.equal(pagingStart, other.pagingStart)
|
||||
&& Objects.equal(pagingLimit, other.pagingLimit)
|
||||
&& Objects.equal(path, other.path)
|
||||
&& Objects.equal(branch, other.branch);
|
||||
&& Objects.equal(branch, other.branch)
|
||||
&& Objects.equal(ancestorChangeset, other.ancestorChangeset);
|
||||
//J+
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ public final class LogCommandRequest implements Serializable, Resetable
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(startChangeset, endChangeset, pagingStart,
|
||||
pagingLimit, path, branch);
|
||||
pagingLimit, path, branch, ancestorChangeset);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,6 +115,7 @@ public final class LogCommandRequest implements Serializable, Resetable
|
||||
pagingLimit = 20;
|
||||
path = null;
|
||||
branch = null;
|
||||
ancestorChangeset = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,6 +135,7 @@ public final class LogCommandRequest implements Serializable, Resetable
|
||||
.add("pagingLimit", pagingLimit)
|
||||
.add("path", path)
|
||||
.add("branch", branch)
|
||||
.add("ancestorChangeset", ancestorChangeset)
|
||||
.toString();
|
||||
//J+
|
||||
}
|
||||
@@ -205,6 +208,10 @@ public final class LogCommandRequest implements Serializable, Resetable
|
||||
this.startChangeset = startChangeset;
|
||||
}
|
||||
|
||||
public void setAncestorChangeset(String ancestorChangeset) {
|
||||
this.ancestorChangeset = ancestorChangeset;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -284,6 +291,10 @@ public final class LogCommandRequest implements Serializable, Resetable
|
||||
return pagingLimit < 0;
|
||||
}
|
||||
|
||||
public String getAncestorChangeset() {
|
||||
return ancestorChangeset;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@@ -303,4 +314,6 @@ public final class LogCommandRequest implements Serializable, Resetable
|
||||
|
||||
/** Field description */
|
||||
private String startChangeset;
|
||||
|
||||
private String ancestorChangeset;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scm-manager/scm-git-plugin",
|
||||
"license" : "BSD-3-Clause",
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "src/main/js/index.js",
|
||||
"scripts": {
|
||||
"build": "ui-bundler plugin",
|
||||
@@ -9,9 +9,9 @@
|
||||
"flow": "flow check"
|
||||
},
|
||||
"dependencies": {
|
||||
"@scm-manager/ui-extensions": "^0.0.7"
|
||||
"@scm-manager/ui-extensions": "^0.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scm-manager/ui-bundler": "^0.0.19"
|
||||
"@scm-manager/ui-bundler": "^0.0.21"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,17 +116,17 @@ public class GitRepositoryHandler
|
||||
public void init(SCMContextProvider context)
|
||||
{
|
||||
super.init(context);
|
||||
scheduleGc();
|
||||
scheduleGc(getConfig().getGcExpression());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(GitConfig config)
|
||||
{
|
||||
scheduleGc(config.getGcExpression());
|
||||
super.setConfig(config);
|
||||
scheduleGc();
|
||||
}
|
||||
|
||||
private void scheduleGc()
|
||||
private void scheduleGc(String expression)
|
||||
{
|
||||
synchronized (LOCK){
|
||||
if ( task != null ){
|
||||
@@ -134,11 +134,10 @@ public class GitRepositoryHandler
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
String exp = getConfig().getGcExpression();
|
||||
if (!Strings.isNullOrEmpty(exp))
|
||||
if (!Strings.isNullOrEmpty(expression))
|
||||
{
|
||||
logger.info("schedule git gc task with expression {}", exp);
|
||||
task = scheduler.schedule(exp, GitGcTask.class);
|
||||
logger.info("schedule git gc task with expression {}", expression);
|
||||
task = scheduler.schedule(expression, GitGcTask.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.revwalk.filter.RevFilter;
|
||||
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
|
||||
import org.eclipse.jgit.transport.FetchResult;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
@@ -716,6 +717,18 @@ public final class GitUtil
|
||||
return (id != null) &&!id.equals(ObjectId.zeroId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the first common ancestor of two revisions, aka merge base.
|
||||
*/
|
||||
public static ObjectId computeCommonAncestor(org.eclipse.jgit.lib.Repository repository, ObjectId revision1, ObjectId revision2) throws IOException {
|
||||
try (RevWalk mergeBaseWalk = new RevWalk(repository)) {
|
||||
mergeBaseWalk.setRevFilter(RevFilter.MERGE_BASE);
|
||||
mergeBaseWalk.markStart(mergeBaseWalk.lookupCommit(revision1));
|
||||
mergeBaseWalk.markStart(mergeBaseWalk.parseCommit(revision2));
|
||||
return mergeBaseWalk.next().getId();
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,27 +34,25 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.eclipse.jgit.diff.DiffEntry;
|
||||
import org.eclipse.jgit.diff.DiffFormatter;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevTree;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.treewalk.EmptyTreeIterator;
|
||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
import org.eclipse.jgit.treewalk.filter.PathFilter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.GitUtil;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -107,7 +105,8 @@ public class GitDiffCommand extends AbstractGitCommand implements DiffCommand
|
||||
|
||||
walk = new RevWalk(gr);
|
||||
|
||||
RevCommit commit = walk.parseCommit(gr.resolve(request.getRevision()));
|
||||
ObjectId revision = gr.resolve(request.getRevision());
|
||||
RevCommit commit = walk.parseCommit(revision);
|
||||
|
||||
walk.markStart(commit);
|
||||
commit = walk.next();
|
||||
@@ -120,7 +119,15 @@ public class GitDiffCommand extends AbstractGitCommand implements DiffCommand
|
||||
treeWalk.setFilter(PathFilter.create(request.getPath()));
|
||||
}
|
||||
|
||||
if (commit.getParentCount() > 0)
|
||||
|
||||
if (!Strings.isNullOrEmpty(request.getAncestorChangeset()))
|
||||
{
|
||||
ObjectId otherRevision = gr.resolve(request.getAncestorChangeset());
|
||||
ObjectId ancestorId = computeCommonAncestor(gr, revision, otherRevision);
|
||||
RevTree tree = walk.parseCommit(ancestorId).getTree();
|
||||
treeWalk.addTree(tree);
|
||||
}
|
||||
else if (commit.getParentCount() > 0)
|
||||
{
|
||||
RevTree tree = commit.getParent(0).getTree();
|
||||
|
||||
@@ -156,7 +163,6 @@ public class GitDiffCommand extends AbstractGitCommand implements DiffCommand
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
// TODO throw exception
|
||||
logger.error("could not create diff", ex);
|
||||
}
|
||||
@@ -167,4 +173,9 @@ public class GitDiffCommand extends AbstractGitCommand implements DiffCommand
|
||||
GitUtil.release(formatter);
|
||||
}
|
||||
}
|
||||
|
||||
private ObjectId computeCommonAncestor(org.eclipse.jgit.lib.Repository repository, ObjectId revision1, ObjectId revision2) throws IOException {
|
||||
return GitUtil.computeCommonAncestor(repository, revision1, revision2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.revwalk.filter.RevFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.AndTreeFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.PathFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
||||
@@ -198,6 +199,14 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
endId = repository.resolve(request.getEndChangeset());
|
||||
}
|
||||
|
||||
Ref branch = getBranchOrDefault(repository,request.getBranch());
|
||||
|
||||
ObjectId ancestorId = null;
|
||||
|
||||
if (!Strings.isNullOrEmpty(request.getAncestorChangeset())) {
|
||||
ancestorId = computeCommonAncestor(request, repository, startId, branch);
|
||||
}
|
||||
|
||||
revWalk = new RevWalk(repository);
|
||||
|
||||
converter = new GitChangesetConverter(repository, revWalk);
|
||||
@@ -208,8 +217,6 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
PathFilter.create(request.getPath()), TreeFilter.ANY_DIFF));
|
||||
}
|
||||
|
||||
Ref branch = getBranchOrDefault(repository,request.getBranch());
|
||||
|
||||
if (branch != null) {
|
||||
if (startId != null) {
|
||||
revWalk.markStart(revWalk.lookupCommit(startId));
|
||||
@@ -217,11 +224,16 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
revWalk.markStart(revWalk.lookupCommit(branch.getObjectId()));
|
||||
}
|
||||
|
||||
|
||||
Iterator<RevCommit> iterator = revWalk.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
RevCommit commit = iterator.next();
|
||||
|
||||
if (commit.getId().equals(ancestorId)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((counter >= start)
|
||||
&& ((limit < 0) || (counter < start + limit))) {
|
||||
changesetList.add(converter.createChangeset(commit));
|
||||
@@ -229,7 +241,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
|
||||
counter++;
|
||||
|
||||
if ((endId != null) && commit.getId().equals(endId)) {
|
||||
if (commit.getId().equals(endId)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -263,4 +275,17 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
|
||||
return changesets;
|
||||
}
|
||||
|
||||
private ObjectId computeCommonAncestor(LogCommandRequest request, Repository repository, ObjectId startId, Ref branch) throws IOException {
|
||||
try (RevWalk mergeBaseWalk = new RevWalk(repository)) {
|
||||
mergeBaseWalk.setRevFilter(RevFilter.MERGE_BASE);
|
||||
if (startId != null) {
|
||||
mergeBaseWalk.markStart(mergeBaseWalk.lookupCommit(startId));
|
||||
} else {
|
||||
mergeBaseWalk.markStart(mergeBaseWalk.lookupCommit(branch.getObjectId()));
|
||||
}
|
||||
mergeBaseWalk.markStart(mergeBaseWalk.parseCommit(repository.resolve(request.getAncestorChangeset())));
|
||||
return mergeBaseWalk.next().getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import type { Links } from "@scm-manager/ui-types";
|
||||
|
||||
import { InputField, Checkbox } from "@scm-manager/ui-components";
|
||||
|
||||
type Configuration = {
|
||||
repositoryDirectory?: string,
|
||||
gcExpression?: string,
|
||||
disabled: boolean,
|
||||
_links: Links
|
||||
}
|
||||
|
||||
type Props = {
|
||||
initialConfiguration: Configuration,
|
||||
readOnly: boolean,
|
||||
|
||||
onConfigurationChange: (Configuration, boolean) => void,
|
||||
|
||||
// context props
|
||||
t: (string) => string
|
||||
}
|
||||
|
||||
type State = Configuration & {
|
||||
|
||||
}
|
||||
|
||||
class GitConfigurationForm extends React.Component<Props, State> {
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = { ...props.initialConfiguration };
|
||||
}
|
||||
|
||||
isValid = () => {
|
||||
return !!this.state.repositoryDirectory;
|
||||
};
|
||||
|
||||
handleChange = (value: any, name: string) => {
|
||||
this.setState({
|
||||
[name]: value
|
||||
}, () => this.props.onConfigurationChange(this.state, this.isValid()));
|
||||
};
|
||||
|
||||
render() {
|
||||
const { repositoryDirectory, gcExpression, disabled } = this.state;
|
||||
const { readOnly, t } = this.props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<InputField name="repositoryDirectory"
|
||||
label={t("scm-git-plugin.config.directory")}
|
||||
helpText={t("scm-git-plugin.config.directoryHelpText")}
|
||||
value={repositoryDirectory}
|
||||
onChange={this.handleChange}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
<InputField name="gcExpression"
|
||||
label={t("scm-git-plugin.config.gcExpression")}
|
||||
helpText={t("scm-git-plugin.config.gcExpressionHelpText")}
|
||||
value={gcExpression}
|
||||
onChange={this.handleChange}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
<Checkbox name="disabled"
|
||||
label={t("scm-git-plugin.config.disabled")}
|
||||
helpText={t("scm-git-plugin.config.disabledHelpText")}
|
||||
checked={disabled}
|
||||
onChange={this.handleChange}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default translate("plugins")(GitConfigurationForm);
|
||||
@@ -0,0 +1,32 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { Title, GlobalConfiguration } from "@scm-manager/ui-components";
|
||||
import GitConfigurationForm from "./GitConfigurationForm";
|
||||
|
||||
type Props = {
|
||||
link: string,
|
||||
|
||||
t: (string) => string
|
||||
};
|
||||
|
||||
class GitGlobalConfiguration extends React.Component<Props> {
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { link, t } = this.props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Title title={t("scm-git-plugin.config.title")}/>
|
||||
<GlobalConfiguration link={link} render={props => <GitConfigurationForm {...props} />}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default translate("plugins")(GitGlobalConfiguration);
|
||||
@@ -3,9 +3,18 @@ import { binder } from "@scm-manager/ui-extensions";
|
||||
import ProtocolInformation from "./ProtocolInformation";
|
||||
import GitAvatar from "./GitAvatar";
|
||||
|
||||
import { ConfigurationBinder as cfgBinder } from "@scm-manager/ui-components";
|
||||
import GitGlobalConfiguration from "./GitGlobalConfiguration";
|
||||
|
||||
// repository
|
||||
|
||||
const gitPredicate = (props: Object) => {
|
||||
return props.repository && props.repository.type === "git";
|
||||
};
|
||||
|
||||
binder.bind("repos.repository-details.information", ProtocolInformation, gitPredicate);
|
||||
binder.bind("repos.repository-avatar", GitAvatar, gitPredicate);
|
||||
|
||||
// global config
|
||||
|
||||
cfgBinder.bindGlobal("/git", "scm-git-plugin.config.link", "gitConfig", GitGlobalConfiguration);
|
||||
|
||||
@@ -4,6 +4,17 @@
|
||||
"clone" : "Clone the repository",
|
||||
"create" : "Create a new repository",
|
||||
"replace" : "Push an existing repository"
|
||||
},
|
||||
"config": {
|
||||
"link": "Git",
|
||||
"title": "Git Configuration",
|
||||
"directory": "Repository Directory",
|
||||
"directoryHelpText": "Location of the Git repositories.",
|
||||
"gcExpression": "GC Cron Expression",
|
||||
"gcExpressionHelpText": "Use Quartz Cron Expressions (SECOND MINUTE HOUR DAYOFMONTH MONTH DAYOFWEEK) to run git gc in intervals.",
|
||||
"disabled": "Disabled",
|
||||
"disabledHelpText": "Enable or disable the Git plugin",
|
||||
"submit": "Submit"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class GitDiffCommandTest extends AbstractGitCommandTestBase {
|
||||
|
||||
public static final String DIFF_FILE_A = "diff --git a/a.txt b/a.txt\n" +
|
||||
"index 7898192..1dc60c7 100644\n" +
|
||||
"--- a/a.txt\n" +
|
||||
"+++ b/a.txt\n" +
|
||||
"@@ -1 +1 @@\n" +
|
||||
"-a\n" +
|
||||
"+a and b\n";
|
||||
public static final String DIFF_FILE_B = "diff --git a/b.txt b/b.txt\n" +
|
||||
"deleted file mode 100644\n" +
|
||||
"index 6178079..0000000\n" +
|
||||
"--- a/b.txt\n" +
|
||||
"+++ /dev/null\n" +
|
||||
"@@ -1 +0,0 @@\n" +
|
||||
"-b\n";
|
||||
public static final String DIFF_FILE_A_MULTIPLE_REVISIONS = "diff --git a/a.txt b/a.txt\n" +
|
||||
"index 7898192..2f8bc28 100644\n" +
|
||||
"--- a/a.txt\n" +
|
||||
"+++ b/a.txt\n" +
|
||||
"@@ -1 +1,2 @@\n" +
|
||||
" a\n" +
|
||||
"+line for blame\n";
|
||||
public static final String DIFF_FILE_F_MULTIPLE_REVISIONS = "diff --git a/f.txt b/f.txt\n" +
|
||||
"new file mode 100644\n" +
|
||||
"index 0000000..6a69f92\n" +
|
||||
"--- /dev/null\n" +
|
||||
"+++ b/f.txt\n" +
|
||||
"@@ -0,0 +1 @@\n" +
|
||||
"+f\n";
|
||||
|
||||
@Test
|
||||
public void diffForOneRevisionShouldCreateDiff() {
|
||||
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
|
||||
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
|
||||
diffCommandRequest.setRevision("3f76a12f08a6ba0dc988c68b7f0b2cd190efc3c4");
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
||||
assertEquals(DIFF_FILE_A + DIFF_FILE_B, output.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffForOneBranchShouldCreateDiff() {
|
||||
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
|
||||
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
|
||||
diffCommandRequest.setRevision("test-branch");
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
||||
assertEquals(DIFF_FILE_A + DIFF_FILE_B, output.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffForPathShouldCreateLimitedDiff() {
|
||||
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
|
||||
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
|
||||
diffCommandRequest.setRevision("test-branch");
|
||||
diffCommandRequest.setPath("a.txt");
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
||||
assertEquals(DIFF_FILE_A, output.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffBetweenTwoBranchesShouldCreateDiff() {
|
||||
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
|
||||
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
|
||||
diffCommandRequest.setRevision("master");
|
||||
diffCommandRequest.setAncestorChangeset("test-branch");
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
||||
assertEquals(DIFF_FILE_A_MULTIPLE_REVISIONS + DIFF_FILE_F_MULTIPLE_REVISIONS, output.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffBetweenTwoBranchesForPathShouldCreateLimitedDiff() {
|
||||
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
|
||||
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
|
||||
diffCommandRequest.setRevision("master");
|
||||
diffCommandRequest.setAncestorChangeset("test-branch");
|
||||
diffCommandRequest.setPath("a.txt");
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
||||
assertEquals(DIFF_FILE_A_MULTIPLE_REVISIONS, output.toString());
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
* Tests log command with the usage of a default branch.
|
||||
*/
|
||||
@Test
|
||||
public void testGetDefaultBranch() throws Exception {
|
||||
public void testGetDefaultBranch() {
|
||||
// without default branch, the repository head should be used
|
||||
ChangesetPagingResult result = createCommand().getChangesets(new LogCommandRequest());
|
||||
|
||||
@@ -92,7 +92,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAll() throws Exception
|
||||
public void testGetAll()
|
||||
{
|
||||
ChangesetPagingResult result =
|
||||
createCommand().getChangesets(new LogCommandRequest());
|
||||
@@ -103,7 +103,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllByPath() throws Exception
|
||||
public void testGetAllByPath()
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
@@ -119,7 +119,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllWithLimit() throws Exception
|
||||
public void testGetAllWithLimit()
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
@@ -143,7 +143,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllWithPaging() throws Exception
|
||||
public void testGetAllWithPaging()
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
@@ -194,7 +194,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRange() throws Exception
|
||||
public void testGetRange()
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
@@ -216,6 +216,26 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
assertEquals("435df2f061add3589cb326cc64be9b9c3897ceca", c2.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAncestor()
|
||||
{
|
||||
LogCommandRequest request = new LogCommandRequest();
|
||||
|
||||
request.setBranch("test-branch");
|
||||
request.setAncestorChangeset("master");
|
||||
|
||||
ChangesetPagingResult result = createCommand().getChangesets(request);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.getTotal());
|
||||
assertEquals(1, result.getChangesets().size());
|
||||
|
||||
Changeset c = result.getChangesets().get(0);
|
||||
|
||||
assertNotNull(c);
|
||||
assertEquals("3f76a12f08a6ba0dc988c68b7f0b2cd190efc3c4", c.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindDefaultBranchFromHEAD() throws Exception {
|
||||
setRepositoryHeadReference("ref: refs/heads/test-branch");
|
||||
|
||||
@@ -707,9 +707,9 @@
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85"
|
||||
|
||||
"@scm-manager/ui-bundler@^0.0.19":
|
||||
version "0.0.19"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae"
|
||||
"@scm-manager/ui-bundler@^0.0.21":
|
||||
version "0.0.21"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.21.tgz#f8b5fa355415cc67b8aaf8744e1701a299dff647"
|
||||
dependencies:
|
||||
"@babel/core" "^7.0.0"
|
||||
"@babel/plugin-proposal-class-properties" "^7.0.0"
|
||||
@@ -747,9 +747,9 @@
|
||||
vinyl-source-stream "^2.0.0"
|
||||
watchify "^3.11.0"
|
||||
|
||||
"@scm-manager/ui-extensions@^0.0.7":
|
||||
version "0.0.7"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-extensions/-/ui-extensions-0.0.7.tgz#a0a657a1410b78838ba0b36096ef631dca7fe27e"
|
||||
"@scm-manager/ui-extensions@^0.1.1":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-extensions/-/ui-extensions-0.1.1.tgz#966e62d89981e92a14adf7e674e646e76de96d45"
|
||||
dependencies:
|
||||
react "^16.4.2"
|
||||
react-dom "^16.4.2"
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
"build": "ui-bundler plugin"
|
||||
},
|
||||
"dependencies": {
|
||||
"@scm-manager/ui-extensions": "^0.0.7"
|
||||
"@scm-manager/ui-extensions": "^0.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scm-manager/ui-bundler": "^0.0.19"
|
||||
"@scm-manager/ui-bundler": "^0.0.21"
|
||||
}
|
||||
}
|
||||
|
||||
113
scm-plugins/scm-hg-plugin/src/main/js/HgConfigurationForm.js
Normal file
113
scm-plugins/scm-hg-plugin/src/main/js/HgConfigurationForm.js
Normal file
@@ -0,0 +1,113 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import type { Links } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
import { InputField, Checkbox } from "@scm-manager/ui-components";
|
||||
|
||||
type Configuration = {
|
||||
"hgBinary": string,
|
||||
"pythonBinary": string,
|
||||
"pythonPath"?: string,
|
||||
"repositoryDirectory": string,
|
||||
"encoding": string,
|
||||
"useOptimizedBytecode": boolean,
|
||||
"showRevisionInId": boolean,
|
||||
"disabled": boolean,
|
||||
"_links": Links
|
||||
};
|
||||
|
||||
type Props = {
|
||||
initialConfiguration: Configuration,
|
||||
readOnly: boolean,
|
||||
|
||||
onConfigurationChange: (Configuration, boolean) => void,
|
||||
|
||||
// context props
|
||||
t: (string) => string
|
||||
}
|
||||
|
||||
type State = Configuration & {
|
||||
validationErrors: string[]
|
||||
};
|
||||
|
||||
class HgConfigurationForm extends React.Component<Props, State> {
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = { ...props.initialConfiguration, validationErrors: [] };
|
||||
}
|
||||
|
||||
updateValidationStatus = () => {
|
||||
const requiredFields = [
|
||||
"hgBinary", "pythonBinary", "repositoryDirectory", "encoding"
|
||||
];
|
||||
|
||||
const validationErrors = [];
|
||||
for (let field of requiredFields) {
|
||||
if (!this.state[field]) {
|
||||
validationErrors.push( field );
|
||||
}
|
||||
}
|
||||
|
||||
this.setState({
|
||||
validationErrors
|
||||
});
|
||||
|
||||
return validationErrors.length === 0;
|
||||
};
|
||||
|
||||
|
||||
hasValidationError = (name: string) => {
|
||||
return this.state.validationErrors.indexOf(name) >= 0;
|
||||
};
|
||||
|
||||
handleChange = (value: any, name: string) => {
|
||||
this.setState({
|
||||
[name]: value
|
||||
}, () => this.props.onConfigurationChange(this.state, this.updateValidationStatus()));
|
||||
};
|
||||
|
||||
inputField = (name: string) => {
|
||||
const { readOnly, t } = this.props;
|
||||
return <InputField
|
||||
name={ name }
|
||||
label={t("scm-hg-plugin.config." + name)}
|
||||
helpText={t("scm-hg-plugin.config." + name + "HelpText")}
|
||||
value={this.state[name]}
|
||||
onChange={this.handleChange}
|
||||
validationError={this.hasValidationError(name)}
|
||||
errorMessage={t("scm-hg-plugin.config.required")}
|
||||
disabled={readOnly}
|
||||
/>;
|
||||
};
|
||||
|
||||
checkbox = (name: string) => {
|
||||
const { readOnly, t } = this.props;
|
||||
return <Checkbox
|
||||
name={ name }
|
||||
label={t("scm-hg-plugin.config." + name)}
|
||||
helpText={t("scm-hg-plugin.config." + name + "HelpText")}
|
||||
checked={this.state[name]}
|
||||
onChange={this.handleChange}
|
||||
disabled={readOnly}
|
||||
/>;
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
{this.inputField("hgBinary")}
|
||||
{this.inputField("pythonBinary")}
|
||||
{this.inputField("pythonPath")}
|
||||
{this.inputField("repositoryDirectory")}
|
||||
{this.inputField("encoding")}
|
||||
{this.checkbox("useOptimizedBytecode")}
|
||||
{this.checkbox("showRevisionInId")}
|
||||
{this.checkbox("disabled")}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default translate("plugins")(HgConfigurationForm);
|
||||
@@ -0,0 +1,28 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { Title, GlobalConfiguration } from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
import HgConfigurationForm from "./HgConfigurationForm";
|
||||
|
||||
type Props = {
|
||||
link: string,
|
||||
|
||||
// context props
|
||||
t: (string) => string
|
||||
}
|
||||
|
||||
class HgGlobalConfiguration extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const { link, t } = this.props;
|
||||
return (
|
||||
<div>
|
||||
<Title title={t("scm-hg-plugin.config.title")}/>
|
||||
<GlobalConfiguration link={link} render={props => <HgConfigurationForm {...props} />}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default translate("plugins")(HgGlobalConfiguration);
|
||||
@@ -2,6 +2,8 @@
|
||||
import { binder } from "@scm-manager/ui-extensions";
|
||||
import ProtocolInformation from "./ProtocolInformation";
|
||||
import HgAvatar from "./HgAvatar";
|
||||
import { ConfigurationBinder as cfgBinder } from "@scm-manager/ui-components";
|
||||
import HgGlobalConfiguration from "./HgGlobalConfiguration";
|
||||
|
||||
const hgPredicate = (props: Object) => {
|
||||
return props.repository && props.repository.type === "hg";
|
||||
@@ -9,3 +11,7 @@ const hgPredicate = (props: Object) => {
|
||||
|
||||
binder.bind("repos.repository-details.information", ProtocolInformation, hgPredicate);
|
||||
binder.bind("repos.repository-avatar", HgAvatar, hgPredicate);
|
||||
|
||||
// bind global configuration
|
||||
|
||||
cfgBinder.bindGlobal("/hg", "scm-hg-plugin.config.link", "hgConfig", HgGlobalConfiguration);
|
||||
|
||||
@@ -4,6 +4,27 @@
|
||||
"clone" : "Clone the repository",
|
||||
"create" : "Create a new repository",
|
||||
"replace" : "Push an existing repository"
|
||||
},
|
||||
"config": {
|
||||
"link": "Mercurial",
|
||||
"title": "Mercurial Configuration",
|
||||
"hgBinary": "HG Binary",
|
||||
"hgBinaryHelpText": "Location of Mercurial binary.",
|
||||
"pythonBinary": "Python Binary",
|
||||
"pythonBinaryHelpText": "Location of Python binary.",
|
||||
"pythonPath": "Python Module Search Path",
|
||||
"pythonPathHelpText": "Python Module Search Path (PYTHONPATH).",
|
||||
"repositoryDirectory": "Repository directory",
|
||||
"repositoryDirectoryHelpText": "Location of Mercurial repositories.",
|
||||
"encoding": "Encoding",
|
||||
"encodingHelpText": "Repository Encoding.",
|
||||
"useOptimizedBytecode": "Optimized Bytecode (.pyo)",
|
||||
"useOptimizedBytecodeHelpText": "Use the Python '-O' switch.",
|
||||
"showRevisionInId": "Show Revision",
|
||||
"showRevisionInIdHelpText": "Show revision as part of the node id.",
|
||||
"disabled": "Disabled",
|
||||
"disabledHelpText": "Enable or disable the Mercurial plugin.",
|
||||
"required": "This configuration value is required"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,9 +641,9 @@
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85"
|
||||
|
||||
"@scm-manager/ui-bundler@^0.0.19":
|
||||
version "0.0.19"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae"
|
||||
"@scm-manager/ui-bundler@^0.0.21":
|
||||
version "0.0.21"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.21.tgz#f8b5fa355415cc67b8aaf8744e1701a299dff647"
|
||||
dependencies:
|
||||
"@babel/core" "^7.0.0"
|
||||
"@babel/plugin-proposal-class-properties" "^7.0.0"
|
||||
@@ -660,7 +660,6 @@
|
||||
browserify-css "^0.14.0"
|
||||
colors "^1.3.1"
|
||||
commander "^2.17.1"
|
||||
connect-history-api-fallback "^1.5.0"
|
||||
eslint "^5.4.0"
|
||||
eslint-config-react-app "^2.1.0"
|
||||
eslint-plugin-flowtype "^2.50.0"
|
||||
@@ -682,9 +681,9 @@
|
||||
vinyl-source-stream "^2.0.0"
|
||||
watchify "^3.11.0"
|
||||
|
||||
"@scm-manager/ui-extensions@^0.0.7":
|
||||
version "0.0.7"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-extensions/-/ui-extensions-0.0.7.tgz#a0a657a1410b78838ba0b36096ef631dca7fe27e"
|
||||
"@scm-manager/ui-extensions@^0.1.1":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-extensions/-/ui-extensions-0.1.1.tgz#966e62d89981e92a14adf7e674e646e76de96d45"
|
||||
dependencies:
|
||||
react "^16.4.2"
|
||||
react-dom "^16.4.2"
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
"build": "ui-bundler plugin"
|
||||
},
|
||||
"dependencies": {
|
||||
"@scm-manager/ui-extensions": "^0.0.7"
|
||||
"@scm-manager/ui-extensions": "^0.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scm-manager/ui-bundler": "^0.0.19"
|
||||
"@scm-manager/ui-bundler": "^0.0.21"
|
||||
}
|
||||
}
|
||||
|
||||
107
scm-plugins/scm-svn-plugin/src/main/js/SvnConfigurationForm.js
Normal file
107
scm-plugins/scm-svn-plugin/src/main/js/SvnConfigurationForm.js
Normal file
@@ -0,0 +1,107 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import type { Links } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
import { InputField, Checkbox, Select } from "@scm-manager/ui-components";
|
||||
|
||||
type Configuration = {
|
||||
repositoryDirectory: string,
|
||||
compatibility: string,
|
||||
enabledGZip: boolean,
|
||||
disabled: boolean,
|
||||
_links: Links
|
||||
};
|
||||
|
||||
type Props = {
|
||||
initialConfiguration: Configuration,
|
||||
readOnly: boolean,
|
||||
|
||||
onConfigurationChange: (Configuration, boolean) => void,
|
||||
|
||||
// context props
|
||||
t: (string) => string
|
||||
}
|
||||
|
||||
type State = Configuration;
|
||||
|
||||
class HgConfigurationForm extends React.Component<Props, State> {
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = { ...props.initialConfiguration, validationErrors: [] };
|
||||
}
|
||||
|
||||
isValid = () => {
|
||||
return !!this.state.repositoryDirectory;
|
||||
};
|
||||
|
||||
handleChange = (value: any, name: string) => {
|
||||
this.setState({
|
||||
[name]: value
|
||||
}, () => this.props.onConfigurationChange(this.state, this.isValid()));
|
||||
};
|
||||
|
||||
compatibilityOptions = (values: string[]) => {
|
||||
const options = [];
|
||||
for (let value of values) {
|
||||
options.push( this.compatibilityOption(value) );
|
||||
}
|
||||
return options;
|
||||
};
|
||||
|
||||
compatibilityOption = (value: string) => {
|
||||
return {
|
||||
value,
|
||||
label: this.props.t("scm-svn-plugin.config.compatibility-values." + value.toLowerCase())
|
||||
};
|
||||
};
|
||||
|
||||
render() {
|
||||
const { readOnly, t } = this.props;
|
||||
const compatibilityOptions = this.compatibilityOptions([
|
||||
"NONE", "PRE14", "PRE15", "PRE16", "PRE17", "WITH17"
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<InputField
|
||||
name="repositoryDirectory"
|
||||
label={t("scm-svn-plugin.config.directory")}
|
||||
helpText={t("scm-svn-plugin.config.directoryHelpText")}
|
||||
value={this.state.repositoryDirectory}
|
||||
errorMessage={t("scm-svn-plugin.config.required")}
|
||||
validationError={!this.state.repositoryDirectory}
|
||||
onChange={this.handleChange}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
<Select
|
||||
name="compatibility"
|
||||
label={t("scm-svn-plugin.config.compatibility")}
|
||||
helpText={t("scm-svn-plugin.config.compatibilityHelpText")}
|
||||
value={this.state.compatibility}
|
||||
options={compatibilityOptions}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
<Checkbox
|
||||
name="enabledGZip"
|
||||
label={t("scm-svn-plugin.config.enabledGZip")}
|
||||
helpText={t("scm-svn-plugin.config.enabledGZipHelpText")}
|
||||
checked={this.state.enabledGZip}
|
||||
onChange={this.handleChange}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
<Checkbox
|
||||
name="disabled"
|
||||
label={t("scm-svn-plugin.config.disabled")}
|
||||
helpText={t("scm-svn-plugin.config.disabledHelpText")}
|
||||
checked={this.state.disabled}
|
||||
onChange={this.handleChange}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default translate("plugins")(HgConfigurationForm);
|
||||
@@ -0,0 +1,28 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { Title, GlobalConfiguration } from "@scm-manager/ui-components";
|
||||
import SvnConfigurationForm from "./SvnConfigurationForm";
|
||||
|
||||
type Props = {
|
||||
link: string,
|
||||
|
||||
// context props
|
||||
t: (string) => string
|
||||
}
|
||||
|
||||
class SvnGlobalConfiguration extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const { link, t } = this.props;
|
||||
return (
|
||||
<div>
|
||||
<Title title={t("scm-svn-plugin.config.title")}/>
|
||||
<GlobalConfiguration link={link} render={props => <SvnConfigurationForm {...props} />}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default translate("plugins")(SvnGlobalConfiguration);
|
||||
@@ -1,7 +1,9 @@
|
||||
// @flow
|
||||
import { binder } from "@scm-manager/ui-extensions";
|
||||
import { ConfigurationBinder as cfgBinder } from "@scm-manager/ui-components";
|
||||
import ProtocolInformation from "./ProtocolInformation";
|
||||
import SvnAvatar from "./SvnAvatar";
|
||||
import SvnGlobalConfiguration from "./SvnGlobalConfiguration";
|
||||
|
||||
const svnPredicate = (props: Object) => {
|
||||
return props.repository && props.repository.type === "svn";
|
||||
@@ -9,3 +11,7 @@ const svnPredicate = (props: Object) => {
|
||||
|
||||
binder.bind("repos.repository-details.information", ProtocolInformation, svnPredicate);
|
||||
binder.bind("repos.repository-avatar", SvnAvatar, svnPredicate);
|
||||
|
||||
// bind global configuration
|
||||
|
||||
cfgBinder.bindGlobal("/svn", "scm-svn-plugin.config.link", "svnConfig", SvnGlobalConfiguration);
|
||||
|
||||
@@ -2,6 +2,27 @@
|
||||
"scm-svn-plugin": {
|
||||
"information": {
|
||||
"checkout" : "Checkout repository"
|
||||
},
|
||||
"config": {
|
||||
"link": "Subversion",
|
||||
"title": "Subversion Configuration",
|
||||
"directory": "Repository Directory",
|
||||
"directoryHelpText": "Location of Subversion repositories.",
|
||||
"compatibility": "Version Compatibility",
|
||||
"compatibilityHelpText": "Specifies with which subversion version repositories are compatible.",
|
||||
"compatibility-values": {
|
||||
"none": "No compatibility",
|
||||
"pre14": "Pre 1.4 Compatible",
|
||||
"pre15": "Pre 1.5 Compatible",
|
||||
"pre16": "Pre 1.6 Compatible",
|
||||
"pre17": "Pre 1.7 Compatible",
|
||||
"with17": "With 1.7 Compatible"
|
||||
},
|
||||
"enabledGZip": "Enable GZip Compression",
|
||||
"enabledGZipHelpText": "Enable GZip compression for svn responses.",
|
||||
"disabled": "Disabled",
|
||||
"disabledHelpText": "Enable or disable the Git plugin",
|
||||
"required": "This configuration value is required"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,9 +641,9 @@
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85"
|
||||
|
||||
"@scm-manager/ui-bundler@^0.0.19":
|
||||
version "0.0.19"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae"
|
||||
"@scm-manager/ui-bundler@^0.0.21":
|
||||
version "0.0.21"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.21.tgz#f8b5fa355415cc67b8aaf8744e1701a299dff647"
|
||||
dependencies:
|
||||
"@babel/core" "^7.0.0"
|
||||
"@babel/plugin-proposal-class-properties" "^7.0.0"
|
||||
@@ -681,9 +681,9 @@
|
||||
vinyl-source-stream "^2.0.0"
|
||||
watchify "^3.11.0"
|
||||
|
||||
"@scm-manager/ui-extensions@^0.0.7":
|
||||
version "0.0.7"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-extensions/-/ui-extensions-0.0.7.tgz#a0a657a1410b78838ba0b36096ef631dca7fe27e"
|
||||
"@scm-manager/ui-extensions@^0.1.1":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-extensions/-/ui-extensions-0.1.1.tgz#966e62d89981e92a14adf7e674e646e76de96d45"
|
||||
dependencies:
|
||||
react "^16.4.2"
|
||||
react-dom "^16.4.2"
|
||||
|
||||
@@ -3,16 +3,18 @@
|
||||
"version": "0.0.1",
|
||||
"description": "UI Components for SCM-Manager and its plugins",
|
||||
"main": "src/index.js",
|
||||
"files": ["src"],
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"repository": "https://bitbucket.org/sdorra/scm-manager",
|
||||
"author": "Sebastian Sdorra <sebastian.sdorra@cloudogu.com>",
|
||||
"license" : "BSD-3-Clause",
|
||||
"license": "BSD-3-Clause",
|
||||
"scripts": {
|
||||
"update-index": "create-index -r src",
|
||||
"eslint-fix": "eslint src --fix"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scm-manager/ui-bundler": "^0.0.19",
|
||||
"@scm-manager/ui-bundler": "^0.0.21",
|
||||
"create-index": "^2.3.0",
|
||||
"enzyme": "^3.5.0",
|
||||
"enzyme-adapter-react-16": "^1.3.1",
|
||||
@@ -23,23 +25,32 @@
|
||||
"react-router-enzyme-context": "^1.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@scm-manager/ui-extensions": "^0.1.1",
|
||||
"@scm-manager/ui-types": "0.0.1",
|
||||
"classnames": "^2.2.6",
|
||||
"moment": "^2.22.2",
|
||||
"react": "^16.5.2",
|
||||
"react-dom": "^16.5.2",
|
||||
"react-i18next": "^7.11.0",
|
||||
"react-jss": "^8.6.1",
|
||||
"react-router-dom": "^4.3.1",
|
||||
"@scm-manager/ui-types": "0.0.1"
|
||||
"react-router-dom": "^4.3.1"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
["browserify-css"],
|
||||
[
|
||||
"browserify-css"
|
||||
],
|
||||
[
|
||||
"babelify",
|
||||
{
|
||||
"plugins": ["@babel/plugin-proposal-class-properties"],
|
||||
"presets": ["@babel/preset-env", "@babel/preset-flow", "@babel/preset-react"]
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-class-properties"
|
||||
],
|
||||
"presets": [
|
||||
"@babel/preset-env",
|
||||
"@babel/preset-flow",
|
||||
"@babel/preset-react"
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { binder } from "@scm-manager/ui-extensions";
|
||||
import { NavLink } from "../navigation";
|
||||
import { Route } from "react-router-dom";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
class ConfigurationBinder {
|
||||
|
||||
i18nNamespace: string = "plugins";
|
||||
|
||||
bindGlobal(to: string, labelI18nKey: string, linkName: string, ConfigurationComponent: any) {
|
||||
|
||||
// create predicate based on the link name of the index resource
|
||||
// if the linkname is not available, the navigation link and the route are not bound to the extension points
|
||||
const configPredicate = (props: Object) => {
|
||||
return props.links && props.links[linkName];
|
||||
};
|
||||
|
||||
// create NavigationLink with translated label
|
||||
const ConfigNavLink = translate(this.i18nNamespace)(({t}) => {
|
||||
return <NavLink to={"/config" + to} label={t(labelI18nKey)} />;
|
||||
});
|
||||
|
||||
// bind navigation link to extension point
|
||||
binder.bind("config.navigation", ConfigNavLink, configPredicate);
|
||||
|
||||
|
||||
// route for global configuration, passes the link from the index resource to component
|
||||
const ConfigRoute = ({ url, links }) => {
|
||||
const link = links[linkName].href;
|
||||
return <Route path={url + to}
|
||||
render={() => <ConfigurationComponent link={link}/>}
|
||||
exact/>;
|
||||
};
|
||||
|
||||
// bind config route to extension point
|
||||
binder.bind("config.route", ConfigRoute, configPredicate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new ConfigurationBinder();
|
||||
@@ -0,0 +1,162 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import type { Links } from "@scm-manager/ui-types";
|
||||
import {
|
||||
apiClient,
|
||||
SubmitButton,
|
||||
Loading,
|
||||
ErrorNotification
|
||||
} from "../";
|
||||
|
||||
type RenderProps = {
|
||||
readOnly: boolean,
|
||||
initialConfiguration: Configuration,
|
||||
onConfigurationChange: (Configuration, boolean) => void
|
||||
};
|
||||
|
||||
type Props = {
|
||||
link: string,
|
||||
render: (props: RenderProps) => any, // ???
|
||||
|
||||
// context props
|
||||
t: (string) => string
|
||||
};
|
||||
|
||||
type Configuration = {
|
||||
_links: Links
|
||||
} & Object;
|
||||
|
||||
type State = {
|
||||
error?: Error,
|
||||
fetching: boolean,
|
||||
modifying: boolean,
|
||||
contentType?: string,
|
||||
|
||||
configuration?: Configuration,
|
||||
modifiedConfiguration?: Configuration,
|
||||
valid: boolean
|
||||
};
|
||||
|
||||
/**
|
||||
* GlobalConfiguration uses the render prop pattern to encapsulate the logic for
|
||||
* synchronizing the configuration with the backend.
|
||||
*/
|
||||
class GlobalConfiguration extends React.Component<Props, State> {
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
fetching: true,
|
||||
modifying: false,
|
||||
valid: false
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { link } = this.props;
|
||||
|
||||
apiClient.get(link)
|
||||
.then(this.captureContentType)
|
||||
.then(response => response.json())
|
||||
.then(this.loadConfig)
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
captureContentType = (response: Response) => {
|
||||
const contentType = response.headers.get("Content-Type");
|
||||
this.setState({
|
||||
contentType
|
||||
});
|
||||
return response;
|
||||
};
|
||||
|
||||
getContentType = (): string => {
|
||||
const { contentType } = this.state;
|
||||
return contentType ? contentType : "application/json";
|
||||
};
|
||||
|
||||
handleError = (error: Error) => {
|
||||
this.setState({
|
||||
error,
|
||||
fetching: false,
|
||||
modifying: false
|
||||
});
|
||||
};
|
||||
|
||||
loadConfig = (configuration: Configuration) => {
|
||||
this.setState({
|
||||
configuration,
|
||||
fetching: false,
|
||||
error: undefined
|
||||
});
|
||||
};
|
||||
|
||||
getModificationUrl = (): ?string => {
|
||||
const { configuration } = this.state;
|
||||
if (configuration) {
|
||||
const links = configuration._links;
|
||||
if (links && links.update) {
|
||||
return links.update.href;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
isReadOnly = (): boolean => {
|
||||
const modificationUrl = this.getModificationUrl();
|
||||
return !modificationUrl;
|
||||
};
|
||||
|
||||
configurationChanged = (configuration: Configuration, valid: boolean) => {
|
||||
this.setState({
|
||||
modifiedConfiguration: configuration,
|
||||
valid
|
||||
});
|
||||
};
|
||||
|
||||
modifyConfiguration = (event: Event) => {
|
||||
event.preventDefault();
|
||||
|
||||
this.setState({ modifying: true });
|
||||
|
||||
const {modifiedConfiguration} = this.state;
|
||||
|
||||
apiClient.put(this.getModificationUrl(), modifiedConfiguration, this.getContentType())
|
||||
.then(() => this.setState({ modifying: false }))
|
||||
.catch(this.handleError);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { t } = this.props;
|
||||
const { fetching, error, configuration, modifying, valid } = this.state;
|
||||
|
||||
if (error) {
|
||||
return <ErrorNotification error={error}/>;
|
||||
} else if (fetching || !configuration) {
|
||||
return <Loading />;
|
||||
} else {
|
||||
const readOnly = this.isReadOnly();
|
||||
|
||||
const renderProps: RenderProps = {
|
||||
readOnly,
|
||||
initialConfiguration: configuration,
|
||||
onConfigurationChange: this.configurationChanged
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={this.modifyConfiguration}>
|
||||
{ this.props.render(renderProps) }
|
||||
<hr/>
|
||||
<SubmitButton
|
||||
label={t("config-form.submit")}
|
||||
disabled={!valid || readOnly}
|
||||
loading={modifying}
|
||||
/>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default translate("config")(GlobalConfiguration);
|
||||
@@ -0,0 +1,3 @@
|
||||
// @flow
|
||||
export { default as ConfigurationBinder } from "./ConfigurationBinder";
|
||||
export { default as GlobalConfiguration } from "./GlobalConfiguration";
|
||||
@@ -4,15 +4,16 @@ import { Help } from "../index";
|
||||
|
||||
type Props = {
|
||||
label?: string,
|
||||
name?: string,
|
||||
checked: boolean,
|
||||
onChange?: boolean => void,
|
||||
onChange?: (value: boolean, name?: string) => void,
|
||||
disabled?: boolean,
|
||||
helpText?: string
|
||||
};
|
||||
class Checkbox extends React.Component<Props> {
|
||||
onCheckboxChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
|
||||
if (this.props.onChange) {
|
||||
this.props.onChange(event.target.checked);
|
||||
this.props.onChange(event.target.checked, this.props.name);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,11 +5,12 @@ import { LabelWithHelpIcon } from "../index";
|
||||
|
||||
type Props = {
|
||||
label?: string,
|
||||
name?: string,
|
||||
placeholder?: string,
|
||||
value?: string,
|
||||
type?: string,
|
||||
autofocus?: boolean,
|
||||
onChange: string => void,
|
||||
onChange: (value: string, name?: string) => void,
|
||||
onReturnPressed?: () => void,
|
||||
validationError: boolean,
|
||||
errorMessage: string,
|
||||
@@ -32,7 +33,7 @@ class InputField extends React.Component<Props> {
|
||||
}
|
||||
|
||||
handleInput = (event: SyntheticInputEvent<HTMLInputElement>) => {
|
||||
this.props.onChange(event.target.value);
|
||||
this.props.onChange(event.target.value, this.props.name);
|
||||
};
|
||||
|
||||
handleKeyPress = (event: SyntheticKeyboardEvent<HTMLInputElement>) => {
|
||||
|
||||
@@ -9,10 +9,11 @@ export type SelectItem = {
|
||||
};
|
||||
|
||||
type Props = {
|
||||
name?: string,
|
||||
label?: string,
|
||||
options: SelectItem[],
|
||||
value?: SelectItem,
|
||||
onChange: string => void,
|
||||
value?: string,
|
||||
onChange: (value: string, name?: string) => void,
|
||||
loading?: boolean,
|
||||
helpText?: string
|
||||
};
|
||||
@@ -29,7 +30,7 @@ class Select extends React.Component<Props> {
|
||||
}
|
||||
|
||||
handleInput = (event: SyntheticInputEvent<HTMLSelectElement>) => {
|
||||
this.props.onChange(event.target.value);
|
||||
this.props.onChange(event.target.value, this.props.name);
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -40,10 +41,10 @@ class Select extends React.Component<Props> {
|
||||
return (
|
||||
<div className="field">
|
||||
<LabelWithHelpIcon label={label} helpText={helpText} />
|
||||
<div className={classNames(
|
||||
"control select",
|
||||
loadingClass
|
||||
)}>
|
||||
<div className={classNames(
|
||||
"control select",
|
||||
loadingClass
|
||||
)}>
|
||||
<select
|
||||
ref={input => {
|
||||
this.field = input;
|
||||
|
||||
@@ -24,6 +24,7 @@ export { getPageFromMatch } from "./urls";
|
||||
export { apiClient, NOT_FOUND_ERROR, UNAUTHORIZED_ERROR } from "./apiclient.js";
|
||||
|
||||
export * from "./buttons";
|
||||
export * from "./config";
|
||||
export * from "./forms";
|
||||
export * from "./layout";
|
||||
export * from "./modals";
|
||||
|
||||
@@ -641,9 +641,9 @@
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85"
|
||||
|
||||
"@scm-manager/ui-bundler@^0.0.19":
|
||||
version "0.0.19"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae"
|
||||
"@scm-manager/ui-bundler@^0.0.21":
|
||||
version "0.0.21"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.21.tgz#f8b5fa355415cc67b8aaf8744e1701a299dff647"
|
||||
dependencies:
|
||||
"@babel/core" "^7.0.0"
|
||||
"@babel/plugin-proposal-class-properties" "^7.0.0"
|
||||
@@ -681,6 +681,13 @@
|
||||
vinyl-source-stream "^2.0.0"
|
||||
watchify "^3.11.0"
|
||||
|
||||
"@scm-manager/ui-extensions@^0.1.1":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-extensions/-/ui-extensions-0.1.1.tgz#966e62d89981e92a14adf7e674e646e76de96d45"
|
||||
dependencies:
|
||||
react "^16.4.2"
|
||||
react-dom "^16.4.2"
|
||||
|
||||
"@types/node@*":
|
||||
version "10.12.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.0.tgz#ea6dcbddbc5b584c83f06c60e82736d8fbb0c235"
|
||||
@@ -6229,6 +6236,15 @@ rc@^1.2.7:
|
||||
minimist "^1.2.0"
|
||||
strip-json-comments "~2.0.1"
|
||||
|
||||
react-dom@^16.4.2:
|
||||
version "16.6.0"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.6.0.tgz#6375b8391e019a632a89a0988bce85f0cc87a92f"
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.2"
|
||||
scheduler "^0.10.0"
|
||||
|
||||
react-dom@^16.5.2:
|
||||
version "16.5.2"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.5.2.tgz#b69ee47aa20bab5327b2b9d7c1fe2a30f2cfa9d7"
|
||||
@@ -6299,6 +6315,15 @@ react-test-renderer@^16.0.0-0:
|
||||
react-is "^16.5.2"
|
||||
schedule "^0.5.0"
|
||||
|
||||
react@^16.4.2:
|
||||
version "16.6.0"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-16.6.0.tgz#b34761cfaf3e30f5508bc732fb4736730b7da246"
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.2"
|
||||
scheduler "^0.10.0"
|
||||
|
||||
react@^16.5.2:
|
||||
version "16.5.2"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42"
|
||||
@@ -6726,6 +6751,13 @@ schedule@^0.5.0:
|
||||
dependencies:
|
||||
object-assign "^4.1.1"
|
||||
|
||||
scheduler@^0.10.0:
|
||||
version "0.10.0"
|
||||
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.10.0.tgz#7988de90fe7edccc774ea175a783e69c40c521e1"
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
|
||||
"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1:
|
||||
version "5.6.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"check": "flow check"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scm-manager/ui-bundler": "^0.0.19"
|
||||
"@scm-manager/ui-bundler": "^0.0.21"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
|
||||
@@ -707,9 +707,9 @@
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/eslint-config/-/eslint-config-0.0.2.tgz#94cc8c3fb4f51f870b235893dc134fc6c423ae85"
|
||||
|
||||
"@scm-manager/ui-bundler@^0.0.19":
|
||||
version "0.0.19"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.19.tgz#646ab1fa1e5389fad614542215c60678fb9816ae"
|
||||
"@scm-manager/ui-bundler@^0.0.21":
|
||||
version "0.0.21"
|
||||
resolved "https://registry.yarnpkg.com/@scm-manager/ui-bundler/-/ui-bundler-0.0.21.tgz#f8b5fa355415cc67b8aaf8744e1701a299dff647"
|
||||
dependencies:
|
||||
"@babel/core" "^7.0.0"
|
||||
"@babel/plugin-proposal-class-properties" "^7.0.0"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "src/index.js",
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-free": "^5.3.1",
|
||||
"@scm-manager/ui-extensions": "^0.0.7",
|
||||
"@scm-manager/ui-extensions": "^0.1.1",
|
||||
"bulma": "^0.7.1",
|
||||
"bulma-tooltip": "^2.0.2",
|
||||
"classnames": "^2.2.5",
|
||||
@@ -48,7 +48,7 @@
|
||||
"pre-commit": "jest && flow && eslint src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scm-manager/ui-bundler": "^0.0.19",
|
||||
"@scm-manager/ui-bundler": "^0.0.21",
|
||||
"copyfiles": "^2.0.0",
|
||||
"enzyme": "^3.3.0",
|
||||
"enzyme-adapter-react-16": "^1.1.1",
|
||||
|
||||
@@ -2,12 +2,19 @@
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { Route } from "react-router";
|
||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||
|
||||
import type { Links } from "@scm-manager/ui-types";
|
||||
import { Page, Navigation, NavLink, Section } from "@scm-manager/ui-components";
|
||||
import GlobalConfig from "./GlobalConfig";
|
||||
import type { History } from "history";
|
||||
import {connect} from "react-redux";
|
||||
import {compose} from "redux";
|
||||
import { getLinks } from "../../modules/indexResource";
|
||||
|
||||
type Props = {
|
||||
links: Links,
|
||||
|
||||
// context objects
|
||||
t: string => string,
|
||||
match: any,
|
||||
@@ -27,15 +34,23 @@ class Config extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { t } = this.props;
|
||||
const { links, t } = this.props;
|
||||
|
||||
const url = this.matchedUrl();
|
||||
const extensionProps = {
|
||||
links,
|
||||
url
|
||||
};
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<div className="columns">
|
||||
<div className="column is-three-quarters">
|
||||
<Route path={url} exact component={GlobalConfig} />
|
||||
<ExtensionPoint name="config.route"
|
||||
props={extensionProps}
|
||||
renderAll={true}
|
||||
/>
|
||||
</div>
|
||||
<div className="column">
|
||||
<Navigation>
|
||||
@@ -44,6 +59,10 @@ class Config extends React.Component<Props> {
|
||||
to={`${url}`}
|
||||
label={t("global-config.navigation-label")}
|
||||
/>
|
||||
<ExtensionPoint name="config.navigation"
|
||||
props={extensionProps}
|
||||
renderAll={true}
|
||||
/>
|
||||
</Section>
|
||||
</Navigation>
|
||||
</div>
|
||||
@@ -53,4 +72,15 @@ class Config extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("config")(Config);
|
||||
const mapStateToProps = (state: any) => {
|
||||
const links = getLinks(state);
|
||||
return {
|
||||
links
|
||||
};
|
||||
};
|
||||
|
||||
export default compose(
|
||||
connect(mapStateToProps),
|
||||
translate("config")
|
||||
)(Config);
|
||||
|
||||
|
||||
@@ -104,7 +104,6 @@ class Main extends React.Component<Props> {
|
||||
authenticated={authenticated}
|
||||
/>
|
||||
<ProtectedRoute
|
||||
exact
|
||||
path="/config"
|
||||
component={Config}
|
||||
authenticated={authenticated}
|
||||
|
||||
@@ -2,22 +2,33 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import GroupForm from "../components/GroupForm";
|
||||
import { modifyGroup } from "../modules/groups";
|
||||
import {
|
||||
modifyGroup,
|
||||
modifyGroupReset,
|
||||
isModifyGroupPending,
|
||||
getModifyGroupFailure
|
||||
} from "../modules/groups";
|
||||
import type { History } from "history";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import type { Group } from "@scm-manager/ui-types";
|
||||
import { isModifyGroupPending, getModifyGroupFailure } from "../modules/groups";
|
||||
import { ErrorNotification } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
group: Group,
|
||||
modifyGroup: (group: Group, callback?: () => void) => void,
|
||||
modifyGroupReset: Group => void,
|
||||
fetchGroup: (name: string) => void,
|
||||
history: History,
|
||||
loading?: boolean,
|
||||
error: Error
|
||||
};
|
||||
|
||||
class EditGroup extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const { group, modifyGroupReset } = this.props;
|
||||
modifyGroupReset(group);
|
||||
}
|
||||
|
||||
groupModified = (group: Group) => () => {
|
||||
this.props.history.push(`/group/${group.name}`);
|
||||
};
|
||||
@@ -56,6 +67,9 @@ const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
modifyGroup: (group: Group, callback?: () => void) => {
|
||||
dispatch(modifyGroup(group, callback));
|
||||
},
|
||||
modifyGroupReset: (group: Group) => {
|
||||
dispatch(modifyGroupReset(group));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ export const MODIFY_GROUP = "scm/groups/MODIFY_GROUP";
|
||||
export const MODIFY_GROUP_PENDING = `${MODIFY_GROUP}_${types.PENDING_SUFFIX}`;
|
||||
export const MODIFY_GROUP_SUCCESS = `${MODIFY_GROUP}_${types.SUCCESS_SUFFIX}`;
|
||||
export const MODIFY_GROUP_FAILURE = `${MODIFY_GROUP}_${types.FAILURE_SUFFIX}`;
|
||||
export const MODIFY_GROUP_RESET = `${MODIFY_GROUP}_${types.RESET_SUFFIX}`;
|
||||
|
||||
export const DELETE_GROUP = "scm/groups/DELETE";
|
||||
export const DELETE_GROUP_PENDING = `${DELETE_GROUP}_${types.PENDING_SUFFIX}`;
|
||||
@@ -238,6 +239,13 @@ export function modifyGroupFailure(group: Group, error: Error): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function modifyGroupReset(group: Group): Action {
|
||||
return {
|
||||
type: MODIFY_GROUP_RESET,
|
||||
itemId: group.name
|
||||
};
|
||||
}
|
||||
|
||||
//delete group
|
||||
|
||||
export function deleteGroup(group: Group, callback?: () => void) {
|
||||
|
||||
@@ -7,7 +7,8 @@ import type { Repository } from "@scm-manager/ui-types";
|
||||
import {
|
||||
modifyRepo,
|
||||
isModifyRepoPending,
|
||||
getModifyRepoFailure
|
||||
getModifyRepoFailure,
|
||||
modifyRepoReset
|
||||
} from "../modules/repos";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import type { History } from "history";
|
||||
@@ -16,6 +17,7 @@ import { ErrorNotification } from "@scm-manager/ui-components";
|
||||
type Props = {
|
||||
repository: Repository,
|
||||
modifyRepo: (Repository, () => void) => void,
|
||||
modifyRepoReset: Repository => void,
|
||||
loading: boolean,
|
||||
error: Error,
|
||||
|
||||
@@ -25,6 +27,10 @@ type Props = {
|
||||
};
|
||||
|
||||
class Edit extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const { modifyRepoReset, repository } = this.props;
|
||||
modifyRepoReset(repository);
|
||||
}
|
||||
repoModified = () => {
|
||||
const { history, repository } = this.props;
|
||||
history.push(`/repo/${repository.namespace}/${repository.name}`);
|
||||
@@ -61,6 +67,9 @@ const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
modifyRepo: (repo: Repository, callback: () => void) => {
|
||||
dispatch(modifyRepo(repo, callback));
|
||||
},
|
||||
modifyRepoReset: (repo: Repository) => {
|
||||
dispatch(modifyRepoReset(repo));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -29,6 +29,7 @@ export const MODIFY_REPO = "scm/repos/MODIFY_REPO";
|
||||
export const MODIFY_REPO_PENDING = `${MODIFY_REPO}_${types.PENDING_SUFFIX}`;
|
||||
export const MODIFY_REPO_SUCCESS = `${MODIFY_REPO}_${types.SUCCESS_SUFFIX}`;
|
||||
export const MODIFY_REPO_FAILURE = `${MODIFY_REPO}_${types.FAILURE_SUFFIX}`;
|
||||
export const MODIFY_REPO_RESET = `${MODIFY_REPO}_${types.RESET_SUFFIX}`;
|
||||
|
||||
export const DELETE_REPO = "scm/repos/DELETE_REPO";
|
||||
export const DELETE_REPO_PENDING = `${DELETE_REPO}_${types.PENDING_SUFFIX}`;
|
||||
@@ -257,6 +258,14 @@ export function modifyRepoFailure(
|
||||
};
|
||||
}
|
||||
|
||||
export function modifyRepoReset(repository: Repository): Action {
|
||||
return {
|
||||
type: MODIFY_REPO_RESET,
|
||||
payload: { repository },
|
||||
itemId: createIdentifier(repository)
|
||||
};
|
||||
}
|
||||
|
||||
// delete
|
||||
|
||||
export function deleteRepo(repository: Repository, callback?: () => void) {
|
||||
|
||||
@@ -7,7 +7,8 @@ import type { User } from "@scm-manager/ui-types";
|
||||
import {
|
||||
modifyUser,
|
||||
isModifyUserPending,
|
||||
getModifyUserFailure
|
||||
getModifyUserFailure,
|
||||
modifyUserReset
|
||||
} from "../modules/users";
|
||||
import type { History } from "history";
|
||||
import { ErrorNotification } from "@scm-manager/ui-components";
|
||||
@@ -18,6 +19,7 @@ type Props = {
|
||||
|
||||
// dispatch functions
|
||||
modifyUser: (user: User, callback?: () => void) => void,
|
||||
modifyUserReset: User => void,
|
||||
|
||||
// context objects
|
||||
user: User,
|
||||
@@ -25,6 +27,10 @@ type Props = {
|
||||
};
|
||||
|
||||
class EditUser extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const { modifyUserReset, user } = this.props;
|
||||
modifyUserReset(user);
|
||||
}
|
||||
userModified = (user: User) => () => {
|
||||
this.props.history.push(`/user/${user.name}`);
|
||||
};
|
||||
@@ -52,6 +58,9 @@ const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
modifyUser: (user: User, callback?: () => void) => {
|
||||
dispatch(modifyUser(user, callback));
|
||||
},
|
||||
modifyUserReset: (user: User) => {
|
||||
dispatch(modifyUserReset(user));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ export const MODIFY_USER = "scm/users/MODIFY_USER";
|
||||
export const MODIFY_USER_PENDING = `${MODIFY_USER}_${types.PENDING_SUFFIX}`;
|
||||
export const MODIFY_USER_SUCCESS = `${MODIFY_USER}_${types.SUCCESS_SUFFIX}`;
|
||||
export const MODIFY_USER_FAILURE = `${MODIFY_USER}_${types.FAILURE_SUFFIX}`;
|
||||
export const MODIFY_USER_RESET = `${MODIFY_USER}_${types.RESET_SUFFIX}`;
|
||||
|
||||
export const DELETE_USER = "scm/users/DELETE";
|
||||
export const DELETE_USER_PENDING = `${DELETE_USER}_${types.PENDING_SUFFIX}`;
|
||||
@@ -239,6 +240,13 @@ export function modifyUserFailure(user: User, error: Error): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function modifyUserReset(user: User): Action {
|
||||
return {
|
||||
type: MODIFY_USER_RESET,
|
||||
itemId: user.name
|
||||
};
|
||||
}
|
||||
|
||||
//delete user
|
||||
|
||||
export function deleteUser(user: User, callback?: () => void) {
|
||||
|
||||
1341
scm-ui/yarn.lock
1341
scm-ui/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@ import com.webcohesion.enunciate.metadata.rs.StatusCodes;
|
||||
import com.webcohesion.enunciate.metadata.rs.TypeHint;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.PageResult;
|
||||
import sonia.scm.repository.Branch;
|
||||
import sonia.scm.repository.Branches;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
@@ -26,6 +27,7 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class BranchRootResource {
|
||||
|
||||
@@ -124,6 +126,49 @@ public class BranchRootResource {
|
||||
}
|
||||
}
|
||||
|
||||
@Path("{branch}/diffchangesets/{otherBranchName}")
|
||||
@GET
|
||||
@StatusCodes({
|
||||
@ResponseCode(code = 200, condition = "success"),
|
||||
@ResponseCode(code = 401, condition = "not authenticated / invalid credentials"),
|
||||
@ResponseCode(code = 403, condition = "not authorized, the current user has no privileges to read the changeset"),
|
||||
@ResponseCode(code = 404, condition = "not found, no changesets available in the repository"),
|
||||
@ResponseCode(code = 500, condition = "internal server error")
|
||||
})
|
||||
@Produces(VndMediaType.CHANGESET_COLLECTION)
|
||||
@TypeHint(CollectionDto.class)
|
||||
public Response changesetDiff(@PathParam("namespace") String namespace,
|
||||
@PathParam("name") String name,
|
||||
@PathParam("branch") String branchName,
|
||||
@PathParam("otherBranchName") String otherBranchName,
|
||||
@DefaultValue("0") @QueryParam("page") int page,
|
||||
@DefaultValue("10") @QueryParam("pageSize") int pageSize) throws Exception {
|
||||
try (RepositoryService repositoryService = serviceFactory.create(new NamespaceAndName(namespace, name))) {
|
||||
List<Branch> allBranches = repositoryService.getBranchesCommand().getBranches().getBranches();
|
||||
if (allBranches.stream().noneMatch(branch -> branchName.equals(branch.getName()))) {
|
||||
throw new NotFoundException("branch", branchName);
|
||||
}
|
||||
if (allBranches.stream().noneMatch(branch -> otherBranchName.equals(branch.getName()))) {
|
||||
throw new NotFoundException("branch", otherBranchName);
|
||||
}
|
||||
Repository repository = repositoryService.getRepository();
|
||||
RepositoryPermissions.read(repository).check();
|
||||
ChangesetPagingResult changesets = new PagedLogCommandBuilder(repositoryService)
|
||||
.page(page)
|
||||
.pageSize(pageSize)
|
||||
.create()
|
||||
.setBranch(branchName)
|
||||
.setAncestorChangeset(otherBranchName)
|
||||
.getChangesets();
|
||||
if (changesets != null && changesets.getChangesets() != null) {
|
||||
PageResult<Changeset> pageResult = new PageResult<>(changesets.getChangesets(), changesets.getTotal());
|
||||
return Response.ok(branchChangesetCollectionToDtoMapper.map(page, pageSize, pageResult, repository, branchName)).build();
|
||||
} else {
|
||||
return Response.ok().build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the branches for a repository.
|
||||
*
|
||||
|
||||
@@ -28,6 +28,7 @@ public abstract class BranchToBranchDtoMapper {
|
||||
Links.Builder linksBuilder = linkingTo()
|
||||
.self(resourceLinks.branch().self(namespaceAndName, target.getName()))
|
||||
.single(linkBuilder("history", resourceLinks.branch().history(namespaceAndName, target.getName())).build())
|
||||
.single(linkBuilder("changesetDiff", resourceLinks.branch().changesetDiff(namespaceAndName, target.getName())).build())
|
||||
.single(linkBuilder("changeset", resourceLinks.changeset().changeset(namespaceAndName.getNamespace(), namespaceAndName.getName(), target.getRevision())).build())
|
||||
.single(linkBuilder("source", resourceLinks.source().self(namespaceAndName.getNamespace(), namespaceAndName.getName(), target.getRevision())).build());
|
||||
target.add(linksBuilder.build());
|
||||
|
||||
@@ -322,6 +322,10 @@ class ResourceLinks {
|
||||
public String history(NamespaceAndName namespaceAndName, String branch) {
|
||||
return branchLinkBuilder.method("getRepositoryResource").parameters(namespaceAndName.getNamespace(), namespaceAndName.getName()).method("branches").parameters().method("history").parameters(branch).href();
|
||||
}
|
||||
|
||||
public String changesetDiff(NamespaceAndName namespaceAndName, String branch) {
|
||||
return branchLinkBuilder.method("getRepositoryResource").parameters(namespaceAndName.getNamespace(), namespaceAndName.getName()).method("branches").parameters().method("changesetDiff").parameters(branch, "").href() + "{otherBranch}";
|
||||
}
|
||||
}
|
||||
|
||||
public BranchCollectionLinks branchCollection() {
|
||||
|
||||
Reference in New Issue
Block a user