<commit_before>import { module } from 'angular';

import { APPLICATION_STATE_PROVIDER, ApplicationStateProvider } from 'core/application/application.state.provider';
import { SETTINGS } from 'core/config';
import { INestedState } from 'core/navigation/state.provider';

import { Environments } from './Environments';
import { featureFlag } from './Environments2';
import { Configuration } from './config/Configuration';
import { EnvironmentsOverview } from './overview/EnvironmentsOverview';

export type Routes = 'overview' | 'config';

const routes: Array<INestedState & { name: Routes }> = [
  {
    name: 'overview',
    url: '/overview',
    component: EnvironmentsOverview,
    $type: 'react',
    children: [],
  },
  {
    name: 'config',
    url: '/config',
    component: Configuration,
    $type: 'react',
    children: [],
  },
];

export const MANAGED_STATES = 'spinnaker.core.managed.states';
module(MANAGED_STATES, [APPLICATION_STATE_PROVIDER]).config([
  'applicationStateProvider',
  (applicationStateProvider: ApplicationStateProvider) => {
    if (SETTINGS.feature.managedDelivery) {
      const artifactVersion: INestedState = {
        name: 'artifactVersion',
        url: '/{reference}/{version}',
        params: {
          reference: { dynamic: true },
          version: { dynamic: true },
        },
        children: [],
      };

      const environments: INestedState = {
        name: 'environments',
        url: '/environments?{new_ui:query}',
        views: {
          insight: { component: Environments, $type: 'react' },
        },
        data: {
          pageTitleSection: {
            title: 'Environments',
          },
        },
        params: {
          new_ui: localStorage.getItem(featureFlag),
        },
        children: [artifactVersion, ...routes],
        redirectTo: (transition) => {
          const { new_ui } = transition.params();
          localStorage.setItem(featureFlag, '1');

          if (new_ui) {
            return 'home.applications.application.environments.overview';
          }
          return undefined;
        },
      };

      applicationStateProvider.addChildState(environments);
    }
  },
]);<commit_msg>fix(md): check if should use the new ui (#9179)<commit_after>import { module } from 'angular';

import { APPLICATION_STATE_PROVIDER, ApplicationStateProvider } from 'core/application/application.state.provider';
import { SETTINGS } from 'core/config';
import { INestedState } from 'core/navigation/state.provider';

import { Environments } from './Environments';
import { featureFlag } from './Environments2';
import { Configuration } from './config/Configuration';
import { EnvironmentsOverview } from './overview/EnvironmentsOverview';

export type Routes = 'overview' | 'config';

const routes: Array<INestedState & { name: Routes }> = [
  {
    name: 'overview',
    url: '/overview',
    component: EnvironmentsOverview,
    $type: 'react',
    children: [],
  },
  {
    name: 'config',
    url: '/config',
    component: Configuration,
    $type: 'react',
    children: [],
  },
];

export const MANAGED_STATES = 'spinnaker.core.managed.states';
module(MANAGED_STATES, [APPLICATION_STATE_PROVIDER]).config([
  'applicationStateProvider',
  (applicationStateProvider: ApplicationStateProvider) => {
    if (SETTINGS.feature.managedDelivery) {
      const artifactVersion: INestedState = {
        name: 'artifactVersion',
        url: '/{reference}/{version}',
        params: {
          reference: { dynamic: true },
          version: { dynamic: true },
        },
        children: [],
      };

      const environments: INestedState = {
        name: 'environments',
        url: '/environments?{new_ui:query}',
        views: {
          insight: { component: Environments, $type: 'react' },
        },
        data: {
          pageTitleSection: {
            title: 'Environments',
          },
        },
        params: {
          new_ui: localStorage.getItem(featureFlag),
        },
        children: [artifactVersion, ...routes],
        redirectTo: (transition) => {
          const { new_ui } = transition.params();
          localStorage.setItem(featureFlag, '1');

          if (new_ui === '1') {
            return 'home.applications.application.environments.overview';
          }
          return undefined;
        },
      };

      applicationStateProvider.addChildState(environments);
    }
  },
]);
{'fraction_non_alphanumeric': 0.13687782805429866, 'fraction_numerical': 0.0020361990950226246, 'mean_word_length': 2.6934001670843775, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3628111', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1226, 'n_words': 257}