<commit_before>import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { compose } from 'recompose';
import { provideUser } from 'stateProviders';
import { injectState } from 'freactal';

import Login from 'components/Login';
import Users from 'components/Users';
import Groups from 'components/Groups';
import Applications from 'components/Applications';
import NoAccess from 'components/NoAccess';
import Nav from 'components/Nav';

const enhance = compose(provideUser);

const ProtectedRoute = injectState(({ renderLogin, component, state, ...rest }) => (
  <Route {...rest} component={state.token ? component : renderLogin && Login} />
));

class App extends React.Component<any, any> {
  render() {
    return (
      <Router>
        <div style={{ height: '100%', display: 'flex' }}>
          <ProtectedRoute path="/(users|groups|apps)/:id?" exact component={Nav} />
          <Switch>
            <Route path="/" exact component={Login} />
            <ProtectedRoute path="/users/:id?" component={Users} renderLogin />
            <ProtectedRoute path="/groups/:id?" component={Groups} renderLogin />
            <ProtectedRoute path="/apps/:id?" component={Applications} renderLogin />
            <Route path="/no-access" exact component={NoAccess} />
          </Switch>
        </div>
      </Router>
    );
  }
}

export default enhance(App);<commit_msg>update routes to handle subresources<commit_after>import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { compose } from 'recompose';
import { provideUser } from 'stateProviders';
import { injectState } from 'freactal';

import Login from 'components/Login';
import Users from 'components/Users';
import Groups from 'components/Groups';
import Applications from 'components/Applications';
import NoAccess from 'components/NoAccess';
import Nav from 'components/Nav';

const enhance = compose(provideUser);

const ProtectedRoute = injectState(({ renderLogin, component, state, ...rest }) => (
  <Route {...rest} component={state.token ? component : renderLogin && Login} />
));

class App extends React.Component<any, any> {
  render() {
    return (
      <Router>
        <div style={{ height: '100%', display: 'flex' }}>
          <ProtectedRoute
            path="/(users|groups|apps)/:id?/:subResourceType?/:subResourceId?"
            exact
            component={Nav}
          />
          <Switch>
            <Route path="/" exact component={Login} />
            <ProtectedRoute
              path="/users/:id?/:subResourceType?/:subResourceId?"
              component={Users}
              renderLogin
            />
            <ProtectedRoute
              path="/groups/:id?/:subResourceType?/:subResourceId?"
              component={Groups}
              renderLogin
            />
            <ProtectedRoute
              path="/apps/:id?/:subResourceType?/:subResourceId?"
              component={Applications}
              renderLogin
            />
            <Route path="/no-access" exact component={NoAccess} />
          </Switch>
        </div>
      </Router>
    );
  }
}

export default enhance(App);
{'fraction_non_alphanumeric': 0.14023060143346838, 'fraction_numerical': 0.001869741352446245, 'mean_word_length': 2.7898465171192446, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, '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': '5027626', 'n_tokens_mistral': 854, 'n_tokens_neox': 849, 'n_words': 221}