diff --git a/README.md b/README.md index 39ea5bfe..e27dedf2 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ To configure your Ubiquibot to run this plugin, add the following to the `.ubiqu startRequiresWallet: true # default is true emptyWalletText: "Please set your wallet address with the /wallet command first and try again." rolesWithReviewAuthority: ["MEMBER", "OWNER"] + requiredLabelsToStart: ["Priority: 5 (Emergency)"] ``` # Testing diff --git a/manifest.json b/manifest.json index 02b81a8d..3aced86e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,13 +1,7 @@ { "name": "Start | Stop", "description": "Assign or un-assign yourself from an issue.", - "ubiquity:listeners": [ - "issue_comment.created", - "issues.assigned", - "issues.unassigned", - "pull_request.opened", - "pull_request.edited" - ], + "ubiquity:listeners": ["issue_comment.created", "issues.assigned", "issues.unassigned", "pull_request.opened", "pull_request.edited"], "commands": { "start": { "ubiquity:example": "/start", @@ -51,12 +45,7 @@ "type": "string" }, "rolesWithReviewAuthority": { - "default": [ - "COLLABORATOR", - "OWNER", - "MEMBER", - "ADMIN" - ], + "default": ["COLLABORATOR", "OWNER", "MEMBER", "ADMIN"], "type": "array", "items": { "type": "string" @@ -79,4 +68,4 @@ "requiredLabelsToStart" ] } -} \ No newline at end of file +} diff --git a/src/handlers/shared/start.ts b/src/handlers/shared/start.ts index df4ab513..c3940f06 100644 --- a/src/handlers/shared/start.ts +++ b/src/handlers/shared/start.ts @@ -16,11 +16,11 @@ export async function start( teammates: string[] ): Promise { const { logger, config } = context; - const { taskStaleTimeoutDuration } = config; + const { taskStaleTimeoutDuration, requiredLabelsToStart } = config; const issueLabels = issue.labels.map((label) => label.name); - if (!config.requiredLabelsToStart.some((label) => issueLabels.includes(label))) { + if (requiredLabelsToStart.length && !requiredLabelsToStart.some((label) => issueLabels.includes(label))) { // The "Priority" label must reflect a business priority, not a development one. throw new Error("This task does not reflect a business priority at the moment and cannot be started. This will be reassessed in the coming weeks."); } diff --git a/src/types/plugin-input.ts b/src/types/plugin-input.ts index c6d5e34b..c93643e7 100644 --- a/src/types/plugin-input.ts +++ b/src/types/plugin-input.ts @@ -45,7 +45,7 @@ export const pluginSettingsSchema = T.Object( rolesWithReviewAuthority: T.Transform(rolesWithReviewAuthority) .Decode((value) => value.map((role) => role.toUpperCase())) .Encode((value) => value.map((role) => role.toUpperCase())), - requiredLabelsToStart: T.Array(T.String()), // no default, must be in the config + requiredLabelsToStart: T.Array(T.String(), { default: [] }), }, { default: {},