|
|
@@ -68,7 +68,7 @@ export default class DOFormSection extends Component<PropsType, StateType> {
|
|
|
componentDidMount = () => {
|
|
|
let { infras } = this.props;
|
|
|
let { selectedInfras } = this.state;
|
|
|
- this.setClusterNameIfNotSet()
|
|
|
+ this.setClusterNameIfNotSet();
|
|
|
|
|
|
if (infras) {
|
|
|
// From the dashboard, only uncheck and disable if "creating" or "created"
|
|
|
@@ -85,21 +85,27 @@ export default class DOFormSection extends Component<PropsType, StateType> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- componentDidUpdate = (prevProps : PropsType, prevState : StateType) => {
|
|
|
+ componentDidUpdate = (prevProps: PropsType, prevState: StateType) => {
|
|
|
if (prevProps.projectName != this.props.projectName) {
|
|
|
- this.setClusterNameIfNotSet()
|
|
|
+ this.setClusterNameIfNotSet();
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
setClusterNameIfNotSet = () => {
|
|
|
- let projectName = this.props.projectName || this.context.currentProject?.name
|
|
|
+ let projectName =
|
|
|
+ this.props.projectName || this.context.currentProject?.name;
|
|
|
|
|
|
- if (!this.state.clusterNameSet && !this.state.clusterName.includes(`${projectName}-cluster`)) {
|
|
|
+ if (
|
|
|
+ !this.state.clusterNameSet &&
|
|
|
+ !this.state.clusterName.includes(`${projectName}-cluster`)
|
|
|
+ ) {
|
|
|
this.setState({
|
|
|
- clusterName: `${projectName}-cluster-${Math.random().toString(36).substring(2, 8)}`
|
|
|
- })
|
|
|
+ clusterName: `${projectName}-cluster-${Math.random()
|
|
|
+ .toString(36)
|
|
|
+ .substring(2, 8)}`,
|
|
|
+ });
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
checkFormDisabled = () => {
|
|
|
if (!this.state.provisionConfirmed) {
|
|
|
@@ -109,7 +115,11 @@ export default class DOFormSection extends Component<PropsType, StateType> {
|
|
|
let { selectedInfras, clusterName } = this.state;
|
|
|
let { projectName } = this.props;
|
|
|
if (projectName || projectName === "") {
|
|
|
- return !isAlphanumeric(projectName) || selectedInfras.length === 0 || !clusterName;
|
|
|
+ return (
|
|
|
+ !isAlphanumeric(projectName) ||
|
|
|
+ selectedInfras.length === 0 ||
|
|
|
+ !clusterName
|
|
|
+ );
|
|
|
} else {
|
|
|
return selectedInfras.length === 0 || !clusterName;
|
|
|
}
|
|
|
@@ -149,7 +159,12 @@ export default class DOFormSection extends Component<PropsType, StateType> {
|
|
|
};
|
|
|
|
|
|
doRedirect = (projectId: number) => {
|
|
|
- let { subscriptionTier, doRegion, selectedInfras, clusterName } = this.state;
|
|
|
+ let {
|
|
|
+ subscriptionTier,
|
|
|
+ doRegion,
|
|
|
+ selectedInfras,
|
|
|
+ clusterName,
|
|
|
+ } = this.state;
|
|
|
let redirectUrl = `/api/oauth/projects/${projectId}/digitalocean?project_id=${projectId}&provision=do`;
|
|
|
redirectUrl += `&tier=${subscriptionTier}®ion=${doRegion}&cluster_name=${clusterName}`;
|
|
|
selectedInfras.forEach((option: { value: string; label: string }) => {
|
|
|
@@ -178,7 +193,11 @@ export default class DOFormSection extends Component<PropsType, StateType> {
|
|
|
return "Project name contains illegal characters";
|
|
|
}
|
|
|
}
|
|
|
- if (!this.state.provisionConfirmed || this.props.projectName === "" || !this.state.clusterName) {
|
|
|
+ if (
|
|
|
+ !this.state.provisionConfirmed ||
|
|
|
+ this.props.projectName === "" ||
|
|
|
+ !this.state.clusterName
|
|
|
+ ) {
|
|
|
return "Required fields missing";
|
|
|
}
|
|
|
};
|
|
|
@@ -186,18 +205,25 @@ export default class DOFormSection extends Component<PropsType, StateType> {
|
|
|
renderClusterNameSection = () => {
|
|
|
let { selectedInfras, clusterName } = this.state;
|
|
|
|
|
|
- if (selectedInfras.length == 2 || (selectedInfras.length == 1 && selectedInfras[0].value === "doks")) {
|
|
|
- return <InputRow
|
|
|
- type="text"
|
|
|
- value={clusterName}
|
|
|
- setValue={(x: string) => this.setState({ clusterName: x, clusterNameSet: true })}
|
|
|
- label="Cluster Name"
|
|
|
- placeholder="ex: porter-cluster"
|
|
|
- width="100%"
|
|
|
- isRequired={true}
|
|
|
- />
|
|
|
+ if (
|
|
|
+ selectedInfras.length == 2 ||
|
|
|
+ (selectedInfras.length == 1 && selectedInfras[0].value === "doks")
|
|
|
+ ) {
|
|
|
+ return (
|
|
|
+ <InputRow
|
|
|
+ type="text"
|
|
|
+ value={clusterName}
|
|
|
+ setValue={(x: string) =>
|
|
|
+ this.setState({ clusterName: x, clusterNameSet: true })
|
|
|
+ }
|
|
|
+ label="Cluster Name"
|
|
|
+ placeholder="ex: porter-cluster"
|
|
|
+ width="100%"
|
|
|
+ isRequired={true}
|
|
|
+ />
|
|
|
+ );
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
render() {
|
|
|
let { setSelectedProvisioner } = this.props;
|