|
|
@@ -98,7 +98,10 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
|
|
|
reValidateMode: "onSubmit",
|
|
|
defaultValues: {
|
|
|
app: {
|
|
|
- name: "",
|
|
|
+ name: {
|
|
|
+ value: "",
|
|
|
+ readOnly: false,
|
|
|
+ },
|
|
|
build: {
|
|
|
method: "pack",
|
|
|
context: "./",
|
|
|
@@ -113,7 +116,7 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
|
|
|
},
|
|
|
deletions: {
|
|
|
serviceNames: [],
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
});
|
|
|
const {
|
|
|
@@ -132,9 +135,9 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
|
|
|
const build = watch("app.build");
|
|
|
const image = watch("source.image");
|
|
|
const services = watch("app.services");
|
|
|
- const { detectedServices: servicesFromYaml, porterYamlFound } = usePorterYaml({ source: source?.type === "github" ? source : null });
|
|
|
+ const { detectedServices: servicesFromYaml, porterYamlFound, detectedName } = usePorterYaml({ source: source?.type === "github" ? source : null });
|
|
|
const deploymentTarget = useDefaultDeploymentTarget();
|
|
|
- const { updateAppStep } = useAppAnalytics(name);
|
|
|
+ const { updateAppStep } = useAppAnalytics(name.value);
|
|
|
const { validateApp } = useAppValidation({
|
|
|
deploymentTargetID: deploymentTarget?.deployment_target_id,
|
|
|
creating: true,
|
|
|
@@ -299,7 +302,7 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
|
|
|
}, [isValidating, isDeploying, deployError, errors]);
|
|
|
|
|
|
const submitDisabled = useMemo(() => {
|
|
|
- return !name || !source || services.length === 0;
|
|
|
+ return !name || !source || services?.length === 0;
|
|
|
}, [name, source, services?.length]);
|
|
|
|
|
|
// reset services when source changes
|
|
|
@@ -345,17 +348,21 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
|
|
|
count: 0,
|
|
|
});
|
|
|
}
|
|
|
- }, [servicesFromYaml, detectedServices.detected]);
|
|
|
+
|
|
|
+ if (detectedName) {
|
|
|
+ setValue("app.name", { value: detectedName, readOnly: true });
|
|
|
+ }
|
|
|
+ }, [servicesFromYaml, detectedName, detectedServices.detected]);
|
|
|
|
|
|
useEffect(() => {
|
|
|
- if (porterApps.includes(name)) {
|
|
|
- setError("app.name", {
|
|
|
+ if (porterApps.includes(name.value)) {
|
|
|
+ setError("app.name.value", {
|
|
|
message: "An app with this name already exists",
|
|
|
});
|
|
|
} else {
|
|
|
- clearErrors("app.name");
|
|
|
+ clearErrors("app.name.value");
|
|
|
}
|
|
|
- }, [porterApps, name]);
|
|
|
+ }, [porterApps, name.value]);
|
|
|
|
|
|
if (!currentProject || !currentCluster) {
|
|
|
return null;
|
|
|
@@ -389,7 +396,11 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
|
|
|
placeholder="ex: academic-sophon"
|
|
|
type="text"
|
|
|
error={errors.app?.name?.message}
|
|
|
- {...register("app.name")}
|
|
|
+ disabled={name.readOnly}
|
|
|
+ disabledTooltip={
|
|
|
+ "You may only edit this field in your porter.yaml."
|
|
|
+ }
|
|
|
+ {...register("app.name.value")}
|
|
|
/>
|
|
|
</>,
|
|
|
<>
|
|
|
@@ -471,15 +482,19 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
|
|
|
}
|
|
|
>
|
|
|
{detectedServices.count > 0
|
|
|
- ? `Detected ${detectedServices.count} service${detectedServices.count > 1 ? "s" : ""
|
|
|
- } from porter.yaml.`
|
|
|
+ ? `Detected ${detectedServices.count} service${
|
|
|
+ detectedServices.count > 1 ? "s" : ""
|
|
|
+ } from porter.yaml.`
|
|
|
: `Could not detect any services from porter.yaml. Make sure it exists in the root of your repo.`}
|
|
|
</Text>
|
|
|
</AppearingDiv>
|
|
|
)}
|
|
|
</Container>
|
|
|
<Spacer y={0.5} />
|
|
|
- <ServiceList addNewText={"Add a new service"} fieldArrayName={"app.services"} />
|
|
|
+ <ServiceList
|
|
|
+ addNewText={"Add a new service"}
|
|
|
+ fieldArrayName={"app.services"}
|
|
|
+ />
|
|
|
</>,
|
|
|
<>
|
|
|
<Text size={16}>Environment variables (optional)</Text>
|
|
|
@@ -536,7 +551,7 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
|
|
|
githubRepoOwner={source.git_repo_name.split("/")[0]}
|
|
|
githubRepoName={source.git_repo_name.split("/")[1]}
|
|
|
branch={source.git_branch}
|
|
|
- stackName={name}
|
|
|
+ stackName={name.value}
|
|
|
projectId={currentProject.id}
|
|
|
clusterId={currentCluster.id}
|
|
|
deployPorterApp={() =>
|