<commit_before>import * as React from 'react';
import { get, upperFirst } from 'lodash';
import {
  IExecutionDetailsSectionProps,
  ExecutionDetailsSection,
  StageFailureMessage,
  IManifest,
} from '@spinnaker/core';
import { KubernetesManifestService } from '../../../../manifest/manifest.service';
import { ManifestStatus } from './ManifestStatus';

interface IManifestSubscription {
  id: string;
  unsubscribe: () => void;
  manifest: IManifest;
}

interface IStageManifest {
  kind: string;
  metadata: {
    namespace: string;
    name: string;
  };
}

interface IDeployStatusState {
  subscriptions: IManifestSubscription[];
}

export class DeployStatus extends React.Component<IExecutionDetailsSectionProps, IDeployStatusState> {
  public static title = 'deployStatus';

  constructor(props: IExecutionDetailsSectionProps) {
    super(props);
    this.state = { subscriptions: [] };
  }

  public componentDidMount() {
    this.buildSubscriptions();
  }

  public componentDidUpdate() {
    this.buildSubscriptions();
  }

  private buildSubscriptions() {
    const subscriptions: IManifestSubscription[] = [];
    const stageManifests = this.getStageManifests();
    stageManifests.forEach(m => {
      const subscription = this.subscribeToManifest(m);
      if (subscription != null) {
        subscriptions.push(subscription);
      }
    });
    if (subscriptions.length > 0) {
      this.setState({ subscriptions });
    }
  }

  public componentWillUnmount() {
    this.state.subscriptions.forEach(({ unsubscribe }) => unsubscribe());
  }

  private manifestIdentifier(manifest: IStageManifest) {
    const kind = manifest.kind.toLowerCase();
    const namespace = manifest.metadata.namespace.toLowerCase();
    const name = manifest.metadata.name.toLowerCase();
    return `${namespace} ${kind} ${name}`;
  }

  private findSubscriptionIndex({ id }: { id: string }): number {
    return this.state.subscriptions.findIndex(sub => sub.id === id);
  }

  private manifestFullName(manifest: any): string {<commit_msg>fix(provider/kubernetes): manifest.metadata.namespace can be null-ish (#5399)<commit_after>import * as React from 'react';
import { get, upperFirst } from 'lodash';
import {
  IExecutionDetailsSectionProps,
  ExecutionDetailsSection,
  StageFailureMessage,
  IManifest,
} from '@spinnaker/core';
import { KubernetesManifestService } from '../../../../manifest/manifest.service';
import { ManifestStatus } from './ManifestStatus';

interface IManifestSubscription {
  id: string;
  unsubscribe: () => void;
  manifest: IManifest;
}

interface IStageManifest {
  kind: string;
  metadata: {
    namespace: string;
    name: string;
  };
}

interface IDeployStatusState {
  subscriptions: IManifestSubscription[];
}

export class DeployStatus extends React.Component<IExecutionDetailsSectionProps, IDeployStatusState> {
  public static title = 'deployStatus';

  constructor(props: IExecutionDetailsSectionProps) {
    super(props);
    this.state = { subscriptions: [] };
  }

  public componentDidMount() {
    this.buildSubscriptions();
  }

  public componentDidUpdate() {
    this.buildSubscriptions();
  }

  private buildSubscriptions() {
    const subscriptions: IManifestSubscription[] = [];
    const stageManifests = this.getStageManifests();
    stageManifests.forEach(m => {
      const subscription = this.subscribeToManifest(m);
      if (subscription != null) {
        subscriptions.push(subscription);
      }
    });
    if (subscriptions.length > 0) {
      this.setState({ subscriptions });
    }
  }

  public componentWillUnmount() {
    this.state.subscriptions.forEach(({ unsubscribe }) => unsubscribe());
  }

  private manifestIdentifier(manifest: IStageManifest) {
    const kind = manifest.kind.toLowerCase();
    // manifest.metadata.namespace doesn't exist if it's a namespace being deployed
    const namespace = (manifest.metadata.namespace || '').toLowerCase();
    const name = manifest.metadata.name.toLowerCase();
    return `${namespace} ${kind} ${name}`;
  }

  private findSubscriptionIndex({ id }: { id: string }): number {
    return this.state.subscriptions.findIndex(sub => sub.id === id);
  }

  private manifestFullName(manifest: any): string {
{'fraction_non_alphanumeric': 0.12612612612612611, 'fraction_numerical': 0.001422475106685633, 'mean_word_length': 4.10774818401937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5633180', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1197, 'n_words': 261}