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

✨ Empty component when no tags #764

Merged
merged 3 commits into from
Mar 27, 2023
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
4 changes: 3 additions & 1 deletion client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"createNew": "Create new",
"createTag": "Create tag",
"createTagCategory": "Create tag category",
"createTags": "Create tags",
"delete": "Delete",
"discardAssessment": "Discard assessment/review",
"downloadCsvTemplate": "Download CSV template",
Expand Down Expand Up @@ -136,7 +137,8 @@
"reviewInstructions": "Use this section to provide your assessment of the possible migration/modernization plan and effort estimation.",
"savingSelection": "Saving selection",
"selectOwnerFromStakeholdersList": "Select owner from list of stakeholders",
"suggestedAdoptionPlanHelpText": "The suggested approach to migration based on effort, priority, and dependencies."
"suggestedAdoptionPlanHelpText": "The suggested approach to migration based on effort, priority, and dependencies.",
"toTagApplication": "Either no tags exist yet or you may not have permission to view any. If you have permission, try creating a new custom tag."
},
"proposedActions": {
"refactor": "Refactor",
Expand Down
4 changes: 3 additions & 1 deletion client/public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"createNew": "Crear nuevo",
"createTag": "Crear etiqueta",
"createTagCategory": "Crear categoría de etiqueta",
"createTags": "Create tags",
"delete": "Eliminar",
"discardAssessment": "Descartar evaluación/revisar",
"downloadCsvTemplate": "Descargar plantilla CSV",
Expand Down Expand Up @@ -136,7 +137,8 @@
"reviewInstructions": "Utilice esta sección para proporcionar su evaluación del posible plan de migración / modernización y la estimación del esfuerzo.",
"savingSelection": "Guardando selección",
"selectOwnerFromStakeholdersList": "Seleccione un propietario de la lista de interesados",
"suggestedAdoptionPlanHelpText": "El enfoque sugerido para la migración basado en el esfuerzo, la prioridad y las dependencias."
"suggestedAdoptionPlanHelpText": "El enfoque sugerido para la migración basado en el esfuerzo, la prioridad y las dependencias.",
"toTagApplication": "Todavía no existen etiquetas o es posible que no tenga permiso para ver ninguna. Si tiene permiso, intente crear una nueva etiqueta personalizada."
},
"proposedActions": {
"refactor": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import {
Button,
Flex,
Label,
Spinner,
Expand All @@ -10,12 +11,13 @@ import {
ToolbarContent,
ToolbarToggleGroup,
ToolbarItem,
ButtonVariant,
} from "@patternfly/react-core";
import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing";
import textStyles from "@patternfly/react-styles/css/utilities/Text/text";
import FilterIcon from "@patternfly/react-icons/dist/esm/icons/filter-icon";
import { DEFAULT_COLOR_LABELS } from "@app/Constants";
import { ConditionalRender } from "@app/shared/components";
import { ConditionalRender, NoDataEmptyState } from "@app/shared/components";
import { Application, Tag, TagCategory } from "@app/api/models";
import { getTagById, getTagCategoryById } from "@app/api/rest";
import {
Expand All @@ -24,6 +26,7 @@ import {
FilterType,
} from "@app/shared/components/FilterToolbar";
import { useFilterState } from "@app/shared/hooks/useFilterState";
import { useHistory } from "react-router-dom";

interface TagWithSource extends Tag {
source?: string;
Expand All @@ -44,6 +47,7 @@ export const ApplicationTags: React.FC<ApplicationTagsProps> = ({
application,
}) => {
const { t } = useTranslation();
const history = useHistory();

const [tags, setTags] = useState<TagWithSource[]>([]);
const [tagCategoriesById, setTagCategoriesById] = useState<
Expand Down Expand Up @@ -164,7 +168,7 @@ export const ApplicationTags: React.FC<ApplicationTagsProps> = ({
}
});

return (
return !!tagsBySource.size ? (
<ConditionalRender when={isFetching} then={<Spinner isSVG size="md" />}>
<Toolbar
clearAllFilters={() => setFilterValues({})}
Expand Down Expand Up @@ -242,5 +246,27 @@ export const ApplicationTags: React.FC<ApplicationTagsProps> = ({
);
})}
</ConditionalRender>
) : (
<>
<NoDataEmptyState
title={t("composed.noDataStateTitle", {
what: "tags",
})}
description={t("message.toTagApplication")}
/>
<div className="pf-u-text-align-center">
<Button
type="button"
id="create-tags"
aria-label="Create Tags"
variant={ButtonVariant.primary}
onClick={() => {
history.push("/controls/tags");
}}
>
{t("actions.createTag")}
</Button>
</div>
</>
);
};