Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add team view button #551

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web-server/src/assets/dora-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 30 additions & 3 deletions web-server/src/components/TeamsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import { ascend } from 'ramda';
import { FC, MouseEventHandler, useCallback, useEffect, useMemo } from 'react';
import { truncate } from 'voca';

import DoraIcon from '@/assets/dora-icon.svg';
import { ROUTES } from '@/constants/routes';
import { FetchState } from '@/constants/ui-states';
import { useAuth } from '@/hooks/useAuth';
import { useBoolState, useEasyState } from '@/hooks/useEasyState';
import { appSlice } from '@/slices/app';
import { deleteTeam, fetchTeams } from '@/slices/team';
import { useDispatch, useSelector } from '@/store';
import { Team } from '@/types/api/teams';
Expand All @@ -36,6 +38,7 @@ export const TeamsList = () => {
const teamsArray = useSelector((state) => state.team.teams);
const searchQuery = useEasyState('');
const router = useRouter();
const dispatch = useDispatch();
const showCreate = useBoolState(false);

const teamsArrayFiltered = useMemo(() => {
Expand All @@ -55,6 +58,14 @@ export const TeamsList = () => {
(state) => state.team?.requests?.teams === FetchState.REQUEST
);

const handleTeamView = (team: Team) => {
if (team) {
dispatch(appSlice.actions.setSingleTeam([team]));
}
const path = ROUTES.DORA_METRICS.PATH;
router.push(path);
};

useEffect(() => {
if (router.query.create === 'true') {
depFn(showCreate.true);
Expand Down Expand Up @@ -89,7 +100,12 @@ export const TeamsList = () => {
}}
>
{teamsArrayFiltered.map((team, index) => (
<TeamCard onEdit={showCreate.false} key={index} team={team} />
<TeamCard
onEdit={showCreate.false}
key={index}
team={team}
onView={handleTeamView}
/>
))}
</FlexBox>
{isLoadingTeams && (
Expand Down Expand Up @@ -178,9 +194,10 @@ const SearchFilter: FC<{
type TeamCardProps = {
team: Team;
onEdit: () => void;
onView: (team: Team) => void;
};

const TeamCard: React.FC<TeamCardProps> = ({ team, onEdit }) => {
const TeamCard: React.FC<TeamCardProps> = ({ team, onEdit, onView }) => {
const { name: teamName, id: teamId } = team;
const teamReposMap = useSelector((state) => state.team.teamReposMaps);
const assignedReposToTeam = useMemo(
Expand Down Expand Up @@ -253,7 +270,17 @@ const TeamCard: React.FC<TeamCardProps> = ({ team, onEdit }) => {
</FlexBox>
</FlexBox>
</FlexBox>
<FlexBox col justifyBetween height={'70px'}>
<FlexBox col justifyBetween minHeight={'70px'} alignCenter>
<FlexBox
title={'View Dora Metrics'}
centered
width={'1.2em'}
maxWidth={'1.2em'}
pointer
onClick={() => onView(team)}
>
<DoraIcon />
</FlexBox>
<EditTeam teamId={teamId} onEdit={onEdit} />
<FlexBox pointer>
<MoreOptions teamId={team.id} />
Expand Down
Loading