Merge pull request #159 from snowball-tools/andrehadianto/T-4968-qol-and-chores

[T-4968] qol and chores
This commit is contained in:
Andre Hadianto 2024-03-07 18:44:04 +08:00 committed by GitHub
commit 1d96f6430f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 50 additions and 32 deletions

View File

@ -9,16 +9,18 @@ export const projectCardTheme = tv({
'flex', 'flex',
'flex-col', 'flex-col',
'group', 'group',
'cursor-pointer',
], ],
upperContent: ['px-4', 'py-4', 'flex', 'items-start', 'gap-3', 'relative'], upperContent: ['px-4', 'py-4', 'flex', 'items-start', 'gap-3', 'relative'],
content: ['flex', 'flex-col', 'gap-1', 'flex-1'], content: ['flex', 'flex-col', 'gap-1', 'flex-1', 'overflow-hidden'],
title: [ title: [
'text-sm', 'text-sm',
'font-medium', 'font-medium',
'text-elements-high-em', 'text-elements-high-em',
'tracking-[-0.006em]', 'tracking-[-0.006em]',
'truncate',
], ],
description: ['text-xs', 'text-elements-low-em'], description: ['text-xs', 'text-elements-low-em', 'truncate'],
icons: ['flex', 'items-center', 'gap-1'], icons: ['flex', 'items-center', 'gap-1'],
lowerContent: [ lowerContent: [
'transition-colors', 'transition-colors',

View File

@ -1,12 +1,18 @@
import {
Menu,
MenuHandler,
MenuItem,
MenuList,
} from '@material-tailwind/react';
import React, { import React, {
ComponentPropsWithoutRef, ComponentPropsWithoutRef,
MouseEvent, MouseEvent,
useCallback, useCallback,
} from 'react'; } from 'react';
import { ProjectCardTheme, projectCardTheme } from './ProjectCard.theme'; import { useNavigate } from 'react-router-dom';
import { Project } from 'gql-client'; import { Project } from 'gql-client';
import { Avatar } from 'components/shared/Avatar';
import { Button } from 'components/shared/Button'; import { Button } from 'components/shared/Button';
import { WavyBorder } from 'components/shared/WavyBorder';
import { import {
BranchIcon, BranchIcon,
ClockIcon, ClockIcon,
@ -14,16 +20,11 @@ import {
HorizontalDotIcon, HorizontalDotIcon,
WarningDiamondIcon, WarningDiamondIcon,
} from 'components/shared/CustomIcon'; } from 'components/shared/CustomIcon';
import { Tooltip } from 'components/shared/Tooltip';
import { WavyBorder } from 'components/shared/WavyBorder';
import { relativeTimeMs } from 'utils/time'; import { relativeTimeMs } from 'utils/time';
import { useNavigate } from 'react-router-dom';
import { Avatar } from 'components/shared/Avatar';
import { getInitials } from 'utils/geInitials'; import { getInitials } from 'utils/geInitials';
import { import { ProjectCardTheme, projectCardTheme } from './ProjectCard.theme';
Menu,
MenuHandler,
MenuItem,
MenuList,
} from '@material-tailwind/react';
export interface ProjectCardProps export interface ProjectCardProps
extends ComponentPropsWithoutRef<'div'>, extends ComponentPropsWithoutRef<'div'>,
@ -72,7 +73,9 @@ export const ProjectCard = ({
/> />
{/* Title and website */} {/* Title and website */}
<div className={theme.content()}> <div className={theme.content()}>
<p className={theme.title()}>{project.name}</p> <Tooltip content={project.name}>
<p className={theme.title()}>{project.name}</p>
</Tooltip>
<p className={theme.description()}> <p className={theme.description()}>
{project.deployments[0]?.domain?.name ?? 'No domain'} {project.deployments[0]?.domain?.name ?? 'No domain'}
</p> </p>

View File

@ -3,17 +3,17 @@ import { Octokit } from 'octokit';
import assert from 'assert'; import assert from 'assert';
import { useDebounce } from 'usehooks-ts'; import { useDebounce } from 'usehooks-ts';
import { Button, Typography } from '@material-tailwind/react';
import { ProjectRepoCard } from 'components/projects/create/ProjectRepoCard'; import { ProjectRepoCard } from 'components/projects/create/ProjectRepoCard';
import { GitOrgDetails, GitRepositoryDetails } from 'types'; import { GitOrgDetails, GitRepositoryDetails } from 'types';
import { import {
ChevronGrabberHorizontal, ChevronGrabberHorizontal,
GithubIcon, GithubIcon,
RefreshIcon,
SearchIcon, SearchIcon,
} from 'components/shared/CustomIcon'; } from 'components/shared/CustomIcon';
import { Select, SelectOption } from 'components/shared/Select'; import { Select, SelectOption } from 'components/shared/Select';
import { Input } from 'components/shared/Input'; import { Input } from 'components/shared/Input';
import { Button } from 'components/shared/Button';
const DEFAULT_SEARCHED_REPO = ''; const DEFAULT_SEARCHED_REPO = '';
const REPOS_PER_PAGE = 5; const REPOS_PER_PAGE = 5;
@ -160,18 +160,16 @@ export const RepositoryList = ({ octokit }: RepositoryListProps) => {
))} ))}
</div> </div>
) : ( ) : (
<div className="mt-4 p-6 flex items-center justify-center"> <div className="mt-4 p-6 flex flex-col gap-4 items-center justify-center">
<div className="text-center"> <p className="text-elements-high-em font-sans">No repository found</p>
<Typography placeholder={''}>No repository found</Typography> <Button
<Button variant="tertiary"
className="rounded-full mt-5" leftIcon={<RefreshIcon />}
size="sm" size="sm"
onClick={handleResetFilters} onClick={handleResetFilters}
placeholder={''} >
> Reset filters
^ Reset filters </Button>
</Button>
</div>
</div> </div>
)} )}
</section> </section>

