-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add sync host timezone for container
Signed-off-by: leoliu <leoliu@yunify.com>
- Loading branch information
leoliu
committed
Jul 28, 2020
1 parent
743d6aa
commit eb58e2d
Showing
10 changed files
with
151 additions
and
5 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
src/components/Forms/Workload/ContainerSettings/ContainerForm/SyncTimeZone/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* This file is part of KubeSphere Console. | ||
* Copyright (C) 2019 The KubeSphere Console Authors. | ||
* | ||
* KubeSphere Console is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* KubeSphere Console is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with KubeSphere Console. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React from 'react' | ||
import { get, set } from 'lodash' | ||
import { Checkbox } from '@pitrix/lego-ui' | ||
|
||
import styles from './index.scss' | ||
|
||
export default class SyncTimeZone extends React.PureComponent { | ||
state = { | ||
isCheck: get(this.props.data, 'volumeMounts', []).some( | ||
vm => vm.mountPath === '/etc/localtime' | ||
), | ||
} | ||
|
||
handleCheck = () => { | ||
this.setState( | ||
({ isCheck }) => ({ isCheck: !isCheck }), | ||
() => { | ||
const vms = get(this.props.data, 'volumeMounts', []) | ||
if (this.state.isCheck) { | ||
set(this.props.data, 'volumeMounts', [ | ||
...vms, | ||
{ | ||
name: 'host-time', | ||
mountPath: '/etc/localtime', | ||
readOnly: true, | ||
}, | ||
]) | ||
} else { | ||
set( | ||
this.props.data, | ||
'volumeMounts', | ||
vms.filter(vm => vm.mountPath !== '/etc/localtime') | ||
) | ||
} | ||
} | ||
) | ||
} | ||
|
||
render() { | ||
const { isCheck } = this.state | ||
return ( | ||
<div className={styles.wrapper}> | ||
<div className={styles.title}> | ||
<Checkbox checked={isCheck} onChange={this.handleCheck}> | ||
{t('Sync Host Timezone')} | ||
</Checkbox> | ||
</div> | ||
<div className={styles.desc}>{t('SYNC_HOST_TIMEZONE_DESC')}</div> | ||
</div> | ||
) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/components/Forms/Workload/ContainerSettings/ContainerForm/SyncTimeZone/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@import '~scss/variables'; | ||
|
||
.wrapper { | ||
margin-bottom: 12px; | ||
padding: 11px 20px; | ||
border-radius: 4px; | ||
border: solid 1px $border-color; | ||
background-color: $white; | ||
|
||
.title { | ||
font-weight: $font-bold; | ||
|
||
:global { | ||
.label-value { | ||
font-weight: $font-bold; | ||
} | ||
} | ||
} | ||
|
||
.desc { | ||
color: $second-text-color; | ||
padding-left: 28px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters