diff --git a/src/containers/NotFound/NotFound.js b/src/containers/NotFound/NotFound.js index e7ea44bd6..b7cf619a2 100644 --- a/src/containers/NotFound/NotFound.js +++ b/src/containers/NotFound/NotFound.js @@ -17,15 +17,18 @@ import { injectIntl } from 'react-intl'; import { Link } from 'react-router-dom'; import { Column, Grid, Row } from 'carbon-components-react'; import { Link as CustomLink } from '@tektoncd/dashboard-components'; -import { urls } from '@tektoncd/dashboard-utils'; +import { ALL_NAMESPACES, urls } from '@tektoncd/dashboard-utils'; +import { useSelectedNamespace } from '../../api'; import robocat from '../../images/robocat_404.svg'; const smallConfig = { offset: 1, span: 2 }; const mediumConfig = { offset: 2, span: 4 }; const largeConfig = { offset: 5, span: 6 }; -function NotFound({ intl }) { +function NotFound({ intl, suggestions = [] }) { + const { selectedNamespace: namespace } = useSelectedNamespace(); + return ( @@ -61,6 +64,13 @@ function NotFound({ intl }) {

diff --git a/src/containers/NotFound/NotFound.stories.js b/src/containers/NotFound/NotFound.stories.js index 79259a46a..f901b4838 100644 --- a/src/containers/NotFound/NotFound.stories.js +++ b/src/containers/NotFound/NotFound.stories.js @@ -1,5 +1,5 @@ /* -Copyright 2021 The Tekton Authors +Copyright 2021-2022 The Tekton Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -13,14 +13,21 @@ limitations under the License. import React from 'react'; +import { NamespaceContext } from '../../api'; import NotFound from './NotFound'; +const namespaceContext = { + selectedNamespace: 'default' +}; + export default { component: NotFound, decorators: [ Story => (
- + + +
) ], @@ -28,3 +35,12 @@ export default { }; export const Base = () => ; + +export const CustomSuggestions = () => ( + +); diff --git a/src/containers/PipelineRun/PipelineRun.js b/src/containers/PipelineRun/PipelineRun.js index c02d4c059..c7921dd5a 100644 --- a/src/containers/PipelineRun/PipelineRun.js +++ b/src/containers/PipelineRun/PipelineRun.js @@ -48,12 +48,12 @@ import { useTaskRuns, useTasks } from '../../api'; - import { getLogsRetriever, getLogsToolbar, getViewChangeHandler } from '../../utils'; +import { NotFound } from '..'; const { PIPELINE_TASK, RETRY, STEP, VIEW } = queryParamConstants; @@ -474,6 +474,26 @@ export /* istanbul ignore next */ function PipelineRunContainer({ intl }) { { enabled: !!podName && view === 'pod' } ); + const isLoading = + isLoadingPipelineRun || + isLoadingTaskRuns || + isLoadingTasks || + isLoadingClusterTasks || + isLoadingPipeline; + + if (!isLoading && (pipelineRunError || !pipelineRun)) { + return ( + + ); + } + let podDetails; if (!currentSelectedStepId) { podDetails = (events || pod) && { events, resource: pod }; @@ -517,13 +537,7 @@ export /* istanbul ignore next */ function PipelineRunContainer({ intl }) { onFallback: setIsUsingExternalLogs })} handleTaskSelected={handleTaskSelected} - loading={ - isLoadingPipelineRun || - isLoadingTaskRuns || - isLoadingTasks || - isLoadingClusterTasks || - isLoadingPipeline - } + loading={isLoading} getLogsToolbar={toolbarParams => getLogsToolbar({ ...toolbarParams, diff --git a/src/containers/PipelineRun/PipelineRun.test.js b/src/containers/PipelineRun/PipelineRun.test.js index 2da8afdef..95baf8b5e 100644 --- a/src/containers/PipelineRun/PipelineRun.test.js +++ b/src/containers/PipelineRun/PipelineRun.test.js @@ -1,5 +1,5 @@ /* -Copyright 2019-2021 The Tekton Authors +Copyright 2019-2022 The Tekton Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -14,6 +14,7 @@ limitations under the License. import React from 'react'; import { waitFor } from '@testing-library/react'; import { createIntl } from 'react-intl'; +import { paths, urls } from '@tektoncd/dashboard-utils'; import { renderWithRouter } from '../../utils/test'; import * as PipelineRunsAPI from '../../api/pipelineRuns'; @@ -51,19 +52,29 @@ it('PipelineRunContainer renders data', async () => { }); it('PipelineRunContainer renders not found state', async () => { + const namespace = 'fake_namespace'; + const pipelineRunName = 'fake_pipelineRunName'; jest .spyOn(PipelineRunsAPI, 'usePipelineRun') .mockImplementation(() => ({ data: null, error: null })); - const { getByText } = renderWithRouter(); - await waitFor(() => getByText(`PipelineRun not found`)); + const { getByText } = renderWithRouter(, { + path: paths.pipelineRuns.byName(), + route: urls.pipelineRuns.byName({ pipelineRunName, namespace }) + }); + await waitFor(() => getByText(/Page not found/)); }); it('PipelineRunContainer renders error state', async () => { + const namespace = 'fake_namespace'; + const pipelineRunName = 'fake_pipelineRunName'; jest .spyOn(PipelineRunsAPI, 'usePipelineRun') .mockImplementation(() => ({ data: null, error: 'some error' })); - const { getByText } = renderWithRouter(); - await waitFor(() => getByText('Error loading PipelineRun')); + const { getByText } = renderWithRouter(, { + path: paths.pipelineRuns.byName(), + route: urls.pipelineRuns.byName({ pipelineRunName, namespace }) + }); + await waitFor(() => getByText(/Page not found/)); }); diff --git a/src/containers/Run/Run.js b/src/containers/Run/Run.js index c3b82ea46..eef7f658e 100644 --- a/src/containers/Run/Run.js +++ b/src/containers/Run/Run.js @@ -29,6 +29,7 @@ import { InlineNotification } from 'carbon-components-react'; import { deleteRun, rerunRun, useIsReadOnly, useRun } from '../../api'; import { getViewChangeHandler } from '../../utils'; +import { NotFound } from '..'; function getRunDuration(run) { if (!run) { @@ -242,6 +243,19 @@ function Run({ intl }) { ]; } + if (!isFetching && (error || !run)) { + return ( + + ); + } + return ( <> {showNotification && ( diff --git a/src/containers/TaskRun/TaskRun.js b/src/containers/TaskRun/TaskRun.js index 27ea5e1cd..55219d775 100644 --- a/src/containers/TaskRun/TaskRun.js +++ b/src/containers/TaskRun/TaskRun.js @@ -40,7 +40,6 @@ import { getLogsToolbar, getViewChangeHandler } from '../../utils'; - import { cancelTaskRun, deleteTaskRun, @@ -54,31 +53,10 @@ import { useTaskByKind, useTaskRun } from '../../api'; +import { NotFound } from '..'; const { STEP, TASK_RUN_DETAILS, VIEW } = queryParamConstants; -function notification({ intl, kind, message }) { - const titles = { - info: intl.formatMessage({ - id: 'dashboard.taskRun.unavailable', - defaultMessage: 'TaskRun not available' - }), - error: intl.formatMessage({ - id: 'dashboard.taskRun.errorLoading', - defaultMessage: 'Error loading TaskRun' - }) - }; - return ( - - ); -} - export function TaskRunContainer({ intl }) { const history = useHistory(); const location = useLocation(); @@ -358,26 +336,17 @@ export function TaskRunContainer({ intl }) { return ; } - if (error) { - return notification({ - intl, - kind: 'error', - message: intl.formatMessage({ - id: 'dashboard.taskRun.errorLoading', - defaultMessage: 'Error loading TaskRun' - }) - }); - } - - if (!taskRun) { - return notification({ - intl, - kind: 'info', - message: intl.formatMessage({ - id: 'dashboard.taskRun.unavailable', - defaultMessage: 'TaskRun not available' - }) - }); + if (error || !taskRun) { + return ( + + ); } const definition = getStepDefinition({ diff --git a/src/nls/messages_de.json b/src/nls/messages_de.json index ddfca34b0..f090925c6 100644 --- a/src/nls/messages_de.json +++ b/src/nls/messages_de.json @@ -246,7 +246,6 @@ "dashboard.tableHeader.task": "", "dashboard.tableHeader.type": "", "dashboard.tableHeader.value": "", - "dashboard.taskRun.errorLoading": "", "dashboard.taskRun.logs": "Protokolle", "dashboard.taskRun.params": "", "dashboard.taskRun.resources": "", @@ -260,7 +259,6 @@ "dashboard.taskRun.status.succeeded": "Abgeschlossen", "dashboard.taskRun.status.succeeded.warning": "", "dashboard.taskRun.status.waiting": "Wartestatus", - "dashboard.taskRun.unavailable": "", "dashboard.taskRunParams.name": "", "dashboard.taskRunParams.value": "", "dashboard.taskRuns.errorLoading": "", diff --git a/src/nls/messages_en.json b/src/nls/messages_en.json index c838435eb..086f48d8e 100644 --- a/src/nls/messages_en.json +++ b/src/nls/messages_en.json @@ -246,7 +246,6 @@ "dashboard.tableHeader.task": "Task", "dashboard.tableHeader.type": "Type", "dashboard.tableHeader.value": "Value", - "dashboard.taskRun.errorLoading": "Error loading TaskRun", "dashboard.taskRun.logs": "Logs", "dashboard.taskRun.params": "Parameters", "dashboard.taskRun.resources": "Resources", @@ -260,7 +259,6 @@ "dashboard.taskRun.status.succeeded": "Completed", "dashboard.taskRun.status.succeeded.warning": "Completed with exit code {exitCode}", "dashboard.taskRun.status.waiting": "Waiting", - "dashboard.taskRun.unavailable": "TaskRun not available", "dashboard.taskRunParams.name": "Name", "dashboard.taskRunParams.value": "Value", "dashboard.taskRuns.errorLoading": "Error loading TaskRuns", diff --git a/src/nls/messages_es.json b/src/nls/messages_es.json index 1512f937f..6f86fd220 100644 --- a/src/nls/messages_es.json +++ b/src/nls/messages_es.json @@ -246,7 +246,6 @@ "dashboard.tableHeader.task": "", "dashboard.tableHeader.type": "", "dashboard.tableHeader.value": "", - "dashboard.taskRun.errorLoading": "", "dashboard.taskRun.logs": "Anotaciones", "dashboard.taskRun.params": "", "dashboard.taskRun.resources": "", @@ -260,7 +259,6 @@ "dashboard.taskRun.status.succeeded": "Completado", "dashboard.taskRun.status.succeeded.warning": "", "dashboard.taskRun.status.waiting": "En espera", - "dashboard.taskRun.unavailable": "", "dashboard.taskRunParams.name": "", "dashboard.taskRunParams.value": "", "dashboard.taskRuns.errorLoading": "", diff --git a/src/nls/messages_fr.json b/src/nls/messages_fr.json index 09d7edc74..9073ad599 100644 --- a/src/nls/messages_fr.json +++ b/src/nls/messages_fr.json @@ -246,7 +246,6 @@ "dashboard.tableHeader.task": "", "dashboard.tableHeader.type": "", "dashboard.tableHeader.value": "", - "dashboard.taskRun.errorLoading": "", "dashboard.taskRun.logs": "Journaux", "dashboard.taskRun.params": "", "dashboard.taskRun.resources": "", @@ -260,7 +259,6 @@ "dashboard.taskRun.status.succeeded": "Terminé", "dashboard.taskRun.status.succeeded.warning": "", "dashboard.taskRun.status.waiting": "En attente", - "dashboard.taskRun.unavailable": "", "dashboard.taskRunParams.name": "", "dashboard.taskRunParams.value": "", "dashboard.taskRuns.errorLoading": "", diff --git a/src/nls/messages_it.json b/src/nls/messages_it.json index fdcae5434..e53c63fcd 100644 --- a/src/nls/messages_it.json +++ b/src/nls/messages_it.json @@ -246,7 +246,6 @@ "dashboard.tableHeader.task": "", "dashboard.tableHeader.type": "", "dashboard.tableHeader.value": "", - "dashboard.taskRun.errorLoading": "", "dashboard.taskRun.logs": "Log", "dashboard.taskRun.params": "", "dashboard.taskRun.resources": "", @@ -260,7 +259,6 @@ "dashboard.taskRun.status.succeeded": "Completato", "dashboard.taskRun.status.succeeded.warning": "", "dashboard.taskRun.status.waiting": "In attesa", - "dashboard.taskRun.unavailable": "", "dashboard.taskRunParams.name": "", "dashboard.taskRunParams.value": "", "dashboard.taskRuns.errorLoading": "", diff --git a/src/nls/messages_ja.json b/src/nls/messages_ja.json index ae5f52436..4bd5ce503 100644 --- a/src/nls/messages_ja.json +++ b/src/nls/messages_ja.json @@ -246,7 +246,6 @@ "dashboard.tableHeader.task": "", "dashboard.tableHeader.type": "種類", "dashboard.tableHeader.value": "値", - "dashboard.taskRun.errorLoading": "TaskRunのロード中にエラーが発生しました", "dashboard.taskRun.logs": "ログ", "dashboard.taskRun.params": "パラメータ", "dashboard.taskRun.resources": "", @@ -260,7 +259,6 @@ "dashboard.taskRun.status.succeeded": "完了", "dashboard.taskRun.status.succeeded.warning": "", "dashboard.taskRun.status.waiting": "待機中", - "dashboard.taskRun.unavailable": "TaskRunは使用できません", "dashboard.taskRunParams.name": "名前", "dashboard.taskRunParams.value": "値", "dashboard.taskRuns.errorLoading": "TaskRunのロード中にエラーが発生しました", diff --git a/src/nls/messages_ko.json b/src/nls/messages_ko.json index e7ddc6380..54397e4d1 100644 --- a/src/nls/messages_ko.json +++ b/src/nls/messages_ko.json @@ -246,7 +246,6 @@ "dashboard.tableHeader.task": "", "dashboard.tableHeader.type": "", "dashboard.tableHeader.value": "", - "dashboard.taskRun.errorLoading": "", "dashboard.taskRun.logs": "로그", "dashboard.taskRun.params": "", "dashboard.taskRun.resources": "", @@ -260,7 +259,6 @@ "dashboard.taskRun.status.succeeded": "완료됨", "dashboard.taskRun.status.succeeded.warning": "", "dashboard.taskRun.status.waiting": "대기 중", - "dashboard.taskRun.unavailable": "", "dashboard.taskRunParams.name": "", "dashboard.taskRunParams.value": "", "dashboard.taskRuns.errorLoading": "", diff --git a/src/nls/messages_pt.json b/src/nls/messages_pt.json index c83d1fd20..d0b709d79 100644 --- a/src/nls/messages_pt.json +++ b/src/nls/messages_pt.json @@ -246,7 +246,6 @@ "dashboard.tableHeader.task": "", "dashboard.tableHeader.type": "", "dashboard.tableHeader.value": "", - "dashboard.taskRun.errorLoading": "", "dashboard.taskRun.logs": "Logs", "dashboard.taskRun.params": "", "dashboard.taskRun.resources": "", @@ -260,7 +259,6 @@ "dashboard.taskRun.status.succeeded": "Concluído", "dashboard.taskRun.status.succeeded.warning": "", "dashboard.taskRun.status.waiting": "Aguardando", - "dashboard.taskRun.unavailable": "", "dashboard.taskRunParams.name": "", "dashboard.taskRunParams.value": "", "dashboard.taskRuns.errorLoading": "", diff --git a/src/nls/messages_zh-Hans.json b/src/nls/messages_zh-Hans.json index fdd9b3d32..5d411683a 100644 --- a/src/nls/messages_zh-Hans.json +++ b/src/nls/messages_zh-Hans.json @@ -246,7 +246,6 @@ "dashboard.tableHeader.task": "Task", "dashboard.tableHeader.type": "种类", "dashboard.tableHeader.value": "值", - "dashboard.taskRun.errorLoading": "加载 TaskRun 时失败", "dashboard.taskRun.logs": "日志", "dashboard.taskRun.params": "参数", "dashboard.taskRun.resources": "资源", @@ -260,7 +259,6 @@ "dashboard.taskRun.status.succeeded": "已完成", "dashboard.taskRun.status.succeeded.warning": "已完成,退出代码 {exitCode}", "dashboard.taskRun.status.waiting": "等待中", - "dashboard.taskRun.unavailable": "TaskRun 不可用", "dashboard.taskRunParams.name": "名称", "dashboard.taskRunParams.value": "值", "dashboard.taskRuns.errorLoading": "TaskRun 加载失败", diff --git a/src/nls/messages_zh-Hant.json b/src/nls/messages_zh-Hant.json index e1e31177f..448a57d72 100644 --- a/src/nls/messages_zh-Hant.json +++ b/src/nls/messages_zh-Hant.json @@ -246,7 +246,6 @@ "dashboard.tableHeader.task": "", "dashboard.tableHeader.type": "", "dashboard.tableHeader.value": "", - "dashboard.taskRun.errorLoading": "", "dashboard.taskRun.logs": "日誌", "dashboard.taskRun.params": "", "dashboard.taskRun.resources": "", @@ -260,7 +259,6 @@ "dashboard.taskRun.status.succeeded": "已完成", "dashboard.taskRun.status.succeeded.warning": "", "dashboard.taskRun.status.waiting": "等待中", - "dashboard.taskRun.unavailable": "", "dashboard.taskRunParams.name": "", "dashboard.taskRunParams.value": "", "dashboard.taskRuns.errorLoading": "",