From c97c25514d8cc5f1a071c4e434a2ead1e0dd7df3 Mon Sep 17 00:00:00 2001 From: keydepth <35625044+keydepth@users.noreply.github.com> Date: Sun, 7 Mar 2021 14:48:21 +0900 Subject: [PATCH] #462 Renamed "Pipeline Status" to "CI/CD Status" --- package.json | 7 ++- src/config.ts | 6 +- src/dataSource.ts | 72 ++++++++++----------- src/extensionState.ts | 2 +- src/gitGraphView.ts | 2 +- src/types.ts | 24 +++---- web/main.ts | 18 +++--- web/settingsWidget.ts | 114 +++++++++++++++++----------------- web/styles/settingsWidget.css | 6 +- 9 files changed, 128 insertions(+), 123 deletions(-) diff --git a/package.json b/package.json index 1229962c..df527744 100644 --- a/package.json +++ b/package.json @@ -477,12 +477,17 @@ "Commit": { "type": "boolean", "title": "Visibility of the Commit column" + }, + "CIDI": { + "type": "boolean", + "title": "Visibility of the CI/DI Status column" } }, "default": { "Date": true, "Author": true, - "Commit": true + "Commit": true, + "CIDI": true }, "description": "An object specifying the default visibility of the Date, Author & Commit columns. Example: {\"Date\": true, \"Author\": true, \"Commit\": true}" }, diff --git a/src/config.ts b/src/config.ts index 85cfe580..f63855f2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -160,10 +160,10 @@ class Config { */ get defaultColumnVisibility(): DefaultColumnVisibility { let obj: any = this.config.get('defaultColumnVisibility', {}); - if (typeof obj === 'object' && obj !== null && typeof obj['Date'] === 'boolean' && typeof obj['Author'] === 'boolean' && typeof obj['Commit'] === 'boolean' && typeof obj['Pipeline'] === 'boolean') { - return { author: obj['Author'], commit: obj['Commit'], date: obj['Date'], pipeline: obj['Pileline']}; + if (typeof obj === 'object' && obj !== null && typeof obj['Date'] === 'boolean' && typeof obj['Author'] === 'boolean' && typeof obj['Commit'] === 'boolean' && typeof obj['CIDI'] === 'boolean') { + return { author: obj['Author'], commit: obj['Commit'], date: obj['Date'], cidi: obj['CIDI']}; } else { - return { author: true, commit: true, date: true, pipeline: true }; + return { author: true, commit: true, date: true, cidi: true }; } } diff --git a/src/dataSource.ts b/src/dataSource.ts index 52c28b51..6e7e9838 100644 --- a/src/dataSource.ts +++ b/src/dataSource.ts @@ -6,7 +6,7 @@ import * as vscode from 'vscode'; import { AskpassEnvironment, AskpassManager } from './askpass/askpassManager'; import { getConfig } from './config'; import { Logger } from './logger'; -import { CommitOrdering, DateType, DeepWriteable, ErrorInfo, GitCommit, GitCommitDetails, GitCommitStash, GitConfigLocation, GitFileChange, GitFileStatus, GitPipelinesData, GitPushBranchMode, GitRepoConfig, GitRepoConfigBranches, GitResetMode, GitSignatureStatus, GitStash, MergeActionOn, PipelineConfig, PipelineProvider, RebaseActionOn, SquashMessageFormat, TagType, Writeable } from './types'; +import { CIDIConfig, CIDIProvider, CommitOrdering, DateType, DeepWriteable, ErrorInfo, GitCIDIData, GitCommit, GitCommitDetails, GitCommitStash, GitConfigLocation, GitFileChange, GitFileStatus, GitPushBranchMode, GitRepoConfig, GitRepoConfigBranches, GitResetMode, GitSignatureStatus, GitStash, MergeActionOn, RebaseActionOn, SquashMessageFormat, TagType, Writeable } from './types'; import { GitExecutable, UNABLE_TO_FIND_GIT_MSG, UNCOMMITTED, abbrevCommit, constructIncompatibleGitVersionMessage, getPathFromStr, getPathFromUri, isGitAtLeastVersion, openGitTerminal, pathWithTrailingSlash, realpath, resolveSpawnOutput, showErrorMessage } from './utils'; import { Disposable } from './utils/disposable'; import { Event } from './utils/event'; @@ -159,15 +159,15 @@ export class DataSource extends Disposable { * @param stashes An array of all stashes in the repository. * @returns The commits in the repository. */ - public getCommits(repo: string, branches: ReadonlyArray | null, maxCommits: number, showTags: boolean, showRemoteBranches: boolean, includeCommitsMentionedByReflogs: boolean, onlyFollowFirstParent: boolean, commitOrdering: CommitOrdering, remotes: ReadonlyArray, hideRemotes: ReadonlyArray, stashes: ReadonlyArray, pipelineConfigs: PipelineConfig[] | null): Promise { + public getCommits(repo: string, branches: ReadonlyArray | null, maxCommits: number, showTags: boolean, showRemoteBranches: boolean, includeCommitsMentionedByReflogs: boolean, onlyFollowFirstParent: boolean, commitOrdering: CommitOrdering, remotes: ReadonlyArray, hideRemotes: ReadonlyArray, stashes: ReadonlyArray, cidiConfigs: CIDIConfig[] | null): Promise { const config = getConfig(); return Promise.all([ this.getLog(repo, branches, maxCommits + 1, showTags && config.showCommitsOnlyReferencedByTags, showRemoteBranches, includeCommitsMentionedByReflogs, onlyFollowFirstParent, commitOrdering, remotes, hideRemotes, stashes), this.getRefs(repo, showRemoteBranches, config.showRemoteHeads, hideRemotes).then((refData: GitRefData) => refData, (errorMessage: string) => errorMessage), - this.getPipelines(pipelineConfigs).then((refData: GitPipelinesData[] | string | undefined) => refData, (errorMessage: string) => errorMessage) + this.getCIDIs(cidiConfigs).then((refData: GitCIDIData[] | string | undefined) => refData, (errorMessage: string) => errorMessage) ]).then(async (results) => { let commits: GitCommitRecord[] = results[0], refData: GitRefData | string = results[1], i; - let pipelines: GitPipelinesData[] | string | undefined = results[2]; + let cidis: GitCIDIData[] | string | undefined = results[2]; let moreCommitsAvailable = commits.length === maxCommits + 1; if (moreCommitsAvailable) commits.pop(); @@ -200,7 +200,7 @@ export class DataSource extends Disposable { for (i = 0; i < commits.length; i++) { commitLookup[commits[i].hash] = i; - commitNodes.push({ ...commits[i], heads: [], tags: [], remotes: [], stash: null, pipeline: null }); + commitNodes.push({ ...commits[i], heads: [], tags: [], remotes: [], stash: null, cidi: null }); } /* Insert Stashes */ @@ -220,7 +220,7 @@ export class DataSource extends Disposable { for (i = toAdd.length - 1; i >= 0; i--) { let stash = toAdd[i].data; commitNodes.splice(toAdd[i].index, 0, { - pipeline: null, + cidi: null, hash: stash.hash, parents: [stash.baseHash], author: stash.author, @@ -261,13 +261,13 @@ export class DataSource extends Disposable { } } - if (typeof pipelines === 'string' || typeof pipelines === 'undefined') { - pipelines = []; + if (typeof cidis === 'string' || typeof cidis === 'undefined') { + cidis = []; } - /* Annotate Pipelines */ - for (i = 0; i < pipelines.length; i++) { - if (typeof commitLookup[pipelines[i].sha] === 'number') { - commitNodes[commitLookup[pipelines[i].sha]].pipeline = pipelines[i]; + /* Annotate CI/DIs */ + for (i = 0; i < cidis.length; i++) { + if (typeof commitLookup[cidis[i].sha] === 'number') { + commitNodes[commitLookup[cidis[i].sha]].cidi = cidis[i]; } } @@ -1512,33 +1512,33 @@ export class DataSource extends Disposable { } /** - * Get the result in a Pipelines. - * @param pipelineConfigs pipeline configuration. + * Get the result in a CI/DIs. + * @param cidiConfigs CI/DI configuration. * @returns The references data. */ - private async getPipelines(pipelineConfigs: PipelineConfig[] | null) { - if (pipelineConfigs === null) { + private async getCIDIs(cidiConfigs: CIDIConfig[] | null) { + if (cidiConfigs === null) { return ''; } return await Promise.all( - pipelineConfigs.map(async pipelineConfig => { - if (pipelineConfig.provider === PipelineProvider.GitHubV3) { + cidiConfigs.map(async cidiConfig => { + if (cidiConfig.provider === CIDIProvider.GitHubV3) { - const match1 = pipelineConfig.gitUrl.match(/^(https?:\/\/|git@)((?=[^/]+@)[^@]+@|(?![^/]+@))([^/:]+)/); + const match1 = cidiConfig.gitUrl.match(/^(https?:\/\/|git@)((?=[^/]+@)[^@]+@|(?![^/]+@))([^/:]+)/); let hostRootUrl = match1 !== null ? 'https://api.' + match1[3] : ''; - const match2 = pipelineConfig.gitUrl.match(/^(https?:\/\/|git@)[^/:]+[/:]([^/]+)\/([^/]*?)(.git|)$/); + const match2 = cidiConfig.gitUrl.match(/^(https?:\/\/|git@)[^/:]+[/:]([^/]+)\/([^/]*?)(.git|)$/); let sourceOwner = match2 !== null ? match2[2] : ''; let sourceRepo = match2 !== null ? match2[3] : ''; const apiRoot = `${hostRootUrl}`; - const pipelinesRootPath = `/repos/${sourceOwner}/${sourceRepo.replace(/\//g, '%2F')}/actions/runs?per_page=100`; + const cidiRootPath = `/repos/${sourceOwner}/${sourceRepo.replace(/\//g, '%2F')}/actions/runs?per_page=100`; const config: request.RequestPromiseOptions = { method: 'GET', headers: { - 'Authorization': `token ${pipelineConfig.glToken}`, + 'Authorization': `token ${cidiConfig.glToken}`, 'Accept': 'application/vnd.github.v3+json', 'User-Agent': 'vscode-git-graph' } @@ -1585,7 +1585,7 @@ export class DataSource extends Disposable { }); } if (typeof res['workflow_runs'] !== 'undefined' && res['workflow_runs'].length >= 1) { // url found - let ret: GitPipelinesData[] = res['workflow_runs'].map( (elm: { [x: string]: any; }) => { + let ret: GitCIDIData[] = res['workflow_runs'].map( (elm: { [x: string]: any; }) => { return { id: elm['id'], status: elm['conclusion'], @@ -1606,37 +1606,37 @@ export class DataSource extends Disposable { return { x_total_pages: 0, ret: e }; } }; - return request(`${apiRoot}${pipelinesRootPath}`, config).then(async (result1st) => { + return request(`${apiRoot}${cidiRootPath}`, config).then(async (result1st) => { let promises = []; promises.push(result1st.ret); for (let i = 1; i < result1st.x_total_pages; i++) { - promises.push(request(`${apiRoot}${pipelinesRootPath}&page=${i + 1}`, config)); + promises.push(request(`${apiRoot}${cidiRootPath}&page=${i + 1}`, config)); } return await Promise.all(promises); }).then((resultAll) => { - let retAll: GitPipelinesData[] = []; + let retAll: GitCIDIData[] = []; for (let i = 0; i < resultAll.length; i++) { retAll = retAll.concat(resultAll[i]); } return retAll; }); } - if (pipelineConfig.provider === PipelineProvider.GitLabV4) { + if (cidiConfig.provider === CIDIProvider.GitLabV4) { - const match1 = pipelineConfig.gitUrl.match(/^(https?:\/\/|git@)((?=[^/]+@)[^@]+@|(?![^/]+@))([^/:]+)/); + const match1 = cidiConfig.gitUrl.match(/^(https?:\/\/|git@)((?=[^/]+@)[^@]+@|(?![^/]+@))([^/:]+)/); let hostRootUrl = match1 !== null ? 'https://' + match1[3] : ''; - const match2 = pipelineConfig.gitUrl.match(/^(https?:\/\/|git@)[^/:]+[/:]([^/]+)\/([^/]*?)(.git|)$/); + const match2 = cidiConfig.gitUrl.match(/^(https?:\/\/|git@)[^/:]+[/:]([^/]+)\/([^/]*?)(.git|)$/); let sourceOwner = match2 !== null ? match2[2] : ''; let sourceRepo = match2 !== null ? match2[3] : ''; const apiRoot = `${hostRootUrl}/api/v4`; - const pipelinesRootPath = `/projects/${sourceOwner}%2F${sourceRepo.replace(/\//g, '%2F')}/pipelines?per_page=100`; + const cidiRootPath = `/projects/${sourceOwner}%2F${sourceRepo.replace(/\//g, '%2F')}/pipelines?per_page=100`; const config: request.RequestPromiseOptions = { method: 'GET', headers: { - 'PRIVATE-TOKEN': pipelineConfig.glToken, + 'PRIVATE-TOKEN': cidiConfig.glToken, 'User-Agent': 'vscode-git-graph' } }; @@ -1646,7 +1646,7 @@ export class DataSource extends Disposable { if (typeof response.headers['x-page'] === 'string' && typeof response.headers['x-total-pages'] === 'string' && typeof response.headers['x-total'] === 'string') { let res: any = JSON.parse(body); if (parseInt(response.headers['x-total']) !== 0 && res.length && res[0].id) { // url found - let ret: GitPipelinesData[] = res; + let ret: GitCIDIData[] = res; if (parseInt(response.headers['x-page']) === 1) { return { x_total_pages: parseInt(response.headers['x-total-pages']), ret: ret }; } @@ -1658,15 +1658,15 @@ export class DataSource extends Disposable { return { x_total_pages: 0, ret: e }; } }; - return request(`${apiRoot}${pipelinesRootPath}`, config).then(async (result1st) => { + return request(`${apiRoot}${cidiRootPath}`, config).then(async (result1st) => { let promises = []; promises.push(result1st.ret); for (let i = 1; i < result1st.x_total_pages; i++) { - promises.push(request(`${apiRoot}${pipelinesRootPath}&page=${i + 1}`, config)); + promises.push(request(`${apiRoot}${cidiRootPath}&page=${i + 1}`, config)); } return await Promise.all(promises); }).then((resultAll) => { - let retAll: GitPipelinesData[] = []; + let retAll: GitCIDIData[] = []; for (let i = 0; i < resultAll.length; i++) { retAll = retAll.concat(resultAll[i]); } @@ -1675,7 +1675,7 @@ export class DataSource extends Disposable { } }) ).then((resultAll2) => { - let retAll: GitPipelinesData[] = []; + let retAll: GitCIDIData[] = []; resultAll2.forEach(resultList => { resultList?.forEach(result => { retAll = retAll.concat(result); diff --git a/src/extensionState.ts b/src/extensionState.ts index 36f67bb7..3a394467 100644 --- a/src/extensionState.ts +++ b/src/extensionState.ts @@ -32,7 +32,7 @@ export const DEFAULT_REPO_STATE: GitRepoState = { onRepoLoadShowCheckedOutBranch: BooleanOverride.Default, onRepoLoadShowSpecificBranches: null, pullRequestConfig: null, - pipelineConfigs: null, + cidiConfigs: null, showRemoteBranches: true, showRemoteBranchesV2: BooleanOverride.Default, showStashes: BooleanOverride.Default, diff --git a/src/gitGraphView.ts b/src/gitGraphView.ts index 4b23e525..7c6a2f98 100644 --- a/src/gitGraphView.ts +++ b/src/gitGraphView.ts @@ -404,7 +404,7 @@ export class GitGraphView extends Disposable { command: 'loadCommits', refreshId: msg.refreshId, onlyFollowFirstParent: msg.onlyFollowFirstParent, - ...await this.dataSource.getCommits(msg.repo, msg.branches, msg.maxCommits, msg.showTags, msg.showRemoteBranches, msg.includeCommitsMentionedByReflogs, msg.onlyFollowFirstParent, msg.commitOrdering, msg.remotes, msg.hideRemotes, msg.stashes, msg.pipelineConfigs) + ...await this.dataSource.getCommits(msg.repo, msg.branches, msg.maxCommits, msg.showTags, msg.showRemoteBranches, msg.includeCommitsMentionedByReflogs, msg.onlyFollowFirstParent, msg.commitOrdering, msg.remotes, msg.hideRemotes, msg.stashes, msg.cidiConfigs) }); break; case 'loadConfig': diff --git a/src/types.ts b/src/types.ts index e8ec3914..3311e7ba 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,7 +1,6 @@ /* Git Interfaces / Types */ export interface GitCommit { - readonly pipeline: GitPipelinesData | null; readonly hash: string; readonly parents: ReadonlyArray; readonly author: string; @@ -12,9 +11,10 @@ export interface GitCommit { readonly tags: ReadonlyArray; readonly remotes: ReadonlyArray; readonly stash: GitCommitStash | null; // null => not a stash, otherwise => stash info + readonly cidi: GitCIDIData | null; } -export interface GitPipelinesData { +export interface GitCIDIData { id: string; status: string; ref: string; @@ -201,12 +201,12 @@ export type PullRequestConfig = PullRequestConfigBuiltIn | PullRequestConfigCust -export interface PipelineConfigBase { +export interface CIDIConfigBase { readonly gitUrl: string; readonly glToken: string; } -export const enum PipelineProvider { +export const enum CIDIProvider { Bitbucket, Custom, GitHubV3, @@ -214,20 +214,20 @@ export const enum PipelineProvider { Jenkins } -interface PipelineConfigBuiltIn extends PipelineConfigBase { - readonly provider: PipelineProvider; +interface CIDIConfigBuiltIn extends CIDIConfigBase { + readonly provider: CIDIProvider; readonly custom: null; } -interface PipelineConfigCustom extends PipelineConfigBase { - readonly provider: PipelineProvider.Custom; +interface CIDIConfigCustom extends CIDIConfigBase { + readonly provider: CIDIProvider.Custom; readonly custom: { readonly name: string, readonly templateUrl: string }; } -export type PipelineConfig = PipelineConfigBuiltIn | PipelineConfigCustom; +export type CIDIConfig = CIDIConfigBuiltIn | CIDIConfigCustom; export interface GitRepoState { cdvDivider: number; @@ -244,7 +244,7 @@ export interface GitRepoState { onRepoLoadShowCheckedOutBranch: BooleanOverride; onRepoLoadShowSpecificBranches: string[] | null; pullRequestConfig: PullRequestConfig | null; - pipelineConfigs: PipelineConfig[] | null; + cidiConfigs: CIDIConfig[] | null; showRemoteBranches: boolean; showRemoteBranchesV2: BooleanOverride; showStashes: BooleanOverride; @@ -469,7 +469,7 @@ export interface DefaultColumnVisibility { readonly date: boolean; readonly author: boolean; readonly commit: boolean; - readonly pipeline: boolean; + readonly cidi: boolean; } export interface DialogDefaults { @@ -927,7 +927,7 @@ export interface RequestLoadCommits extends RepoRequest { readonly remotes: ReadonlyArray; readonly hideRemotes: ReadonlyArray; readonly stashes: ReadonlyArray; - readonly pipelineConfigs: PipelineConfig[] | null; + readonly cidiConfigs: CIDIConfig[] | null; } export interface ResponseLoadCommits extends ResponseWithErrorInfo { readonly command: 'loadCommits'; diff --git a/web/main.ts b/web/main.ts index e6fad767..5b4a6ad0 100644 --- a/web/main.ts +++ b/web/main.ts @@ -616,7 +616,7 @@ class GitGraphView { remotes: this.gitRemotes, hideRemotes: repoState.hideRemotes, stashes: this.gitStashes, - pipelineConfigs: repoState.pipelineConfigs + cidiConfigs: repoState.cidiConfigs }); } @@ -821,7 +821,7 @@ class GitGraphView { (colVisibility.date ? 'Date' : '') + (colVisibility.author ? 'Author' : '') + (colVisibility.commit ? 'Commit' : '') + - (colVisibility.pipeline ? 'Pipeline' : '') + + (colVisibility.cidi ? 'CI/DI Status' : '') + ''; for (let i = 0; i < this.commits.length; i++) { @@ -870,7 +870,7 @@ class GitGraphView { (colVisibility.date ? '' + date.formatted + '' : '') + (colVisibility.author ? '' + (this.config.fetchAvatars ? '' + (typeof this.avatars[commit.email] === 'string' ? '' : '') + '' : '') + escapeHtml(commit.author) + '' : '') + (colVisibility.commit ? '' + abbrevCommit(commit.hash) + '' : '') + - (colVisibility.pipeline ? (commit.pipeline ? '' + '' + commit.pipeline.status + '' : '*') : '') + + (colVisibility.cidi ? (commit.cidi ? '' + '' + commit.cidi.status + '' : '*') : '') + ''; } this.tableElem.innerHTML = '' + html + '
'; @@ -929,7 +929,7 @@ class GitGraphView { (colVisibility.date ? '' + date.formatted + '' : '') + (colVisibility.author ? '*' : '') + (colVisibility.commit ? '*' : '') + - (colVisibility.pipeline ? '*' : ''); + (colVisibility.cidi ? '*' : ''); } private renderFetchButton() { @@ -1658,7 +1658,7 @@ class GitGraphView { let cWidths = this.gitRepos[this.currentRepo].columnWidths; if (cWidths === null) { // Initialise auto column layout if it is the first time viewing the repo. let defaults = this.config.defaultColumnVisibility; - columnWidths = [COLUMN_AUTO, COLUMN_AUTO, defaults.date ? COLUMN_AUTO : COLUMN_HIDDEN, defaults.author ? COLUMN_AUTO : COLUMN_HIDDEN, defaults.commit ? COLUMN_AUTO : COLUMN_HIDDEN, defaults.pipeline ? COLUMN_AUTO : COLUMN_HIDDEN]; + columnWidths = [COLUMN_AUTO, COLUMN_AUTO, defaults.date ? COLUMN_AUTO : COLUMN_HIDDEN, defaults.author ? COLUMN_AUTO : COLUMN_HIDDEN, defaults.commit ? COLUMN_AUTO : COLUMN_HIDDEN, defaults.cidi ? COLUMN_AUTO : COLUMN_HIDDEN]; this.saveColumnWidths(columnWidths); } else { columnWidths = [cWidths[0], COLUMN_AUTO, cWidths[1], cWidths[2], cWidths[3], cWidths[4]]; @@ -1778,7 +1778,7 @@ class GitGraphView { onClick: () => toggleColumnState(4, 80) }, { - title: 'Pepeline', + title: 'CI/DI Status', visible: true, checked: columnWidths[5] !== COLUMN_HIDDEN, onClick: () => toggleColumnState(5, 80) @@ -1811,16 +1811,16 @@ class GitGraphView { public getColumnVisibility() { let colWidths = this.gitRepos[this.currentRepo].columnWidths; if (colWidths !== null) { - return { date: colWidths[1] !== COLUMN_HIDDEN, author: colWidths[2] !== COLUMN_HIDDEN, commit: colWidths[3] !== COLUMN_HIDDEN, pipeline: colWidths[4] !== COLUMN_HIDDEN }; + return { date: colWidths[1] !== COLUMN_HIDDEN, author: colWidths[2] !== COLUMN_HIDDEN, commit: colWidths[3] !== COLUMN_HIDDEN, cidi: colWidths[4] !== COLUMN_HIDDEN }; } else { let defaults = this.config.defaultColumnVisibility; - return { date: defaults.date, author: defaults.author, commit: defaults.commit, pipeline: defaults.pipeline }; + return { date: defaults.date, author: defaults.author, commit: defaults.commit, cidi: defaults.cidi }; } } private getNumColumns() { let colVisibility = this.getColumnVisibility(); - return 2 + (colVisibility.date ? 1 : 0) + (colVisibility.author ? 1 : 0) + (colVisibility.commit ? 1 : 0) + (colVisibility.pipeline ? 1 : 0); + return 2 + (colVisibility.date ? 1 : 0) + (colVisibility.author ? 1 : 0) + (colVisibility.commit ? 1 : 0) + (colVisibility.cidi ? 1 : 0); } /** diff --git a/web/settingsWidget.ts b/web/settingsWidget.ts index acc37dbe..ba170e07 100644 --- a/web/settingsWidget.ts +++ b/web/settingsWidget.ts @@ -240,24 +240,24 @@ class SettingsWidget { } if (this.config !== null) { - html += '

