<commit_before>
class SecretList extends React.Component {
    constructor(props) {
        super(props)

        this.state = {
            currentFolder: props.path.split("/")
        };

        this.handleSecretCreate = this.handleSecretCreate.bind(this);
    }

    componentDidMount() {
        this.listSecrets(this.state.currentFolder)
    }

    listSecrets(newPath) {
        const path = "/v1/" + newPath.join("/") + "/"

        $.ajax({
            url: path,
            context: this,
            headers: {
                "X-Vault-Token": globalLoginToken
            },
            type: 'LIST',
            success: function(result) {
                console.info(result)
                this.setState(result)
            },
            error: function(e) {
                console.log(e);
                console.log(e.responseJSON.errors);
                this.setState({errors: e.responseJSON.errors});
            },
        });
    }

    deleteSecrets(deletePath) {
        const path = "/v1/" + deletePath

        $.ajax({
            url: path,
            context: this,
            headers: {
                "X-Vault-Token": globalLoginToken
            },
            type: 'DELETE',
            success: function() {
                this.listSecrets(this.state.currentFolder)
            },
            error: function(e) {
                console.log(e);
                console.log(e.responseJSON.errors);
            },
        });
    }

    handleSecretExpansion(path, event) {
        let newPath = this.state.currentFolder
        newPath.push(path.replace("/", ""))
        this.setState({currentFolder: newPath})
        this.listSecrets(newPath)<commit_msg>Implemented sorting of secrets. Folders first, then secrets, then aphabetically.<commit_after>
class SecretList extends React.Component {
    constructor(props) {
        super(props)

        this.state = {
            currentFolder: props.path.split("/")
        };

        this.handleSecretCreate = this.handleSecretCreate.bind(this);
    }

    componentDidMount() {
        this.listSecrets(this.state.currentFolder)
    }

    listSecrets(newPath) {
        const path = "/v1/" + newPath.join("/") + "/"

        $.ajax({
            url: path,
            context: this,
            headers: {
                "X-Vault-Token": globalLoginToken
            },
            type: 'LIST',
            success: function(result) {
                console.info(result)
                this.sortSecrets(result)
                this.setState(result)
            },
            error: function(e) {
                console.log(e);
                console.log(e.responseJSON.errors);
                this.setState({errors: e.responseJSON.errors});
            },
        });
    }

    sortSecrets(result) {
        result.data.keys.sort(
            function compare(a, b) {
                if (a.endsWith("/") && !b.endsWith("/")) {
                    return -1
                } else if (b.endsWith("/") && !a.endsWith("/")) {
                    return 1
                } else {
                    return (a > b) ? 1 : -1
                }
            }
        )
    }

    deleteSecrets(deletePath) {
        const path = "/v1/" + deletePath

        $.ajax({
            url: path,
            context: this,
            headers: {
                "X-Vault-Token": globalLoginToken
            },
            type: 'DELETE',
            success: function() {
                this.listSecrets(this.state.currentFolder)
            },
            error: function(e) {
                console.log(e);
                console.log(e.responseJSON.errors);
            },
        });
    }

    handleSecretExpansion(path, event) {
        let newPath = this.state.currentFolder
        newPath.push(path.replace("/", ""))
        this.setState({currentFolder: newPath})
        this.listSecrets(newPath)
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.0020491803278688526, 'mean_word_length': 1.3495788206979542, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 4, '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': '1301611', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1029, 'n_words': 171}