Skip to content

Commit

Permalink
✨ Empty component when no tags (konveyor#764) (konveyor#770)
Browse files Browse the repository at this point in the history
* Empty component when no tags

* Add button

* change test style

(cherry picked from commit d7d0270)
Signed-off-by: Gilles Dubreuil <[email protected]>
  • Loading branch information
gildub authored Mar 27, 2023
1 parent 895a750 commit 29e57ec
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
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>
</>
);
};

0 comments on commit 29e57ec

Please sign in to comment.