Display project URLs in Overview tab #20

Merged
nabarun merged 5 commits from nv-display-base-domain into main 2024-10-29 14:10:02 +00:00
10 changed files with 143 additions and 121 deletions

View File

@ -140,6 +140,7 @@ export class Database {
) )
.leftJoinAndSelect('deployments.createdBy', 'user') .leftJoinAndSelect('deployments.createdBy', 'user')
.leftJoinAndSelect('deployments.domain', 'domain') .leftJoinAndSelect('deployments.domain', 'domain')
.leftJoinAndSelect('deployments.deployer', 'deployer')
.leftJoinAndSelect('project.owner', 'owner') .leftJoinAndSelect('project.owner', 'owner')
.leftJoinAndSelect('project.deployers', 'deployers') .leftJoinAndSelect('project.deployers', 'deployers')
.leftJoinAndSelect('project.organization', 'organization') .leftJoinAndSelect('project.organization', 'organization')

View File

@ -143,6 +143,7 @@ type Deployer {
paymentAddress: String paymentAddress: String
createdAt: String! createdAt: String!
updatedAt: String! updatedAt: String!
baseDomain: String
} }
type AuthResult { type AuthResult {

View File

@ -70,6 +70,7 @@ const Configure = () => {
maxPrice: DEFAULT_MAX_PRICE, maxPrice: DEFAULT_MAX_PRICE,
lrn: '', lrn: '',
numProviders: 1, numProviders: 1,
variables: [],
}, },
}); });
@ -173,6 +174,7 @@ const Configure = () => {
const handleFormSubmit = useCallback( const handleFormSubmit = useCallback(
async (createFormData: FieldValues) => { async (createFormData: FieldValues) => {
try {
const deployerLrn = createFormData.lrn; const deployerLrn = createFormData.lrn;
const deployer = deployers.find( const deployer = deployers.find(
(deployer) => deployer.deployerLrn === deployerLrn, (deployer) => deployer.deployerLrn === deployerLrn,
@ -268,6 +270,15 @@ const Configure = () => {
`/${orgSlug}/projects/create/deploy?projectId=${projectId}`, `/${orgSlug}/projects/create/deploy?projectId=${projectId}`,
); );
} }
} catch (error) {
console.error(error);
toast({
id: 'error-deploying-app',
title: 'Error deploying app',
variant: 'error',
onDismiss: dismiss,
});
}
}, },
[client, createProject, dismiss, toast], [client, createProject, dismiss, toast],
); );
@ -281,10 +292,13 @@ const Configure = () => {
setSelectedAccount(account); setSelectedAccount(account);
}, []); }, []);
const onDeployerChange = useCallback((selectedLrn: string) => { const onDeployerChange = useCallback(
(selectedLrn: string) => {
const deployer = deployers.find((d) => d.deployerLrn === selectedLrn); const deployer = deployers.find((d) => d.deployerLrn === selectedLrn);
setSelectedDeployer(deployer); setSelectedDeployer(deployer);
}, [deployers]); },
[deployers],
);
const cosmosSendTokensHandler = useCallback( const cosmosSendTokensHandler = useCallback(
async (selectedAccount: string, amount: string) => { async (selectedAccount: string, amount: string) => {
@ -496,8 +510,7 @@ const Configure = () => {
<EnvironmentVariablesForm /> <EnvironmentVariablesForm />
</div> </div>
{selectedOption === 'LRN' && {selectedOption === 'LRN' && !selectedDeployer?.minimumPayment ? (
!selectedDeployer?.minimumPayment ? (
<div> <div>
<Button <Button
{...buttonSize} {...buttonSize}

View File

@ -46,27 +46,27 @@ export const AuctionCard = ({ project }: { project: Project }) => {
const result = await client.getAuctionData(project.auctionId); const result = await client.getAuctionData(project.auctionId);
setAuctionStatus(result.status); setAuctionStatus(result.status);
setAuctionDetails(result); setAuctionDetails(result);
setDeployers(project.deployers); }, [project.auctionId, project.deployers, project.fundsReleased]);
setFundsStatus(project.fundsReleased);
}, []); const fetchUpdatedProject = useCallback(async () => {
const updatedProject = await client.getProject(project.id);
setDeployers(updatedProject.project!.deployers!);
setFundsStatus(updatedProject.project!.fundsReleased!);
}, [project.id]);
const fetchData = useCallback(async () => {
await Promise.all([checkAuctionStatus(), fetchUpdatedProject()]);
}, [checkAuctionStatus, fetchUpdatedProject]);
useEffect(() => { useEffect(() => {
if (auctionStatus !== 'completed') { fetchData();
checkAuctionStatus();
const intervalId = setInterval(checkAuctionStatus, WAIT_DURATION);
return () => clearInterval(intervalId);
}
if (auctionStatus === 'completed') { const timerId = setInterval(() => {
const fetchUpdatedProject = async () => { fetchData();
// Wait for 5 secs since the project is not immediately updated with deployer LRNs }, WAIT_DURATION);
await new Promise((resolve) => setTimeout(resolve, WAIT_DURATION));
const updatedProject = await client.getProject(project.id); return () => clearInterval(timerId);
setDeployers(updatedProject.project?.deployers || []); }, [fetchData]);
};
fetchUpdatedProject();
}
}, [auctionStatus, client]);
const renderAuctionStatus = useCallback( const renderAuctionStatus = useCallback(
() => ( () => (
@ -134,7 +134,7 @@ export const AuctionCard = ({ project }: { project: Project }) => {
size="xs" size="xs"
type={fundsStatus ? 'positive' : 'emphasized'} type={fundsStatus ? 'positive' : 'emphasized'}
> >
{fundsStatus ? 'RELEASED' : 'LOCKED'} {fundsStatus ? 'RELEASED' : 'WAITING'}
</Tag> </Tag>
</div> </div>
</div> </div>

View File

@ -31,8 +31,8 @@ const axiosInstance = axios.create({
withCredentials: true, withCredentials: true,
}); });
const metadata = { const metadata = {
name: 'Web3Modal', name: 'Deploy App Auth',
description: 'Snowball Web3Modal', description: '',
url: window.location.origin, url: window.location.origin,
icons: ['https://avatars.githubusercontent.com/u/37784886'], icons: ['https://avatars.githubusercontent.com/u/37784886'],
}; };

View File

@ -41,6 +41,7 @@ const deployment: Deployment = {
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu', deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
deployerLrn: 'lrn://example/deployers/webapp-deployer-api.example.com', deployerLrn: 'lrn://example/deployers/webapp-deployer-api.example.com',
minimumPayment: '1000alnt', minimumPayment: '1000alnt',
baseDomain: 'pwa.example.com',
}, },
status: DeploymentStatus.Ready, status: DeploymentStatus.Ready,
createdBy: { createdBy: {

View File

@ -129,16 +129,16 @@ const OverviewTabPanel = () => {
<Heading className="text-lg leading-6 font-medium truncate"> <Heading className="text-lg leading-6 font-medium truncate">
{project.name} {project.name}
</Heading> </Heading>
{project.baseDomains && {project.deployments &&
project.baseDomains.length > 0 && project.deployments.length > 0 &&
project.baseDomains.map((baseDomain, index) => ( project.deployments.map((deployment, index) => (
<p> <p>
<a <a
key={index} key={index}
href={`https://${project.name.toLowerCase()}.${baseDomain}`} href={`https://${project.name.toLowerCase()}.${deployment.deployer.baseDomain}`}
className="text-sm text-elements-low-em tracking-tight truncate" className="text-sm text-elements-low-em tracking-tight truncate"
> >
{baseDomain} {deployment.deployer.baseDomain}
</a> </a>
</p> </p>
))} ))}

View File

@ -107,6 +107,7 @@ export const deployment0: Deployment = {
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu', deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
deployerLrn: 'lrn://deployer.apps.snowballtools.com ', deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
minimumPayment: '1000alnt', minimumPayment: '1000alnt',
baseDomain: 'pwa.example.com',
}, },
applicationDeploymentRequestId: applicationDeploymentRequestId:
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize', 'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
@ -134,6 +135,7 @@ export const project: Project = {
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu', deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
deployerLrn: 'lrn://deployer.apps.snowballtools.com ', deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
minimumPayment: '1000alnt', minimumPayment: '1000alnt',
baseDomain: 'pwa.example.com',
}, },
], ],
paymentAddress: '0x657868687686rb4787987br8497298r79284797487', paymentAddress: '0x657868687686rb4787987br8497298r79284797487',

View File

@ -57,6 +57,9 @@ query ($projectId: String!) {
commitHash commitHash
createdAt createdAt
environment environment
deployer {
baseDomain
}
domain { domain {
status status
branch branch

View File

@ -119,6 +119,7 @@ export type Deployer = {
deployerLrn: string; deployerLrn: string;
deployerId: string; deployerId: string;
deployerApiUrl: string; deployerApiUrl: string;
baseDomain: string;
minimumPayment: string | null; minimumPayment: string | null;
} }