<commit_before>import { createWidget } from 'discourse/widgets/widget';
import { iconNode } from 'discourse/helpers/fa-icon';
import { h } from 'virtual-dom';

function renderIcon(name, key, canAct) {
  const iconArgs = key === 'unpinned' ? { 'class': 'unpinned' } : null,
        icon = iconNode(name, iconArgs);

  const attributes = { title: Discourse.Utilities.escapeExpression(I18n.t(`topic_statuses.${key}.help`)) };
  return h(`${canAct ? 'a' : 'span'}.topic-status`, attributes, icon);
}

export default createWidget('topic-status', {
  html(attrs) {
    const topic = attrs.topic;
    const canAct = this.currentUser && !attrs.disableActions;

    const result = [];
    const renderIconIf = (conditionProp, name, key) => {
      if (!topic.get(conditionProp)) { return; }
      result.push(renderIcon(name, key, canAct));
    };

    renderIconIf('is_warning', 'envelope', 'warning');

    if (topic.get('closed') && topic.get('archived')) {
      renderIcon('lock', 'locked_and_archived');
    } else {
      renderIconIf('topic.closed', 'lock', 'locked');
      renderIconIf('topic.archived', 'lock', 'archived');
    }

    renderIconIf('topic.pinned', 'thumb-tack', 'pinned');
    renderIconIf('topic.unpinned', 'thumb-tack', 'unpinned');
    renderIconIf('topic.invisible', 'eye-slash', 'invisible');

    return result;
  }
});
<commit_msg>FIX: Missing topic status icons in header<commit_after>import { createWidget } from 'discourse/widgets/widget';
import { iconNode } from 'discourse/helpers/fa-icon';
import { h } from 'virtual-dom';

function renderIcon(name, key, canAct) {
  const iconArgs = key === 'unpinned' ? { 'class': 'unpinned' } : null,
        icon = iconNode(name, iconArgs);

  const attributes = { title: Discourse.Utilities.escapeExpression(I18n.t(`topic_statuses.${key}.help`)) };
  return h(`${canAct ? 'a' : 'span'}.topic-status`, attributes, icon);
}

export default createWidget('topic-status', {
  tagName: 'div.topic-statuses',

  html(attrs) {
    const topic = attrs.topic;
    const canAct = this.currentUser && !attrs.disableActions;

    const result = [];
    const renderIconIf = (conditionProp, name, key) => {
      if (!topic.get(conditionProp)) { return; }
      result.push(renderIcon(name, key, canAct));
    };

    renderIconIf('is_warning', 'envelope', 'warning');

    if (topic.get('closed') && topic.get('archived')) {
      renderIcon('lock', 'locked_and_archived');
    } else {
      renderIconIf('closed', 'lock', 'locked');
      renderIconIf('archived', 'lock', 'archived');
    }

    renderIconIf('pinned', 'thumb-tack', 'pinned');
    renderIconIf('unpinned', 'thumb-tack', 'unpinned');
    renderIconIf('invisible', 'eye-slash', 'invisible');

    return result;
  }
});

{'fraction_non_alphanumeric': 0.17784256559766765, 'fraction_numerical': 0.0014577259475218659, 'mean_word_length': 4.130841121495327, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4262369', 'n_tokens_mistral': 900, 'n_tokens_neox': 884, 'n_words': 180}