<commit_before>import React, { Component } from 'react';
import { Link } from 'react-router';
import { shortUUID } from './uuid'

export class NomadLink extends Component {
    render() {
        const short = this.props.short === 'true'

        let children = this.props.children
        let linkProps = Object.assign({}, this.props)
        Object.keys(linkProps).filter(_ => {return _.endsWith('Id')}).forEach(k => {
            delete linkProps[k]
        })
        delete linkProps['short']

        // member
        if (this.props.memberId !== undefined) {
            const memberId = this.props.memberId
            if (children === undefined) {
                children = short ? shortUUID(memberId) : memberId
            }
            return (
                <Link {...linkProps} to={`/members/${memberId}`}>{children}</Link>
            )
        }

        // node
        if (this.props.nodeId !== undefined) {
            const nodeId = this.props.nodeId
            if (children === undefined) {
                children = short ? shortUUID(nodeId) : nodeId
            }
            return (
                <Link {...linkProps} to={`/nodes/${nodeId}`}>{children}</Link>
            )
        }

        // eval
        if (this.props.evalId !== undefined) {
            const evalId = this.props.evalId
            if (children === undefined) {
                children = short ? shortUUID(evalId) : evalId
            }
            return (
                <Link {...linkProps} to={`/evaluations/${evalId}`}>{children}</Link>
            )
        }

        // alloc
        if (this.props.allocId !== undefined) {
            const allocId = this.props.allocId
            if (children === undefined) {
                children = short ? shortUUID(allocId) : allocId
            }
            return (
                <Link {...linkProps} to={`/allocations/${allocId}`}>{children}</Link>
            )
        }

        // tasks
        if (this.props.taskId !== undefined) {
            if (this.props.jobId !== undefined && this.props.taskGroupId !== undefined) {
                const jobId = this.props.jobId
                const taskGroupId = this.props.taskGroupId
                const taskId = this.props.taskId

                if (children === undefined) {
                    children = short ? shortUUID(taskId) : taskId
                }
                return (
                    <Link {...linkProps} to={`/jobs/${jobId}/tasks`}
                                         query={{taskGroupId: taskGroupId, taskId: taskId}}>{children}</Link>
                )
            } else {
                console.error('NomadLink: You must also provide taskGroupId and jobId for task links!')
            }
        }

        // taskGroup (must be after task)
        if (this.props.taskGroupId !== undefined) {
            if (this.props.jobId !== undefined) {
                const jobId = this.props.jobId
                const taskGroupId = this.props.taskGroupId

                if (children === undefined) {
                    children = short ? shortUUID(taskGroupId) : taskGroupId
                }
                return (
                    <Link {...linkProps} to={`/jobs/${jobId}/taskGroups`}
                                         query={{taskGroupId: taskGroupId}}>{children}</Link>
                )
            } else {
                console.error('NomadLink: You must also provide jobId for taskGroup links!')
            }
        }

        // job (must be after task & taskGroup
        if (this.props.jobId !== undefined) {
            const jobId = this.props.jobId

            if (children === undefined) {
                children = short ? shortUUID(jobId) : jobId
            }
            return (
                <Link {...linkProps} to={`/jobs/${jobId}`}>{children}</Link>
            )
        }

        // nothing by default
        return null
    }
}
<commit_msg>Small import fix.<commit_after>import React, { Component } from 'react';
import { Link } from 'react-router';
import shortUUID from './uuid'

export class NomadLink extends Component {
    render() {
        const short = this.props.short === 'true'

        let children = this.props.children
        let linkProps = Object.assign({}, this.props)
        Object.keys(linkProps).filter(_ => {return _.endsWith('Id')}).forEach(k => {
            delete linkProps[k]
        })
        delete linkProps['short']

        // member
        if (this.props.memberId !== undefined) {
            const memberId = this.props.memberId
            if (children === undefined) {
                children = short ? shortUUID(memberId) : memberId
            }
            return (
                <Link {...linkProps} to={`/members/${memberId}`}>{children}</Link>
            )
        }

        // node
        if (this.props.nodeId !== undefined) {
            const nodeId = this.props.nodeId
            if (children === undefined) {
                children = short ? shortUUID(nodeId) : nodeId
            }
            return (
                <Link {...linkProps} to={`/nodes/${nodeId}`}>{children}</Link>
            )
        }

        // eval
        if (this.props.evalId !== undefined) {
            const evalId = this.props.evalId
            if (children === undefined) {
                children = short ? shortUUID(evalId) : evalId
            }
            return (
                <Link {...linkProps} to={`/evaluations/${evalId}`}>{children}</Link>
            )
        }

        // alloc
        if (this.props.allocId !== undefined) {
            const allocId = this.props.allocId
            if (children === undefined) {
                children = short ? shortUUID(allocId) : allocId
            }
            return (
                <Link {...linkProps} to={`/allocations/${allocId}`}>{children}</Link>
            )
        }

        // tasks
        if (this.props.taskId !== undefined) {
            if (this.props.jobId !== undefined && this.props.taskGroupId !== undefined) {
                const jobId = this.props.jobId
                const taskGroupId = this.props.taskGroupId
                const taskId = this.props.taskId

                if (children === undefined) {
                    children = short ? shortUUID(taskId) : taskId
                }
                return (
                    <Link {...linkProps} to={`/jobs/${jobId}/tasks`}
                                         query={{taskGroupId: taskGroupId, taskId: taskId}}>{children}</Link>
                )
            } else {
                console.error('NomadLink: You must also provide taskGroupId and jobId for task links!')
            }
        }

        // taskGroup (must be after task)
        if (this.props.taskGroupId !== undefined) {
            if (this.props.jobId !== undefined) {
                const jobId = this.props.jobId
                const taskGroupId = this.props.taskGroupId

                if (children === undefined) {
                    children = short ? shortUUID(taskGroupId) : taskGroupId
                }
                return (
                    <Link {...linkProps} to={`/jobs/${jobId}/taskGroups`}
                                         query={{taskGroupId: taskGroupId}}>{children}</Link>
                )
            } else {
                console.error('NomadLink: You must also provide jobId for taskGroup links!')
            }
        }

        // job (must be after task & taskGroup
        if (this.props.jobId !== undefined) {
            const jobId = this.props.jobId

            if (children === undefined) {
                children = short ? shortUUID(jobId) : jobId
            }
            return (
                <Link {...linkProps} to={`/jobs/${jobId}`}>{children}</Link>
            )
        }

        // nothing by default
        return null
    }
}

{'fraction_non_alphanumeric': 0.12636525273050547, 'fraction_numerical': 0.0, 'mean_word_length': 1.367708959711365, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1643705', 'n_tokens_mistral': 2063, 'n_tokens_neox': 2016, 'n_words': 446}