<commit_before>import {IVocabulary} from 'superdesk-interfaces/Vocabulary';
import {gettext} from 'core/utils';

const TYPE_LABEL = {
    text: gettext('text'),
    media: '',
    date: gettext('date'),
    embed: gettext('embed'),
    related_content: gettext('related content'),
};

export const getLabelForType = (fieldType: IVocabulary['field_type']) => {
    if (TYPE_LABEL.hasOwnProperty(fieldType)) {
        return TYPE_LABEL[fieldType];
    }

    return gettext('custom vocabulary');
};

export const getTypeForFieldId = (fieldId, vocabularies: Array<IVocabulary>) => {
    const vocabulary = vocabularies.find((obj) => obj._id === fieldId);

    if (vocabulary && vocabulary.field_type) {
        return getLabelForType(vocabulary.field_type);
    }

    return '';
};
<commit_msg>[SDESK-3572] Show related content label for media fields (#2830)<commit_after>import {IVocabulary} from 'superdesk-interfaces/Vocabulary';
import {gettext} from 'core/utils';

const TYPE_LABEL = {
    text: gettext('text'),
    media: gettext('related content'),
    date: gettext('date'),
    embed: gettext('embed'),
    related_content: gettext('related content'),
};

export const getLabelForType = (fieldType: IVocabulary['field_type']) => {
    if (TYPE_LABEL.hasOwnProperty(fieldType)) {
        return TYPE_LABEL[fieldType];
    }

    return gettext('custom vocabulary');
};

export const getTypeForFieldId = (fieldId, vocabularies: Array<IVocabulary>) => {
    const vocabulary = vocabularies.find((obj) => obj._id === fieldId);

    if (vocabulary && vocabulary.field_type) {
        return getLabelForType(vocabulary.field_type);
    }

    return '';
};

{'fraction_non_alphanumeric': 0.14345991561181434, 'fraction_numerical': 0.004822182037371911, 'mean_word_length': 4.407166123778501, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1211158', 'n_tokens_mistral': 531, 'n_tokens_neox': 519, 'n_words': 108}