diff --git a/frontend/packages/pipelines-plugin/locales/en/pipelines-plugin.json b/frontend/packages/pipelines-plugin/locales/en/pipelines-plugin.json index e4a47c1ba35..5ca80b9d054 100644 --- a/frontend/packages/pipelines-plugin/locales/en/pipelines-plugin.json +++ b/frontend/packages/pipelines-plugin/locales/en/pipelines-plugin.json @@ -129,7 +129,6 @@ "Medium": "Medium", "Low": "Low", "Resource is being deleted.": "Resource is being deleted.", - "Resource is being fetched from Tekton Results.": "Resource is being fetched from Tekton Results.", "View GitHub App": "View GitHub App", "EventListener details": "EventListener details", "URL": "URL", @@ -453,6 +452,7 @@ "Start last run": "Start last run", "This action will delete resource from k8s but still the resource can be fetched from Tekton Results": "This action will delete resource from k8s but still the resource can be fetched from Tekton Results", "Delete {{kind}}": "Delete {{kind}}", + "Resource is being fetched from Tekton Results.": "Resource is being fetched from Tekton Results.", "Stop": "Stop", "Let the running tasks complete, then execute finally tasks": "Let the running tasks complete, then execute finally tasks", "Interrupt any executing non finally tasks, then execute finally tasks": "Interrupt any executing non finally tasks, then execute finally tasks", diff --git a/frontend/packages/pipelines-plugin/src/components/pipelineruns/PipelineRunDetailsPage.tsx b/frontend/packages/pipelines-plugin/src/components/pipelineruns/PipelineRunDetailsPage.tsx index d6cc8b8ed5d..7af5971d321 100644 --- a/frontend/packages/pipelines-plugin/src/components/pipelineruns/PipelineRunDetailsPage.tsx +++ b/frontend/packages/pipelines-plugin/src/components/pipelineruns/PipelineRunDetailsPage.tsx @@ -4,6 +4,10 @@ import { ArchiveIcon } from '@patternfly/react-icons'; import { useTranslation } from 'react-i18next'; import { DetailsPage, DetailsPageProps } from '@console/internal/components/factory'; import { KebabAction, navFactory, viewYamlComponent } from '@console/internal/components/utils'; +import { + DELETED_RESOURCE_IN_K8S_ANNOTATION, + RESOURCE_LOADED_FROM_RESULTS_ANNOTATION, +} from '../../const'; import * as SignedPipelinerunIcon from '../../images/signed-badge.svg'; import { PipelineRunKind } from '../../types'; import { usePipelineTechPreviewBadge } from '../../utils/hooks'; @@ -42,7 +46,8 @@ const PipelineRunDetailsPage: React.FC = (props) => { {t('pipelines-plugin~Signed')} )} - {obj?.metadata?.annotations?.['resource.deleted.in.k8s'] === 'true' && ( + {(obj?.metadata?.annotations?.[DELETED_RESOURCE_IN_K8S_ANNOTATION] === 'true' || + obj?.metadata?.annotations?.[RESOURCE_LOADED_FROM_RESULTS_ANNOTATION] === 'true') && ( diff --git a/frontend/packages/pipelines-plugin/src/components/pipelineruns/list-page/PipelineRunRow.tsx b/frontend/packages/pipelines-plugin/src/components/pipelineruns/list-page/PipelineRunRow.tsx index 4bc812d1dc2..a63de694d18 100644 --- a/frontend/packages/pipelines-plugin/src/components/pipelineruns/list-page/PipelineRunRow.tsx +++ b/frontend/packages/pipelines-plugin/src/components/pipelineruns/list-page/PipelineRunRow.tsx @@ -5,6 +5,10 @@ import { useTranslation } from 'react-i18next'; import { TableData, RowFunctionArgs } from '@console/internal/components/factory'; import { Timestamp, ResourceLink } from '@console/internal/components/utils'; import { referenceForModel } from '@console/internal/module/k8s'; +import { + DELETED_RESOURCE_IN_K8S_ANNOTATION, + RESOURCE_LOADED_FROM_RESULTS_ANNOTATION, +} from '../../../const'; import * as SignedPipelinerunIcon from '../../../images/signed-badge.svg'; import { PipelineRunModel } from '../../../models'; import { PipelineRunKind, TaskRunKind } from '../../../types'; @@ -62,7 +66,8 @@ const PipelineRunRow: React.FC> = ({ obj, custo ) : null} - {obj?.metadata?.annotations?.['resource.deleted.in.k8s'] === 'true' ? ( + {obj?.metadata?.annotations?.[DELETED_RESOURCE_IN_K8S_ANNOTATION] === 'true' || + obj?.metadata?.annotations?.[RESOURCE_LOADED_FROM_RESULTS_ANNOTATION] === 'true' ? (
diff --git a/frontend/packages/pipelines-plugin/src/components/pipelineruns/triggered-by/ResourceKebab.tsx b/frontend/packages/pipelines-plugin/src/components/pipelineruns/triggered-by/ResourceKebab.tsx index f9860a2ad10..a171411146a 100644 --- a/frontend/packages/pipelines-plugin/src/components/pipelineruns/triggered-by/ResourceKebab.tsx +++ b/frontend/packages/pipelines-plugin/src/components/pipelineruns/triggered-by/ResourceKebab.tsx @@ -14,23 +14,14 @@ export const ResourceKebab = connectToModel((props: ResourceKebabProps) => { actions.map((a) => a(kindObj, resource, null, customData)), 'hidden', ); - const isResourceLoadedFromTR = - resource?.metadata?.annotations?.['resource.loaded.from.tektonResults']; - const isResourceDeletedInK8s = resource?.metadata?.annotations?.['resource.deleted.in.k8s']; return ( diff --git a/frontend/packages/pipelines-plugin/src/components/pipelineruns/utils/tekton-results.ts b/frontend/packages/pipelines-plugin/src/components/pipelineruns/utils/tekton-results.ts index d7de6ad31ed..1a33b0ec16a 100644 --- a/frontend/packages/pipelines-plugin/src/components/pipelineruns/utils/tekton-results.ts +++ b/frontend/packages/pipelines-plugin/src/components/pipelineruns/utils/tekton-results.ts @@ -8,6 +8,10 @@ import { import { RouteModel } from '@console/internal/models'; import { k8sGet } from '@console/internal/module/k8s'; import { consoleProxyFetchJSON } from '@console/shared/src/utils/proxy'; +import { + DELETED_RESOURCE_IN_K8S_ANNOTATION, + RESOURCE_LOADED_FROM_RESULTS_ANNOTATION, +} from '../../../const'; import { TektonResultModel } from '../../../models'; import { PipelineRunKind, TaskRunKind } from '../../../types'; @@ -64,7 +68,7 @@ export const decodeValueJson = (value: string) => { let resourceDeletedInK8sAnnotation; if (_.has(decodedValue?.metadata, 'deletionTimestamp')) { delete decodedValue?.metadata?.deletionTimestamp; - resourceDeletedInK8sAnnotation = { 'resource.deleted.in.k8s': 'true' }; + resourceDeletedInK8sAnnotation = { [DELETED_RESOURCE_IN_K8S_ANNOTATION]: 'true' }; } const decodedValueWithTRAnnotation = decodedValue ? { @@ -73,7 +77,7 @@ export const decodeValueJson = (value: string) => { ...decodedValue?.metadata, annotations: { ...decodedValue?.metadata?.annotations, - 'resource.loaded.from.tektonResults': 'true', + [RESOURCE_LOADED_FROM_RESULTS_ANNOTATION]: 'true', ...resourceDeletedInK8sAnnotation, }, }, diff --git a/frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/utils.ts b/frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/utils.ts index fac4c6dfa9f..97a9d07fe8c 100644 --- a/frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/utils.ts +++ b/frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/utils.ts @@ -1,6 +1,10 @@ import * as _ from 'lodash'; import { getActiveUserName } from '@console/internal/actions/ui'; import { getRandomChars } from '@console/shared'; +import { + DELETED_RESOURCE_IN_K8S_ANNOTATION, + RESOURCE_LOADED_FROM_RESULTS_ANNOTATION, +} from '../../../../const'; import { PipelineRunModel } from '../../../../models'; import { PipelineKind, @@ -113,8 +117,8 @@ export const getPipelineRunData = ( delete annotations['results.tekton.dev/log']; delete annotations['results.tekton.dev/record']; delete annotations['results.tekton.dev/result']; - delete annotations['resource.deleted.in.k8s']; - delete annotations['resource.loaded.from.tektonResults']; + delete annotations[DELETED_RESOURCE_IN_K8S_ANNOTATION]; + delete annotations[RESOURCE_LOADED_FROM_RESULTS_ANNOTATION]; const newPipelineRun = { apiVersion: pipeline ? pipeline.apiVersion : latestRun.apiVersion, diff --git a/frontend/packages/pipelines-plugin/src/components/repository/RepositoryPipelineRunRow.tsx b/frontend/packages/pipelines-plugin/src/components/repository/RepositoryPipelineRunRow.tsx index e1fe186040c..ca5a5c70554 100644 --- a/frontend/packages/pipelines-plugin/src/components/repository/RepositoryPipelineRunRow.tsx +++ b/frontend/packages/pipelines-plugin/src/components/repository/RepositoryPipelineRunRow.tsx @@ -10,6 +10,7 @@ import { ExternalLink, } from '@console/internal/components/utils'; import { referenceForModel } from '@console/internal/module/k8s'; +import { DELETED_RESOURCE_IN_K8S_ANNOTATION } from '../../const'; import * as SignedPipelinerunIcon from '../../images/signed-badge.svg'; import { PipelineRunModel } from '../../models'; import { PipelineRunKind, TaskRunKind } from '../../types'; @@ -78,7 +79,7 @@ const RepositoryPipelineRunRow: React.FC> = ({
) : null} - {obj?.metadata?.annotations?.['resource.deleted.in.k8s'] === 'true' ? ( + {obj?.metadata?.annotations?.[DELETED_RESOURCE_IN_K8S_ANNOTATION] === 'true' ? (
diff --git a/frontend/packages/pipelines-plugin/src/components/taskruns/TaskRunDetailsPage.tsx b/frontend/packages/pipelines-plugin/src/components/taskruns/TaskRunDetailsPage.tsx index 4fe4f077c57..45fd423bd47 100644 --- a/frontend/packages/pipelines-plugin/src/components/taskruns/TaskRunDetailsPage.tsx +++ b/frontend/packages/pipelines-plugin/src/components/taskruns/TaskRunDetailsPage.tsx @@ -4,6 +4,10 @@ import { ArchiveIcon } from '@patternfly/react-icons'; import { useTranslation } from 'react-i18next'; import { DetailsPage, DetailsPageProps } from '@console/internal/components/factory'; import { navFactory, viewYamlComponent } from '@console/internal/components/utils'; +import { + DELETED_RESOURCE_IN_K8S_ANNOTATION, + RESOURCE_LOADED_FROM_RESULTS_ANNOTATION, +} from '../../const'; import { TaskRunKind } from '../../types'; import { usePipelineTechPreviewBadge } from '../../utils/hooks'; import { useTaskRun } from '../pipelineruns/hooks/usePipelineRuns'; @@ -24,7 +28,8 @@ const TaskRunDetailsPage: React.FC = (props) => { return (
{obj?.metadata?.name}{' '} - {obj?.metadata?.annotations?.['resource.deleted.in.k8s'] === 'true' && ( + {(obj?.metadata?.annotations?.[DELETED_RESOURCE_IN_K8S_ANNOTATION] === 'true' || + obj?.metadata?.annotations?.[RESOURCE_LOADED_FROM_RESULTS_ANNOTATION] === 'true') && ( diff --git a/frontend/packages/pipelines-plugin/src/components/taskruns/list-page/TaskRunsRow.tsx b/frontend/packages/pipelines-plugin/src/components/taskruns/list-page/TaskRunsRow.tsx index 8b4b2d9374e..357200ee128 100644 --- a/frontend/packages/pipelines-plugin/src/components/taskruns/list-page/TaskRunsRow.tsx +++ b/frontend/packages/pipelines-plugin/src/components/taskruns/list-page/TaskRunsRow.tsx @@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next'; import { TableData, RowFunctionArgs } from '@console/internal/components/factory'; import { ResourceLink, Timestamp } from '@console/internal/components/utils'; import { referenceForModel } from '@console/internal/module/k8s'; +import { DELETED_RESOURCE_IN_K8S_ANNOTATION } from '../../../const'; import { TaskRunModel, PipelineModel } from '../../../models'; import { TaskRunKind } from '../../../types'; import { getTaskRunKebabActions } from '../../../utils/pipeline-actions'; @@ -34,7 +35,7 @@ const TaskRunsRow: React.FC> = ({ obj, customData } data-test-id={obj.metadata.name} nameSuffix={ <> - {obj?.metadata?.annotations?.['resource.deleted.in.k8s'] === 'true' ? ( + {obj?.metadata?.annotations?.[DELETED_RESOURCE_IN_K8S_ANNOTATION] === 'true' ? (
diff --git a/frontend/packages/pipelines-plugin/src/const.ts b/frontend/packages/pipelines-plugin/src/const.ts index 0f0b0188f0b..0ec7f37d390 100644 --- a/frontend/packages/pipelines-plugin/src/const.ts +++ b/frontend/packages/pipelines-plugin/src/const.ts @@ -8,3 +8,5 @@ export const PIPELINE_STRATEGY_LABEL = 'pipeline.openshift.io/strategy'; export const PREFERRED_DEV_PIPELINE_PAGE_TAB_USER_SETTING_KEY = 'pipeline.preferredPipelinePageTab'; export const FUNC_PIPELINE_RUNTIME_LABEL = 'function.knative.dev/runtime'; export const ARTIFACTHUB_API_BASE_URL = 'https://artifacthub.io/api/v1'; +export const DELETED_RESOURCE_IN_K8S_ANNOTATION = 'resource.deleted.in.k8s'; +export const RESOURCE_LOADED_FROM_RESULTS_ANNOTATION = 'resource.loaded.from.tektonResults'; diff --git a/frontend/packages/pipelines-plugin/src/utils/pipeline-actions.tsx b/frontend/packages/pipelines-plugin/src/utils/pipeline-actions.tsx index 0152b2b45dd..7d9623eeae5 100644 --- a/frontend/packages/pipelines-plugin/src/utils/pipeline-actions.tsx +++ b/frontend/packages/pipelines-plugin/src/utils/pipeline-actions.tsx @@ -19,6 +19,7 @@ import { } from '../components/pipelines/modals'; import { getPipelineRunData } from '../components/pipelines/modals/common/utils'; import { getTaskRunsOfPipelineRun } from '../components/taskruns/useTaskRuns'; +import { RESOURCE_LOADED_FROM_RESULTS_ANNOTATION } from '../const'; import { EventListenerModel, PipelineModel, PipelineRunModel, TaskRunModel } from '../models'; import { PipelineKind, PipelineRunKind, TaskRunKind } from '../types'; import { shouldHidePipelineRunStop, shouldHidePipelineRunCancel } from './pipeline-augment'; @@ -179,7 +180,8 @@ export const deleteResourceObj: KebabAction = ( resourceObj?.metadata?.annotations?.['results.tekton.dev/log'] || resourceObj?.metadata?.annotations?.['results.tekton.dev/record'] || resourceObj?.metadata?.annotations?.['results.tekton.dev/result']; - const isResourceDeletedInK8s = resourceObj?.metadata?.annotations?.['resource.deleted.in.k8s']; + const isResourceLoadedFromTR = + resourceObj?.metadata?.annotations?.[RESOURCE_LOADED_FROM_RESULTS_ANNOTATION]; const message = (

@@ -196,11 +198,11 @@ export const deleteResourceObj: KebabAction = ( deleteModal({ kind, resource: resourceObj, - message: !isResourceDeletedInK8s && tektonResultsFlag ? message : '', + message: !isResourceLoadedFromTR && tektonResultsFlag ? message : '', }), accessReview: asAccessReview(kind, resourceObj, 'delete'), - isDisabled: !!isResourceDeletedInK8s, - tooltip: isResourceDeletedInK8s + isDisabled: !!isResourceLoadedFromTR, + tooltip: isResourceLoadedFromTR ? i18n.t('pipelines-plugin~Resource is being fetched from Tekton Results.') : '', };