fix: problem with empty project configuration with number #2066

This commit is contained in:
Hugaleno Bezerra 2022-05-04 21:52:47 -03:00 committed by Johannes Millan
parent 4b9bc81f04
commit fe7e37a177

View file

@ -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];
}