import browser from 'webextension-polyfill'; import {getText, createTab, getActiveTab} from 'utils/common'; function showNotification({message, messageId, title, type = 'info'}) { if (!title) { title = getText('extensionName'); } if (messageId) { message = getText(messageId); } return browser.notifications.create(`sbi-notification-${type}`, { type: 'basic', title: title, message: message, iconUrl: '/src/icons/app/icon-48.png' }); } function getOptionLabels(data, scope = 'optionValue') { const labels = {}; for (const [group, items] of Object.entries(data)) { labels[group] = []; items.forEach(function(value) { labels[group].push({ id: value, label: getText(`${scope}_${group}_${value}`) }); }); } return labels; } async function showContributePage(action = false) { const activeTab = await getActiveTab(); let url = browser.extension.getURL('/src/contribute/index.html'); if (action) { url = `${url}?action=${action}`; } await createTab(url, {index: activeTab.index + 1}); } export {showNotification, getOptionLabels, showContributePage};