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

🪟 🎨 Improve empty state of resource pages #18066

Merged
merged 2 commits into from
Oct 19, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@ import { FormattedMessage } from "react-intl";
import { Button } from "components/ui/Button";
import { Text } from "components/ui/Text";

import { ReactComponent as BowtieHalf } from "./bowtie-half.svg";
import styles from "./EmptyResourceListView.module.scss";

interface EmptyResourceListViewProps {
buttonLabel: string;
resourceType: "connections" | "destinations" | "sources";
onCreateClick: () => void;
}

export const EmptyResourceListView: React.FC<EmptyResourceListViewProps> = ({ resourceType, onCreateClick }) => {
const { headingMessageId, buttonMessageId, singularResourceType } = useMemo(() => {
export const EmptyResourceListView: React.FC<EmptyResourceListViewProps> = ({
resourceType,
onCreateClick,
buttonLabel,
}) => {
const { headingMessageId, singularResourceType } = useMemo(() => {
const singularResourceType = resourceType.substring(0, resourceType.length - 1);
const baseMessageId = resourceType === "connections" ? singularResourceType : resourceType;

const headingMessageId = `${baseMessageId}.description`;
const buttonMessageId = `${baseMessageId}.new${
singularResourceType.substring(0, 1).toUpperCase() + singularResourceType.substring(1)
}`;

return { headingMessageId, buttonMessageId, singularResourceType };
return { headingMessageId, singularResourceType };
}, [resourceType]);

return (
Expand All @@ -32,20 +35,20 @@ export const EmptyResourceListView: React.FC<EmptyResourceListViewProps> = ({ re
</Text>
<div className={classNames(styles.container, styles.illustration)}>
{resourceType !== "destinations" && (
<img src="/images/bowtie-half.svg" alt="Left Bowtie" className={classNames(styles.bowtie, styles.left)} />
<BowtieHalf aria-hidden="true" className={classNames(styles.bowtie, styles.left)} />
)}
{resourceType !== "sources" && (
<img src="/images/bowtie-half.svg" alt="Right Bowtie" className={classNames(styles.bowtie, styles.right)} />
<BowtieHalf aria-hidden="true" className={classNames(styles.bowtie, styles.right)} />
)}
<img
className={styles.octavia}
src={`/images/octavia/empty-${resourceType}.png`}
alt="Octavia"
alt=""
resource={resourceType}
/>
</div>
<Button onClick={onCreateClick} size="lg" data-id={`new-${singularResourceType}`}>
<FormattedMessage id={buttonMessageId} />
{buttonLabel}
</Button>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions airbyte-webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
"sources.full_refresh": "Full refresh",
"sources.incremental": "Incremental - based on...",
"sources.newSource": "New source",
"sources.createFirst": "Connect your first source",
"sources.newSourceTitle": "New Source",
"sources.selectSource": "Select a source",
"sources.status": "Status",
Expand Down Expand Up @@ -310,6 +311,7 @@

"destination.destinationSettings": "Destination Settings",
"destinations.newDestination": "New destination",
"destinations.createFirst": "Connect your first destination",
"destinations.description": "<b>Destinations</b> are where you <b>send</b> or <b>push</b> your data to.",
"destinations.noDestinations": "Destination list is empty",
"destinations.noSources": "No sources yet",
Expand Down Expand Up @@ -361,6 +363,7 @@
"connection.catalogTree.destinationSchema": "'<destination schema>",

"connection.newConnection": "New connection",
"connection.createFirst": "Create your first connection",
"connection.newConnectionTitle": "New connection",
"connection.noConnections": "Connection list is empty",
"connection.disabledConnection": "Disabled connection",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { Suspense } from "react";
import { FormattedMessage } from "react-intl";
import { FormattedMessage, useIntl } from "react-intl";
import { useNavigate } from "react-router-dom";

import { LoadingPage, MainPageWithScroll } from "components";
Expand All @@ -18,6 +18,7 @@ import ConnectionsTable from "./components/ConnectionsTable";

const AllConnectionsPage: React.FC = () => {
const navigate = useNavigate();
const { formatMessage } = useIntl();

useTrackPage(PageTrackingCodes.CONNECTIONS_LIST);
const { connections } = useConnectionList();
Expand All @@ -43,7 +44,11 @@ const AllConnectionsPage: React.FC = () => {
<ConnectionsTable connections={connections} />
</MainPageWithScroll>
) : (
<EmptyResourceListView resourceType="connections" onCreateClick={onCreateClick} />
<EmptyResourceListView
resourceType="connections"
onCreateClick={onCreateClick}
buttonLabel={formatMessage({ id: "connection.createFirst" })}
/>
)}
</Suspense>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React from "react";
import { FormattedMessage } from "react-intl";
import { FormattedMessage, useIntl } from "react-intl";
import { useNavigate } from "react-router-dom";

import { EmptyResourceListView } from "components/EmptyResourceListView";
Expand All @@ -18,6 +18,7 @@ import DestinationsTable from "./components/DestinationsTable";

const AllDestinationsPage: React.FC = () => {
const navigate = useNavigate();
const { formatMessage } = useIntl();
const { destinations } = useDestinationList();
useTrackPage(PageTrackingCodes.DESTINATION_LIST);

Expand Down Expand Up @@ -45,7 +46,11 @@ const AllDestinationsPage: React.FC = () => {
<DestinationsTable destinations={destinations} />
</MainPageWithScroll>
) : (
<EmptyResourceListView resourceType="destinations" onCreateClick={onCreateDestination} />
<EmptyResourceListView
resourceType="destinations"
onCreateClick={onCreateDestination}
buttonLabel={formatMessage({ id: "destinations.createFirst" })}
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React from "react";
import { FormattedMessage } from "react-intl";
import { FormattedMessage, useIntl } from "react-intl";
import { useNavigate } from "react-router-dom";

import { EmptyResourceListView } from "components/EmptyResourceListView";
Expand All @@ -18,6 +18,7 @@ import SourcesTable from "./components/SourcesTable";

const AllSourcesPage: React.FC = () => {
const navigate = useNavigate();
const { formatMessage } = useIntl();
const { sources } = useSourceList();
useTrackPage(PageTrackingCodes.SOURCE_LIST);
const onCreateSource = () => navigate(`${RoutePaths.SourceNew}`);
Expand All @@ -38,7 +39,11 @@ const AllSourcesPage: React.FC = () => {
<SourcesTable sources={sources} />
</MainPageWithScroll>
) : (
<EmptyResourceListView resourceType="sources" onCreateClick={onCreateSource} />
<EmptyResourceListView
resourceType="sources"
onCreateClick={onCreateSource}
buttonLabel={formatMessage({ id: "sources.createFirst" })}
/>
);
};

Expand Down