Display DNS deployment URLs in overview section (#21)
All checks were successful
Lint / lint (20.x) (push) Successful in 4m40s

Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75)

- Disable `Deploy` button in configure step if account and deployer not selected
- Update organization slug
- Only display project if current user is project owner

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Co-authored-by: Adw8 <adwaitgharpure@gmail.com>
Reviewed-on: #21
This commit is contained in:
nabarun 2024-10-30 13:11:04 +00:00
parent 05bd766133
commit ea9a56eb65
12 changed files with 57 additions and 42 deletions

View File

@ -22,8 +22,8 @@ export const createResolvers = async (service: Service): Promise<any> => {
return service.getOrganizationsByUserId(context.user); return service.getOrganizationsByUserId(context.user);
}, },
project: async (_: any, { projectId }: { projectId: string }) => { project: async (_: any, { projectId }: { projectId: string }, context: any) => {
return service.getProjectById(projectId); return service.getProjectById(context.user, projectId);
}, },
projectsInOrganization: async ( projectsInOrganization: async (

View File

@ -407,8 +407,13 @@ export class Service {
return dbOrganizations; return dbOrganizations;
} }
async getProjectById(projectId: string): Promise<Project | null> { async getProjectById(user: User, projectId: string): Promise<Project | null> {
const dbProject = await this.db.getProjectById(projectId); const dbProject = await this.db.getProjectById(projectId);
if (dbProject && dbProject.owner.id !== user.id) {
return null;
}
return dbProject; return dbProject;
} }

View File

@ -1,8 +1,8 @@
[ [
{ {
"id": "2379cf1f-a232-4ad2-ae14-4d881131cc26", "id": "2379cf1f-a232-4ad2-ae14-4d881131cc26",
"name": "Snowball Tools", "name": "Deploy Tools",
"slug": "snowball-tools-1" "slug": "deploy-tools"
}, },
{ {
"id": "7eb9b3eb-eb74-4b53-b59a-69884c82a7fb", "id": "7eb9b3eb-eb74-4b53-b59a-69884c82a7fb",

View File

@ -515,7 +515,7 @@ const Configure = () => {
<Button <Button
{...buttonSize} {...buttonSize}
type="submit" type="submit"
disabled={isLoading} disabled={isLoading || !selectedDeployer || !selectedAccount}
rightIcon={ rightIcon={
isLoading ? ( isLoading ? (
<LoadingIcon className="animate-spin" /> <LoadingIcon className="animate-spin" />
@ -538,7 +538,9 @@ const Configure = () => {
<Button <Button
{...buttonSize} {...buttonSize}
type="submit" type="submit"
disabled={isLoading || isPaymentLoading} disabled={
isLoading || isPaymentLoading || !selectedAccount
}
rightIcon={ rightIcon={
isLoading || isPaymentLoading ? ( isLoading || isPaymentLoading ? (
<LoadingIcon className="animate-spin" /> <LoadingIcon className="animate-spin" />

View File

@ -42,31 +42,31 @@ export const AuctionCard = ({ project }: { project: Project }) => {
<LoadingIcon className="animate-spin" /> <LoadingIcon className="animate-spin" />
); );
const checkAuctionStatus = useCallback(async () => { const checkAuctionStatus = useCallback(async () => {
const result = await client.getAuctionData(project.auctionId); const result = await client.getAuctionData(project.auctionId);
setAuctionStatus(result.status); setAuctionStatus(result.status);
setAuctionDetails(result); setAuctionDetails(result);
}, [project.auctionId, project.deployers, project.fundsReleased]); }, [project.auctionId, project.deployers, project.fundsReleased]);
const fetchUpdatedProject = useCallback(async () => { const fetchUpdatedProject = useCallback(async () => {
const updatedProject = await client.getProject(project.id); const updatedProject = await client.getProject(project.id);
setDeployers(updatedProject.project!.deployers!); setDeployers(updatedProject.project!.deployers!);
setFundsStatus(updatedProject.project!.fundsReleased!); setFundsStatus(updatedProject.project!.fundsReleased!);
}, [project.id]); }, [project.id]);
const fetchData = useCallback(async () => { const fetchData = useCallback(async () => {
await Promise.all([checkAuctionStatus(), fetchUpdatedProject()]); await Promise.all([checkAuctionStatus(), fetchUpdatedProject()]);
}, [checkAuctionStatus, fetchUpdatedProject]); }, [checkAuctionStatus, fetchUpdatedProject]);
useEffect(() => { useEffect(() => {
fetchData();
const timerId = setInterval(() => {
fetchData(); fetchData();
}, WAIT_DURATION);
const timerId = setInterval(() => { return () => clearInterval(timerId);
fetchData(); }, [fetchData]);
}, WAIT_DURATION);
return () => clearInterval(timerId);
}, [fetchData]);
const renderAuctionStatus = useCallback( const renderAuctionStatus = useCallback(
() => ( () => (

View File

@ -10,7 +10,6 @@ import {
import SignClient from '@walletconnect/sign-client'; import SignClient from '@walletconnect/sign-client';
import { getSdkError } from '@walletconnect/utils'; import { getSdkError } from '@walletconnect/utils';
import { SessionTypes } from '@walletconnect/types'; import { SessionTypes } from '@walletconnect/types';
import { StargateClient } from '@cosmjs/stargate';
import { walletConnectModal } from '../utils/web3modal'; import { walletConnectModal } from '../utils/web3modal';
import { import {
@ -46,10 +45,6 @@ export const WalletConnectClientProvider = ({
const isSignClientInitializing = useRef<boolean>(false); const isSignClientInitializing = useRef<boolean>(false);
const createCosmosClient = useCallback(async (endpoint: string) => {
return await StargateClient.connect(endpoint);
}, []);
const onSessionConnect = useCallback(async (session: SessionTypes.Struct) => { const onSessionConnect = useCallback(async (session: SessionTypes.Struct) => {
setSession(session); setSession(session);
}, []); }, []);
@ -166,6 +161,11 @@ export const WalletConnectClientProvider = ({
if (!session) { if (!session) {
return; return;
} }
if (!session.namespaces['cosmos']) {
console.log('Accounts for cosmos namespace not found');
return;
}
const cosmosAddresses = session.namespaces['cosmos'].accounts; const cosmosAddresses = session.namespaces['cosmos'].accounts;
const cosmosAccounts = cosmosAddresses.map((address) => ({ const cosmosAccounts = cosmosAddresses.map((address) => ({
@ -178,7 +178,7 @@ export const WalletConnectClientProvider = ({
}; };
populateAccounts(); populateAccounts();
}, [session, createCosmosClient]); }, [session]);
useEffect(() => { useEffect(() => {
if (!signClient) { if (!signClient) {

View File

@ -92,9 +92,13 @@ const Id = () => {
Open repo Open repo
</Button> </Button>
</Link> </Link>
<Button {...buttonSize} className="h-11 transition-colors"> {(project.deployments.length > 0) &&
Go to app <Link to={`https://${project.name.toLowerCase()}.${project.deployments[0].deployer.baseDomain}`}>
</Button> <Button {...buttonSize} className="h-11 transition-colors">
Go to app
</Button>
</Link>
}
</div> </div>
</div> </div>
<WavyBorder /> <WavyBorder />

View File

@ -180,14 +180,18 @@ const OverviewTabPanel = () => {
{/* DEPLOYMENT */} {/* DEPLOYMENT */}
<OverviewInfo label="Deployment URL" icon={<CursorBoxIcon />}> <OverviewInfo label="Deployment URL" icon={<CursorBoxIcon />}>
{project.deployments &&
project.deployments.length > 0 &&
project.deployments.map((deployment) => (
<div className="flex gap-2 items-center"> <div className="flex gap-2 items-center">
<Link to="#"> <Link to={`https://${project.name.toLowerCase()}.${deployment.deployer.baseDomain}`}>
<span className="text-controls-primary group hover:border-controls-primary transition-colors border-b border-b-transparent flex gap-2 items-center text-sm tracking-tight"> <span className="text-controls-primary group hover:border-controls-primary transition-colors border-b border-b-transparent flex gap-2 items-center text-sm tracking-tight">
{liveDomain?.name}{' '} {`https://${project.name.toLowerCase()}.${deployment.deployer.baseDomain}`}
<LinkIcon className="group-hover:rotate-45 transition-transform" /> <LinkIcon className="group-hover:rotate-45 transition-transform" />
</span> </span>
</Link> </Link>
</div> </div>
))}
</OverviewInfo> </OverviewInfo>
{/* DEPLOYMENT DATE */} {/* DEPLOYMENT DATE */}

View File

@ -17,7 +17,7 @@ const meta: Meta<typeof AddEnvironmentVariableRow> = {
pathParams: { userId: 'me' }, pathParams: { userId: 'me' },
}, },
routing: { routing: {
path: '/snowball-tools-1/projects/6bb3bec2-d71b-4fc0-9e32-4767f68668f4/settings', path: '/deploy-tools/projects/6bb3bec2-d71b-4fc0-9e32-4767f68668f4/settings',
}, },
}), }),
}, },

View File

@ -17,7 +17,7 @@ const meta: Meta<typeof Config> = {
pathParams: { userId: 'me' }, pathParams: { userId: 'me' },
}, },
routing: { routing: {
path: '/snowball-tools-1/projects/6bb3bec2-d71b-4fc0-9e32-4767f68668f4/settings/domains/add/config', path: '/deploy-tools/projects/6bb3bec2-d71b-4fc0-9e32-4767f68668f4/settings/domains/add/config',
}, },
}), }),
}, },

View File

@ -18,7 +18,7 @@ const meta: Meta<typeof DeleteProjectDialog> = {
pathParams: { userId: 'me' }, pathParams: { userId: 'me' },
}, },
routing: { routing: {
path: '/snowball-tools-1/projects/6bb3bec2-d71b-4fc0-9e32-4767f68668f4/settings', path: '/deploy-tools/projects/6bb3bec2-d71b-4fc0-9e32-4767f68668f4/settings',
}, },
}), }),
}, },

View File

@ -17,7 +17,7 @@ const meta: Meta<typeof SetupDomain> = {
pathParams: { userId: 'me' }, pathParams: { userId: 'me' },
}, },
routing: { routing: {
path: '/snowball-tools-1/projects/6bb3bec2-d71b-4fc0-9e32-4767f68668f4/settings/domains', path: '/deploy-tools/projects/6bb3bec2-d71b-4fc0-9e32-4767f68668f4/settings/domains',
}, },
}), }),
}, },