List deployer LRNs in deployment configuration step #11

Merged
nabarun merged 9 commits from iv-deployer-dropdown into main 2024-10-23 15:36:20 +00:00
5 changed files with 67 additions and 21 deletions
Showing only changes of commit 967eded8b1 - Show all commits

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

@ -155,19 +155,19 @@ const Configure = () => {
if (templateId) { if (templateId) {
createFormData.option === 'Auction' createFormData.option === 'Auction'
? navigate( ? navigate(
`/${orgSlug}/projects/create/success/${projectId}?isAuction=true`, `/${orgSlug}/projects/create/success/${projectId}?isAuction=true`,
) )
: navigate( : navigate(
`/${orgSlug}/projects/create/template/deploy?projectId=${projectId}&templateId=${templateId}`, `/${orgSlug}/projects/create/template/deploy?projectId=${projectId}&templateId=${templateId}`,
); );
} else { } else {
createFormData.option === 'Auction' createFormData.option === 'Auction'
? navigate( ? navigate(
`/${orgSlug}/projects/create/success/${projectId}?isAuction=true`, `/${orgSlug}/projects/create/success/${projectId}?isAuction=true`,
) )
: navigate( : navigate(
`/${orgSlug}/projects/create/deploy?projectId=${projectId}`, `/${orgSlug}/projects/create/deploy?projectId=${projectId}`,
); );
} }
}, },
[client, createProject, dismiss, toast], [client, createProject, dismiss, toast],
@ -176,9 +176,9 @@ const Configure = () => {
const fetchDeployers = useCallback(async () => { const fetchDeployers = useCallback(async () => {
const res = await client.getDeployers() const res = await client.getDeployers()
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">