Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix the wrong url of the harbor image #2784

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ export default class DropdownContent extends React.Component {
showContent = () => {
this.setState({ visible: true }, () => {
document.addEventListener('click', this.handleDOMClick)
if (this.hubType !== 'dockerHub') {
this.fetchHarborList('', this.state.hubUrl)
}
})
}

Expand All @@ -145,7 +148,9 @@ export default class DropdownContent extends React.Component {
)[0].url
this.setState({ hubUrl: url })
}

const { formTemplate } = this.props

set(formTemplate, 'pullSecret', value)
this.props.onChange(this.registryUrl)
}
Expand Down Expand Up @@ -186,10 +191,10 @@ export default class DropdownContent extends React.Component {
)
const url = this.state.hubUrl
const tag = await this.fetchHarborImageTag(url, projectName, repository)
const image = `${url}/${imageDetail.repository_name}:${tag}`
const image = `${imageDetail.repository_name}:${tag}`
const logo = ''
const short_description = ''
this.props.onChange(image)
this.props.onChange(`${this.registryUrl}/${image}`)
this.hideContent()
this.props.onEnter({ logo, short_description })
}
Expand All @@ -204,6 +209,7 @@ export default class DropdownContent extends React.Component {

fetchDockerList = async keyword => {
this.setState({ isLoading: true })

const result = await this.store
.getDockerImagesLists({
q: keyword,
Expand All @@ -214,13 +220,16 @@ export default class DropdownContent extends React.Component {
.finally(() => {
!this.isUnMounted && this.setState({ isLoading: false })
})

!this.isUnMounted &&
this.setState({ dockerList: get(result, 'summaries', []) })
}

fetchHarborList = async (keyword, url) => {
if (!url) return

this.setState({ isLoading: true })

const result = await this.store
.getHarborImagesLists(
{
Expand All @@ -231,6 +240,7 @@ export default class DropdownContent extends React.Component {
.finally(() => {
!this.isUnMounted && this.setState({ isLoading: false })
})

!this.isUnMounted &&
this.setState({ harborList: get(result, 'repository', []) })
}
Expand All @@ -256,7 +266,7 @@ export default class DropdownContent extends React.Component {
}

renderContent = () => {
if (this.hubType === 'dockerHub') {
if (this.state.visible) {
return (
<div
className={classnames(styles.dropContent, {
Expand All @@ -267,35 +277,24 @@ export default class DropdownContent extends React.Component {
<div className={styles.header}>
<InputSearch
className={styles.search}
onSearch={this.handleSearchDockerHub}
onSearch={
this.hubType === 'dockerHub'
? this.handleSearchDockerHub
: this.handleSearchHarbor
}
placeholder={t('SEARCH')}
/>
{this.state.isLoading && (
<Loading className="float-left" size={28} />
)}
</div>
{this.renderDockerList()}
{this.hubType === 'dockerHub'
? this.renderDockerList()
: this.renderHarborList()}
</div>
)
}
return (
<div
className={classnames(styles.dropContent, {
[styles.dropContent_hide]: !this.state.visible,
})}
ref={this.dropContentRef}
>
<div className={styles.header}>
<InputSearch
className={styles.search}
onSearch={this.handleSearchHarbor}
placeholder={t('SEARCH')}
/>
{this.state.isLoading && <Loading className="float-left" size={28} />}
</div>
{this.renderHarborList()}
</div>
)
return null
}

renderDockerList() {
Expand All @@ -305,8 +304,10 @@ export default class DropdownContent extends React.Component {
<div
className={classnames(styles.selectedContent, styles.emptyContent)}
>
<Icon name="docker" className={styles.icon} />
<p className={styles.desc}>{t('NO_IMAGE_FOUND')}</p>
<div>
<Icon name="docker" className={styles.icon} />
<p className={styles.desc}>{t('NO_IMAGE_FOUND')}</p>
</div>
</div>
</ul>
)
Expand Down Expand Up @@ -367,8 +368,10 @@ export default class DropdownContent extends React.Component {
<div
className={classnames(styles.selectedContent, styles.emptyContent)}
>
<Icon name="docker" className={styles.icon} />
<p className={styles.desc}>{t('NO_IMAGE_FOUND')}</p>
<div>
<Icon name="docker" className={styles.icon} />
<p className={styles.desc}>{t('NO_IMAGE_FOUND')}</p>
</div>
</div>
</ul>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ export default class Select extends React.Component {
}

toggleShowOptions = () => {
const { showOptions } = this.state
this.setState({ showOptions: !showOptions })
this.setState(({ showOptions }) => {
!showOptions
})
}

handleShowOptions = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
right: 6px;
transition: transform 0.5s ease;
transform-origin: center;

svg {
color: white;
}
}

.rightIcon_toggle {
transform: rotate(180deg)
transform: rotate(180deg);
}

&.selected {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ export default class ImageSearch extends Component {
<div
className={classnames(styles.selectedContent, styles.emptyContent)}
>
<Icon name="docker" className={styles.icon} />
<p className={styles.desc}>{t('NO_IMAGE_FOUND')}</p>
<div>
<Icon name="docker" className={styles.icon} />
<p className={styles.desc}>{t('NO_IMAGE_FOUND')}</p>
</div>
</div>
)
}
Expand Down Expand Up @@ -270,8 +272,10 @@ export default class ImageSearch extends Component {
}
return (
<div className={classnames(styles.selectedContent, styles.emptyContent)}>
<Icon name="docker" className={styles.icon} />
<p className={styles.desc}>{t('SET_IMAGE_DESC')}</p>
<div>
<Icon name="docker" className={styles.icon} />
<p className={styles.desc}>{t('SET_IMAGE_DESC')}</p>
</div>
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,23 @@
}

.emptyContent {
padding-top: 38px;
text-align: center;
height: calc(100% - 12px);
position: relative;

& > div {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
}

.icon {
width: 48px;
height: 48px;
margin-bottom: 12px;
}

.desc {
height: 20px;
@include TypographyParagraph($dark-color01);
Expand Down