Skip to content

Commit

Permalink
add different messages when there is no tests and when no tests match…
Browse files Browse the repository at this point in the history
…ed to the filters
  • Loading branch information
epszaw committed Dec 19, 2024
1 parent ea63252 commit 2343f2c
Show file tree
Hide file tree
Showing 24 changed files with 146 additions and 48 deletions.
12 changes: 12 additions & 0 deletions packages/plugin-api/src/utils/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ export const createTreeByLabels = (data: TestResult[], labelNames: string[]) =>
);
};

/**
* Mutates the given tree by sorting leaves in each group.
* Returns the link to the same tree.
* @param tree
* @param comparator
*/
export const sortTree = <L, G>(tree: TreeData<L, G>, comparator: Comparator<TreeLeaf<L>>) => {
const { root, leavesById, groupsById } = tree;
const sortGroupLeaves = (group: TreeGroup<G>) => {
Expand Down Expand Up @@ -152,6 +158,12 @@ export const sortTree = <L, G>(tree: TreeData<L, G>, comparator: Comparator<Tree
return tree;
};

/**
* Mutates the given tree by applying the transformer function to each leaf.
* Returns the link to the same tree.
* @param tree
* @param transformer
*/
export const transformTree = <L, G>(
tree: TreeData<L, G>,
transformer: (leaf: TreeLeaf<L>, idx: number) => TreeLeaf<L>,
Expand Down
29 changes: 24 additions & 5 deletions packages/web-awesome/src/components/app/Tree/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useEffect } from "preact/hooks";
import { useTabsContext } from "@/components/app/Tabs";
import Tree from "@/components/app/Tree/Tree";
import { Button } from "@/components/commons/Button";
import { Loadable } from "@/components/commons/Loadable";
import { PageLoader } from "@/components/commons/PageLoader";
import { Text } from "@/components/commons/Typography";
import { useI18n } from "@/stores/locale";
import { filteredTree, setTreeStatus, treeStore } from "@/stores/tree";
import { clearTreeFilters, filteredTree, noTests, noTestsFound, setTreeStatus, treeStore } from "@/stores/tree";
import type { AllureAwesomeStatus } from "../../../../types";
import * as styles from "./styles.scss";

Expand All @@ -21,10 +22,8 @@ export const TreeList = () => {
<Loadable
source={treeStore}
renderLoader={() => <PageLoader />}
renderData={(treeData) => {
const { groups, leaves } = treeData?.root ?? {};

if (!groups && !leaves) {
renderData={() => {
if (noTests.value) {
return (
<div className={styles["tree-list"]}>
<div className={styles["tree-empty-results"]}>
Expand All @@ -34,6 +33,26 @@ export const TreeList = () => {
);
}

if (noTestsFound.value) {
return (
<div className={styles["tree-list"]}>
<div className={styles["tree-empty-results"]}>
<Text tag="p" className={styles["tree-empty-results-title"]}>
{t("no-tests-found")}
</Text>
<Button
className={styles["tree-empty-results-clear-button"]}
type="button"
text={t("clear-filters")}
size={"s"}
style={"outline"}
onClick={() => clearTreeFilters()}
/>
</div>
</div>
);
}

return (
<div className={styles["tree-list"]}>
<Tree tree={filteredTree.value} statusFilter={currentTab as AllureAwesomeStatus} root />
Expand Down
8 changes: 5 additions & 3 deletions packages/web-awesome/src/components/app/Tree/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,18 @@
}

.tree-empty-results {
display: flex;
padding: 44px 24px;
align-items: center;
justify-content: center;
text-align: center;
}

.tree-empty-results-title {
color: var(--on-text-secondary);
}

.tree-empty-results-clear-button {
margin-top: 4px;
}

.order {
user-select: none;
}
12 changes: 7 additions & 5 deletions packages/web-awesome/src/components/commons/SearchBox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { clsx } from "clsx";
import { useState } from "preact/hooks";
import {useEffect, useState} from "preact/hooks";
import searchIcon from "@/assets/svg/line-general-search-md.svg";
import closeIcon from "@/assets/svg/line-general-x-close.svg";
import { useDebouncedCallback } from "@/hooks/useDebouncedCallback";
Expand All @@ -20,25 +20,27 @@ type Props = {
export const SearchBox = (props: Props) => {
const { placeholder, value, onChange, changeDebounce = 300 } = props;
const [localValue, setLocalValue] = useState(value);

const onChangeDebounced = useDebouncedCallback(onChange, changeDebounce);

const handleChange = (e: Event) => {
const newValue = (e.target as HTMLInputElement).value;

setLocalValue(newValue);
onChangeDebounced(newValue);
};

const handleClear = (e: PointerEvent) => {
e.preventDefault();
e.stopPropagation();
setLocalValue("");
onChangeDebounced("");
};

const showClear = !!localValue;

useEffect(() => {
if (localValue !== value) {
setLocalValue(value);
}
}, [value]);

return (
<Text className={styles.inputWrap} type="ui" size="m" tag="div">
<SvgIcon id={searchIcon.id} size="s" className={styles.leadingIcon} />
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/am.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "Հակադարձված"
},
"empty": {
"no-results": "Արդյունքներ չեն գտնվել",
"no-results": "Ոչ մի արդյունք",
"no-tests-found": "Արդյունքներ չեն գտնվել",
"clear-filters": "Մաքրել ֆիլտրները",
"no-attachments-results": "Կցորդների մասին տեղեկություններ չկան",
"no-history-results": "Պատմության մասին տեղեկություններ չկան",
"no-retries-results": "Կրկնությունների մասին տեղեկություններ չկան"
Expand Down
2 changes: 2 additions & 0 deletions packages/web-awesome/src/i18n/locales/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
},
"empty": {
"no-results": "Nəticə tapılmadı",
"no-tests-found": "Nəticə tapılmadı",
"clear-filters": "Filtrləri təmizlə",
"no-attachments-results": "Əlavə məlumatı mövcud deyil",
"no-history-results": "Tarixçə məlumatı mövcud deyil",
"no-retries-results": "Təkrar məlumatı mövcud deyil"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "Umgekehrt"
},
"empty": {
"no-results": "Keine Ergebnisse gefunden",
"no-results": "Keine Ergebnisse",
"no-tests-found": "Keine Ergebnisse gefunden",
"clear-filters": "Filter löschen",
"no-attachments-results": "Keine Anhängeinformationen verfügbar",
"no-history-results": "Keine Verlaufsinformationen verfügbar",
"no-retries-results": "Keine Wiederholungsinformationen verfügbar"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "Reversed"
},
"empty": {
"no-results": "No results found",
"no-results": "No results",
"no-tests-found": "No results found",
"clear-filters": "Clear filters",
"no-attachments-results": "No attachments information available",
"no-history-results": "No history information available",
"no-retries-results": "No retries information available"
Expand Down
3 changes: 3 additions & 0 deletions packages/web-awesome/src/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
"status-desc-short": "Invertido"
},
"empty": {
"no-results": "Sin resultados",
"no-tests-found": "No se encontraron resultados",
"clear-filters": "Limpiar filtros",
"no-attachments-results": "No hay información de adjuntos disponible",
"no-history-results": "No hay información de historial disponible",
"no-retries-results": "No hay información de reintentos disponible"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "Inversé"
},
"empty": {
"no-results": "Aucun résultat trouvé",
"no-results": "Aucun résultat",
"no-tests-found": "Aucun résultat trouvé",
"clear-filters": "Effacer les filtres",
"no-attachments-results": "Aucune information sur les pièces jointes disponible",
"no-history-results": "Aucune information sur l'historique disponible",
"no-retries-results": "Aucune information sur les réessais disponible"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "הפוך"
},
"empty": {
"no-results": "לא נמצאו תוצאות",
"no-results": "אין תוצאות",
"no-tests-found": "לא נמצאו תוצאות",
"clear-filters": "נקה מסננים",
"no-attachments-results": "לא נמצאה מידע על קבצים מצורפים",
"no-history-results": "לא נמצאה מידע על היסטוריה",
"no-retries-results": "לא נמצאה מידע על נסיונות חוזרים"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "Invertito"
},
"empty": {
"no-results": "Nessun risultato trovato",
"no-results": "Nessun risultato",
"no-tests-found": "Nessun risultato trovato",
"clear-filters": "Cancella i filtri",
"no-attachments-results": "Nessuna informazione sugli allegati disponibile",
"no-history-results": "Nessuna informazione sulla cronologia disponibile",
"no-retries-results": "Nessuna informazione sui ritentativi disponibile"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "逆順"
},
"empty": {
"no-results": "結果が見つかりません",
"no-results": "結果がありません",
"no-tests-found": "結果が見つかりません",
"clear-filters": "フィルターをクリア",
"no-attachments-results": "添付ファイル情報が利用できません",
"no-history-results": "履歴情報が利用できません",
"no-retries-results": "再試行情報が利用できません"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/ka.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "შებრუნებული"
},
"empty": {
"no-results": "შედეგები არ მოიძებნა",
"no-results": "შედეგები არ არის",
"no-tests-found": "შედეგები არ მოიძებნა",
"clear-filters": "ფილტრების გასუფთავება",
"no-attachments-results": "დანართების ინფორმაცია არ არის ხელმისაწვდომი",
"no-history-results": "ისტორიის ინფორმაცია არ არის ხელმისაწვდომი",
"no-retries-results": "ხელახალი ცდების ინფორმ���ცია არ არის ხელმისაწვდომი"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/kr.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "역순"
},
"empty": {
"no-results": "결과를 찾을 수 없습니다",
"no-results": "결과 없음",
"no-tests-found": "결과를 찾을 수 없음",
"clear-filters": "필터 지우기",
"no-attachments-results": "첨부파일 정보를 사용할 수 없습니다",
"no-history-results": "기록 정보를 사용할 수 없습니다",
"no-retries-results": "재시도 정보를 사용할 수 없습니다"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "Omgekeerd"
},
"empty": {
"no-results": "Geen resultaten gevonden",
"no-results": "Geen resultaten",
"no-tests-found": "Geen resultaten gevonden",
"clear-filters": "Filters wissen",
"no-attachments-results": "Geen bijlageninformatie beschikbaar",
"no-history-results": "Geen geschiedenisinformatie beschikbaar",
"no-retries-results": "Geen herhalingsinformatie beschikbaar"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
"status-desc-short": "Domyślnie"
},
"empty": {
"no-results": "Nie znaleziono wyników",
"no-results": "Brak wyników",
"no-tests-found": "Nie znaleziono wyników",
"clear-filters": "Wyczyść filtry",
"no-attachments-results": "Brak dostępnych informacji o załącznikach",
"no-history-results": "Brak dostępnych informacji o historii",
"no-retries-results": "Brak dostępnych informacji o ponownych próbach"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "Invertido"
},
"empty": {
"no-results": "Nenhum resultado encontrado",
"no-results": "Sem resultados",
"no-tests-found": "Nenhum resultado encontrado",
"clear-filters": "Limpar filtros",
"no-attachments-results": "Nenhuma informação de anexos disponível",
"no-history-results": "Nenhuma informação de histórico disponível",
"no-retries-results": "Nenhuma informação de repetições disponível"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
"status-desc-short": "По обычному"
},
"empty": {
"no-results": "Результатов не найдено",
"no-results": "Нет результатов",
"no-tests-found": "Результаты не найдены",
"clear-filters": "Очистить фильтры",
"no-attachments-results": "Информация о вложениях отсутствует",
"no-history-results": "Информация об истории отсутствует",
"no-retries-results": "Информация о перезапусках отсутствует"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "Omvänd"
},
"empty": {
"no-results": "Inga resultat hittades",
"no-results": "Inga resultat",
"no-tests-found": "Inga resultat hittades",
"clear-filters": "Rensa filter",
"no-attachments-results": "Ingen bilaga information tillgänglig",
"no-history-results": "Ingen historik information tillgänglig",
"no-retries-results": "Ingen omtagningar information tillgänglig"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "Ters"
},
"empty": {
"no-results": "Sonuç bulunamadı",
"no-results": "Sonuç yok",
"no-tests-found": "Sonuç bulunamadı",
"clear-filters": "Filtreleri temizle",
"no-attachments-results": "Ek bilgisi mevcut değil",
"no-history-results": "Geçmiş bilgisi mevcut değil",
"no-retries-results": "Tekrar deneme bilgisi mevcut değil"
Expand Down
4 changes: 3 additions & 1 deletion packages/web-awesome/src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"status-desc-short": "反转"
},
"empty": {
"no-results": "未找到结果",
"no-results": "没有结果",
"no-tests-found": "未找到结果",
"clear-filters": "清除过滤器",
"no-attachments-results": "没有附件信息",
"no-history-results": "没有历史信息",
"no-retries-results": "没有重试信息"
Expand Down
Loading

0 comments on commit 2343f2c

Please sign in to comment.