From fe7e37a1776d4be2dcc028491f74c59bc7883dcf Mon Sep 17 00:00:00 2001 From: Hugaleno Bezerra Date: Wed, 4 May 2022 21:52:47 -0300 Subject: [PATCH] fix: problem with empty project configuration with number #2066 --- .../project-settings-page.component.ts | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/app/pages/project-settings-page/project-settings-page.component.ts b/src/app/pages/project-settings-page/project-settings-page.component.ts index c81b375a63..f793f84c81 100644 --- a/src/app/pages/project-settings-page/project-settings-page.component.ts +++ b/src/app/pages/project-settings-page/project-settings-page.component.ts @@ -20,18 +20,18 @@ import { import { Subscription } from 'rxjs'; import { ProjectService } from '../../features/project/project.service'; import { BASIC_PROJECT_CONFIG_FORM_CONFIG } from '../../features/project/project-form-cfg.const'; -import { ISSUE_PROVIDER_FORM_CFGS } from '../../features/issue/issue.const'; +import { + ISSUE_PROVIDER_FORM_CFGS, + DEFAULT_ISSUE_PROVIDER_CFGS, +} from '../../features/issue/issue.const'; import { GLOBAL_CONFIG_FORM_CONFIG } from '../../features/config/global-config-form-config.const'; import { IS_ELECTRON } from '../../app.constants'; -import { DEFAULT_JIRA_CFG } from '../../features/issue/providers/jira/jira.const'; -import { DEFAULT_GITHUB_CFG } from '../../features/issue/providers/github/github.const'; import { WorkContextAdvancedCfg, WorkContextThemeCfg, } from '../../features/work-context/work-context.model'; import { WORK_CONTEXT_THEME_CONFIG_FORM_CONFIG } from '../../features/work-context/work-context.const'; import { WorkContextService } from '../../features/work-context/work-context.service'; -import { DEFAULT_GITLAB_CFG } from 'src/app/features/issue/providers/gitlab/gitlab.const'; import { distinctUntilChanged } from 'rxjs/operators'; import { isObject } from '../../util/is-object'; @@ -102,17 +102,6 @@ export class ProjectSettingsPageComponent implements OnInit, OnDestroy { // in case there are new ones... this.issueIntegrationCfgs = { ...project.issueIntegrationCfgs }; - // Unfortunately needed, to make sure we have no empty configs - // TODO maybe think of a better solution for the defaults - if (!this.issueIntegrationCfgs.JIRA) { - this.issueIntegrationCfgs.JIRA = DEFAULT_JIRA_CFG; - } - if (!this.issueIntegrationCfgs.GITHUB) { - this.issueIntegrationCfgs.GITHUB = DEFAULT_GITHUB_CFG; - } - if (!this.issueIntegrationCfgs.GITLAB) { - this.issueIntegrationCfgs.GITLAB = DEFAULT_GITLAB_CFG; - } this._cd.detectChanges(); }), ); @@ -179,7 +168,7 @@ export class ProjectSettingsPageComponent implements OnInit, OnDestroy { getIssueIntegrationCfg(key: IssueProviderKey): IssueIntegrationCfg { if (!(this.issueIntegrationCfgs as any)[key]) { - throw new Error('Invalid issue integration cfg'); + return DEFAULT_ISSUE_PROVIDER_CFGS[key]; } return (this.issueIntegrationCfgs as any)[key]; }