Skip to content

Commit

Permalink
Merge branch 'master' into pick2ks/1900
Browse files Browse the repository at this point in the history
  • Loading branch information
yazhouio authored Oct 23, 2023
2 parents 91b6acc + 5dbc288 commit 278c1a1
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 51 deletions.
14 changes: 7 additions & 7 deletions locales/en/l10n-devopsProjects-pipeline-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ module.exports = {
BRANCH_EXCLUDED: 'Excluded Branches',
BRANCH_INCLUDED: 'Included Branches',
// List > Create > Advanced Settings
DELETE_OUTDATED_BRANCHES: 'Delete outdated branches',
DELETE_OUTDATED_BRANCHES_TIP: 'Set the system to automatically delete outdated branches to save disk space.',
BRANCH_SETTINGS: 'Branch Settings',
BRANCH_RETENTION_PERIOD_DAYS: 'Branch Retention Period (days)',
MAXIMUM_BRANCHES: 'Maximum Branches',
BRANCH_RETENTION_PERIOD_DAYS_DESC: 'Branches that exceed the retention period are deleted. The default value is 7.',
MAXIMUM_BRANCHES_DESC: 'When the number of branches exceeds the maximum number allowed, the earliest branch is deleted. The default value is 5.',
DELETE_OUTDATED_BRANCHES: 'Delete outdated pipelines',
DELETE_OUTDATED_BRANCHES_TIP: 'Set the system to automatically delete outdated pipelines to save disk space.',
BRANCH_SETTINGS: 'Pipelines Settings',
BRANCH_RETENTION_PERIOD_DAYS: 'Pipelines Retention Period (days)',
MAXIMUM_BRANCHES: 'Maximum Pipelines',
BRANCH_RETENTION_PERIOD_DAYS_DESC: 'Pipelines that exceed the retention period are deleted. The default value is 7.',
MAXIMUM_BRANCHES_DESC: 'When the number of pipelines exceeds the maximum number allowed, the earliest pipeline is deleted. The default value is 5.',
ADD_STRATEGY: 'Add Strategy',
DISCOVER_TAG_BRANCHES: 'Discover Tags',
DISCOVER_BRANCHES: 'Discover Branches',
Expand Down
12 changes: 6 additions & 6 deletions locales/tc/l10n-devopsProjects-pipeline-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ module.exports = {
BRANCH_EXCLUDED: '排除分支',
BRANCH_INCLUDED: '包括分支',
// List > Create > Advanced Settings
DELETE_OUTDATED_BRANCHES: '丢棄舊的分支',
DELETE_OUTDATED_BRANCHES: '丢棄舊的流水線',
DELETE_OUTDATED_BRANCHES_TIP: 'Set the system to automatically delete outdated branches to save disk space.',
BRANCH_SETTINGS: ' 分支設置',
BRANCH_RETENTION_PERIOD_DAYS: '保留分支的天數',
MAXIMUM_BRANCHES: '保留分支的最大個數',
BRANCH_RETENTION_PERIOD_DAYS_DESC: '達到保留天數的分支將被刪除,默認值為 7。',
MAXIMUM_BRANCHES_DESC: '如果分支數量超過保留的最大數量,將丟棄舊的分支。默認值為 5。',
BRANCH_SETTINGS: ' 流水線設置',
BRANCH_RETENTION_PERIOD_DAYS: '保留流水線的天數',
MAXIMUM_BRANCHES: '保留流水線的最大個數',
BRANCH_RETENTION_PERIOD_DAYS_DESC: '達到保留天數的流水線將被刪除,默認值為 7。',
MAXIMUM_BRANCHES_DESC: '如果流水線數量超過保留的最大數量,將丟棄舊的流水線。默認值為 5。',
ADD_STRATEGY: 'Add Strategy',
DISCOVER_TAG_BRANCHES: '發現 Tag 分支',
DISCOVER_BRANCHES: '發現分支',
Expand Down
12 changes: 6 additions & 6 deletions locales/zh/l10n-devopsProjects-pipeline-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ module.exports = {
BRANCH_EXCLUDED: '排除分支',
BRANCH_INCLUDED: '包括分支',
// List > Create > Advanced Settings
DELETE_OUTDATED_BRANCHES: '删除旧分支',
DELETE_OUTDATED_BRANCHES_TIP: '设置系统自动删除过期分支以节省磁盘空间。',
BRANCH_SETTINGS: ' 分支设置',
BRANCH_RETENTION_PERIOD_DAYS: '分支保留天数(天)',
MAXIMUM_BRANCHES: '分支最大数量',
BRANCH_RETENTION_PERIOD_DAYS_DESC: '超过保留期限的分支将被删除。默认值为 7。',
DELETE_OUTDATED_BRANCHES: '删除旧流水线',
DELETE_OUTDATED_BRANCHES_TIP: '设置系统自动删除过期流水线以节省磁盘空间。',
BRANCH_SETTINGS: ' 流水线设置',
BRANCH_RETENTION_PERIOD_DAYS: '流水线保留天数(天)',
MAXIMUM_BRANCHES: '流水线最大数量',
BRANCH_RETENTION_PERIOD_DAYS_DESC: '超过保留期限的流水线将被删除。默认值为 7。',
MAXIMUM_BRANCHES_DESC: '当构建记录数量超过允许的最大数量,最早的构建记录将被删除。默认值为 5。',
ADD_STRATEGY: '添加策略',
DISCOVER_TAG_BRANCHES: '发现标签',
Expand Down
44 changes: 44 additions & 0 deletions server/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,50 @@ const k8sResourceProxy = {

NEED_OMIT_HEADERS.forEach(key => proxyReq.removeHeader(key))
},
proxyRes(proxyRes, req, client_res) {
let maxBufferSize = req.headers['x-file-size-limit']
if (maxBufferSize) {
maxBufferSize = Number(maxBufferSize)
let body = Buffer.alloc(maxBufferSize)
let offset = 0
let end = false
proxyRes.on('data', chunk => {
if (end) {
return
}
if (offset >= maxBufferSize) {
if (!client_res.getHeader('x-file-size-limit-out')) {
client_res.setHeader('x-file-size-limit-out', 'true')
}
proxyRes.emit('end')
end = true
return
}
chunk.copy(body, offset)

offset += chunk.length
})
proxyRes.pipe = function(res) {
proxyRes.on('end', () => {
end = true
const offset1 = Math.min(offset, maxBufferSize)
body = body.slice(0, offset1)
res.writeHead(proxyRes.statusCode, {
...proxyRes.headers,
'x-file-size': offset1,
})
res.end(body)
})
}
}
let addHeaders = req.headers['x-add-res-header']
if (addHeaders) {
addHeaders = JSON.parse(addHeaders)
Object.keys(addHeaders).forEach(key => {
proxyRes.headers[key] = addHeaders[key]
})
}
},
},
}

Expand Down
1 change: 1 addition & 0 deletions src/actions/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export default {
on({ store, success, devops, cluster, ...props }) {
const modal = Modal.open({
onOk: async (parameters, branch) => {
Notify.success({ content: `${t('PIPELINE_RUN_START_SI')}` })
await store.runBranch({
devops,
name: props.params.name,
Expand Down
9 changes: 8 additions & 1 deletion src/components/Forms/Pipelines/ParamsFormModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export default class ParamsFormModal extends React.Component {
const { parameters, currentBranch } = this.state

this.formRef.current.validate(() => {
if (!isEmpty(formParameters) && formParameters.__branch) {
formParameters.branch = formParameters.__branch
delete formParameters.__branch
}
const params = isEmpty(formParameters)
? !isEmpty(parameters) && Array.isArray(parameters)
? parameters.map(item => ({
Expand Down Expand Up @@ -171,7 +175,10 @@ export default class ParamsFormModal extends React.Component {
label={param.name}
desc={param.description}
>
<Input defaultValue={defaultValue} name={param.name} />
<Input
defaultValue={defaultValue}
name={param.name === 'branch' ? '__branch' : param.name}
/>
</Form.Item>
)
case 'text':
Expand Down
8 changes: 4 additions & 4 deletions src/components/Modals/CredentialCreate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ export default class CredentialModal extends React.Component {
label: t('CREDENTIAL_TYPE_SECRET_TEXT'),
value: 'secret_text',
},
{
label: t('CREDENTIAL_TYPE_KUBECONFIG'),
value: 'kubeconfig',
},
// {
// label: t('CREDENTIAL_TYPE_KUBECONFIG'),
// value: 'kubeconfig',
// },
]}
disabled={isEditMode}
onChange={this.handleTypeChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export default class Activity extends React.Component {
disabledBrancheNames: toJS(detail.disabledBrancheNames),
parameters: toJS(detail.parameters),
success: () => {
Notify.success({ content: `${t('PIPELINE_RUN_START_SI')}` })
this.handleFetch()
},
})
Expand Down Expand Up @@ -246,8 +245,8 @@ export default class Activity extends React.Component {
width: '10%',
key: 'run',
render: record =>
record.result === 'ABORTED' || !record.result ? (
<span>{record.id}</span>
!record.id ? (
<span>-</span>
) : (
<Link className="item-name" to={this.getRunhref(record)}>
{record.id}
Expand Down
19 changes: 18 additions & 1 deletion src/pages/devops/containers/Pipelines/Detail/Layout/pipeline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { getPipelineStatus } from 'utils/status'

import { trigger } from 'utils/action'

import { getCodeRepoTemplate } from 'utils/devOpsRepos'
import './index.scss'

@inject('rootStore', 'devopsStore', 'pipelineStore')
Expand Down Expand Up @@ -256,6 +257,17 @@ export default class PipelineDetailLayout extends React.Component {

getAttrs = () => {
const { devopsName } = this.props.devopsStore
let repo = {}
if (this.store.detail.isMultiBranch) {
const config = toJS(this.store.pipelineConfig)
const provider = get(config, 'spec.multi_branch_pipeline.source_type')
const source = get(
config,
`spec.multi_branch_pipeline.${provider}_source`,
{}
)
repo = getCodeRepoTemplate[provider]?.(source) ?? {}
}

const syncStatus = get(
this.store.pipelineConfig,
Expand All @@ -275,6 +287,11 @@ export default class PipelineDetailLayout extends React.Component {
name: t('KIND_TCAP'),
value: kind,
},
{
hide: !this.store.detail.isMultiBranch,
name: t('CODE_REPO'),
value: repo.repo && repo.url ? `${repo.repo}(${repo.url})` : repo.url,
},
{
name: t('TASK_STATUS'),
value: <Status {...getPipelineStatus(this.getCurrentState())} />,
Expand All @@ -287,7 +304,7 @@ export default class PipelineDetailLayout extends React.Component {
name: t('UPDATE_TIME_TCAP'),
value: this.getUpTime(),
},
]
].filter(i => !i.hide)
}

handleScanRepository = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export default class FullLogs extends React.Component {
}

@action
getPipelineIndexLog() {
getPipelineIndexLog(refresh = false) {
const { params } = this.props
this.store.getRunStatusLogs(params)
this.store.getRunStatusLogs(params, refresh)
}

@computed
Expand Down Expand Up @@ -87,7 +87,8 @@ export default class FullLogs extends React.Component {
}

handleRefreshLogs = async () => {
await this.getPipelineIndexLog()
await this.getPipelineIndexLog(true)
await this.handleRealtime()
this.scrollToBottom()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
@import '~scss/mixins';

.container {
display: flex;
display: grid;
grid-template-columns: 215px 1fr;
height: 100%;
}

Expand All @@ -17,13 +18,16 @@
}

.left {
flex-basis: 215px;
height: 500px;
overflow: auto;
}

.right {
flex-grow: 1;
// max-height: calc(100vh - 200px);
overflow-y: auto;
display: grid;
grid-template-rows: auto 1fr;
gap: 12px;
}

.cutTitle {
Expand Down Expand Up @@ -71,7 +75,6 @@

.header {
height: 32px;
margin-bottom: 12px;
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
Expand All @@ -93,7 +96,6 @@

.logContainer {
width: 100%;
height: 100%;
padding: 12px;
border-radius: 4px;
background-color: #242e42;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export default class TaskStatus extends React.Component {
/>
</div>

<Button icon="restart" type="flat" onClick={this.handleRefresh} />
<Button icon="refresh" type="flat" onClick={this.handleRefresh} />
</div>
{this.state.activeTab === 'pipeline' && (
<div
Expand Down
3 changes: 1 addition & 2 deletions src/pages/devops/containers/layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,9 @@ export default class Layout extends Component {
`clusterConfig.${params.cluster}`,
this.clusterStore.detail.configz
)

globals.app.cacheHistory(this.props.match.url, {
type: 'DevOps',
name: this.devops,
name: this.store.data.name,
aliasName: this.store.data.aliasName,
cluster: pick(this.clusterStore.detail, [
'name',
Expand Down
20 changes: 13 additions & 7 deletions src/pages/workspaces/containers/DevOps/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { Avatar, Status } from 'components/Base'
import Banner from 'components/Cards/Banner'
import withList, { ListPage } from 'components/HOCs/withList'
import { computed } from 'mobx'
import { computed, toJS } from 'mobx'
import React from 'react'

import DevOpsStore from 'stores/devops'
Expand Down Expand Up @@ -84,12 +84,18 @@ export default class DevOps extends React.Component {

@computed
get clusters() {
return this.workspaceStore.clusters.data.map(item => ({
label: item.name,
value: item.name,
disabled: !item.isReady,
cluster: item,
}))
const list = this.workspaceStore.clusters.data
.map(item => ({
label: item.name,
value: item.name,
disabled: !item.isReady || !item.configz?.devops,
cluster: toJS(item),
}))
.sort((a, b) => a.disabled - b.disabled)
if (list[0]) {
this.workspaceStore.cluster = list[0]?.value
}
return list
}

get clusterProps() {
Expand Down
9 changes: 7 additions & 2 deletions src/stores/devops/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import { omit, isArray, get, isEmpty } from 'lodash'
import { saveAs } from 'file-saver'
import { action, observable, toJS } from 'mobx'
import { action, computed, observable, toJS } from 'mobx'
import { Notify } from '@kube-design/components'
import { getClusterUrl, safeParseJSON } from 'utils'

Expand Down Expand Up @@ -92,6 +92,11 @@ export default class PipelineRunStore extends BaseStore {
@observable
lastDetailLogs = ''

@computed
get runDetailLogs() {
return this.runStartDetailLogs + this.lastDetailLogs
}

getUrl({ cluster, devops, name }) {
return `${this.getDevopsUrlV2({
cluster,
Expand Down Expand Up @@ -505,4 +510,4 @@ ${result}`
}
)
}
}
}
12 changes: 11 additions & 1 deletion src/utils/devOpsRepos.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// ------------- pipeline source to code repo obj -----------

/**
* type repo
* { provider, url, server, owner, repo }
*/

/**
* github to repo
* example: {
Expand Down Expand Up @@ -74,6 +75,15 @@ export function getGitSource(data) {
}
}

export const getCodeRepoTemplate = {
github: getGithubSource,
gitlab: getGitlabSource,
bitbucket_server: getBitbucketSource,
git: getGitSource,
}

// ------------ code repo obj to pipeline source -----------

const gitRepositorySpec2BaseSource = (spec, name) => {
return {
scm_id: name,
Expand Down
Loading

0 comments on commit 278c1a1

Please sign in to comment.