<commit_before>
<link rel="import" href="cr-butterbar.html">
<link rel="import" href="cr-button.html">
<link rel="import" href="cr-issue-editor.html">
<link rel="import" href="cr-toolbar.html">

<polymer-element name="cr-issue-publish-dialog" attributes="issue">
    <template>
        <link rel="stylesheet" href="common.css">
        <style>
            #dialog {
                max-width: 800px;
                width: 100%;
                padding: 0;
                border: 1px solid #ccc;
                box-shadow: 0 0 5px 3px rgba(0, 0, 0, 0.2);
                top: 100px;
                color: #222;
            }

            h1 {
                -webkit-user-select: none;
                cursor: default;
            }

            label {
                -webkit-user-select: none;
            }

            .issue-publish-label {
                font-weight: bold;
                color: #959595;
                -webkit-user-select: none;
                cursor: default;
            }

            .issue-publish-field,
            .issue-publish-label {
                padding: 0.5em 16px;
            }
        </style>

        <dialog id="dialog" on-cancel="{{ cancel }}">
            <cr-butterbar message="{{ butterbarMessage }}"></cr-butterbar>

            <h1>Publish Comments</h1>

            <cr-issue-editor
                id="editor"
                fields="cc reviewers"
                issue="{{ issue }}"
                errors="{{ errors }}"
                disabled?="{{ saving }}"></cr-issue-editor>

            <fieldset class="issue-publish-fields" disabled?="{{ sending }}">
                <label class="issue-publish-label" for="message">Message</label>
                <div class="issue-publish-field">
                    <textarea id="message" value="{{ message }}" rows="20"></textarea>
                </div>
            </fieldset>

            <cr-toolbar>
                <cr-button primary on-tap="{{ send }}">Send</cr-button>
                <cr-button  on-tap="{{ sendAndCommit }}">Send + CQ</cr-button>
                <cr-button on-tap="{{ cancel }}">Cancel</cr-button>
            </cr-toolbar>
        </dialog>
    </template>
    <script>
        Polymer("cr-issue-publish-dialog", {
            issue: null,
            message: "",
            butterbarMessage: "",
            sending: false,
            commit: false,
            cancel: function(event) {
                if (this.$.editor.dismissAutocomplete()) {
                    event.preventDefault();
                    return;
                }
                this.close();
            },
            reset: function() {
                this.$.editor.reset();
                this.sending = false;
                this.butterbarMessage = "";
                this.message = "";
                this.$.editor.dismissAutocomplete();
            },
            close: function() {
                this.reset();
                this.$.dialog.close();
            },
            sendAndCommit: function() {
                this.send({commit: true});
            },
            send: function(options) {
                var data = this.$.editor.createEditData();
                data.message = this.message;
                data.addAsReviewer = true;
                data.publishDrafts = true;
                data.commit = options.commit;
                this.sending = true;
                this.butterbarMessage = "Saving...";
                this.issue.publish(data)
                    .then(this.saveSuccess.bind(this))
                    .catch(this.saveFailure.bind(this));
            },
            saveSuccess: function() {
                this.fire("issue-refresh");
                this.close();
            },
            saveFailure: function(error) {
                // FIXME: We should show an better error message.
                this.sending = false;
                this.butterbarMessage = "Error: " + error.message;
            },
            showModal: function() {
                if (!this.issue)
                    return;
                this.$.editor.reset();<commit_msg>Allow publishing comments and not becoming a reviewer.<commit_after>
<link rel="import" href="cr-butterbar.html">
<link rel="import" href="cr-button.html">
<link rel="import" href="cr-issue-editor.html">
<link rel="import" href="cr-toolbar.html">

<polymer-element name="cr-issue-publish-dialog" attributes="issue addAsReviewer">
    <template>
        <link rel="stylesheet" href="common.css">
        <style>
            #dialog {
                max-width: 800px;
                width: 100%;
                padding: 0;
                border: 1px solid #ccc;
                box-shadow: 0 0 5px 3px rgba(0, 0, 0, 0.2);
                top: 100px;
                color: #222;
            }

            h1 {
                -webkit-user-select: none;
                cursor: default;
            }

            label {
                -webkit-user-select: none;
            }

            .issue-publish-label {
                font-weight: bold;
                color: #959595;
                -webkit-user-select: none;
                cursor: default;
            }

            .issue-publish-field,
            .issue-publish-label {
                padding: 0.5em 16px;
            }
        </style>

        <dialog id="dialog" on-cancel="{{ cancel }}">
            <cr-butterbar message="{{ butterbarMessage }}"></cr-butterbar>

            <h1>Publish Comments</h1>

            <cr-issue-editor
                id="editor"
                fields="cc reviewers"
                issue="{{ issue }}"
                errors="{{ errors }}"
                disabled?="{{ saving }}"></cr-issue-editor>

            <fieldset class="issue-publish-fields" disabled?="{{ sending }}">
                <label class="issue-publish-label" for="message">Message</label>
                <div class="issue-publish-field">
                    <textarea id="message" value="{{ message }}" rows="20"></textarea>
                </div>
            </fieldset>

            <cr-toolbar>
                <cr-button primary on-tap="{{ send }}">Send</cr-button>
                <cr-button  on-tap="{{ sendAndCommit }}">Send + CQ</cr-button>
                <cr-button on-tap="{{ cancel }}">Cancel</cr-button>
                <label>
                    <input type="checkbox" checked="{{ addAsReviewer }}">
                    Add as reviewer
                </label>
            </cr-toolbar>
        </dialog>
    </template>
    <script>
        Polymer("cr-issue-publish-dialog", {
            issue: null,
            message: "",
            butterbarMessage: "",
            sending: false,
            addAsReviewer: true,
            cancel: function(event) {
                if (this.$.editor.dismissAutocomplete()) {
                    event.preventDefault();
                    return;
                }
                this.close();
            },
            reset: function() {
                this.$.editor.reset();
                this.sending = false;
                this.addAsReviewer = true;
                this.butterbarMessage = "";
                this.message = "";
                this.$.editor.dismissAutocomplete();
            },
            close: function() {
                this.reset();
                this.$.dialog.close();
            },
            sendAndCommit: function() {
                this.send({commit: true});
            },
            send: function(options) {
                var data = this.$.editor.createEditData();
                data.message = this.message;
                data.addAsReviewer = this.addAsReviewer;
                data.publishDrafts = true;
                data.commit = options.commit;
                this.sending = true;
                this.butterbarMessage = "Saving...";
                this.issue.publish(data)
                    .then(this.saveSuccess.bind(this))
                    .catch(this.saveFailure.bind(this));
            },
            saveSuccess: function() {
                this.fire("issue-refresh");
                this.close();
            },
            saveFailure: function(error) {
                // FIXME: We should show an better error message.
                this.sending = false;
                this.butterbarMessage = "Error: " + error.message;
            },
            showModal: function() {
                if (!this.issue)
                    return;
                this.$.editor.reset();
{'fraction_non_alphanumeric': 0.13316141132340875, 'fraction_numerical': 0.008908685968819599, 'mean_word_length': 1.2207183758459137, 'pattern_counts': {'":': 0, '<': 76, '<?xml version=': 0, '>': 76, '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': '402048', 'n_tokens_mistral': 2333, 'n_tokens_neox': 2108, 'n_words': 420}