<commit_before>import React from 'react'
import DocsBrowser from 'tocco-docs-browser/src/main'

import {ListLink, DetailLink} from '../entities/utils/navigationStrategy'

const DocsBrowserApp = props => (
  <DocsBrowser {...props} navigationStrategy={{
    ListLink,
    DetailLink
  }}/>
)
<commit_msg>refactor(admin): adjust docs navigation Strategy<commit_after>import React from 'react'
import PropTypes from 'prop-types'
import DocsBrowser from 'tocco-docs-browser/src/main'
import {AdminLink as StyledLink} from 'tocco-ui'
import queryString from 'query-string'

import {DetailLink} from '../entities/utils/navigationStrategy'

export const ListLink = ({entityName, entityKeys, children}) => {
  const rootNodes = entityKeys.map(key => ({entityName, key}))
  return <StyledLink to={`/docs?rootNodes=${JSON.stringify(rootNodes)}`} target="_blank">{children}</StyledLink>
}

ListLink.propTypes = {
  entityName: PropTypes.string.isRequired,
  children: PropTypes.any.isRequired,
  entityKeys: PropTypes.arrayOf(PropTypes.string)
}

const DocsBrowserApp = props => {
  const queryParams = queryString.parse(props.history.location.search)

  return <DocsBrowser
    {...props}
    navigationStrategy={{
      ListLink,
      DetailLink
    }}
    {...queryParams.rootNodes && {rootNodes: JSON.parse(queryParams.rootNodes)}}
/>
}

DocsBrowserApp.propTypes = {
  history: PropTypes.object.isRequired
}

{'fraction_non_alphanumeric': 0.13195435092724678, 'fraction_numerical': 0.0, 'mean_word_length': 4.995726495726496, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '5512136', 'n_tokens_mistral': 432, 'n_tokens_neox': 429, 'n_words': 91}