Skip to content

Commit

Permalink
show edit option for only resources created via add flow
Browse files Browse the repository at this point in the history
  • Loading branch information
vikram-raj committed Feb 26, 2020
1 parent 883c693 commit c8ea1bb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { KebabOption } from '@console/internal/components/utils';
import { truncateMiddle } from '@console/internal/components/utils/truncate-middle';
import { K8sResourceKind, K8sKind } from '@console/internal/module/k8s';
import { ServiceModel } from '@console/knative-plugin';
import { RESOURCE_NAME_TRUNCATE_LENGTH } from '../const';
import { editApplicationModal } from '../components/modals';

Expand All @@ -25,8 +26,13 @@ export const ModifyApplication = (kind: K8sKind, obj: K8sResourceKind): KebabOpt
};

export const EditApplication = (model: K8sKind, obj: K8sResourceKind): KebabOption => {
const annotation =
obj.metadata.annotations && obj.metadata.annotations['openshift.io/generated-by'];
return {
label: `Edit ${truncateMiddle(obj.metadata.name, { length: RESOURCE_NAME_TRUNCATE_LENGTH })}`,
hidden:
(obj.kind !== ServiceModel.kind && !annotation) ||
(annotation && annotation !== 'OpenShiftWebConsole'),
href: `/edit/ns/${obj.metadata.namespace}?name=${obj.metadata.name}&kind=${obj.kind ||
model.kind}`,
accessReview: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ export const createOrUpdateDeployImageResources = async (
internalImageName || name,
imageStreamTag,
internalImageNamespace,
undefined,
annotations,
_.get(appResources, 'editAppResource.data'),
);
requests.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Object {
"defaultAnnotations": Object {
"app.openshift.io/vcs-ref": "master",
"app.openshift.io/vcs-uri": "https://github.com/test/repo",
"openshift.io/generated-by": "OpenShiftWebConsole",
},
"labels": Object {
"app": "test-app",
Expand Down Expand Up @@ -109,6 +110,7 @@ Object {
"annotations": Object {
"app.openshift.io/vcs-ref": "master",
"app.openshift.io/vcs-uri": "https://github.com/test/repo",
"openshift.io/generated-by": "OpenShiftWebConsole",
},
"labels": Object {
"app": "test-app",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const getAppAnnotations = (gitURL: string, gitRef: string) => {
return {
'app.openshift.io/vcs-uri': gitURL,
'app.openshift.io/vcs-ref': ref,
'openshift.io/generated-by': 'OpenShiftWebConsole',
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const getKnativeServiceDepResource = (
...labels,
...(!create && { 'serving.knative.dev/visibility': `cluster-local` }),
},
annotations,
},
spec: {
template: {
Expand Down

0 comments on commit c8ea1bb

Please sign in to comment.