Show custom domain in overview tabs panel
This commit is contained in:
parent
6a79ee5c47
commit
a7190ed804
@ -605,10 +605,10 @@ export class Database {
|
|||||||
|
|
||||||
async getOldestDomainByProjectId(
|
async getOldestDomainByProjectId(
|
||||||
projectId: string,
|
projectId: string,
|
||||||
): Promise<Domain[]> {
|
): Promise<Domain | null> {
|
||||||
const domainRepository = this.dataSource.getRepository(Domain);
|
const domainRepository = this.dataSource.getRepository(Domain);
|
||||||
|
|
||||||
const domains = await domainRepository.find({
|
const domain = await domainRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
project: {
|
project: {
|
||||||
id: projectId
|
id: projectId
|
||||||
@ -619,7 +619,7 @@ export class Database {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return domains;
|
return domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLatestDNSDataByProjectId(
|
async getLatestDNSDataByProjectId(
|
||||||
|
@ -70,6 +70,18 @@ export const createResolvers = async (service: Service): Promise<any> => {
|
|||||||
return service.getDomainsByProjectId(projectId, filter);
|
return service.getDomainsByProjectId(projectId, filter);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
oldestDomain: async (
|
||||||
|
_: any,
|
||||||
|
{ projectId }: { projectId: string },
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
return await service.getOldestDomainByProjectId(projectId);
|
||||||
|
} catch (err) {
|
||||||
|
log(err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getAuctionData: async (
|
getAuctionData: async (
|
||||||
_: any,
|
_: any,
|
||||||
{ auctionId }: { auctionId: string },
|
{ auctionId }: { auctionId: string },
|
||||||
|
@ -274,6 +274,7 @@ type Query {
|
|||||||
searchProjects(searchText: String!): [Project!]
|
searchProjects(searchText: String!): [Project!]
|
||||||
getAuctionData(auctionId: String!): Auction!
|
getAuctionData(auctionId: String!): Auction!
|
||||||
getLatestDNSDataByProjectId(projectId: String!): DNSRecordAttributes
|
getLatestDNSDataByProjectId(projectId: String!): DNSRecordAttributes
|
||||||
|
oldestDomain(projectId: String!): Domain
|
||||||
domains(projectId: String!, filter: FilterDomainsInput): [Domain]
|
domains(projectId: String!, filter: FilterDomainsInput): [Domain]
|
||||||
deployers: [Deployer]
|
deployers: [Deployer]
|
||||||
address: String!
|
address: String!
|
||||||
|
@ -674,7 +674,7 @@ export class Service {
|
|||||||
appName: repo,
|
appName: repo,
|
||||||
repository: repoUrl,
|
repository: repoUrl,
|
||||||
environmentVariables: environmentVariablesObj,
|
environmentVariables: environmentVariablesObj,
|
||||||
dns: domain?.[0]?.name ?? `${newDeployment.project.name}`,
|
dns: domain?.name ?? `${newDeployment.project.name}`,
|
||||||
lrn: deployer!.deployerLrn!,
|
lrn: deployer!.deployerLrn!,
|
||||||
apiUrl: deployer!.deployerApiUrl!,
|
apiUrl: deployer!.deployerApiUrl!,
|
||||||
payment: data.project.txHash,
|
payment: data.project.txHash,
|
||||||
@ -1342,6 +1342,12 @@ export class Service {
|
|||||||
return updateResult;
|
return updateResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getOldestDomainByProjectId(
|
||||||
|
projectId: string,
|
||||||
|
): Promise<Domain | null> {
|
||||||
|
return await this.db.getOldestDomainByProjectId(projectId)
|
||||||
|
}
|
||||||
|
|
||||||
async authenticateGitHub(
|
async authenticateGitHub(
|
||||||
code: string,
|
code: string,
|
||||||
user: User,
|
user: User,
|
||||||
|
@ -32,6 +32,7 @@ const OverviewTabPanel = () => {
|
|||||||
const [activities, setActivities] = useState<GitCommitWithBranch[]>([]);
|
const [activities, setActivities] = useState<GitCommitWithBranch[]>([]);
|
||||||
const [fetchingActivities, setFetchingActivities] = useState(true);
|
const [fetchingActivities, setFetchingActivities] = useState(true);
|
||||||
const [liveDomain, setLiveDomain] = useState<Domain>();
|
const [liveDomain, setLiveDomain] = useState<Domain>();
|
||||||
|
const [customDomain, setCustomDomain] = useState<Domain | null>(null);
|
||||||
|
|
||||||
const client = useGQLClient();
|
const client = useGQLClient();
|
||||||
const { project, onUpdate } = useOutletContext<OutletContextType>();
|
const { project, onUpdate } = useOutletContext<OutletContextType>();
|
||||||
@ -124,6 +125,16 @@ const OverviewTabPanel = () => {
|
|||||||
fetchLiveProdDomain();
|
fetchLiveProdDomain();
|
||||||
}, [project]);
|
}, [project]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchCustomDomain = async () => {
|
||||||
|
const { oldestDomain } = await client.oldestDomain(project.id);
|
||||||
|
|
||||||
|
setCustomDomain(oldestDomain);
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchCustomDomain();
|
||||||
|
}, [project]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-5 gap-6 md:gap-[72px]">
|
<div className="grid grid-cols-5 gap-6 md:gap-[72px]">
|
||||||
<div className="col-span-5 md:col-span-3">
|
<div className="col-span-5 md:col-span-3">
|
||||||
@ -194,10 +205,15 @@ const OverviewTabPanel = () => {
|
|||||||
project.deployments.map((deployment) => (
|
project.deployments.map((deployment) => (
|
||||||
<div className="flex gap-2 items-center">
|
<div className="flex gap-2 items-center">
|
||||||
<Link
|
<Link
|
||||||
to={`https://${project.name.toLowerCase()}.${deployment.deployer.baseDomain}`}
|
to={
|
||||||
|
customDomain && customDomain.name
|
||||||
|
? `https://${customDomain.name}`
|
||||||
|
: `https://${project.name.toLowerCase()}.${deployment.deployer.baseDomain}`
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<span className="text-controls-primary dark:text-foreground 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 dark:text-foreground group hover:border-controls-primary transition-colors border-b border-b-transparent flex gap-2 items-center text-sm tracking-tight">
|
||||||
{`https://${project.name.toLowerCase()}.${deployment.deployer.baseDomain}`}
|
{customDomain?.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>
|
||||||
|
@ -393,6 +393,21 @@ export class GQLClient {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async oldestDomain(
|
||||||
|
projectId: string,
|
||||||
|
): Promise<types.OldestDomainResponse> {
|
||||||
|
const { data } = await this.client.query({
|
||||||
|
query: queries.oldestDomain,
|
||||||
|
variables: {
|
||||||
|
projectId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log({data})
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
async authenticateGitHub(
|
async authenticateGitHub(
|
||||||
code: string
|
code: string
|
||||||
): Promise<types.AuthenticateGitHubResponse> {
|
): Promise<types.AuthenticateGitHubResponse> {
|
||||||
|
@ -261,6 +261,19 @@ query ($projectId: String!, $filter: FilterDomainsInput) {
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const oldestDomain = gql`
|
||||||
|
query ($projectId: String!) {
|
||||||
|
oldestDomain(projectId: $projectId) {
|
||||||
|
branch
|
||||||
|
createdAt
|
||||||
|
id
|
||||||
|
name
|
||||||
|
status
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
export const getAuctionData = gql`
|
export const getAuctionData = gql`
|
||||||
query ($auctionId: String!) {
|
query ($auctionId: String!) {
|
||||||
getAuctionData(auctionId: $auctionId){
|
getAuctionData(auctionId: $auctionId){
|
||||||
|
@ -236,6 +236,10 @@ export type GetDomainsResponse = {
|
|||||||
domains: Domain[];
|
domains: Domain[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type OldestDomainResponse = {
|
||||||
|
oldestDomain: Domain | null;
|
||||||
|
}
|
||||||
|
|
||||||
export type GetDeployersResponse = {
|
export type GetDeployersResponse = {
|
||||||
deployers: Deployer[];
|
deployers: Deployer[];
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user