View File

@ -4,10 +4,13 @@ import { GitCommitWithBranch } from 'types';
import { Heading } from 'components/shared/Heading'; import { Heading } from 'components/shared/Heading';
import ActivityCard from './ActivityCard'; import ActivityCard from './ActivityCard';
import { Button } from 'components/shared/Button'; import { Button } from 'components/shared/Button';
import { LoadingIcon } from 'components/shared/CustomIcon';
export const Activity = ({ export const Activity = ({
isLoading,
activities, activities,
}: { }: {
isLoading: boolean;
activities: GitCommitWithBranch[]; activities: GitCommitWithBranch[];
}) => { }) => {
return ( return (
@ -19,9 +22,17 @@ export const Activity = ({
</Button> </Button>
</div> </div>
<div className="mt-5"> <div className="mt-5">
{activities.map((activity, index) => { {isLoading ? (
return <ActivityCard activity={activity} key={`activity-${index}`} />; <div className="grid place-content-center mt-10">
})} <LoadingIcon className="animate-spin" />
</div>
) : (
activities.map((activity, index) => {
return (
<ActivityCard activity={activity} key={`activity-${index}`} />
);
})
)}
</div> </div>
</div> </div>
); );

View File

@ -71,7 +71,7 @@ export const tabsTheme = tv({
'gap-5', 'gap-5',
'border-b', 'border-b',
'border-transparent', 'border-transparent',
'overflow-scroll', 'overflow-auto',
// Horizontal default // Horizontal default
'data-[orientation=horizontal]:border-border-interactive/10', 'data-[orientation=horizontal]:border-border-interactive/10',
// Vertical // Vertical

View File

@ -32,6 +32,7 @@ const OverviewTabPanel = () => {
const { octokit } = useOctokit(); const { octokit } = useOctokit();
const navigate = useNavigate(); const navigate = useNavigate();
const [activities, setActivities] = useState<GitCommitWithBranch[]>([]); const [activities, setActivities] = useState<GitCommitWithBranch[]>([]);
const [fetchingActivities, setFetchingActivities] = useState(true);
const [liveDomain, setLiveDomain] = useState<Domain>(); const [liveDomain, setLiveDomain] = useState<Domain>();
const client = useGQLClient(); const client = useGQLClient();
@ -39,6 +40,7 @@ const OverviewTabPanel = () => {
const { project } = useOutletContext<OutletContextType>(); const { project } = useOutletContext<OutletContextType>();
useEffect(() => { useEffect(() => {
setFetchingActivities(true);
// TODO: Save repo commits in DB and avoid using GitHub API in frontend // TODO: Save repo commits in DB and avoid using GitHub API in frontend
// TODO: Figure out fetching latest commits for all branches // TODO: Figure out fetching latest commits for all branches
const fetchRepoActivity = async () => { const fetchRepoActivity = async () => {
@ -91,6 +93,8 @@ const OverviewTabPanel = () => {
// TODO: Show warning in activity section on request error // TODO: Show warning in activity section on request error
console.log(err.message); console.log(err.message);
} finally {
setFetchingActivities(false);
} }
}; };
@ -217,7 +221,7 @@ const OverviewTabPanel = () => {
</p> </p>
)} )}
</div> </div>
<Activity activities={activities} /> <Activity activities={activities} isLoading={fetchingActivities} />
</div> </div>
); );
}; };