diff --git a/src/app/features/issue/providers/github/github.const.ts b/src/app/features/issue/providers/github/github.const.ts index d8734b2b3ab..8b56e4bb3c1 100644 --- a/src/app/features/issue/providers/github/github.const.ts +++ b/src/app/features/issue/providers/github/github.const.ts @@ -7,6 +7,7 @@ import { } from '../../../config/global-config.model'; import { IssueProviderGithub } from '../../issue.model'; import { ISSUE_PROVIDER_COMMON_FORM_FIELDS } from '../../common-issue-form-stuff.const'; +import { FormlyFieldConfig } from '@ngx-formly/core'; export const DEFAULT_GITHUB_CFG: GithubCfg = { isEnabled: false, @@ -42,8 +43,16 @@ export const GITHUB_CONFIG_FORM: LimitedFormlyFieldConfig[] props: { label: T.F.GITHUB.FORM.TOKEN, required: true, + placeholder: 'ghp_... (classic token)', type: 'password', }, + validators: { + token: { + expression: (c: { value: string | undefined }) => c.value?.startsWith('ghp_'), + message: (error: any, field: FormlyFieldConfig) => + `${field.formControl?.value} ${T.F.GITHUB.FORM.INVALID_TOKEN_MESSAGE}`, + }, + }, }, { type: 'link', diff --git a/src/app/t.const.ts b/src/app/t.const.ts index 1ab9bac1ad0..572b55518af 100644 --- a/src/app/t.const.ts +++ b/src/app/t.const.ts @@ -229,6 +229,7 @@ const T = { IS_ASSIGNEE_FILTER: 'F.GITHUB.FORM.IS_ASSIGNEE_FILTER', REPO: 'F.GITHUB.FORM.REPO', TOKEN: 'F.GITHUB.FORM.TOKEN', + INVALID_TOKEN_MESSAGE: 'F.GITHUB.FORM.INVALID_TOKEN_MESSAGE', }, FORM_SECTION: { HELP: 'F.GITHUB.FORM_SECTION.HELP', diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 7d5657fb159..2a5a41b037e 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -227,7 +227,8 @@ "FILTER_USER": "Username (e.g. to filter out changes by yourself)", "IS_ASSIGNEE_FILTER": "Only import issues assigned to me to backlog", "REPO": "username/repositoryName", - "TOKEN": "Access Token" + "TOKEN": "Access Token", + "INVALID_TOKEN_MESSAGE": "is not a valid GitHub token. It must start with \"ghp_\"." }, "FORM_SECTION": { "HELP": "

Here you can configure SuperProductivity to list open GitHub issues for a specific repository in the task creation panel in the daily planning view. They will be listed as suggestions and will provide a link to the issue as well as more information about it.

In addition you can automatically import all open issues.

To get by usage limits and to access you can provide a an access token. More info about its scopes can be found here.",