mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-04 20:45:52 +01:00
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:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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>(
|
||||
|
||||
Reference in New Issue
Block a user