Skip to content

Commit

Permalink
Merge branch 'main' into feature/provider/pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-arc10 committed Dec 4, 2024
2 parents 8dec5aa + 62aefe3 commit 499722c
Show file tree
Hide file tree
Showing 38 changed files with 293 additions and 178 deletions.
3 changes: 2 additions & 1 deletion .commitlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"repo",
"styling",
"observability",
"analytics"
"analytics",
"template"
]
]
}
Expand Down
16 changes: 16 additions & 0 deletions apps/api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@


## [2.35.4-beta.0](https://github.com/akash-network/console/compare/console-api/v2.35.3...console-api/v2.35.4-beta.0) (2024-12-03)


### Bug Fixes

* **billing:** filter prices by product ([45eb976](https://github.com/akash-network/console/commit/45eb9762b7c7fd542359bf91b8f92cf7c708b749)), closes [#511](https://github.com/akash-network/console/issues/511)

## [2.35.3](https://github.com/akash-network/console/compare/console-api/v2.35.3-beta.0...console-api/v2.35.3) (2024-12-03)

## [2.35.3-beta.0](https://github.com/akash-network/console/compare/console-api/v2.35.2...console-api/v2.35.3-beta.0) (2024-12-03)


### Bug Fixes

* **deployment:** update the Block import ([5db9f02](https://github.com/akash-network/console/commit/5db9f02d380c63db0dc694eeb7cb7bb5c6aa1c32)), closes [#512](https://github.com/akash-network/console/issues/512)

## [2.35.2](https://github.com/akash-network/console/compare/console-api/v2.35.2-beta.0...console-api/v2.35.2) (2024-12-02)

## [2.35.2-beta.0](https://github.com/akash-network/console/compare/console-api/v2.35.1...console-api/v2.35.2-beta.0) (2024-11-28)
Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@akashnetwork/console-api",
"version": "2.35.2",
"version": "2.35.4-beta.0",
"description": "Api providing data to the deploy tool",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/billing/services/stripe/stripe.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class StripeService extends Stripe {
}

private async getPrice(amount?: string) {
const { data: prices } = await this.prices.list({ product: this.billingConfig.get("STRIPE_PRODUCT_ID") });
const { data: prices } = await this.prices.list({ active: true, product: this.billingConfig.get("STRIPE_PRODUCT_ID") });

const price = prices.find(price => {
const isCustom = !amount && !!price.custom_unit_amount;
Expand All @@ -62,7 +62,7 @@ export class StripeService extends Stripe {
}

async findPrices(): Promise<StripePrices[]> {
const { data: prices } = await this.prices.list({ active: true });
const { data: prices } = await this.prices.list({ active: true, product: this.billingConfig.get("STRIPE_PRODUCT_ID") });
const responsePrices = prices.map(price => ({
unitAmount: price.custom_unit_amount ? undefined : price.unit_amount / 100,
isCustom: !!price.custom_unit_amount,
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/chain/repositories/block.repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Block } from "@akashnetwork/database/dbSchemas/base";
import { Block } from "@akashnetwork/database/dbSchemas";
import { singleton } from "tsyringe";

@singleton()
Expand Down
28 changes: 15 additions & 13 deletions apps/api/src/routes/v1/templates/byId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ const route = createRoute({
content: {
"application/json": {
schema: z.object({
id: z.string(),
name: z.string(),
path: z.string(),
logoUrl: z.string().nullable(),
summary: z.string(),
readme: z.string().nullable(),
deploy: z.string(),
persistentStorageEnabled: z.boolean(),
guide: z.string().nullable(),
githubUrl: z.string(),
config: z.object({
ssh: z.boolean().optional()
data: z.object({
id: z.string(),
name: z.string(),
path: z.string(),
logoUrl: z.string().nullable(),
summary: z.string(),
readme: z.string().nullable(),
deploy: z.string(),
persistentStorageEnabled: z.boolean(),
guide: z.string().nullable(),
githubUrl: z.string(),
config: z.object({
ssh: z.boolean().optional()
})
})
})
}
Expand All @@ -51,5 +53,5 @@ export default new OpenAPIHono().openapi(route, async c => {
return c.text("Template not found", 404);
}

return c.json(template);
return c.json({ data: template });
});
7 changes: 7 additions & 0 deletions apps/deploy-web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@


## [2.25.1-beta.1](https://github.com/akash-network/console/compare/console-web/v2.25.1-beta.0...console-web/v2.25.1-beta.1) (2024-12-03)


### Bug Fixes

* ensure proper schema type on server props getter ([aedf03d](https://github.com/akash-network/console/commit/aedf03d837fd6b2ebd6e76b32a694e043053a441))

## [2.25.1-beta.0](https://github.com/akash-network/console/compare/console-web/v2.25.0...console-web/v2.25.1-beta.0) (2024-11-28)


Expand Down
4 changes: 3 additions & 1 deletion apps/deploy-web/env/.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ NEXT_PUBLIC_REDIRECT_URI='https://console.akash.network/new-deployment'
NEXT_PUBLIC_GITHUB_APP_INSTALLATION_URL='https://github.com/apps/akash-console-build-and-deploy-app/installations/new'
NEXT_PUBLIC_BITBUCKET_CLIENT_ID=tdH2xfRkTcdqVP6cwW
NEXT_PUBLIC_GITHUB_CLIENT_ID=Iv23lidSwihrsSL7aGew
NEXT_PUBLIC_GITLAB_CLIENT_ID=beb5370aad2fdb6147edb44248d20d30c3e189ddfb40c26f651c77bbe949d5a8
NEXT_PUBLIC_GITLAB_CLIENT_ID=beb5370aad2fdb6147edb44248d20d30c3e189ddfb40c26f651c77bbe949d5a8

NEXT_PUBLIC_CI_CD_IMAGE_NAME=hoomanhq/automation
2 changes: 1 addition & 1 deletion apps/deploy-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@akashnetwork/console-web",
"version": "2.25.1-beta.0",
"version": "2.25.1-beta.1",
"private": true,
"description": "Web UI to deploy on the Akash Network and view statistic about network usage.",
"license": "Apache-2.0",
Expand Down
18 changes: 9 additions & 9 deletions apps/deploy-web/src/components/deployments/DeploymentDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { createRef, useEffect, useState } from "react";
import { createRef, FC, useEffect, useState } from "react";
import { Alert, Button, buttonVariants, Spinner, Tabs, TabsList, TabsTrigger } from "@akashnetwork/ui/components";
import { cn } from "@akashnetwork/ui/utils";
import { ArrowLeft } from "iconoir-react";
Expand All @@ -9,15 +9,13 @@ 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 { extractRepositoryUrl, isCiCdImageInYaml } from "@src/services/remote-deploy/remote-deployment-controller.service";
import { AnalyticsCategory, AnalyticsEvents } from "@src/types/analytics";
import { RouteStep } from "@src/types/route-steps.type";
import { getDeploymentLocalData } from "@src/utils/deploymentLocalDataUtils";
Expand All @@ -31,17 +29,19 @@ import { DeploymentSubHeader } from "./DeploymentSubHeader";
import { LeaseRow } from "./LeaseRow";
import { ManifestUpdate } from "./ManifestUpdate";

export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: string }>) {
export interface DeploymentDetailProps {
dseq: string;
}

export const DeploymentDetail: FC<DeploymentDetailProps> = ({ dseq }) => {
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 isRemoteDeploy: boolean = !!editedManifest && !!isCiCdImageInYaml(editedManifest);
const repo: string | null = isRemoteDeploy ? extractRepositoryUrl(editedManifest) : null;

const {
Expand Down Expand Up @@ -255,4 +255,4 @@ export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: strin
)}
</Layout>
);
}
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";
import { FC, useEffect, useState } from "react";
import { FC, useCallback, useEffect, useState } from "react";
import { TemplateOutput } from "@akashnetwork/http-sdk/src/template/template-http.service";
import { useAtomValue } from "jotai";
import { useRouter, useSearchParams } from "next/navigation";

Expand All @@ -8,7 +9,7 @@ import { CI_CD_TEMPLATE_ID } from "@src/config/remote-deploy.config";
import { useLocalNotes } from "@src/context/LocalNoteProvider";
import { useSdlBuilder } from "@src/context/SdlBuilderProvider";
import { useTemplates } from "@src/context/TemplatesProvider";
import { isImageInYaml } from "@src/services/remote-deploy/remote-deployment-controller.service";
import { isCiCdImageInYaml } from "@src/services/remote-deploy/remote-deployment-controller.service";
import sdlStore from "@src/store/sdlStore";
import { TemplateCreation } from "@src/types";
import { RouteStep } from "@src/types/route-steps.type";
Expand All @@ -20,15 +21,19 @@ import { ManifestEdit } from "./ManifestEdit";
import { CustomizedSteppers } from "./Stepper";
import { TemplateList } from "./TemplateList";

export const NewDeploymentContainer: FC = () => {
export interface NewDeploymentContainerProps {
template?: TemplateOutput;
templateId?: string;
}

export const NewDeploymentContainer: FC<NewDeploymentContainerProps> = ({ template: requestedTemplate, templateId }) => {
const [isGitProviderTemplate, setIsGitProviderTemplate] = useState<boolean>(false);
const { isLoading: isLoadingTemplates, templates } = useTemplates();
const [activeStep, setActiveStep] = useState<number | null>(null);
const [selectedTemplate, setSelectedTemplate] = useState<TemplateCreation | null>(null);
const [editedManifest, setEditedManifest] = useState<string | null>(null);
const deploySdl = useAtomValue(sdlStore.deploySdl);
const { getDeploymentData } = useLocalNotes();
const { getTemplateById } = useTemplates();
const router = useRouter();
const searchParams = useSearchParams();
const dseq = searchParams?.get("dseq");
Expand Down Expand Up @@ -78,8 +83,7 @@ export const NewDeploymentContainer: FC = () => {
toggleCmp("ssh");
}

const cicdTemplate = getTemplateById(CI_CD_TEMPLATE_ID);
const isRemoteYamlImage = isImageInYaml(template?.content as string, cicdTemplate?.deploy);
const isRemoteYamlImage = isCiCdImageInYaml(template?.content as string);
const queryStep = searchParams?.get("step");
if (queryStep !== RouteStep.editDeployment) {
if (isRemoteYamlImage) {
Expand Down Expand Up @@ -113,34 +117,25 @@ export const NewDeploymentContainer: FC = () => {
return template;
};

const getGalleryTemplate = (): Partial<{
code: string;
name: string;
content: string;
valuesToChange: any[];
config: { ssh?: boolean };
}> | null => {
const queryTemplateId = searchParams?.get("templateId");
if (queryTemplateId) {
const templateById = getTemplateById(queryTemplateId as string);
if (templateById) {
return {
const getGalleryTemplate = useCallback(():
| Partial<{
code: string;
name: string;
content: string;
valuesToChange: any[];
config: { ssh?: boolean };
}>
| undefined => {
return requestedTemplate
? {
code: "empty",
name: templateById.name,
content: templateById.deploy,
valuesToChange: templateById.valuesToChange || [],
config: templateById.config
};
}

const hardCodedTemplate = hardcodedTemplates.find(t => t.code === queryTemplateId);
if (hardCodedTemplate) {
return hardCodedTemplate;
}
}

return null;
};
name: requestedTemplate.name,
content: requestedTemplate.deploy,
valuesToChange: [],
config: requestedTemplate.config
}
: hardcodedTemplates.find(t => t.code === templateId);
}, [requestedTemplate, templateId]);

function getStepIndexByParam(step: (typeof RouteStep)[keyof typeof RouteStep] | null) {
switch (step) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { useSnackbar } from "notistack";

import { EnvFormModal } from "@src/components/sdl/EnvFormModal";
import { EnvVarList } from "@src/components/sdl/EnvVarList";
import { CI_CD_TEMPLATE_ID, CURRENT_SERVICE, protectedEnvironmentVariables } from "@src/config/remote-deploy.config";
import { browserEnvConfig } from "@src/config/browser-env.config";
import { CURRENT_SERVICE, protectedEnvironmentVariables } from "@src/config/remote-deploy.config";
import { SdlBuilderProvider } from "@src/context/SdlBuilderProvider";
import { useTemplates } from "@src/context/TemplatesProvider";
import { EnvVarUpdater } from "@src/services/remote-deploy/remote-deployment-controller.service";
import { tokens } from "@src/store/remoteDeployStore";
import { SdlBuilderFormValuesType, ServiceType } from "@src/types";
Expand All @@ -26,8 +26,6 @@ const RemoteDeployUpdate = ({ sdlString, onManifestChange }: { sdlString: string
const [isEditingEnv, setIsEditingEnv] = useState<number | boolean | null>(false);
const { control, watch, setValue } = useForm<SdlBuilderFormValuesType>({ defaultValues: { services: [defaultService] } });
const { fields: services } = useFieldArray({ control, name: "services", keyName: "id" });
const { getTemplateById } = useTemplates();
const remoteDeployTemplate = getTemplateById(CI_CD_TEMPLATE_ID);
const envVarUpdater = useMemo(() => new EnvVarUpdater(services), [services]);

useEffect(() => {
Expand All @@ -51,10 +49,7 @@ const RemoteDeployUpdate = ({ sdlString, onManifestChange }: { sdlString: string

const createAndValidateSdl = (yamlStr: string) => {
try {
if (!yamlStr) return [];
const services = importSimpleSdl(yamlStr);

return services;
return yamlStr ? importSimpleSdl(yamlStr) : [];
} catch (err) {
if (err.name === "YAMLException" || err.name === "CustomValidationError") {
enqueueSnackbar(<Snackbar title={err.message} />, { variant: "error" });
Expand All @@ -65,7 +60,7 @@ const RemoteDeployUpdate = ({ sdlString, onManifestChange }: { sdlString: string
}
}
};
return remoteDeployTemplate?.deploy?.includes(services?.[0]?.image) && services?.[0]?.env && services?.[0]?.env?.length > 0 ? (
return services?.[0]?.image.startsWith(browserEnvConfig.NEXT_PUBLIC_CI_CD_IMAGE_NAME) && services?.[0]?.env && services?.[0]?.env?.length > 0 ? (
<div className="flex flex-col gap-6 rounded border bg-card px-4 py-6 md:px-6">
<div className="flex flex-col gap-3 rounded border bg-card px-6 py-6 text-card-foreground">
<div className="flex items-center justify-between gap-5">
Expand Down
Loading

0 comments on commit 499722c

Please sign in to comment.