Order repo info extensions (#2041)

Set order priority for repository information extensions.
Also add new annotation to set custom resource bundles for cli commands.
This commit is contained in:
Eduard Heimbuch
2022-05-23 15:06:08 +02:00
committed by GitHub
parent 1cac44972f
commit 8f0facf394
8 changed files with 145 additions and 37 deletions

View File

@@ -22,23 +22,17 @@
* SOFTWARE.
*/
import "@scm-manager/ui-tests/i18n";
import "@scm-manager/ui-tests";
import { Repository } from "@scm-manager/ui-types";
import { gitPredicate } from "./index";
const repository: Repository = { _links: {}, namespace: "hitchhiker", name: "HeartOfGold", type: "git" };
describe("test git predicate", () => {
it("should return false", () => {
expect(gitPredicate(undefined)).toBe(false);
expect(gitPredicate({})).toBe(false);
expect(
gitPredicate({
repository: {},
})
).toBe(false);
expect(
gitPredicate({
repository: {
type: "hg",
},
repository: { ...repository, type: "hg" },
})
).toBe(false);
});
@@ -46,9 +40,7 @@ describe("test git predicate", () => {
it("should return true", () => {
expect(
gitPredicate({
repository: {
type: "git",
},
repository,
})
).toBe(true);
});

View File

@@ -36,15 +36,14 @@ import GitTagInformation from "./GitTagInformation";
// repository
// @visibleForTesting
export const gitPredicate = (props: any) => {
export const gitPredicate = (props: extensionPoints.RepositoryDetailsInformation["props"]) => {
return !!(props && props.repository && props.repository.type === "git");
};
binder.bind<extensionPoints.RepositoryDetailsInformation>(
"repos.repository-details.information",
ProtocolInformation,
gitPredicate
);
binder.bind<extensionPoints.RepositoryDetailsInformation>("repos.repository-details.information", ProtocolInformation, {
predicate: gitPredicate,
priority: 100,
});
binder.bind("repos.branch-details.information", GitBranchInformation, { priority: 100, predicate: gitPredicate });
binder.bind<extensionPoints.RepositoryTagDetailsInformation>(