Files
SCM-Manager/scm-ui/ui-components/src/repos/changesets/changesets.ts

35 lines
863 B
TypeScript
Raw Normal View History

import { Changeset, Repository } from "@scm-manager/ui-types";
2019-02-07 10:27:11 +01:00
2018-10-18 14:40:35 +02:00
export type Description = {
title: string;
message: string;
2018-10-18 14:40:35 +02:00
};
2019-10-21 10:57:56 +02:00
export function createChangesetLink(repository: Repository, changeset: Changeset) {
return `/repo/${repository.namespace}/${repository.name}/code/changeset/${changeset.id}`;
2019-02-07 10:27:11 +01:00
}
2019-10-21 10:57:56 +02:00
export function createSourcesLink(repository: Repository, changeset: Changeset) {
2020-01-08 12:38:21 +01:00
return `/repo/${repository.namespace}/${repository.name}/code/sources/${changeset.id}`;
2019-02-07 10:27:11 +01:00
}
export function parseDescription(description?: string): Description {
const desc = description ? description : "";
const lineBreak = desc.indexOf("\n");
2018-10-18 14:40:35 +02:00
let title;
let message = "";
2018-10-18 14:40:35 +02:00
if (lineBreak > 0) {
title = desc.substring(0, lineBreak);
message = desc.substring(lineBreak + 1);
2018-10-18 14:40:35 +02:00
} else {
title = desc;
2018-10-18 14:40:35 +02:00
}
return {
title,
message
2018-10-18 14:40:35 +02:00
};
}