Skip to content
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
17 changes: 10 additions & 7 deletions client/web/src/settings/ApplicationComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import globalConfig from '../config/appConfig'
import AppSettingsSubform from './AppSettingsSubform'
import BillingSubform from './BillingSubform'
import ServicesComponent from './ServicesComponent'
import { FILESYSTEM_DEFAULTS, FILESYSTEM_TYPES } from './components/filesystem'
import { FILESYSTEM_DEFAULTS, FILESYSTEM_TYPES, OS_TO_FS_TYPES } from './components/filesystem'

import { dismissConfigError, dismissConfigMessage } from './ducks'

Expand Down Expand Up @@ -69,11 +69,11 @@ export function ApplicationComponent(props) {
window.scrollTo(0, 0)
}

const generateAppConfigOrDefaultInitialValuesForTier = (tierValues, defaultValues) => {
const generateAppConfigOrDefaultInitialValuesForTier = (tierValues, defaultValues, os) => {
let filesystem = {
...FILESYSTEM_DEFAULTS,
...defaultValues.filesystem,
...tierValues.filesystem
...splitWeeklyMaintenanceTime(tierValues.filesystem)
}
let defaults = Object.assign({
min: 0,
Expand All @@ -84,12 +84,15 @@ export function ApplicationComponent(props) {
...defaults,
filesystem: filesystem,
}

let filesystemType = OS_TO_FS_TYPES[os]?.filter(type => type.configId === tierValues.filesystem?.type)[0]?.id || ''

return {
...uncleanedInitialTierValues,
provisionDb: !!tierValues.database,
provisionFS: !!tierValues.filesystem,
filesystemType: tierValues.filesystem?.type || '',
filesystem: splitWeeklyMaintenanceTime(uncleanedInitialTierValues.filesystem),
filesystemType: filesystemType,
filesystem: filesystem,
}
}

Expand Down Expand Up @@ -144,11 +147,11 @@ export function ApplicationComponent(props) {
}
const windowsVersion = os === WINDOWS ? thisService.operatingSystem : ''
let defaultTierName = tiers.filter(t => t.defaultTier)[0].name
let defaultTierValues = generateAppConfigOrDefaultInitialValuesForTier(Object.assign({}, thisService?.tiers[defaultTierName]), {})
let defaultTierValues = generateAppConfigOrDefaultInitialValuesForTier(Object.assign({}, thisService?.tiers[defaultTierName]), {}, os)
let initialTierValues = {}
for (var i = 0; i < tiers.length; i++) {
var tierName = tiers[i].name
initialTierValues[tierName] = generateAppConfigOrDefaultInitialValuesForTier(Object.assign({}, thisService?.tiers[tierName]), defaultTierValues)
initialTierValues[tierName] = generateAppConfigOrDefaultInitialValuesForTier(Object.assign({}, thisService?.tiers[tierName]), defaultTierValues, os)
}
return {
...thisService,
Expand Down
15 changes: 3 additions & 12 deletions client/web/src/settings/ApplicationContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,27 +146,18 @@ export function ApplicationContainer(props) {
updateConfiguration(formValues)
}

const getFormattedTime = (timeString) => {
// Expecting timeString to be HH:MM:SS
let parts = timeString.split(':')
if (parts.length === 3) {
parts = parts.splice(0, 2) //Trim the trailing :00. Server doesn't need seconds
}
return parts.join(':')
}

const cleanFilesystemForSubmittal = (provisionFS, filesystemType, filesystem) => {
if (provisionFS) {
let {
weeklyMaintenanceDay,
weeklyMaintenanceTime,
...cleanedFs
} = filesystem
cleanedFs.type = filesystemType
cleanedFs.type = FILESYSTEM_TYPES[filesystemType].configId
if (weeklyMaintenanceDay && weeklyMaintenanceTime) {
cleanedFs.weeklyMaintenanceTime = `${weeklyMaintenanceDay}:${getFormattedTime(weeklyMaintenanceTime)}`
cleanedFs.weeklyMaintenanceTime = `${weeklyMaintenanceDay}:${weeklyMaintenanceTime}`
}
let wantedKeys = Object.keys(FILESYSTEM_TYPES[cleanedFs.type].defaults)
let wantedKeys = Object.keys(FILESYSTEM_TYPES[filesystemType].defaults)
Object.keys(cleanedFs).forEach(k => {
if (!wantedKeys.includes(k) && k !== 'type') {
delete cleanedFs[k]
Expand Down
33 changes: 19 additions & 14 deletions client/web/src/settings/TierServiceSettingsSubform.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,24 @@ const TierServiceSettingsSubform = (props) => {

const formikTierPrefix = formikServicePrefix + '.tiers[' + selectedTier + ']'

// set compute size if default exists and this tier doesn't
if (!!!serviceValues?.tiers[selectedTier]?.computeSize && !!serviceValues?.tiers[defaultTier]?.computeSize) {
// set instance to default if it doesn't exist already
setFieldValue(formikTierPrefix + '.computeSize', serviceValues?.tiers[defaultTier]?.computeSize)
}
if (!!serviceValues?.tiers) {
// set compute size if default exists and this tier doesn't
if (!!!serviceValues?.tiers[selectedTier]?.computeSize && !!serviceValues?.tiers[defaultTier]?.computeSize) {
// set instance to default if it doesn't exist already
setFieldValue(formikTierPrefix + '.computeSize', serviceValues?.tiers[defaultTier]?.computeSize)
}

// set min if default exists and this tier doesn't
if (!!!serviceValues?.tiers[selectedTier]?.min && !!serviceValues?.tiers[defaultTier]?.min) {
// set instance to default if it doesn't exist already
setFieldValue(formikTierPrefix + '.min', serviceValues?.tiers[defaultTier]?.min)
}
// set min if default exists and this tier doesn't
if (!!!serviceValues?.tiers[selectedTier]?.min && !!serviceValues?.tiers[defaultTier]?.min) {
// set instance to default if it doesn't exist already
setFieldValue(formikTierPrefix + '.min', serviceValues?.tiers[defaultTier]?.min)
}

// set max if default exists and this tier doesn't
if (!!!serviceValues?.tiers[selectedTier]?.max && !!serviceValues?.tiers[defaultTier]?.max) {
// set instance to default if it doesn't exist already
setFieldValue(formikTierPrefix + '.max', serviceValues?.tiers[defaultTier]?.max)
// set max if default exists and this tier doesn't
if (!!!serviceValues?.tiers[selectedTier]?.max && !!serviceValues?.tiers[defaultTier]?.max) {
// set instance to default if it doesn't exist already
setFieldValue(formikTierPrefix + '.max', serviceValues?.tiers[defaultTier]?.max)
}
}

return (
Expand Down Expand Up @@ -108,6 +110,7 @@ const TierServiceSettingsSubform = (props) => {
label="Minimum Instance Count"
name={formikTierPrefix + '.min'}
type="number"
min="0"
/>
</Col>
<Col>
Expand All @@ -116,6 +119,7 @@ const TierServiceSettingsSubform = (props) => {
label="Maximum Instance Count"
name={formikTierPrefix + '.max'}
type="number"
min="0"
/>
</Col>
</Row>
Expand All @@ -131,6 +135,7 @@ const TierServiceSettingsSubform = (props) => {
serviceValues?.tiers[selectedTier]?.provisionFS
}
containerOs={serviceValues?.operatingSystem}
containerLaunchType={serviceValues?.ecsLaunchType}
filesystemType={serviceValues?.tiers[selectedTier]?.filesystemType}
setFieldValue={props.setFieldValue}
></FileSystemSubform>
Expand Down
17 changes: 14 additions & 3 deletions client/web/src/settings/components/filesystem/FileSystemSubform.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const FilesystemType = (props) => {
id={"fs-" + fs.id + "-" + props.formikTierPrefix}
name={props.formikTierPrefix + ".filesystemType"}
value={fs.id}
disabled={props.isLocked}
disabled={!fs.enabled(props.containerOs, props.containerLaunchType)}
/>
<Label className="form-check-label" check htmlFor={"fs-" + fs.id + "-" + props.formikTierPrefix}>
<CIcon icon={fs.icon} /> {fs.name}
Expand All @@ -71,9 +71,17 @@ const FilesystemType = (props) => {
</FormGroup>)
}

class EmptyComponent extends React.Component {
render() {
return null
}
}

export default class FileSystemSubform extends React.Component {
render() {
var FsComponent = !!this.props.filesystemType ? FILESYSTEM_TYPES[this.props.filesystemType].component : null
var FsComponent = (!!this.props.filesystemType && FILESYSTEM_TYPES[this.props.filesystemType])
? FILESYSTEM_TYPES[this.props.filesystemType].component
: EmptyComponent
return (
<Fragment>
<Row className="mt-3">
Expand All @@ -86,7 +94,9 @@ export default class FileSystemSubform extends React.Component {
name={this.props.formikTierPrefix + '.provisionFS'}
label="Provision a File System for the application."
/>
<FilesystemType {...this.props}></FilesystemType>
{this.props.provisionFs && (
<FilesystemType {...this.props}></FilesystemType>
)}
{this.props.provisionFs && this.props.filesystemType && (
<FsComponent {...this.props}></FsComponent>
)}
Expand All @@ -103,6 +113,7 @@ FileSystemSubform.propTypes = {
provisionFs: PropTypes.bool,
filesystemType: PropTypes.string,
containerOs: PropTypes.string,
containerLaunchType: PropTypes.string,
isLocked: PropTypes.bool,
filesystem: PropTypes.object,
formik: PropTypes.object,
Expand Down
Loading