Display deployer LRNs in dropdown

This commit is contained in:
IshaVenikar 2024-10-23 10:45:15 +05:30
parent 055dd52a7d
commit 967eded8b1
5 changed files with 67 additions and 21 deletions

View File

@ -283,6 +283,7 @@ export class Registry {
this.registryConfig.privateKey, this.registryConfig.privateKey,
fee fee
); );
log(`Application deployment request record published: ${result.id}`); log(`Application deployment request record published: ${result.id}`);
log('Application deployment request data:', applicationDeploymentRequest); log('Application deployment request data:', applicationDeploymentRequest);

View File

@ -443,11 +443,6 @@ export class Service {
return dbDeployments; return dbDeployments;
} }
async getDeployers(): Promise<Deployer[]> {
const dbDeployers = await this.db.getDeployers();
return dbDeployers;
}
async getEnvironmentVariablesByProjectId( async getEnvironmentVariablesByProjectId(
projectId: string, projectId: string,
): Promise<EnvironmentVariable[]> { ): Promise<EnvironmentVariable[]> {
@ -1374,4 +1369,38 @@ export class Service {
return false; return false;
} }
async getDeployers(): Promise<Deployer[]> {
const dbDeployers = await this.db.getDeployers();
if (dbDeployers.length > 0) {
this.updateDeployersFromRegistry();
return dbDeployers;
} else {
return await this.updateDeployersFromRegistry();
}
}
async updateDeployersFromRegistry(): Promise<Deployer[]> {
const deployerRecords = await this.laconicRegistry.getDeployerRecordsByFilter({});
for (const record of deployerRecords) {
const deployerId = record.id;
const deployerLrn = record.names[0];
const deployerApiUrl = record.attributes.apiUrl;
const baseDomain = deployerApiUrl.substring(deployerApiUrl.indexOf('.') + 1);
const deployerData = {
deployerId,
deployerLrn,
deployerApiUrl,
baseDomain
};
await this.db.addDeployer(deployerData);
}
return await this.db.getDeployers();
}
} }

View File

@ -178,7 +178,7 @@ const Configure = () => {
setDeployers(res.deployers) setDeployers(res.deployers)
}, [client]) }, [client])
useEffect(()=>{ useEffect(() => {
fetchDeployers() fetchDeployers()
}, []) }, [])
@ -236,15 +236,25 @@ const Configure = () => {
> >
The app will be deployed by the configured deployer The app will be deployed by the configured deployer
</Heading> </Heading>
<span className="text-sm text-elements-high-em">
Enter LRN for deployer
</span>
<Controller <Controller
name="lrn" name="lrn"
control={methods.control} control={methods.control}
rules={{ required: true }} rules={{ required: true }}
render={({ field: { value, onChange } }) => ( render={({ field: { value, onChange } }) => (
<Input value={value} onChange={onChange} /> <Select
label="Select deployer LRN"
value={{
value: value || '',
label: value || ''
} as SelectOption}
onChange={(selectedOption) =>
onChange((selectedOption as SelectOption).value)
}
options={deployers.map(deployer => ({
value: deployer.deployerLrn,
label: deployer.deployerLrn
}))}
/>
)} )}
/> />
</div> </div>

View File

@ -102,7 +102,7 @@ export const AuctionCard = ({ project }: { project: Project }) => {
</span> </span>
</div> </div>
{deployers?.length > 0 && ( {deployers?.length > 0 ? (
<div className="mt-3"> <div className="mt-3">
<span className="text-elements-high-em text-sm font-medium tracking-tight"> <span className="text-elements-high-em text-sm font-medium tracking-tight">
Deployer LRNs Deployer LRNs
@ -113,6 +113,12 @@ export const AuctionCard = ({ project }: { project: Project }) => {
</p> </p>
))} ))}
</div> </div>
) : (
<div className="mt-3">
<span className="text-elements-high-em text-sm font-medium tracking-tight">
No winning deployers
</span>
</div>
)} )}
<div className="flex justify-between items-center mt-1"> <div className="flex justify-between items-center mt-1">