<commit_before>// @flow
import React from 'react';
import environment from '@ncigdc/modern_components/environment';
import { commitMutation, graphql } from 'react-relay';
import JSURL from 'jsurl';
import { compose } from 'recompose';

import withRouter from '@ncigdc/utils/withRouter';
import { makeFilter } from '@ncigdc/utils/filters';

import CreateSetButtonBase from './CreateSetButtonBase';

const exploreMutation = graphql`
  mutation CreateExploreCaseSetButtonMutation(
    $input: CreateSetInput
    $never_used: RelayIsDumb
  ) {
    sets(input: $never_used) {
      create {
        explore {
          case(input: $input) {
            set_id
          }
        }
      }
    }
  }
`;

const enhance = compose(withRouter);

const CreateExploreCaseSetButton = ({ filters, setSize, style, push }) => {
  const reRouteOnCompleted = setId => {
    push({
      pathname: '/repository',
      query: {
        filters: JSURL.stringify(
          makeFilter([
            {
              field: 'cases.case_id',
              value: `set_id:${setId}`,
            },
          ]),
        ),
      },
    });
  };

  return (
    <CreateSetButtonBase
      style={style}
      field="cases.case_id"
      filters={filters}
      disabled={!setSize}
      setIdExtractor={response => response.sets.create.explore.case.set_id}
      commitMutation={(variables, onCompleted, onError) => {
        commitMutation(environment, {
          mutation: exploreMutation,
          variables,
          onCompleted,
          onError,
        });
      }}
      reRouteOnCompleted={reRouteOnCompleted}
    >
      View {setSize.toLocaleString()} {setSize === 1 ? ' Case' : ' Cases'} in
      Repository
    </CreateSetButtonBase>
  );
};

export default enhance(CreateExploreCaseSetButton);<commit_msg>✏️PRTL-1443 rename button to "View in Repository" (#1937)<commit_after>// @flow
import React from 'react';
import environment from '@ncigdc/modern_components/environment';
import { commitMutation, graphql } from 'react-relay';
import JSURL from 'jsurl';
import { compose } from 'recompose';

import withRouter from '@ncigdc/utils/withRouter';
import { makeFilter } from '@ncigdc/utils/filters';

import CreateSetButtonBase from './CreateSetButtonBase';

const exploreMutation = graphql`
  mutation CreateExploreCaseSetButtonMutation(
    $input: CreateSetInput
    $never_used: RelayIsDumb
  ) {
    sets(input: $never_used) {
      create {
        explore {
          case(input: $input) {
            set_id
          }
        }
      }
    }
  }
`;

const enhance = compose(withRouter);

const CreateExploreCaseSetButton = ({ filters, setSize, style, push }) => {
  const reRouteOnCompleted = setId => {
    push({
      pathname: '/repository',
      query: {
        filters: JSURL.stringify(
          makeFilter([
            {
              field: 'cases.case_id',
              value: `set_id:${setId}`,
            },
          ]),
        ),
      },
    });
  };

  return (
    <CreateSetButtonBase
      style={style}
      field="cases.case_id"
      filters={filters}
      disabled={!setSize}
      setIdExtractor={response => response.sets.create.explore.case.set_id}
      commitMutation={(variables, onCompleted, onError) => {
        commitMutation(environment, {
          mutation: exploreMutation,
          variables,
          onCompleted,
          onError,
        });
      }}
      reRouteOnCompleted={reRouteOnCompleted}
    >
      View in Repository
    </CreateSetButtonBase>
  );
};

export default enhance(CreateExploreCaseSetButton);
{'fraction_non_alphanumeric': 0.11876750700280111, 'fraction_numerical': 0.0025210084033613447, 'mean_word_length': 2.4941291585127203, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '3960622', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1054, 'n_words': 209}