Skip to content

Commit

Permalink
fix: Fix workload prob card missing startUp probe
Browse files Browse the repository at this point in the history
Signed-off-by: leoliu <leoliu@yunify.com>
  • Loading branch information
leoliu committed Jul 15, 2020
1 parent 95f2881 commit c8d219b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 26 deletions.
27 changes: 19 additions & 8 deletions src/components/Cards/Containers/Item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,32 @@ export default class ContainerItem extends React.Component {
}

renderProbe() {
const { livenessProbe, readinessProbe } = this.props.detail
const { livenessProbe, readinessProbe, startupProbe } = this.props.detail

if (!livenessProbe && !readinessProbe) return null
if (!livenessProbe && !readinessProbe && !startupProbe) return null

return (
<div className={styles.probe}>
{this.renderProbeRecord(readinessProbe, 'readiness')}
{this.renderProbeRecord(livenessProbe, 'liveness')}
{this.renderProbeRecord({
probe: readinessProbe,
title: t('Readiness Probe'),
tagType: 'primary',
})}
{this.renderProbeRecord({
probe: livenessProbe,
title: t('Liveness Probe'),
tagType: 'warning',
})}
{this.renderProbeRecord({
probe: startupProbe,
title: t('Startup Probe'),
tagType: 'info',
})}
</div>
)
}

renderProbeRecord(probe, type) {
renderProbeRecord({ probe, title, tagType }) {
if (!probe) return null

const delay = probe.initialDelaySeconds || 0
Expand All @@ -113,9 +126,7 @@ export default class ContainerItem extends React.Component {
return (
<div className={styles.probeItem}>
<div>
<Tag type={type === 'liveness' ? 'warning' : 'primary'}>
{type === 'liveness' ? t('Liveness Probe') : t('Readiness Probe')}
</Tag>
<Tag type={tagType}>{title}</Tag>
<span className={styles.probeType}>{t(probeType)}</span>
<span className={styles.probeTime}>
{t('Initial Delay')}: {delay}s &nbsp;&nbsp;
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/workload.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export default {
'Specify Replicas Number': 'Specify Replicas Number',
startingDeadlineSeconds: 'startingDeadlineSeconds',
'startingDeadlineSeconds(s)': 'startingDeadlineSeconds(s)',
'Startup Probe': 'Startup Probe',
'Storage Size': 'Storage Size',
'Strategy Type': 'Strategy Type',
'sub path': 'sub path',
Expand Down
1 change: 1 addition & 0 deletions src/locales/tc/workload.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ export default {
PROBE_TIME: '初始延时: {delay}s 超时时间:{timeout}s',
'Readiness Probe': '就绪探针',
'Liveness Probe': '存活探针',
'Startup Probe': '启动探针',

INITIAL_DELAY_DESC: '在检查其运行状况之前,容器启动后需要等待多长时间。',
TIMEOUT_DESC:
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh/workload.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ export default {
PROBE_TIME: '初始延时: {delay}s 超时时间:{timeout}s',
'Readiness Probe': '就绪探针',
'Liveness Probe': '存活探针',
'Startup Probe': '启动探针',

INITIAL_DELAY_DESC: '在检查其运行状况之前,容器启动后需要等待多长时间。',
TIMEOUT_DESC:
Expand Down
27 changes: 19 additions & 8 deletions src/pages/projects/components/Cards/ContainerTemplate/Item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,32 @@ export default class ContainerItem extends React.Component {
}

renderProbe() {
const { livenessProbe, readinessProbe } = this.props.detail
const { livenessProbe, readinessProbe, startupProbe } = this.props.detail

if (!livenessProbe && !readinessProbe) return null
if (!livenessProbe && !readinessProbe && !startupProbe) return null

return (
<div className={styles.probe}>
{this.renderProbeRecord(readinessProbe, 'readiness')}
{this.renderProbeRecord(livenessProbe, 'liveness')}
{this.renderProbeRecord({
probe: readinessProbe,
title: t('Readiness Probe'),
tagType: 'primary',
})}
{this.renderProbeRecord({
probe: livenessProbe,
title: t('Liveness Probe'),
tagType: 'warning',
})}
{this.renderProbeRecord({
probe: startupProbe,
title: t('Startup Probe'),
tagType: 'info',
})}
</div>
)
}

renderProbeRecord(probe, type) {
renderProbeRecord({ probe, title, tagType }) {
if (!probe) return null

const delay = probe.initialDelaySeconds || 0
Expand All @@ -76,9 +89,7 @@ export default class ContainerItem extends React.Component {
return (
<div className={styles.probeItem}>
<div>
<Tag type={type === 'liveness' ? 'warning' : 'primary'}>
{type === 'liveness' ? t('Liveness Probe') : t('Readiness Probe')}
</Tag>
<Tag type={tagType}>{title}</Tag>
<span className={styles.probeType}>{t(probeType)}</span>
<span className={styles.probeTime}>
{t('Initial Delay')}: {delay}s &nbsp;&nbsp;
Expand Down
31 changes: 21 additions & 10 deletions src/pages/projects/components/Cards/Probe/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,32 @@ import styles from './index.scss'

export default class ProbeCard extends React.Component {
renderProbe() {
const { livenessProbe, readinessProbe } = this.props.detail
const { livenessProbe, readinessProbe, startupProbe } = this.props.detail

if (!livenessProbe && !readinessProbe) return null
if (!livenessProbe && !readinessProbe && !startupProbe) return null

return (
<div className={styles.probe}>
{this.renderProbeRecord(readinessProbe, 'readiness')}
{this.renderProbeRecord(livenessProbe, 'liveness')}
{this.renderProbeRecord({
probe: readinessProbe,
title: t('Readiness Probe'),
tagType: 'primary',
})}
{this.renderProbeRecord({
probe: livenessProbe,
title: t('Liveness Probe'),
tagType: 'warning',
})}
{this.renderProbeRecord({
probe: startupProbe,
title: t('Startup Probe'),
tagType: 'info',
})}
</div>
)
}

renderProbeRecord(probe, type) {
renderProbeRecord({ probe, title, tagType }) {
if (!probe) return null

const delay = probe.initialDelaySeconds || 0
Expand All @@ -61,11 +74,9 @@ export default class ProbeCard extends React.Component {
details = [{ title: command.join(' '), description: t('Command') }]
}

const title = (
const titleElm = (
<>
<Tag type={type === 'liveness' ? 'warning' : 'primary'}>
{type === 'liveness' ? t('Liveness Probe') : t('Readiness Probe')}
</Tag>
<Tag type={tagType}>{title}</Tag>
<span className={styles.probeType}>{t(probeType)}</span>
</>
)
Expand All @@ -79,7 +90,7 @@ export default class ProbeCard extends React.Component {
return (
<List.Item
icon="monitor"
title={title}
title={titleElm}
description={description}
details={details}
/>
Expand Down

0 comments on commit c8d219b

Please sign in to comment.