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

Added support to redirect to specific domain #121

Merged
merged 2 commits into from
May 9, 2023
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
1 change: 1 addition & 0 deletions src/containers/apps/AppDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ interface IAppDefinitionBase {
preDeployFunction?: string
serviceUpdateOverride?: string
customNginxConfig?: string
redirectDomain?: string
networks: string[]
customDomain: IAppCustomDomain[]
tags?: IAppTag[]
Expand Down
58 changes: 57 additions & 1 deletion src/containers/apps/appDetails/HttpSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { InfoCircleOutlined } from '@ant-design/icons'
import type { SelectProps } from 'antd'
import {
Button,
Checkbox,
Expand All @@ -7,12 +8,14 @@ import {
message,
Modal,
Row,
Select,
Tooltip,
} from 'antd'
import React, { Component, Fragment } from 'react'
import { Component, Fragment } from 'react'
import Toaster from '../../../utils/Toaster'
import Utils from '../../../utils/Utils'
import NewTabLink from '../../global/NewTabLink'
import { IAppDef } from '../AppDefinition'
import { AppDetailsTabProps } from './AppDetails'

const Search = Input.Search
Expand Down Expand Up @@ -139,6 +142,58 @@ export default class HttpSettings extends Component<
)
}

createRedirectDropdownIfNeeded(app: IAppDef, rootDomain: string) {
const self = this
const customDomains = (
this.props.apiData!.appDefinition.customDomain || []
).map((it) => it.publicDomain)

if (customDomains.length === 0) {
return undefined
} else {
customDomains.push(`${app.appName}.${rootDomain}`)

const options: SelectProps['options'] = []
options.push({
value: '',
label: 'No redirects',
})
customDomains.forEach((it) => {
options.push({
value: it,
label: it,
})
})

const widthOfSelect = self.props.isMobile ? 200 : 350

return (
<Fragment>
<Row>
<span style={{ marginRight: 10 }}>
Redirect all domains to:
</span>

<Select
size="small"
defaultValue={app.redirectDomain || ''}
onChange={(value) => {
const newApiData = Utils.copyObject(
self.props.apiData!
)
newApiData.appDefinition.redirectDomain = value
self.props.updateApiData(newApiData)
}}
style={{ width: widthOfSelect }}
options={options}
/>
</Row>
<br />
</Fragment>
)
}
}

createCustomDomainRows() {
const customDomains =
this.props.apiData!.appDefinition.customDomain || []
Expand Down Expand Up @@ -286,6 +341,7 @@ export default class HttpSettings extends Component<
</Row>
{this.createCustomDomainRows()}
<br />
{this.createRedirectDropdownIfNeeded(app, rootDomain)}
<Row>
<Col xs={{ span: 24 }} lg={{ span: 15 }}>
{this.props.isMobile ? (
Expand Down
Loading