mirror of
https://github.com/snowball-tools/snowballtools-base
synced 2025-08-08 09:54:06 +00:00
* Publish record in laconic registry on creating project and deployment * Refactor publish record method * Set name for the published record * Publish application deployment request * Add README for publishing record * Add await in add project resolver method * Update meta data for deployment request record * Remove title field from deployment entity * Refactor service and registry class for publishing record * Add record data to project and deployment entity * Set record id and data as nullable in project entity --------- Co-authored-by: neeraj <neeraj.rtly@gmail.com>
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import React, { useCallback } from 'react';
|
|
import { useNavigate, useParams } from 'react-router-dom';
|
|
|
|
import { Chip, IconButton } from '@material-tailwind/react';
|
|
|
|
import { relativeTimeISO } from '../../../utils/time';
|
|
import { GitRepositoryDetails } from '../../../types/project';
|
|
import { useGQLClient } from '../../../context/GQLClientContext';
|
|
|
|
interface ProjectRepoCardProps {
|
|
repository: GitRepositoryDetails;
|
|
}
|
|
|
|
const ProjectRepoCard: React.FC<ProjectRepoCardProps> = ({ repository }) => {
|
|
const client = useGQLClient();
|
|
const navigate = useNavigate();
|
|
|
|
const { orgSlug } = useParams();
|
|
|
|
const createProject = useCallback(async () => {
|
|
if (!repository) {
|
|
return;
|
|
}
|
|
|
|
const { addProject } = await client.addProject(orgSlug!, {
|
|
name: `${repository.owner!.login}-${repository.name}`,
|
|
prodBranch: repository.default_branch!,
|
|
repository: repository.full_name,
|
|
// TODO: Compute template from repo
|
|
template: 'webapp',
|
|
});
|
|
|
|
navigate(`import?projectId=${addProject.id}`);
|
|
}, [client, repository]);
|
|
|
|
return (
|
|
<div
|
|
className="group flex items-center gap-4 text-gray-500 text-xs hover:bg-gray-100 p-2 cursor-pointer"
|
|
onClick={createProject}
|
|
>
|
|
<div>^</div>
|
|
<div className="grow">
|
|
<div>
|
|
<span className="text-black">{repository.full_name}</span>
|
|
{repository.visibility === 'private' && (
|
|
<Chip
|
|
className="normal-case inline ml-6 font-normal"
|
|
size="sm"
|
|
value="Private"
|
|
icon={'^'}
|
|
/>
|
|
)}
|
|
</div>
|
|
<p>{repository.updated_at && relativeTimeISO(repository.updated_at)}</p>
|
|
</div>
|
|
<div className="hidden group-hover:block">
|
|
<IconButton size="sm">{'>'}</IconButton>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default ProjectRepoCard;
|