message: Add namespace label selector to namespace dashboard links
diff: @@ -3,7 +3,7 @@ import * as _ from 'lodash-es';
  import Dashboard from '@console/shared/src/components/dashboard/Dashboard';
  import DashboardGrid from '@console/shared/src/components/dashboard/DashboardGrid';
  -import { K8sResourceKind } from '../../../module/k8s';
  +import { K8sResourceKind, LabelSelector, Selector } from '../../../module/k8s';
  import { DetailsCard } from './details-card';
  import { StatusCard } from './status-card';
  import { UtilizationCard } from './utilization-card';
  @@ -26,13 +26,29 @@ const getNamespaceDashboardConsoleLinks = (
  ns: K8sResourceKind,
  consoleLinks: K8sResourceKind[],
  ): K8sResourceKind[] => {
  - return _.filter(consoleLinks, (link: K8sResourceKind) => {
  + return _.filter(
  + consoleLinks,
  + (link: K8sResourceKind): boolean => {
  if (link.spec.location !== 'NamespaceDashboard') {
  return false;
  }
  - const namespaces: string[] = _.get(link, ['spec', 'namespaceDashboard', 'namespaces']);
  - return _.isEmpty(namespaces) || _.includes(namespaces, ns.metadata.name);
  - });
  +
  + const namespaces: string[] = _.get(link, 'spec.namespaceDashboard.namespaces');
  + const selector: Selector = _.get(link, 'spec.namespaceDashboard.namespaceSelector');
  +
  + // If neither namespaces or selector was provided, show the link for all namespaces.
  + if (_.isEmpty(namespaces) && _.isEmpty(selector)) {
  + return true;
  + }
  +
  + // Show the link if either namespaces or the selector matches this namespace.
  + if (_.includes(namespaces, ns.metadata.name)) {
  + return true;
  + }
  +
  + return !_.isEmpty(selector) && new LabelSelector(selector).matches(ns);
  + },
  + );
  };
  const ProjectDashboard_: React.FC<ProjectDashboardReduxProps & ProjectDashboardProps> = ({
  