<commit_before>AuthoringWorkspaceService.$inject = ['$location', 'superdeskFlags', 'authoring', 'lock', 'send'];
export function AuthoringWorkspaceService($location, superdeskFlags, authoring, lock, send) {
    this.item = null;
    this.action = null;
    this.state = null;

    var self = this;

    /**
     * Open item for editing
     *
     * @param {Object} item
     * @param {string} action
     */
    this.edit = function(item, action) {
        if (item) {
            authoringOpen(item._id, action || 'edit', item._type || null);
        } else {
            self.close();
        }
    };

    /**
     * Open an item in readonly mode without locking it
     *
     * @param {Object} item
     */
    this.view = function(item) {
        self.edit(item, 'view');
    };

    /**
     * Open an item - if possible for edit, otherwise read only
     *
     * @param {Object} item
     */
    this.open = function(item) {
        var _open = function (_item) {
            var actions = authoring.itemActions(_item);
            if (actions.edit) {
                this.edit(_item);
            } else {
                this.view(_item);
            }
        }.bind(this);

        if (item._type === 'ingest' || item.state === 'ingested') {
            send.one(item).then(_open);
        } else {
            _open(item);
        }
    };

    /**<commit_msg>fix(ingest): Disable doubleclick on noneditable ingested items<commit_after>AuthoringWorkspaceService.$inject = ['$location', 'superdeskFlags', 'authoring', 'lock', 'send', 'config'];
export function AuthoringWorkspaceService($location, superdeskFlags, authoring, lock, send, config) {
    this.item = null;
    this.action = null;
    this.state = null;

    var self = this;

    /**
     * Open item for editing
     *
     * @param {Object} item
     * @param {string} action
     */
    this.edit = function(item, action) {
        if (item) {
            authoringOpen(item._id, action || 'edit', item._type || null);
        } else {
            self.close();
        }
    };

    /**
     * Open an item in readonly mode without locking it
     *
     * @param {Object} item
     */
    this.view = function(item) {
        self.edit(item, 'view');
    };

    /**
     * Open an item - if possible for edit, otherwise read only
     *
     * @param {Object} item
     */
    this.open = function(item) {
        var _open = function (_item) {
            var actions = authoring.itemActions(_item);
            if (actions.edit) {
                this.edit(_item);
            } else {
                this.view(_item);
            }
        }.bind(this);

        // disable open for external ingest sources that are not editable(fetch not available)
        if (item._type === 'externalsource' && config.features.editFeaturedImage === false) {
            return;
        }

        if (item._type === 'ingest' || item.state === 'ingested') {
            send.one(item).then(_open);
        } else {
            _open(item);
        }
    };

    /**
{'fraction_non_alphanumeric': 0.13862364175172867, 'fraction_numerical': 0.0, 'mean_word_length': 1.8103607770582795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6988706', 'n_tokens_mistral': 894, 'n_tokens_neox': 875, 'n_words': 218}