diff --git a/src/app/features/issue/providers/github/github-common-interfaces.service.ts b/src/app/features/issue/providers/github/github-common-interfaces.service.ts index 2f1defeb0a2..e71fac11f32 100644 --- a/src/app/features/issue/providers/github/github-common-interfaces.service.ts +++ b/src/app/features/issue/providers/github/github-common-interfaces.service.ts @@ -7,11 +7,16 @@ import { GithubApiService } from './github-api.service'; import { ProjectService } from '../../../project/project.service'; import { SearchResultItem } from '../../issue.model'; import { GithubCfg } from './github.model'; -import { GithubIssue, GithubIssueReduced } from './github-issue/github-issue.model'; +import { + GithubIssue, + GithubIssueReduced, + GithubLabel, +} from './github-issue/github-issue.model'; import { truncate } from '../../../../util/truncate'; import { getTimestamp } from '../../../../util/get-timestamp'; import { isGithubEnabled } from './is-github-enabled.util'; import { GITHUB_INITIAL_POLL_DELAY, GITHUB_POLL_INTERVAL } from './github.const'; +import { TagService } from '../../../tag/tag.service'; @Injectable({ providedIn: 'root', @@ -20,6 +25,7 @@ export class GithubCommonInterfacesService implements IssueServiceInterface { constructor( private readonly _githubApiService: GithubApiService, private readonly _projectService: ProjectService, + private _tagService: TagService, ) {} pollTimer$: Observable = timer(GITHUB_INITIAL_POLL_DELAY, GITHUB_POLL_INTERVAL); @@ -156,6 +162,7 @@ export class GithubCommonInterfacesService implements IssueServiceInterface { // NOTE: we use Date.now() instead to because updated does not account for comments issueLastUpdated: new Date(issue.updated_at).getTime(), isDone: this._isIssueDone(issue), + tagIds: this._getGithubLabelsAsTags(issue.labels), }; } @@ -174,4 +181,12 @@ export class GithubCommonInterfacesService implements IssueServiceInterface { private _isIssueDone(issue: GithubIssueReduced): boolean { return issue.state === 'closed'; } + + private _getGithubLabelsAsTags(labels: GithubLabel[]): string[] { + const getTagIds: string[] = []; + labels.forEach((label: GithubLabel) => { + getTagIds.push(this._tagService.addTag({ title: label.name, color: label.color })); + }, this); + return getTagIds; + } } diff --git a/src/app/features/issue/providers/github/github-issue/github-issue-map.util.ts b/src/app/features/issue/providers/github/github-issue/github-issue-map.util.ts index a20a2916ba3..0ec8bb34eb2 100644 --- a/src/app/features/issue/providers/github/github-issue/github-issue-map.util.ts +++ b/src/app/features/issue/providers/github/github-issue/github-issue-map.util.ts @@ -49,6 +49,7 @@ export const mapGithubReducedIssueFromGraphQL = ({ node }: any): GithubIssueRedu title: node.title, state: node.state, updated_at: node.updatedAt, + labels: node.labels, }; }; diff --git a/src/app/features/issue/providers/github/github-issue/github-issue.model.ts b/src/app/features/issue/providers/github/github-issue/github-issue.model.ts index 4c19ba27ecd..03421b0bc53 100644 --- a/src/app/features/issue/providers/github/github-issue/github-issue.model.ts +++ b/src/app/features/issue/providers/github/github-issue/github-issue.model.ts @@ -25,6 +25,9 @@ export type GithubIssueReduced = Readonly<{ id: number; number: number; + // to include labels as tags + labels: GithubLabel[]; + // removed // node_id: string; // assignees: GithubOriginalUser[]; @@ -40,7 +43,7 @@ export type GithubIssue = GithubIssueReduced & events_url: string; html_url: string; body: string; - labels: GithubLabel[]; + // labels: GithubLabel[]; milestone: GithubMileStone; locked: boolean; active_lock_reason: string; diff --git a/src/app/features/issue/providers/github/github.const.ts b/src/app/features/issue/providers/github/github.const.ts index 629be333e24..28f8c8f9ddb 100644 --- a/src/app/features/issue/providers/github/github.const.ts +++ b/src/app/features/issue/providers/github/github.const.ts @@ -15,6 +15,7 @@ export const DEFAULT_GITHUB_CFG: GithubCfg = { isAutoAddToBacklog: false, filterUsername: null, filterIssuesAssignedToMe: false, + isImportLabelsAsTags: false, }; // NOTE: we need a high limit because git has low usage limits :( @@ -97,6 +98,14 @@ export const GITHUB_CONFIG_FORM: LimitedFormlyFieldConfig[] = [ label: T.F.GITHUB.FORM.IS_ASSIGNEE_FILTER, }, }, + { + key: 'isImportLabelsAsTags', + type: 'checkbox', + hideExpression: (model: any) => !model.isEnabled, + templateOptions: { + label: T.F.GITHUB.FORM.IS_IMPORT_LABELS_AS_TAGS, + }, + }, ]; export const GITHUB_CONFIG_FORM_SECTION: ConfigFormSection = { diff --git a/src/app/features/issue/providers/github/github.model.ts b/src/app/features/issue/providers/github/github.model.ts index c9a108ffa89..e68e61af769 100644 --- a/src/app/features/issue/providers/github/github.model.ts +++ b/src/app/features/issue/providers/github/github.model.ts @@ -8,4 +8,5 @@ export interface GithubCfg extends BaseIssueProviderCfg { repo: string | null; token: string | null; filterIssuesAssignedToMe: boolean; + isImportLabelsAsTags: boolean; } diff --git a/src/app/t.const.ts b/src/app/t.const.ts index 89e837678f5..473a4f74e2c 100644 --- a/src/app/t.const.ts +++ b/src/app/t.const.ts @@ -262,6 +262,7 @@ const T = { TOKEN: 'F.GITHUB.FORM.TOKEN', TOKEN_DESCRIPTION: 'F.GITHUB.FORM.TOKEN_DESCRIPTION', IS_ASSIGNEE_FILTER: 'F.GITHUB.FORM.IS_ASSIGNEE_FILTER', + IS_IMPORT_LABELS_AS_TAGS: 'F.GITHUB.FORM.IS_IMPORT_LABELS_AS_TAGS', }, FORM_SECTION: { HELP: 'F.GITHUB.FORM_SECTION.HELP', diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index d6a435abfec..07fbb021048 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -260,7 +260,8 @@ "REPO": "\"Benutzername / Repositoryname\" für das Git-Repository, das Sie verfolgen möchten", "TOKEN": "Zugangstoken", "TOKEN_DESCRIPTION": "Erforderlich für den Zugriff auf private Repositories", - "IS_ASSIGNEE_FILTER": "Filtert die mir zugewiesenen Issues" + "IS_ASSIGNEE_FILTER": "Filtert die mir zugewiesenen Issues", + "IS_IMPORT_LABELS_AS_TAGS": "GitHub Labels als tags in SuperProductivity importieren" }, "FORM_SECTION": { "HELP": "

Hier können Sie SuperProductivity so konfigurieren, dass offene GitHub-Issues für ein bestimmtes Repository im Aufgabenerstellungsbereich in der Tagesplanungsansicht aufgelistet werden. Sie werden als Vorschläge aufgeführt und enthalten einen Link zum Thema sowie weitere Informationen dazu.

Außerdem können Sie alle offenen Issues automatisch zu Ihrem Aufgaben-Backlog hinzufügen und synchronisieren.

", diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index ef086566e46..9e2ab3443df 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -260,7 +260,8 @@ "REPO": "\"username/repositoryName\" for the git repository you want to track", "TOKEN": "Access Token", "TOKEN_DESCRIPTION": "Required for private repository access", - "IS_ASSIGNEE_FILTER": "Filter Issues Assigned to Me" + "IS_ASSIGNEE_FILTER": "Filter Issues Assigned to Me", + "IS_IMPORT_LABELS_AS_TAGS": "Import GitHub labels as tags in SuperProductivity" }, "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.",