Skip to content

Commit c9b7fc3

Browse files
author
Owen Evans
committed
Merged in feature/GFW-1081_empty_content_teams (pull request #124)
Normal: Empty state for teams page (small) Approved-by: Milad Dehghani Approved-by: Kevin Borrill
2 parents 1c478e2 + 9bf91bf commit c9b7fc3

File tree

3 files changed

+55
-27
lines changed

3 files changed

+55
-27
lines changed
Lines changed: 4 additions & 0 deletions
Loading

src/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@
171171
"teams.invalidEmail": "Email is invalid",
172172
"teams.add.manager": "Add Manager",
173173
"teams.add.monitor": "Add Monitor",
174+
"teams.empty.state.title": "No Teams Added",
175+
"teams.empty.state.subTitle": "Create a Team",
174176
"layers.name": "Layers",
175177
"reports.noReportsFound": "No reports found",
176178
"table.next": "next",

src/pages/teams/Teams.tsx

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { FC, useEffect, useMemo } from "react";
22
import { RouteComponentProps, Link } from "react-router-dom";
33
import { TPropsFromRedux } from "./TeamsContainer";
4+
import EmptyState from "components/ui/EmptyState/EmptyState";
45
import Hero from "components/layouts/Hero/Hero";
56
import Article from "components/layouts/Article";
67
import Loader from "components/ui/Loader";
7-
import { FormattedMessage } from "react-intl";
8+
import { FormattedMessage, useIntl } from "react-intl";
89
import TeamsListing from "components/teams-listing/TeamsListing";
910
import Button from "components/ui/Button/Button";
1011
import useGetUserId from "hooks/useGetUserId";
1112
import CreateTeam from "./actions/CreateTeam";
1213
import PlusIcon from "assets/images/icons/PlusWhite.svg";
14+
import EmptyStateIcon from "assets/images/icons/EmptyTeams.svg";
1315

1416
interface IProps extends TPropsFromRedux, RouteComponentProps {
1517
isCreatingTeam: boolean;
@@ -18,6 +20,7 @@ interface IProps extends TPropsFromRedux, RouteComponentProps {
1820
const Teams: FC<IProps> = props => {
1921
const { teams, myInvites, getUserTeams, getMyTeamInvites, numOfActiveFetches, isCreatingTeam = false, match } = props;
2022

23+
const intl = useIntl();
2124
const userId = useGetUserId();
2225

2326
useEffect(() => {
@@ -62,32 +65,51 @@ const Teams: FC<IProps> = props => {
6265
</div>
6366
</div>
6467
)}
65-
<div className="l-content c-teams">
66-
<Article
67-
className="c-teams__heading"
68-
title="teams.managedByMe"
69-
titleValues={{ num: managedTeams.length.toString() }}
70-
actions={
71-
<Link to={`${match.path}/create`}>
72-
<Button variant="primary">
73-
<img src={PlusIcon} alt="" role="presentation" className="c-button__inline-icon" />
74-
<FormattedMessage id="teams.create" />
75-
</Button>
76-
</Link>
77-
}
78-
>
79-
<TeamsListing teams={managedTeams} />
80-
</Article>
81-
</div>
82-
<div className="l-content l-content--neutral-400 c-teams">
83-
<Article
84-
className="c-teams__heading"
85-
title="teams.joinedByMe"
86-
titleValues={{ num: joinedTeams.length.toString() }}
87-
>
88-
<TeamsListing teams={joinedTeams} />
89-
</Article>
90-
</div>
68+
{/* No teams are in state but fetches are being made - show nothing to the user */}
69+
{/* No teams are in state and fetches have finished - show empty state to the user */}
70+
{/* Teams are in state - show the teams to the user */}
71+
{!teams.length && numOfActiveFetches > 0 ? null : !teams.length && numOfActiveFetches === 0 ? (
72+
<div className="l-content l-content--neutral-400">
73+
<div className="row column">
74+
<EmptyState
75+
iconUrl={EmptyStateIcon}
76+
title={intl.formatMessage({ id: "teams.empty.state.title" })}
77+
text={intl.formatMessage({ id: "teams.empty.state.subTitle" })}
78+
ctaText={intl.formatMessage({ id: "teams.create" })}
79+
ctaTo={`${match.path}/create`}
80+
/>
81+
</div>
82+
</div>
83+
) : (
84+
<>
85+
<div className="l-content c-teams">
86+
<Article
87+
className="c-teams__heading"
88+
title="teams.managedByMe"
89+
titleValues={{ num: managedTeams.length.toString() }}
90+
actions={
91+
<Link to={`${match.path}/create`}>
92+
<Button variant="primary">
93+
<img src={PlusIcon} alt="" role="presentation" className="c-button__inline-icon" />
94+
<FormattedMessage id="teams.create" />
95+
</Button>
96+
</Link>
97+
}
98+
>
99+
<TeamsListing teams={managedTeams} />
100+
</Article>
101+
</div>
102+
<div className="l-content l-content--neutral-400 c-teams">
103+
<Article
104+
className="c-teams__heading"
105+
title="teams.joinedByMe"
106+
titleValues={{ num: joinedTeams.length.toString() }}
107+
>
108+
<TeamsListing teams={joinedTeams} />
109+
</Article>
110+
</div>
111+
</>
112+
)}
91113

92114
<CreateTeam isOpen={isCreatingTeam} />
93115
</div>

0 commit comments

Comments
 (0)