Pipeline Status Configuration

'; - const pipelineConfigs = this.repo.pipelineConfigs; - if (pipelineConfigs !== null && pipelineConfigs.length !== 0) { - pipelineConfigs.forEach((pipelineConfig, i) => { + html += '

CI/DI Status Configuration

ProviderURLAction
'; + const cidiConfigs = this.repo.cidiConfigs; + if (cidiConfigs !== null && cidiConfigs.length !== 0) { + cidiConfigs.forEach((cidiConfig, i) => { let providerOptions:any = {}; - providerOptions[(GG.PipelineProvider.GitLabV4).toString()] = 'GitLabV4'; - providerOptions[(GG.PipelineProvider.GitHubV3).toString()] = 'GitHubV3'; - const gitUrl = escapeHtml(pipelineConfig.gitUrl || 'Not Set'); + providerOptions[(GG.CIDIProvider.GitHubV3).toString()] = 'GitHub'; + providerOptions[(GG.CIDIProvider.GitLabV4).toString()] = 'GitLab V4(8.11-)'; + const gitUrl = escapeHtml(cidiConfig.gitUrl || 'Not Set'); html += '' + - '' + + '' + '' + - '' + + '' + ''; }); } else { - html += ''; + html += ''; } - html += '
ProviderURLAction
' + escapeHtml(providerOptions[pipelineConfig.provider]) + '' + escapeHtml(providerOptions[cidiConfig.provider]) + '' + gitUrl + '
' + SVG_ICONS.pencil + '
' + SVG_ICONS.close + '
' + SVG_ICONS.pencil + '
' + SVG_ICONS.close + '
There are no pipelines configured for this repository.
There are no CI/DI configured for this repository.
' + SVG_ICONS.plus + 'Add Pipeline
'; + html += '
' + SVG_ICONS.plus + 'Add CI/DI
'; } html += '

