feat: allow setting editorial workflow PR label prefix (#4181)

This commit is contained in:
Kancer (Nilay) Gökırmak
2020-09-06 20:13:46 +02:00
committed by GitHub
parent c0fc423040
commit 6b8fa3fc45
18 changed files with 170 additions and 44 deletions

View File

@ -2,10 +2,15 @@ export const CMS_BRANCH_PREFIX = 'cms';
export const DEFAULT_PR_BODY = 'Automatically generated by Netlify CMS';
export const MERGE_COMMIT_MESSAGE = 'Automatically generated. Merged on Netlify CMS.';
const NETLIFY_CMS_LABEL_PREFIX = 'netlify-cms/';
export const isCMSLabel = (label: string) => label.startsWith(NETLIFY_CMS_LABEL_PREFIX);
export const labelToStatus = (label: string) => label.substr(NETLIFY_CMS_LABEL_PREFIX.length);
export const statusToLabel = (status: string) => `${NETLIFY_CMS_LABEL_PREFIX}${status}`;
const DEFAULT_NETLIFY_CMS_LABEL_PREFIX = 'netlify-cms/';
const getLabelPrefix = (labelPrefix: string) => labelPrefix || DEFAULT_NETLIFY_CMS_LABEL_PREFIX;
export const isCMSLabel = (label: string, labelPrefix: string) =>
label.startsWith(getLabelPrefix(labelPrefix));
export const labelToStatus = (label: string, labelPrefix: string) =>
label.substr(getLabelPrefix(labelPrefix).length);
export const statusToLabel = (status: string, labelPrefix: string) =>
`${getLabelPrefix(labelPrefix)}${status}`;
export const generateContentKey = (collectionName: string, slug: string) =>
`${collectionName}/${slug}`;