Skip to content

Commit

Permalink
hide scale buttons in donut for Pods
Browse files Browse the repository at this point in the history
  • Loading branch information
rottencandy committed Dec 7, 2020
1 parent 7b07e5c commit 37ad641
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as _ from 'lodash';
import { TFunction } from 'i18next';
import { K8sResourceKind } from '@console/internal/module/k8s';
import { DeploymentConfigModel } from '@console/internal/models';
import { DeploymentConfigModel, PodModel } from '@console/internal/models';
import { RevisionModel } from '@console/knative-plugin';
import * as utils from '../pod-utils';
import { usePodScalingAccessStatus, podRingLabel, getFailedPods } from '../pod-ring-utils';
Expand Down Expand Up @@ -199,6 +199,14 @@ describe('usePodScalingAccessStatus', () => {
});
});

it('should return false for pods', (done) => {
obj.kind = 'Pod';
testHook(() => {
expect(usePodScalingAccessStatus(obj, PodModel, [], true)).toBe(false);
done();
});
});

it('should return false when api call returns false for a resource', (done) => {
obj.kind = 'DeploymentConfig';
testHook(() => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/packages/console-shared/src/utils/pod-ring-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export const usePodScalingAccessStatus = (
}, [pods, obj, resourceKind, impersonate, setEditable]);

const isKnativeRevision = obj.kind === 'Revision';
const isScalingAllowed = !isKnativeRevision && editable && enableScaling;
const isPod = obj.kind === 'Pod';
const isScalingAllowed = !isKnativeRevision && !isPod && editable && enableScaling;
return isScalingAllowed;
};

0 comments on commit 37ad641

Please sign in to comment.