Skip to content

Commit

Permalink
fix: remove custom b2i files limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ymh1028 committed Feb 21, 2020
1 parent 7afcc27 commit 30db7d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Notify from 'components/Base/Notify'
import { isNumber, get, set } from 'lodash'
import classnames from 'classnames'
import { formatSize } from 'utils'
import { B2I_SUPPORTED_TYPES } from 'utils/constants'

import BuilderStore from 'src/stores/s2i/builder'
import styles from './index.scss'
Expand All @@ -37,13 +38,17 @@ class Uploader extends React.Component {
constructor(props) {
super(props)
this.store = new BuilderStore()
let acceptOptions = {}
if (this.filesType && this.filesType !== 'binary') {
acceptOptions = { accept: `.${this.filesType}` }
}
this.uploaderProps = {
name: 's2ibinary',
method: 'put',
action: this.getUploadUrl,
multiple: false,
headers,
...(this.filesType === 'binary' ? {} : { accept: `.${this.filesType}` }),
...acceptOptions,
beforeUpload: this.beforeUploadHandler,
onStart: this.startHandler,
onSuccess: this.successHandler,
Expand All @@ -59,7 +64,14 @@ class Uploader extends React.Component {
}

get filesType() {
return get(this.props.formTemplate, 'metadata.annotations.languageType')
const type = get(
this.props.formTemplate,
'metadata.annotations.languageType'
)
if (type && B2I_SUPPORTED_TYPES.includes(type)) {
return type
}
return ''
}

get uploadedfile() {
Expand Down Expand Up @@ -244,7 +256,7 @@ class Uploader extends React.Component {
{t('Click to select the artifact file to upload')}
</p>
<p className={styles.desc}>
{t(`${this.filesType.toUpperCase()}_DESC`)}
{t(`${this.filesType.toUpperCase() || 'B2I_DEFAULT'}_DESC`)}
</p>
</div>
</Upload>
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/s2i.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default {
IMAGE_FROM_S2I: 'Build a new image from code',
IMAGE_FROM_B2I: 'Build a new image from the artifact',
B2I_DESC: 'Please choose your artifact to build a container image',
B2I_DEFAULT_DESC: 'Please choose your artifact to build a container image',
JAR_DESC:
'A JAR file is a package file format that is commonly used to aggregate a large number of Java class files, related metadata and resources (text, images, etc.) files into a file.',
WAR_DESC:
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh/s2i.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default {
'Click to select the artifact file to upload': '点击制品文件进行上传',
'Upload Artifacts': '上传制品',
'Choose a language': '选择语言',
B2I_DEFAULT_DESC: '点击制品文件进行上传',
JAR_DESC:
'Jar 文件是一种软件包文件格式,通常用于聚合大量的 Java 类文件、相关的元数据和资源(文本、图片等)文件到一个文件',
WAR_DESC:
Expand Down

0 comments on commit 30db7d9

Please sign in to comment.