Git Graph Configuration

' + @@ -473,8 +473,8 @@ class SettingsWidget { }); const updateConfigWithFormValues = (values: DialogInputValue[]) => { - let config: GG.PipelineConfig = { - provider: parseInt(values[0]), gitUrl: values[1], + let config: GG.CIDIConfig = { + provider: parseInt(values[0]), gitUrl: values[1], glToken: values[2], custom: null }; @@ -482,71 +482,71 @@ class SettingsWidget { }; const copyConfigs = () => { if (this.repo === null) return []; - let configs: GG.PipelineConfig[]; - if (this.repo.pipelineConfigs === null) { + let configs: GG.CIDIConfig[]; + if (this.repo.cidiConfigs === null) { configs = []; } else { - configs = Object.assign([], this.repo.pipelineConfigs); + configs = Object.assign([], this.repo.cidiConfigs); } return configs; }; - document.getElementById('settingsAddPipeline')!.addEventListener('click', () => { - let defaultProvider = GG.PipelineProvider.GitHubV3.toString(); + document.getElementById('settingsAddCIDI')!.addEventListener('click', () => { + let defaultProvider = GG.CIDIProvider.GitHubV3.toString(); let providerOptions = [ - // { name: 'Bitbucket', value: (GG.PipelineProvider.Bitbucket).toString() }, - { name: 'GitHubV3', value: (GG.PipelineProvider.GitHubV3).toString() }, - { name: 'GitLabV4', value: (GG.PipelineProvider.GitLabV4).toString() } + // { name: 'Bitbucket', value: (GG.CIDIProvider.Bitbucket).toString() }, + { name: 'GitHubV3', value: (GG.CIDIProvider.GitHubV3).toString() }, + { name: 'GitLabV4', value: (GG.CIDIProvider.GitLabV4).toString() } ]; - dialog.showForm('Add a new pipeline to this repository:', [ + dialog.showForm('Add a new cidi to this repository:', [ { type: DialogInputType.Select, name: 'Provider', options: providerOptions, default: defaultProvider, - info: 'In addition to the built-in publicly hosted Pipeline providers.' + info: 'In addition to the built-in publicly hosted CI/DI providers.' }, - { type: DialogInputType.Text, name: 'Git URL', default: '', placeholder: null, info: 'The Pipeline provider\'s Git URL (e.g. https://gitlab.com/OWNER/REPO.git).' }, + { type: DialogInputType.Text, name: 'Git URL', default: '', placeholder: null, info: 'The CI/DI provider\'s Git URL (e.g. https://gitlab.com/OWNER/REPO.git).' }, { type: DialogInputType.PasswordRef, name: 'Access Token', default: '', info: 'The GitLab personal access token or project access token.' } - ], 'Add Pipeline', (values) => { - let configs: GG.PipelineConfig[] = copyConfigs(); - let config: GG.PipelineConfig = updateConfigWithFormValues(values); + ], 'Add CI/DI', (values) => { + let configs: GG.CIDIConfig[] = copyConfigs(); + let config: GG.CIDIConfig = updateConfigWithFormValues(values); configs.push(config); - this.setPipelineConfig(configs); + this.setCIDIConfig(configs); }, { type: TargetType.Repo }); }); - addListenerToClass('editPipeline', 'click', (e) => { - const pipelineConfig = this.getPipelineForBtnEvent(e); - if (pipelineConfig === null) return; + addListenerToClass('editCIDI', 'click', (e) => { + const cidiConfig = this.getCIDIForBtnEvent(e); + if (cidiConfig === null) return; let providerOptions = [ - // { name: 'Bitbucket', value: (GG.PipelineProvider.Bitbucket).toString() }, - { name: 'GitHubV3', value: (GG.PipelineProvider.GitHubV3).toString() }, - { name: 'GitLabV4', value: (GG.PipelineProvider.GitLabV4).toString() } + // { name: 'Bitbucket', value: (GG.CIDIProvider.Bitbucket).toString() }, + { name: 'GitHub', value: (GG.CIDIProvider.GitHubV3).toString() }, + { name: 'GitLab V4(8.11-)', value: (GG.CIDIProvider.GitLabV4).toString() } ]; - dialog.showForm('Edit the Pipeline ' + escapeHtml(pipelineConfig.gitUrl || 'Not Set') + ':', [ + dialog.showForm('Edit the CI/DI ' + escapeHtml(cidiConfig.gitUrl || 'Not Set') + ':', [ { type: DialogInputType.Select, name: 'Provider', - options: providerOptions, default: pipelineConfig.provider.toString(), - info: 'In addition to the built-in publicly hosted Pipeline providers.' + options: providerOptions, default: cidiConfig.provider.toString(), + info: 'In addition to the built-in publicly hosted CI/DI providers.' }, - { type: DialogInputType.Text, name: 'Git URL', default: pipelineConfig.gitUrl || '', placeholder: null, info: 'The Pipeline provider\'s Git URL (e.g. https://gitlab.com/OWNER/REPO.git).' }, - { type: DialogInputType.PasswordRef, name: 'Personal Access Token', default: pipelineConfig.glToken, info: 'The GitLab personal access token.' } + { type: DialogInputType.Text, name: 'Git URL', default: cidiConfig.gitUrl || '', placeholder: null, info: 'The CI/DI provider\'s Git URL (e.g. https://gitlab.com/OWNER/REPO.git).' }, + { type: DialogInputType.PasswordRef, name: 'Personal Access Token', default: cidiConfig.glToken, info: 'The GitLab personal access token.' } ], 'Save Changes', (values) => { - let index = parseInt(((e.target).closest('.pipelineBtns')!).dataset.index!); - let configs: GG.PipelineConfig[] = copyConfigs(); - let config: GG.PipelineConfig = updateConfigWithFormValues(values); + let index = parseInt(((e.target).closest('.cidiBtns')!).dataset.index!); + let configs: GG.CIDIConfig[] = copyConfigs(); + let config: GG.CIDIConfig = updateConfigWithFormValues(values); configs[index] = config; - this.setPipelineConfig(configs); + this.setCIDIConfig(configs); }, { type: TargetType.Repo }); }); - addListenerToClass('deletePipeline', 'click', (e) => { - const pipelineConfig = this.getPipelineForBtnEvent(e); - if (pipelineConfig === null) return; - dialog.showConfirmation('Are you sure you want to delete the Pipeline ' + escapeHtml(pipelineConfig.gitUrl) + '?', 'Yes, delete', () => { - let index = parseInt(((e.target).closest('.pipelineBtns')!).dataset.index!); - let configs: GG.PipelineConfig[] = copyConfigs(); + addListenerToClass('deleteCIDI', 'click', (e) => { + const cidiConfig = this.getCIDIForBtnEvent(e); + if (cidiConfig === null) return; + dialog.showConfirmation('Are you sure you want to delete the CI/DI ' + escapeHtml(cidiConfig.gitUrl) + '?', 'Yes, delete', () => { + let index = parseInt(((e.target).closest('.cidiBtns')!).dataset.index!); + let configs: GG.CIDIConfig[] = copyConfigs(); configs.splice(index, 1); - this.setPipelineConfig(configs); + this.setCIDIConfig(configs); }, { type: TargetType.Repo }); }); @@ -674,9 +674,9 @@ class SettingsWidget { * Save the pull request configuration for this repository. * @param config The pull request configuration to save. */ - private setPipelineConfig(config: GG.PipelineConfig[] | null) { + private setCIDIConfig(config: GG.CIDIConfig[] | null) { if (this.currentRepo === null) return; - this.view.saveRepoStateValue(this.currentRepo, 'pipelineConfigs', config); + this.view.saveRepoStateValue(this.currentRepo, 'cidiConfigs', config); this.render(); } @@ -911,13 +911,13 @@ class SettingsWidget { } /** - * Get the pipeline details corresponding to a mouse event. + * Get the cidi details corresponding to a mouse event. * @param e The mouse event. - * @returns The details of the pipeline. + * @returns The details of the cidi. */ - private getPipelineForBtnEvent(e: Event) { - return this.repo !== null && this.repo.pipelineConfigs !== null - ? this.repo.pipelineConfigs[parseInt(((e.target).closest('.pipelineBtns')!).dataset.index!)] + private getCIDIForBtnEvent(e: Event) { + return this.repo !== null && this.repo.cidiConfigs !== null + ? this.repo.cidiConfigs[parseInt(((e.target).closest('.cidiBtns')!).dataset.index!)] : null; } diff --git a/web/styles/settingsWidget.css b/web/styles/settingsWidget.css index b894e47f..1cb65f49 100644 --- a/web/styles/settingsWidget.css +++ b/web/styles/settingsWidget.css @@ -140,17 +140,17 @@ vertical-align:top; cursor:pointer; } -.settingsSection > table td.btns.remoteBtns div, .settingsSection > table td.btns.pipelineBtns div{ +.settingsSection > table td.btns.remoteBtns div, .settingsSection > table td.btns.cidiBtns div{ vertical-align:middle; } -.settingsSection > table #editRepoName svg, .settingsSection > table #editInitialBranches svg, .settingsSection > table .editRemote svg, .settingsSection > table .editPipeline svg{ +.settingsSection > table #editRepoName svg, .settingsSection > table #editInitialBranches svg, .settingsSection > table .editRemote svg, .settingsSection > table .editCIDI svg{ position:absolute; left:1.5px; top:1.5px; width:14px !important; height:14px !important; } -.settingsSection > table #deleteRepoName svg, .settingsSection > table #clearInitialBranches svg, .settingsSection > table .deleteRemote svg, .settingsSection > table .fetchRemote svg, .settingsSection > table .pruneRemote svg, .settingsSection > table .deletePipeline svg{ +.settingsSection > table #deleteRepoName svg, .settingsSection > table #clearInitialBranches svg, .settingsSection > table .deleteRemote svg, .settingsSection > table .fetchRemote svg, .settingsSection > table .pruneRemote svg, .settingsSection > table .deleteCIDI svg{ position:absolute; left:0.5px; top:0.5px;