Skip to content

Commit

Permalink
update the checks for showing Archived to Tekton results icon for PLR…
Browse files Browse the repository at this point in the history
…s and TRs list and details page
  • Loading branch information
vikram-raj committed Dec 15, 2023
1 parent 5292251 commit 07b0002
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -42,7 +46,8 @@ const PipelineRunDetailsPage: React.FC<DetailsPageProps> = (props) => {
<img src={SignedPipelinerunIcon} alt={t('pipelines-plugin~Signed')} />
</Tooltip>
)}
{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') && (
<Tooltip content={t('pipelines-plugin~Archived in Tekton results')}>
<ArchiveIcon className="pipelinerun-details-page__results-indicator" />
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -62,7 +66,8 @@ const PipelineRunRow: React.FC<RowFunctionArgs<PipelineRunKind>> = ({ obj, custo
</div>
</Tooltip>
) : 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' ? (
<Tooltip content={t('pipelines-plugin~Archived in Tekton results')}>
<div className="opp-pipeline-run-list__results-indicator">
<ArchiveIcon />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Kebab
options={options}
key={resource.metadata.uid}
isDisabled={
isDisabled ??
((_.has(resource.metadata, 'deletionTimestamp') && !isResourceLoadedFromTR) ||
options.length === 0)
}
isDisabled={isDisabled ?? options.length === 0}
terminatingTooltip={
_.has(resource.metadata, 'deletionTimestamp') && !isResourceLoadedFromTR
_.has(resource.metadata, 'deletionTimestamp')
? terminatingTooltip || t('pipelines-plugin~Resource is being deleted.')
: isResourceDeletedInK8s
? t('pipelines-plugin~Resource is being fetched from Tekton Results.')
: ''
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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
? {
Expand All @@ -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,
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -78,7 +79,7 @@ const RepositoryPipelineRunRow: React.FC<RowFunctionArgs<PipelineRunKind>> = ({
</div>
</Tooltip>
) : null}
{obj?.metadata?.annotations?.['resource.deleted.in.k8s'] === 'true' ? (
{obj?.metadata?.annotations?.[DELETED_RESOURCE_IN_K8S_ANNOTATION] === 'true' ? (
<Tooltip content={t('pipelines-plugin~Archived in Tekton results')}>
<div className="opp-pipeline-run-list__results-indicator">
<ArchiveIcon />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,7 +28,8 @@ const TaskRunDetailsPage: React.FC<DetailsPageProps> = (props) => {
return (
<div className="taskrun-details-page">
{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') && (
<Tooltip content={t('pipelines-plugin~Archived in Tekton results')}>
<ArchiveIcon className="pipelinerun-details-page__results-indicator" />
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -34,7 +35,7 @@ const TaskRunsRow: React.FC<RowFunctionArgs<TaskRunKind>> = ({ 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' ? (
<Tooltip content={t('pipelines-plugin~Archived in Tekton results')}>
<div className="opp-task-run-list__results-indicator">
<ArchiveIcon />
Expand Down
2 changes: 2 additions & 0 deletions frontend/packages/pipelines-plugin/src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 = (
<p>
Expand All @@ -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.')
: '',
};
Expand Down

0 comments on commit 07b0002

Please sign in to comment.