Родитель
6fe6e6dee4
Коммит
9da0e6206f
|
@ -10,25 +10,29 @@ import ReactGA from 'react-ga';
|
|||
|
||||
export class Home extends Component {
|
||||
static displayName = Home.name;
|
||||
|
||||
static initialState = {
|
||||
showMore: false,
|
||||
templateType: ".NET Templates",
|
||||
level2SelectorType: "net",
|
||||
lang: "C#",
|
||||
steeltoeVersion: "2.4.0",
|
||||
steeltoeVersionInvalid: "",
|
||||
targetFrameworkVersion: "netcoreapp2.2"
|
||||
};
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
|
||||
this.state = {
|
||||
showMore: false,
|
||||
templateType: ".NET Templates",
|
||||
level2SelectorType: "net",
|
||||
lang: "C#",
|
||||
steeltoeVersion: "2.4.0",
|
||||
targetFrameworkVersion: "netcoreapp2.2"
|
||||
}
|
||||
|
||||
this.state = Home.initialState;
|
||||
this.toggleMore = this.toggleMore.bind(this);
|
||||
this.handleInputChange = this.handleInputChange.bind(this);
|
||||
this.trackSubmitEvent = this.trackSubmitEvent.bind(this);
|
||||
this.OnSubmit = this.OnSubmit.bind(this);
|
||||
|
||||
}
|
||||
OnSubmit(e){
|
||||
this.setState(Home.initialState);
|
||||
this.trackSubmitEvent(e);
|
||||
}
|
||||
trackSubmitEvent(e) {
|
||||
let i;
|
||||
const elements = e.target.elements;
|
||||
|
@ -65,19 +69,27 @@ export class Home extends Component {
|
|||
}
|
||||
handleInputChange(name, selectedValue) {
|
||||
|
||||
//if (name === "templateType") {
|
||||
// this.setState({ level2SelectorType: selectedValue === ".NET Templates" ? "net" : "steeltoe"})
|
||||
//}
|
||||
if (name == "targetFrameworkVersion" && selectedValue == "netcoreapp3.1" && this.state.steeltoeVersion == "2.3.0") {
|
||||
|
||||
if (name === "targetFrameworkVersion" && selectedValue === "netcoreapp3.1" && this.state.steeltoeVersion === "2.3.0") {
|
||||
this.setState({
|
||||
"steeltoeVersion": "2.4.0",
|
||||
[name]: selectedValue
|
||||
[name]: selectedValue,
|
||||
"steeltoeVersionInvalid": ""
|
||||
})
|
||||
}
|
||||
else if(name === "steeltoeVersion" && selectedValue === "2.3.0" && this.state.targetFrameworkVersion === "netcoreapp3.1"){
|
||||
this.setState({
|
||||
"steeltoeVersion": "2.4.0",
|
||||
"steeltoeVersionInvalid": "2.4.0 is the lowest version compatible with netcoreapp3.1",
|
||||
})
|
||||
}
|
||||
else {
|
||||
this.setState({ [name]: selectedValue });
|
||||
this.setState({
|
||||
[name]: selectedValue,
|
||||
"steeltoeVersionInvalid": ""
|
||||
});
|
||||
}
|
||||
console.log("parent setting hanglechange" , name, selectedValue)
|
||||
// console.log("parent setting hanglechange" , name, selectedValue)
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,10 +98,10 @@ export class Home extends Component {
|
|||
|
||||
return (
|
||||
<div>
|
||||
<form name="form" action="/starter.zip" method="post" autoComplete="off" onSubmit={this.trackSubmitEvent} >
|
||||
<form name="form" action="/starter.zip" method="post" autoComplete="off" onSubmit={this.OnSubmit} >
|
||||
<div>
|
||||
<InputSelector id="steeltoeVersion" title="Steeltoe Version" name="steeltoeVersion" values={["2.3.0", "2.4.0"]} defaultValue="2.4.0" selectedValue={this.state.steeltoeVersion} onChange={this.handleInputChange} />
|
||||
|
||||
<InputSelector id="steeltoeVersion" title="Steeltoe Version" name="steeltoeVersion" values={["2.3.0", "2.4.0"]} defaultValue="2.4.0" selectedValue={this.state.steeltoeVersion} onChange={this.handleInputChange} invalidText={this.state.steeltoeVersionInvalid} />
|
||||
|
||||
<div className="line">
|
||||
<div className="left">Project Metadata</div>
|
||||
<div className="right">
|
||||
|
|
|
@ -8,7 +8,7 @@ export class InputSelector extends Component {
|
|||
|
||||
}
|
||||
handleChange(e) {
|
||||
this.props.onChange(this.props.name, e.target.attributes['data-value'].value)
|
||||
this.props.onChange(this.props.name, e.target.attributes['data-value'].value);
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,9 +26,11 @@ export class InputSelector extends Component {
|
|||
</div>
|
||||
})
|
||||
}
|
||||
|
||||
<input type="hidden" name={this.props.name} value={this.props.selectedValue} />
|
||||
|
||||
</div>
|
||||
<span style={{display: this.props.invalidText? "block": "none" , "color": "red"}} > {this.props.invalidText} </span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -51,8 +51,6 @@ namespace Steeltoe.Initializr.Controllers
|
|||
[IsCurlRequest]
|
||||
public ActionResult<string> CurlHelp()
|
||||
{
|
||||
// get dependencies
|
||||
|
||||
var result = new StringBuilder();
|
||||
result.Append(LOGO);
|
||||
result.Append(GetDependencies());
|
||||
|
@ -99,7 +97,7 @@ Get project:
|
|||
|
||||
private string GetRow(string title, string description, int[] fieldWidths)
|
||||
{
|
||||
return string.Format("+ {0}+ {1}+\n", title.PadRight(fieldWidths[0] - 1), description.PadRight(fieldWidths[1] - 1));
|
||||
return $"| {title.PadRight(fieldWidths[0] - 1)}| {description.PadRight(fieldWidths[1] - 1)}|\n";
|
||||
}
|
||||
|
||||
private string GetHorizontalBorder(int[] widths)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||
using Microsoft.AspNetCore.Mvc.ActionConstraints;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Steeltoe.Initializr.Controllers
|
||||
{
|
||||
public class IsCurlRequestAttribute : ActionMethodSelectorAttribute
|
||||
{
|
||||
public override bool IsValidForRequest(RouteContext routeContext, ActionDescriptor action)
|
||||
{
|
||||
var headers = routeContext.HttpContext.Request.Headers;
|
||||
return headers["User-Agent"].Any(h => h.ToLower().Contains("curl"));
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче