<commit_before>import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import { Page, Table } from '@jenkins-cd/design-language';
import { i18nTranslator, ContentPageHeader, AppConfig, ShowMoreButton } from '@jenkins-cd/blueocean-core-js';
import Extensions from '@jenkins-cd/js-extensions';
import { observer } from 'mobx-react';
import debounce from 'lodash.debounce';
import { Icon } from '@jenkins-cd/react-material-icons';

import { documentTitle } from './DocumentTitle';
import CreatePipelineLink from './CreatePipelineLink';
import PipelineRowItem from './PipelineRowItem';
import { DashboardPlaceholder } from './placeholder/DashboardPlaceholder';
import updateGetParam from '../util/UpdateGetParam';

const translate = i18nTranslator('blueocean-dashboard');

@observer
export class Pipelines extends Component {
    componentWillMount() {
        this.setState({ searchText: this.getSearchText() });
    }
    
    onChange = value => {
        this.setState({ searchText: value });
        this.updateSearchText(value);
    }

    getSearchText() {
        return this.props.location.query.search ? decodeURIComponent(this.props.location.query.search) : '';
    }

    updateSearchText = debounce(value => {
        this.context.router.push(`${this.props.location.pathname}${updateGetParam('search', value, this.props.location.query)}`);
    }, 200);

    _initPager() {
        const org = this.props.params.organization ? this.props.params.organization : AppConfig.getOrganizationName();
        const searchText = this.getSearchText();

        this.pager = this.context.pipelineService.pipelinesPager(org, searchText);
    }

    render() {
        this._initPager();

        const pipelines = this.pager.data;
        const { organization, location = { } } = this.context.params;

        const orgLink = organization ?
            <Link
                to={ `organizations/${organization}` }
                query={ location.query }
            >
                { organization }
            </Link> : '';

        const showPipelineList = pipelines && pipelines.length > 0;
        const showEmptyState = !this.pager.pending && !this.getSearchText() && (!pipelines || !pipelines.length);
<commit_msg>encode search string when pushing it to the url string (#1137)<commit_after>import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import { Page, Table } from '@jenkins-cd/design-language';
import { i18nTranslator, ContentPageHeader, AppConfig, ShowMoreButton } from '@jenkins-cd/blueocean-core-js';
import Extensions from '@jenkins-cd/js-extensions';
import { observer } from 'mobx-react';
import debounce from 'lodash.debounce';
import { Icon } from '@jenkins-cd/react-material-icons';

import { documentTitle } from './DocumentTitle';
import CreatePipelineLink from './CreatePipelineLink';
import PipelineRowItem from './PipelineRowItem';
import { DashboardPlaceholder } from './placeholder/DashboardPlaceholder';
import updateGetParam from '../util/UpdateGetParam';

const translate = i18nTranslator('blueocean-dashboard');

@observer
export class Pipelines extends Component {
    componentWillMount() {
        this.setState({ searchText: this.getSearchText() });
    }
    
    onChange = value => {
        this.setState({ searchText: value });
        this.updateSearchText(value);
    }

    getSearchText() {
        return this.props.location.query.search ? decodeURIComponent(this.props.location.query.search) : '';
    }

    updateSearchText = debounce(value => {
        this.context.router.push(`${this.props.location.pathname}${updateGetParam('search', encodeURIComponent(value), this.props.location.query)}`);
    }, 200);

    _initPager() {
        const org = this.props.params.organization ? this.props.params.organization : AppConfig.getOrganizationName();
        const searchText = this.getSearchText();

        this.pager = this.context.pipelineService.pipelinesPager(org, searchText);
    }

    render() {
        this._initPager();

        const pipelines = this.pager.data;
        const { organization, location = { } } = this.context.params;

        const orgLink = organization ?
            <Link
                to={ `organizations/${organization}` }
                query={ location.query }
            >
                { organization }
            </Link> : '';

        const showPipelineList = pipelines && pipelines.length > 0;
        const showEmptyState = !this.pager.pending && !this.getSearchText() && (!pipelines || !pipelines.length);

{'fraction_non_alphanumeric': 0.13005464480874318, 'fraction_numerical': 0.004371584699453552, 'mean_word_length': 3.288659793814433, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '6643745', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1252, 'n_words': 268}