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

feature: Enable Deployment from Git Repositories to Akash Network #381

Closed
wants to merge 117 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
001311a
create 23 files and update 8 files
dharamveergit Aug 16, 2024
93053db
feat: Update Remote Deploy
dharamveergit Aug 16, 2024
774ed43
update 4 files and create 2 files
dharamveergit Aug 16, 2024
2c8636d
feat: new Repo selection
dharamveergit Aug 16, 2024
1dec0b3
feat: Bitbucket Repo Selection
dharamveergit Aug 16, 2024
ab30a3b
feat: Gitlab Repo Selection
dharamveergit Aug 16, 2024
d7ef049
fix: Gitlab repos ui fix
dharamveergit Aug 16, 2024
82e25fe
feat: update disable _pull
dharamveergit Aug 16, 2024
89f5d5c
fix : update ui
dharamveergit Aug 17, 2024
5c125d5
feat: New Frameworks
dharamveergit Aug 17, 2024
6466920
feat: vite Framework
dharamveergit Aug 17, 2024
dc35ad4
fix: open fix repos
dharamveergit Aug 17, 2024
040a626
update Repos.tsx, RemoteDeployUpdate.tsx and utils.ts
dharamveergit Aug 19, 2024
d047872
fix : more git repo fetch
dharamveergit Aug 20, 2024
4fb2650
test: temp fix
dharamveergit Aug 21, 2024
0a8a3eb
fix: relogin
dharamveergit Aug 22, 2024
cf05236
feat: remote-deploy: bug fixes
dharamveergit Aug 22, 2024
a788457
fix: redeploy advanced
dharamveergit Aug 22, 2024
6805c5a
update GihubDeploy.tsx
dharamveergit Aug 23, 2024
f681b75
update 5 files
dharamveergit Aug 23, 2024
cf15e95
update RemoteDeployUpdate.tsx and templates.ts
dharamveergit Aug 24, 2024
4ec0ee1
Merge remote-tracking branch 'upstream/main'
dharamveergit Aug 26, 2024
449c4e4
update : descriptions
dharamveergit Aug 26, 2024
29591f1
fixes: type
dharamveergit Aug 28, 2024
5e5b392
fix:repo filtering
dharamveergit Aug 28, 2024
7cd8536
remove: console.logs
dharamveergit Aug 28, 2024
21973f8
fix: repo redeploy selection
dharamveergit Aug 28, 2024
933c1a4
feat: images for git accounts
dharamveergit Aug 28, 2024
41a30c6
Merge remote-tracking branch 'upstream/main'
dharamveergit Aug 29, 2024
b9239ea
fix: filtering of repo (In Github)
dharamveergit Aug 29, 2024
0d64352
fix: ui (remote deploy)
dharamveergit Aug 30, 2024
a18e288
ui fix : rollback
dharamveergit Aug 30, 2024
1d785ef
Merge remote-tracking branch 'upstream/main'
dharamveergit Aug 30, 2024
e2d66fc
update Rollback.tsx
dharamveergit Aug 30, 2024
5547af2
fix : names( Remote Deploy)
dharamveergit Aug 31, 2024
7c623b5
update LeaseRow.tsx
dharamveergit Aug 31, 2024
5491178
fix: ui issues (Remote Deploy)
dharamveergit Aug 31, 2024
895d42c
remove : service name edit form remote deploy
dharamveergit Aug 31, 2024
cbf4dd9
update Advanced.tsx and EnvFormModal.tsx
dharamveergit Sep 3, 2024
69c0366
api: github api (next)
dharamveergit Sep 5, 2024
0bdadb4
Merge remote-tracking branch 'upstream/main'
dharamveergit Sep 6, 2024
18bdf90
next api: remote deploy - gitlab,bitbucket
dharamveergit Sep 6, 2024
874145c
ui fixes : Env and account ui (Remote Deploy)
dharamveergit Sep 7, 2024
c49d5d1
fix : env in update deployment
dharamveergit Sep 7, 2024
83ec32b
fix: Account select in smaller screens (Remote Deploy)
dharamveergit Sep 7, 2024
7e0d4f8
Merge remote-tracking branch 'upstream/main'
dharamveergit Sep 7, 2024
4c1c7a0
remove: console logs (Remote Deploy)
dharamveergit Sep 7, 2024
2cd1458
update api.ts
dharamveergit Sep 7, 2024
2841b9e
Merge pull request #6 from dharamveergit/main
dharamveergit Sep 7, 2024
376bbfa
fix: auth github
dharamveergit Sep 7, 2024
86428b0
build(deps): update package-lock.json
dharamveergit Sep 7, 2024
6104d66
update authenticate.ts
dharamveergit Sep 7, 2024
65c1d49
fix : Deploy
dharamveergit Sep 7, 2024
c86d5bc
Merge pull request #7 from dharamveergit/main
dharamveergit Sep 7, 2024
1469353
fix: remove "Environment Variables" in expanded state (Remote Deploy)
dharamveergit Sep 9, 2024
01708cd
Merge pull request #8 from dharamveergit/main
dharamveergit Sep 9, 2024
b9ed85b
Merge remote-tracking branch 'upstream/main'
dharamveergit Sep 12, 2024
29c8d5a
fix: Reordering of variables and useEffects
dharamveergit Sep 12, 2024
2da9923
fix: code clean (Remote Deploy)
dharamveergit Sep 12, 2024
a693d7a
fix: type fixes (Remote Deploy)
dharamveergit Sep 12, 2024
6f38fa9
fix: types (Remote Deploy)
dharamveergit Sep 12, 2024
299fe33
update Repos.tsx, bitbucket-api.ts and gitlab-api.ts
dharamveergit Sep 12, 2024
c026375
fix: vercel deploy fix
dharamveergit Sep 12, 2024
5647200
revert: vercel deploy
dharamveergit Sep 12, 2024
bcf6b8d
Merge pull request #9 from dharamveergit/main
dharamveergit Sep 12, 2024
5821792
fix: types and api class logic (Remote Deployment)
dharamveergit Sep 13, 2024
1a2ab6b
fix: vercel deploy
dharamveergit Sep 13, 2024
c133100
Merge pull request #10 from dharamveergit/main
dharamveergit Sep 13, 2024
999660c
Merge remote-tracking branch 'upstream/main'
dharamveergit Sep 13, 2024
beebec7
Merge pull request #11 from dharamveergit/main
dharamveergit Sep 13, 2024
dfb4367
fix: fetch deploy.yml from awesome akash
dharamveergit Sep 16, 2024
166016f
Merge pull request #12 from dharamveergit/main
dharamveergit Sep 16, 2024
83a2a06
Merge remote-tracking branch 'upstream/main'
dharamveergit Sep 20, 2024
3052eca
Merge remote-tracking branch 'upstream/main'
dharamveergit Sep 20, 2024
368b22a
build(deps): update browser-env.config.ts, env-config.schema.ts and p…
dharamveergit Sep 20, 2024
cc5beed
Merge pull request #13 from dharamveergit/main
dharamveergit Sep 20, 2024
a2a6f0e
delete: dup env component
dharamveergit Sep 20, 2024
c6cb364
delete: static github template from templates.ts
dharamveergit Sep 20, 2024
25206aa
fix: vercel deployment
dharamveergit Sep 20, 2024
29f6011
Merge pull request #14 from dharamveergit/main
dharamveergit Sep 21, 2024
a56c164
Merge remote-tracking branch 'upstream/main'
dharamveergit Sep 25, 2024
98aaebe
Merge pull request #15 from dharamveergit/main
dharamveergit Sep 25, 2024
c241ed8
Merge remote-tracking branch 'upstream/main'
dharamveergit Sep 28, 2024
87e5de0
code clean
dharamveergit Sep 28, 2024
732a365
fix: remote deploy name change
dharamveergit Sep 28, 2024
51fdcaf
deployment: vercel
dharamveergit Sep 28, 2024
c117b69
fix: dseq
dharamveergit Sep 28, 2024
57f02e4
fix: template id
dharamveergit Sep 28, 2024
47952e9
fix: error code
dharamveergit Sep 28, 2024
e50c2a5
Merge pull request #16 from dharamveergit/main
HoomanDgtl Sep 29, 2024
3b1a78f
Merge remote-tracking branch 'upstream/main'
dharamveergit Oct 3, 2024
766f8db
fix: code clean (remote Deploy)
dharamveergit Oct 3, 2024
f3881c0
fix: queries
dharamveergit Oct 3, 2024
ce4bfb1
fix: build errors
dharamveergit Oct 3, 2024
61ba6e5
fix: bitbucket auth error
dharamveergit Oct 3, 2024
993f936
fix: (Remote Deploy) - Query keys , Remote Deploy Services
dharamveergit Oct 4, 2024
a02e258
fix: (remote-deploy) Camel case
dharamveergit Oct 4, 2024
8d0f432
fix: types (Remote Deploy) Github
dharamveergit Oct 4, 2024
88e993e
fix: remote types
dharamveergit Oct 4, 2024
04f1f7c
fix: vercel deploy
dharamveergit Oct 4, 2024
e3d41ef
fix: revert vercel deploy
dharamveergit Oct 4, 2024
5dc5ee5
Merge remote-tracking branch 'upstream/main'
dharamveergit Oct 5, 2024
019b0f5
Merge pull request #17 from dharamveergit/main
dharamveergit Oct 5, 2024
8d5c138
fix: dot env build error (deploy-web)
dharamveergit Oct 5, 2024
d1cbd3e
fix: gitlab service
dharamveergit Oct 5, 2024
ee969cb
Merge pull request #18 from dharamveergit/main
dharamveergit Oct 5, 2024
91d3434
fix: boolean isRemoteDeploy
dharamveergit Oct 6, 2024
0ca1bf7
Merge pull request #19 from dharamveergit/main
dharamveergit Oct 6, 2024
c77b9d1
fix: openapi type to dev
dharamveergit Oct 6, 2024
d545837
Merge pull request #20 from dharamveergit/main
dharamveergit Oct 7, 2024
349e1e0
fix: gitlab refresh token
dharamveergit Oct 8, 2024
79991c5
Merge pull request #21 from dharamveergit/main
dharamveergit Oct 8, 2024
470e34c
Merge remote-tracking branch 'upstream/main'
dharamveergit Oct 10, 2024
2e9f0f2
fix: useMemo in envVArUpdater
dharamveergit Oct 10, 2024
cdf71a4
Merge pull request #22 from dharamveergit/main
dharamveergit Oct 10, 2024
e1003ef
fix: class in remote deploy
dharamveergit Oct 10, 2024
c0966c5
Merge pull request #23 from dharamveergit/main
dharamveergit Oct 10, 2024
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
2 changes: 1 addition & 1 deletion apps/deploy-web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const moduleExports = {
styledComponents: true
},
images: {
domains: ["raw.githubusercontent.com"]
domains: ["raw.githubusercontent.com", "avatars.githubusercontent.com"]
},
output: "standalone",
typescript: {
Expand Down
2 changes: 2 additions & 0 deletions apps/deploy-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"clsx": "^2.0.0",
"cosmjs-types": "^0.9.0",
"date-fns": "^2.29.3",
"dotenv": "^16.4.5",
"file-saver": "^2.0.5",
"geist": "^1.3.0",
"http-proxy": "^1.18.1",
Expand Down Expand Up @@ -114,6 +115,7 @@
"@akashnetwork/dev-config": "*",
"@keplr-wallet/types": "^0.12.111",
"@next/bundle-analyzer": "^14.0.1",
"@octokit/openapi-types": "^22.2.0",
"@playwright/test": "^1.45.0",
"@types/auth0": "^2.35.3",
"@types/file-saver": "^2.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import { useRouter, useSearchParams } from "next/navigation";
import { NextSeo } from "next-seo";
import { event } from "nextjs-google-analytics";

import { CI_CD_TEMPLATE_ID } from "@src/config/remote-deploy.config";
import { useCertificate } from "@src/context/CertificateProvider";
import { useSettings } from "@src/context/SettingsProvider";
import { useTemplates } from "@src/context/TemplatesProvider";
import { useWallet } from "@src/context/WalletProvider";
import { useDeploymentDetail } from "@src/queries/useDeploymentQuery";
import { useDeploymentLeaseList } from "@src/queries/useLeaseQuery";
import { useProviderList } from "@src/queries/useProvidersQuery";
import { extractRepositoryUrl, isImageInYaml } from "@src/services/remote-deploy/remote-deployment-controller.service";
import { RouteStep } from "@src/types/route-steps.type";
import { AnalyticsEvents } from "@src/utils/analytics";
import { getDeploymentLocalData } from "@src/utils/deploymentLocalDataUtils";
Expand All @@ -31,10 +34,16 @@ import { ManifestUpdate } from "./ManifestUpdate";
export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: string }>) {
const router = useRouter();
const [activeTab, setActiveTab] = useState("LEASES");
const [editedManifest, setEditedManifest] = useState<string | null>(null);
const { address, isWalletLoaded } = useWallet();
const { isSettingsInit } = useSettings();
const [leaseRefs, setLeaseRefs] = useState<Array<any>>([]);
const [deploymentManifest, setDeploymentManifest] = useState<string | null>(null);
const { getTemplateById } = useTemplates();
const remoteDeployTemplate = getTemplateById(CI_CD_TEMPLATE_ID);
const isRemoteDeploy: boolean = !!editedManifest && !!isImageInYaml(editedManifest, remoteDeployTemplate?.deploy);
const repo: string | null = isRemoteDeploy ? extractRepositoryUrl(editedManifest) : null;

const {
data: deployment,
isFetching: isLoadingDeployment,
Expand All @@ -45,7 +54,6 @@ export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: strin
if (_deploymentDetail) {
getLeases();
getProviders();

const deploymentData = getDeploymentLocalData(dseq);
setDeploymentManifest(deploymentData?.manifest || "");
}
Expand Down Expand Up @@ -84,6 +92,7 @@ export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: strin
const { isLocalCertMatching, localCert, isCreatingCert, createCertificate } = useCertificate();
const { data: providers, isFetching: isLoadingProviders, refetch: getProviders } = useProviderList();
const isActive = deployment?.state === "active" && leases?.some(x => x.state === "active");

const searchParams = useSearchParams();
const tabQuery = searchParams?.get("tab");
const logsModeQuery = searchParams?.get("logsMode");
Expand Down Expand Up @@ -189,6 +198,9 @@ export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: strin

{activeTab === "EDIT" && deployment && leases && (
<ManifestUpdate
editedManifest={editedManifest as string}
onManifestChange={setEditedManifest}
isRemoteDeploy={isRemoteDeploy}
deployment={deployment}
leases={leases}
closeManifestEditor={() => {
Expand All @@ -215,6 +227,7 @@ export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: strin
{leases &&
leases.map((lease, i) => (
<LeaseRow
repo={repo}
key={lease.id}
index={i}
lease={lease}
Expand All @@ -224,6 +237,7 @@ export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: strin
dseq={dseq}
providers={providers || []}
loadDeploymentDetail={loadDeploymentDetail}
isRemoteDeploy={isRemoteDeploy}
/>
))}

Expand Down
16 changes: 15 additions & 1 deletion apps/deploy-web/src/components/deployments/LeaseRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ type Props = {
dseq: string;
providers: ApiProviderList[];
loadDeploymentDetail: () => void;
isRemoteDeploy?: boolean;
repo?: string | null;
};

export type AcceptRefType = {
getLeaseStatus: () => void;
};

export const LeaseRow = React.forwardRef<AcceptRefType, Props>(
({ index, lease, setActiveTab, deploymentManifest, dseq, providers, loadDeploymentDetail }, ref) => {
({ index, lease, setActiveTab, deploymentManifest, dseq, providers, loadDeploymentDetail, isRemoteDeploy, repo }, ref) => {
const provider = providers?.find(p => p.owner === lease?.provider);
const { localCert } = useCertificate();
const isLeaseActive = lease.state === "active";
Expand Down Expand Up @@ -356,6 +358,18 @@ export const LeaseRow = React.forwardRef<AcceptRefType, Props>(
</div>
)}

{isRemoteDeploy && repo && (
<div className="mt-2">
<LabelValueOld label="Deployed Repo:" />
<ul className="mt-2 space-y-2">
<li className="flex items-center">
<Link href={repo} target="_blank" className="inline-flex items-center space-x-2 truncate text-sm">
<span>{repo?.replace("https://github.com/", "")?.replace("https://gitlab.com/", "")}</span> <OpenInWindow className="text-xs" />
</Link>
</li>
</ul>
</div>
)}
{service.uris?.length > 0 && (
<>
<div className="mt-2">
Expand Down
29 changes: 22 additions & 7 deletions apps/deploy-web/src/components/deployments/ManifestUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,31 @@ import { deploymentData } from "@src/utils/deploymentData";
import { getDeploymentLocalData, saveDeploymentManifest } from "@src/utils/deploymentLocalDataUtils";
import { sendManifestToProvider } from "@src/utils/deploymentUtils";
import { TransactionMessageData } from "@src/utils/TransactionMessageData";
import RemoteDeployUpdate from "../remote-deploy/update/RemoteDeployUpdate";
import { ManifestErrorSnackbar } from "../shared/ManifestErrorSnackbar";
import { Title } from "../shared/Title";

type Props = {
deployment: DeploymentDto;
leases: LeaseDto[];
closeManifestEditor: () => void;
isRemoteDeploy: boolean;
editedManifest: string;
onManifestChange: (value: string) => void;
};

export const ManifestUpdate: React.FunctionComponent<Props> = ({ deployment, leases, closeManifestEditor }) => {
export const ManifestUpdate: React.FunctionComponent<Props> = ({
deployment,
leases,
closeManifestEditor,
isRemoteDeploy,
editedManifest,
onManifestChange
}) => {
const [parsingError, setParsingError] = useState<string | null>(null);
const [deploymentVersion, setDeploymentVersion] = useState<string | null>(null);
const [editedManifest, setEditedManifest] = useState("");
const [isSendingManifest, setIsSendingManifest] = useState(false);
const [showOutsideDeploymentMessage, setShowOutsideDeploymentMessage] = useState(false);
const [isSendingManifest, setIsSendingManifest] = useState(false);
const { settings } = useSettings();
const { address, signAndBroadcastTx, isManaged: isManagedWallet } = useWallet();
const { data: providers } = useProviderList();
Expand All @@ -48,7 +58,7 @@ export const ManifestUpdate: React.FunctionComponent<Props> = ({ deployment, lea
const localDeploymentData = getDeploymentLocalData(deployment.dseq);

if (localDeploymentData?.manifest) {
setEditedManifest(localDeploymentData.manifest);
onManifestChange(localDeploymentData.manifest);

try {
const yamlVersion = yaml.load(localDeploymentData.manifest);
Expand Down Expand Up @@ -99,7 +109,7 @@ export const ManifestUpdate: React.FunctionComponent<Props> = ({ deployment, lea
}, [editedManifest, deployment.dseq, settings.apiEndpoint, address]);

function handleTextChange(value) {
setEditedManifest(value);
onManifestChange(value);

if (deploymentVersion) {
setDeploymentVersion(null);
Expand Down Expand Up @@ -244,6 +254,7 @@ export const ManifestUpdate: React.FunctionComponent<Props> = ({ deployment, lea
disabled={!!parsingError || !editedManifest || !providers || isSendingManifest || deployment.state !== "active"}
onClick={() => handleUpdateClick()}
size="sm"
type="button"
>
Update Deployment
</Button>
Expand All @@ -255,8 +266,12 @@ export const ManifestUpdate: React.FunctionComponent<Props> = ({ deployment, lea

<LinearLoadingSkeleton isLoading={isSendingManifest} />

<ViewPanel stickToBottom style={{ overflow: "hidden" }}>
<DynamicMonacoEditor value={editedManifest} onChange={handleTextChange} />
<ViewPanel stickToBottom style={{ overflow: isRemoteDeploy ? "unset" : "hidden" }}>
{isRemoteDeploy ? (
<RemoteDeployUpdate sdlString={editedManifest} onManifestChange={onManifestChange} />
) : (
<DynamicMonacoEditor value={editedManifest} onChange={handleTextChange} />
)}
</ViewPanel>
</div>
</>
Expand Down
114 changes: 72 additions & 42 deletions apps/deploy-web/src/components/new-deployment/ManifestEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"use client";
import { Dispatch, SetStateAction, useEffect, useRef, useState } from "react";
import { certificateManager } from "@akashnetwork/akashjs/build/certificates/certificate-manager";
import { Alert, Button, CustomTooltip, Input, Spinner } from "@akashnetwork/ui/components";
import { Alert, Button, CustomTooltip, Input, Snackbar, Spinner } from "@akashnetwork/ui/components";
import { EncodeObject } from "@cosmjs/proto-signing";
import { useTheme as useMuiTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";
import { ArrowRight, InfoCircle } from "iconoir-react";
import { useAtom } from "jotai";
import { useRouter, useSearchParams } from "next/navigation";
import { event } from "nextjs-google-analytics";
import { useSnackbar } from "notistack";

import { browserEnvConfig } from "@src/config/browser-env.config";
import { useCertificate } from "@src/context/CertificateProvider";
Expand Down Expand Up @@ -47,15 +48,23 @@ type Props = {
selectedTemplate: TemplateCreation | null;
editedManifest: string | null;
setEditedManifest: Dispatch<SetStateAction<string>>;
isGitProviderTemplate?: boolean;
};

export const ManifestEdit: React.FunctionComponent<Props> = ({ editedManifest, setEditedManifest, onTemplateSelected, selectedTemplate }) => {
export const ManifestEdit: React.FunctionComponent<Props> = ({
editedManifest,
setEditedManifest,
onTemplateSelected,
selectedTemplate,
isGitProviderTemplate
}) => {
const [parsingError, setParsingError] = useState<string | null>(null);
const [deploymentName, setDeploymentName] = useState("");
const [isCreatingDeployment, setIsCreatingDeployment] = useState(false);
const [isDepositingDeployment, setIsDepositingDeployment] = useState(false);
const [isCheckingPrerequisites, setIsCheckingPrerequisites] = useState(false);
const [selectedSdlEditMode, setSelectedSdlEditMode] = useAtom(sdlStore.selectedSdlEditMode);
const [isRepoInputValid, setIsRepoInputValid] = useState(false);
const [sdlDenom, setSdlDenom] = useState("uakt");
const { settings } = useSettings();
const { address, signAndBroadcastTx, isManaged } = useWallet();
Expand All @@ -75,6 +84,7 @@ export const ManifestEdit: React.FunctionComponent<Props> = ({ editedManifest, s
const wallet = useWallet();
const managedDenom = useManagedWalletDenom();
const { createDeploymentConfirm } = useManagedDeploymentConfirm();
const { enqueueSnackbar } = useSnackbar();

useWhen(
wallet.isManaged && sdlDenom === "uakt" && editedManifest,
Expand All @@ -84,11 +94,14 @@ export const ManifestEdit: React.FunctionComponent<Props> = ({ editedManifest, s
},
[editedManifest, wallet.isManaged, sdlDenom]
);

useWhen(hasComponent("ssh"), () => {
setSelectedSdlEditMode("builder");
});

useWhen(isGitProviderTemplate, () => {
setSelectedSdlEditMode("builder");
}, [isGitProviderTemplate]);

const propagateUploadedSdl = (event: React.ChangeEvent<HTMLInputElement>) => {
const selectedFiles = event.target.files ?? [];
const hasFileSelected = selectedFiles.length > 0;
Expand Down Expand Up @@ -176,6 +189,13 @@ export const ManifestEdit: React.FunctionComponent<Props> = ({ editedManifest, s
}

const handleCreateDeployment = async () => {
if (isGitProviderTemplate && !isRepoInputValid) {
enqueueSnackbar(<Snackbar title={"Please Fill All Required Fields"} subTitle="You need fill repo url and branch to deploy" iconVariant="error" />, {
variant: "error"
});
return;
}

if (selectedSdlEditMode === "builder") {
const valid = await sdlBuilderRef.current?.validate();
if (!valid) return;
Expand Down Expand Up @@ -350,44 +370,46 @@ export const ManifestEdit: React.FunctionComponent<Props> = ({ editedManifest, s
</div>
</div>

<div className="mb-2 flex gap-2">
{hasComponent("yml-editor") && (
<div className="flex items-center">
<Button
variant={selectedSdlEditMode === "builder" ? "default" : "outline"}
onClick={() => changeMode("builder")}
size="sm"
className={cn("flex-grow sm:flex-grow-0", { "rounded-e-none": hasComponent("yml-editor") })}
disabled={!!parsingError && selectedSdlEditMode === "yaml"}
>
Builder
</Button>
<Button
variant={selectedSdlEditMode === "yaml" ? "default" : "outline"}
color={selectedSdlEditMode === "yaml" ? "secondary" : "primary"}
onClick={() => changeMode("yaml")}
size="sm"
className="flex-grow rounded-s-none sm:flex-grow-0"
>
YAML
</Button>
</div>
)}
{hasComponent("yml-uploader") && !templateId && (
<>
<input type="file" ref={fileUploadRef} onChange={propagateUploadedSdl} style={{ display: "none" }} accept=".yml,.yaml,.txt" />
<Button
variant="outline"
color="secondary"
onClick={() => triggerFileInput()}
size="sm"
className="flex-grow hover:bg-primary hover:text-white sm:flex-grow-0"
>
Upload SDL
</Button>
</>
)}
</div>
{!isGitProviderTemplate && (
<div className="mb-2 flex gap-2">
{hasComponent("yml-editor") && (
<div className="flex items-center">
<Button
variant={selectedSdlEditMode === "builder" ? "default" : "outline"}
onClick={() => changeMode("builder")}
size="sm"
className={cn("flex-grow sm:flex-grow-0", { "rounded-e-none": hasComponent("yml-editor") })}
disabled={!!parsingError && selectedSdlEditMode === "yaml"}
>
Builder
</Button>
<Button
variant={selectedSdlEditMode === "yaml" ? "default" : "outline"}
color={selectedSdlEditMode === "yaml" ? "secondary" : "primary"}
onClick={() => changeMode("yaml")}
size="sm"
className="flex-grow rounded-s-none sm:flex-grow-0"
>
YAML
</Button>
</div>
)}
{hasComponent("yml-uploader") && !templateId && (
<>
<input type="file" ref={fileUploadRef} onChange={propagateUploadedSdl} style={{ display: "none" }} accept=".yml,.yaml,.txt" />
<Button
variant="outline"
color="secondary"
onClick={() => triggerFileInput()}
size="sm"
className="flex-grow hover:bg-primary hover:text-white sm:flex-grow-0"
>
Upload SDL
</Button>
</>
)}
</div>
)}

{parsingError && <Alert variant="warning">{parsingError}</Alert>}

Expand All @@ -397,7 +419,15 @@ export const ManifestEdit: React.FunctionComponent<Props> = ({ editedManifest, s
</ViewPanel>
)}
{(hasComponent("ssh") || selectedSdlEditMode === "builder") && (
<SdlBuilder sdlString={editedManifest} ref={sdlBuilderRef} setEditedManifest={setEditedManifest} />
<SdlBuilder
sdlString={editedManifest}
ref={sdlBuilderRef}
isGitProviderTemplate={isGitProviderTemplate}
setEditedManifest={setEditedManifest}
setDeploymentName={setDeploymentName}
deploymentName={deploymentName}
setIsRepoInputValid={setIsRepoInputValid}
/>
)}

{isDepositingDeployment && (
Expand Down
Loading
Loading