<commit_before>import PropTypes from 'prop-types';
import React, { Component } from 'react';
import apiClient from 'panoptes-client/lib/api-client';

import ProjectIcon from '../../components/project-icon';
import getWorkflowsInOrder from '../../lib/get-workflows-in-order';
import WorkflowToggle from '../../components/workflow-toggle';
import LoadingIndicator from '../../components/loading-indicator';

import VersionList from './project-status/version-list';
import ExperimentalFeatures from './project-status/experimental-features';
import Toggle from './project-status/toggle';
import FeaturedProjectToggle from './featured-project-toggle';
import RedirectToggle from './project-status/redirect-toggle';
import WorkflowDefaultDialog from './workflow-default-dialog';

class ProjectStatus extends Component {
  constructor(props) {
    super(props);
    this.onChangeWorkflowLevel = this.onChangeWorkflowLevel.bind(this);
    this.getWorkflows = this.getWorkflows.bind(this);
    this.forceUpdate = this.forceUpdate.bind(this);
    this.renderWorkflows = this.renderWorkflows.bind(this);
    this.handleToggle = this.handleToggle.bind(this);
    this.getProjectAndWorkflows = this.getProjectAndWorkflows.bind(this);
    this.handleDialogCancel = this.handleDialogCancel.bind(this);
    this.handleDialogSuccess = this.handleDialogSuccess.bind(this);
    this.handleProjectStateChange = this.handleProjectStateChange.bind(this);
    this.handleFeaturedProjectChange = this.handleFeaturedProjectChange.bind(this);
    this.state = {
      dialogIsOpen: false,
      error: null,
      featuredProject: null,
      project: null,
      usedWorkflowLevels: [],
      workflows: []
    };
  }

  componentDidMount() {
    this.getFeaturedProject();
    this.getProjectAndWorkflows();
  }

  componentWillUnmount() {
    this.state.project.stopListening('change', this.forceUpdate);
  }

  onChangeWorkflowLevel(workflow, event) {
    this.setState({ error: null });
    let selected = event.target.value;
    selected = selected === 'none' ? undefined : selected;
    return workflow.update({ 'configuration.level': selected }).save()
      .then(() => this.getWorkflows())
      .catch(error => this.setState({ error }));
  }

  getFeaturedProject() {
    return apiClient.type('projects')
      .get({ featured: true })
      .then(([featuredProject]) => {
        this.setState({ featuredProject });
      });
  }

  getProject() {<commit_msg>use cards request for featured project (#4639)<commit_after>import PropTypes from 'prop-types';
import React, { Component } from 'react';
import apiClient from 'panoptes-client/lib/api-client';

import ProjectIcon from '../../components/project-icon';
import getWorkflowsInOrder from '../../lib/get-workflows-in-order';
import WorkflowToggle from '../../components/workflow-toggle';
import LoadingIndicator from '../../components/loading-indicator';

import VersionList from './project-status/version-list';
import ExperimentalFeatures from './project-status/experimental-features';
import Toggle from './project-status/toggle';
import FeaturedProjectToggle from './featured-project-toggle';
import RedirectToggle from './project-status/redirect-toggle';
import WorkflowDefaultDialog from './workflow-default-dialog';

class ProjectStatus extends Component {
  constructor(props) {
    super(props);
    this.onChangeWorkflowLevel = this.onChangeWorkflowLevel.bind(this);
    this.getWorkflows = this.getWorkflows.bind(this);
    this.forceUpdate = this.forceUpdate.bind(this);
    this.renderWorkflows = this.renderWorkflows.bind(this);
    this.handleToggle = this.handleToggle.bind(this);
    this.getProjectAndWorkflows = this.getProjectAndWorkflows.bind(this);
    this.handleDialogCancel = this.handleDialogCancel.bind(this);
    this.handleDialogSuccess = this.handleDialogSuccess.bind(this);
    this.handleProjectStateChange = this.handleProjectStateChange.bind(this);
    this.handleFeaturedProjectChange = this.handleFeaturedProjectChange.bind(this);
    this.state = {
      dialogIsOpen: false,
      error: null,
      featuredProject: null,
      project: null,
      usedWorkflowLevels: [],
      workflows: []
    };
  }

  componentDidMount() {
    this.getFeaturedProject();
    this.getProjectAndWorkflows();
  }

  componentWillUnmount() {
    this.state.project.stopListening('change', this.forceUpdate);
  }

  onChangeWorkflowLevel(workflow, event) {
    this.setState({ error: null });
    let selected = event.target.value;
    selected = selected === 'none' ? undefined : selected;
    return workflow.update({ 'configuration.level': selected }).save()
      .then(() => this.getWorkflows())
      .catch(error => this.setState({ error }));
  }

  getFeaturedProject() {
    return apiClient.type('projects')
      .get({ featured: true, cards: true })
      .then(([featuredProject]) => {
        this.setState({ featuredProject });
      });
  }

  getProject() {
{'fraction_non_alphanumeric': 0.13426488456865127, 'fraction_numerical': 0.0008100445524503848, 'mean_word_length': 4.139438085327783, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3203252', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1394, 'n_words': 266}