<commit_before>// @flow

import type {Project} from '../stores/ProjectSearchStore.js';

import ProjectAPIUtils from '../utils/ProjectAPIUtils.js';
import ProjectCard from '../componentsBySection/FindProjects/ProjectCard.jsx';
import React from 'react';

type State = {|
  projects: $ReadOnlyArray<Project>,
|};

class MyProjectsController extends React.PureComponent<{||}, State> {

  constructor(): void {
    super();
    this.state = {
      projects: [],
    };
  }

  componentWillMount(): void {
    const xhr = new XMLHttpRequest();
    xhr.addEventListener(
      'load',
      () =>
        this.setState({
          projects: JSON.parse(xhr.response)
            .map(ProjectAPIUtils.projectFromAPIData)}),
    );
    xhr.open('GET', '/api/my_projects');
    xhr.send();
  }

  render(): React$Node {
    return (
      <div>
        <div>
          My Projects | Applications
        </div>
        <div>
          {this.state.projects.map(project => {
            return <ProjectCard key={project.name} project={project} />;
          })}
        </div>
      </div>
    );
  }
}

export default MyProjectsController;<commit_msg>for beta release, only show projects owned projects; change request to XHR to preserve session cookie<commit_after>// @flow

import type {Project} from '../stores/ProjectSearchStore.js';

import ProjectAPIUtils from '../utils/ProjectAPIUtils.js';
import MyProjectCard from '../componentsBySection/MyProjects/MyProjectCard.jsx';
import React from 'react';

type State = {|
  projects: $ReadOnlyArray<Project>,
|};

class MyProjectsController extends React.PureComponent<{||}, State> {

  constructor(): void {
    super();
    this.state = {
      projects: [],
    };
  }

  componentWillMount(): void {
    const xhr = new XMLHttpRequest();
    xhr.addEventListener(
      'load',
      () =>
        this.setState({
          projects: JSON.parse(xhr.response)
            .map(ProjectAPIUtils.projectFromAPIData)}),
    );
    xhr.open('GET', '/api/my_projects');
    xhr.send();
  }

  render(): React$Node {
    return (
      <div>
        <div>
          {this.state.projects.map(project => {
            return <MyProjectCard key={project.name} project={project} />;
          })}
        </div>
      </div>
    );
  }
}

export default MyProjectsController;
{'fraction_non_alphanumeric': 0.14731369150779897, 'fraction_numerical': 0.0, 'mean_word_length': 2.6248037676609104, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '931915', 'n_tokens_mistral': 694, 'n_tokens_neox': 686, 'n_words': 145}