message: Bug fix: add RBAC check on Set Traffic Distribution button
diff: @@ -3,7 +3,11 @@ import * as _ from 'lodash';
  import { ListGroup } from 'patternfly-react';
  import { Button } from '@patternfly/react-core';
  import { K8sResourceKind, referenceForModel } from '@console/internal/module/k8s';
  -import { ResourceLink, SidebarSectionHeading } from '@console/internal/components/utils';
  +import {
  + ResourceLink,
  + SidebarSectionHeading,
  + useAccessReview,
  +} from '@console/internal/components/utils';
  import { RevisionModel } from '@console/knative-plugin';
  import { trafficModalLauncher } from '../traffic-splitting/TrafficSplittingController';
  import { ServiceModel } from '../../models';
  @@ -45,11 +49,20 @@ const RevisionsOverviewListItem: React.FC<RevisionsOverviewListItemProps> = ({
  );
  };
  -const RevisionsOverviewList: React.FC<RevisionsOverviewListProps> = ({ revisions, service }) => (
  +const RevisionsOverviewList: React.FC<RevisionsOverviewListProps> = ({ revisions, service }) => {
  + const canSetTrafficDistribution = useAccessReview({
  + group: ServiceModel.apiGroup,
  + resource: ServiceModel.plural,
  + namespace: service.metadata.namespace,
  + verb: 'update',
  + });
  +
  + return (
  <>
  <SidebarSectionHeading text="Revisions" className="revision-overview-list">
  {/* add extra check, if sidebar is opened for a knative deployment */}
  - {service.kind === ServiceModel.kind && (
  + {canSetTrafficDistribution &&
  + (service.kind === ServiceModel.kind && (
  <Button
  variant="secondary"
  onClick={() => trafficModalLauncher({ obj: service })}
  @@ -57,7 +70,7 @@ const RevisionsOverviewList: React.FC<RevisionsOverviewListProps> = ({ revisions
  >
  Set Traffic Distribution
  </Button>
  - )}
  + ))}
  </SidebarSectionHeading>
  {_.isEmpty(revisions) ? (
  <span className="text-muted">No Revisions found for this resource.</span>
  @@ -74,5 +87,6 @@ const RevisionsOverviewList: React.FC<RevisionsOverviewListProps> = ({ revisions
  )}
  </>
  );
  +};
  export default RevisionsOverviewList;
  