From edde6a15ecc9117efad343561aa5edfa58a001db Mon Sep 17 00:00:00 2001 From: Lam Tang Date: Sun, 4 Dec 2022 19:32:52 +0800 Subject: [PATCH 01/10] temporarily remove hypertrons button --- src/anchors/HypertronsAnchor.tsx | 46 ---- src/pages/ContentScripts/index.ts | 2 - src/services/hypertrons.ts | 41 ---- src/views/HypertronsView/HypertronsView.tsx | 237 -------------------- 4 files changed, 326 deletions(-) delete mode 100644 src/anchors/HypertronsAnchor.tsx delete mode 100644 src/services/hypertrons.ts delete mode 100644 src/views/HypertronsView/HypertronsView.tsx diff --git a/src/anchors/HypertronsAnchor.tsx b/src/anchors/HypertronsAnchor.tsx deleted file mode 100644 index bff1c586..00000000 --- a/src/anchors/HypertronsAnchor.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react'; -import { render } from 'react-dom'; -import $ from 'jquery'; -import * as pageDetect from 'github-url-detection'; -import { runsWhen } from '../utils/utils'; -import PerceptorBase from '../PerceptorBase'; -import logger from '../utils/logger'; -import HypertronsView from '../views/HypertronsView/HypertronsView'; - -@runsWhen([pageDetect.isPR, pageDetect.isIssue]) -class HypertronsAnchor extends PerceptorBase { - public static hypertronsConfig: any; - - private static renderView(): void { - // avoid redundant button - if ($('#hypertrons_button').length > 0) { - logger.info('hypertrons tab exists'); - return; - } - - // add hypertrons tab - const commentForm = $('.js-new-comment-form'); - const parentContainer = commentForm.find('.d-flex.flex-justify-end'); - const hypertronsTab = document.createElement('div'); - render( - , - hypertronsTab - ); - parentContainer.prepend(hypertronsTab); - } - - public async run(config: any): Promise { - HypertronsAnchor.hypertronsConfig = config; - // @ts-ignore - const observer = new MutationObserver(HypertronsAnchor.renderView); - const element = document.querySelector('#new_comment_field'); - // @ts-ignore - observer.observe(element, { - attributes: true, - }); - - HypertronsAnchor.renderView(); - } -} - -export default HypertronsAnchor; diff --git a/src/pages/ContentScripts/index.ts b/src/pages/ContentScripts/index.ts index a4b11f0e..b6e07a0b 100644 --- a/src/pages/ContentScripts/index.ts +++ b/src/pages/ContentScripts/index.ts @@ -13,7 +13,6 @@ import PerceptorTabAnchor from '../../anchors/PerceptorTabAnchor'; import PerceptorLayoutAnchor from '../../anchors/PerceptorLayoutAnchor'; import DeveloperNetworkAnchor from '../../anchors/DeveloperNetworkAnchor'; import ProjectNetworkAnchor from '../../anchors/ProjectNetworkAnchor'; -import HypertronsAnchor from '../../anchors/HypertronsAnchor'; import { inject2Perceptor, Perceptor } from '../../Perceptor'; import { loadSettings } from '../../utils/settings'; @@ -32,7 +31,6 @@ inject2Perceptor(PerceptorTabAnchor); inject2Perceptor(PerceptorLayoutAnchor); inject2Perceptor(DeveloperNetworkAnchor); inject2Perceptor(ProjectNetworkAnchor); -inject2Perceptor(HypertronsAnchor); async function mainInject() { const settings = await loadSettings(); diff --git a/src/services/hypertrons.ts b/src/services/hypertrons.ts deleted file mode 100644 index 3b6b0ccf..00000000 --- a/src/services/hypertrons.ts +++ /dev/null @@ -1,41 +0,0 @@ -export interface Command { - command: string; -} - -export const LabelStyles: string[] = [ - '--label-r:17;--label-g:238;--label-b:17;--label-h:120;--label-s:86;--label-l:50', - '--label-r:3;--label-g:102;--label-b:214;--label-h:211;--label-s:97;--label-l:42', - '--label-r:199;--label-g:222;--label-b:248;--label-h:211;--label-s:77;--label-l:87', - '--label-r:184;--label-g:20;--label-b:91;--label-h:334;--label-s:80;--label-l:40', - '--label-r:95;--label-g:221;--label-b:164;--label-h:152;--label-s:64;--label-l:61', - '--label-r:112;--label-g:87;--label-b:255;--label-h:248;--label-s:100;--label-l:67', - '--label-r:252;--label-g:41;--label-b:41;--label-h:0;--label-s:97;--label-l:57', - '--label-r:251;--label-g:202;--label-b:4;--label-h:48;--label-s:96;--label-l:50', - '--label-r:246;--label-g:180;--label-b:222;--label-h:321;--label-s:78;--label-l:83', - '--label-r:67;--label-g:1;--label-b:137;--label-h:269;--label-s:98;--label-l:27', - '--label-r:237;--label-g:237;--label-b:237;--label-h:0;--label-s:0;--label-l:92', - '--label-r:147;--label-g:245;--label-b:168;--label-h:132;--label-s:83;--label-l:76', -]; - -export function Label2Style(lable: string) { - let result: { [key: string]: number } = {}; - const group = lable.split(';'); - for (const kv of group) { - const kvp = kv.split(':'); - result[kvp[0]] = parseInt(kvp[1]); - } - return result; -} - -export async function getUserNameFromCookie() { - return new Promise((resolve, reject) => { - chrome.runtime.sendMessage( - { - task_type: 'get_username_from_cookie', - }, - (response) => { - resolve(response); - } - ); - }); -} diff --git a/src/views/HypertronsView/HypertronsView.tsx b/src/views/HypertronsView/HypertronsView.tsx deleted file mode 100644 index 65f09d6e..00000000 --- a/src/views/HypertronsView/HypertronsView.tsx +++ /dev/null @@ -1,237 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { fire } from 'delegated-events'; -import { - Callout, - Stack, - Link, - Text, - mergeStyleSets, - FontWeights, - DirectionalHint, -} from '@fluentui/react'; -import { useBoolean } from '@fluentui/react-hooks'; -import { - Command, - LabelStyles, - Label2Style, - getUserNameFromCookie, -} from '../../services/hypertrons'; -import { - getGithubTheme, - getMessageByLocale, - runsWhen, -} from '../../utils/utils'; -import Settings, { loadSettings } from '../../utils/settings'; - -const githubTheme = getGithubTheme(); - -const styles = mergeStyleSets({ - callout: { - width: 360, - }, - title: { - fontWeight: FontWeights.bold, - marginBottom: 10, - }, - buttons: { - marginTop: 20, - overflow: 'hidden', - }, -}); - -interface HypertronsTabViewProps { - hypertronsConfig: any; -} - -const HypertronsView: React.FC = ({ - hypertronsConfig, -}) => { - const commandsInit: Command[] = []; - const [settings, setSettings] = useState(new Settings()); - const [settingsInited, setSettingsInited] = useState(false); - const [isCalloutVisible, { toggle: toggleIsCalloutVisible }] = - useBoolean(false); - const [userName, setUserName] = useState(null); - const [userNameInited, setUserNameInited] = useState(false); - const [commandsCurrent, setCommandsCurrent] = useState(commandsInit); - const [commandsCurrentInited, setCommandsCurrentInited] = useState(false); - - useEffect(() => { - const initSettings = async () => { - const temp = await loadSettings(); - setSettings(temp); - setSettingsInited(true); - }; - if (!settingsInited) { - initSettings(); - } - }, [settingsInited, settings]); - - useEffect(() => { - const initUserName = async () => { - const userNameFromCookie = await getUserNameFromCookie(); - // @ts-ignore - setUserName(userNameFromCookie['message']); - setUserNameInited(true); - }; - if (!userNameInited) { - initUserName(); - } - }, [userNameInited, userName]); - - useEffect(() => { - const initCommandsCurrent = async () => { - let commandsCanUse = new Set([]); - if ('role' in hypertronsConfig) { - // @ts-ignore - const roleConfig = hypertronsConfig['role']; - if ('roles' in roleConfig) { - const rolesConfig = roleConfig['roles']; - // @ts-ignore - for (const role of rolesConfig) { - const roleName = role['name']; - const usersSet = new Set(role['users']); - const commands = role['commands']; - if (usersSet.has(userName) || roleName === 'anyone') { - for (const command of commands) { - // @ts-ignore - commandsCanUse.add(command); - } - } - } - } - } - let commandsFinal: Command[] = []; - for (const command of commandsCanUse) { - const commandNew: Command = { command: command }; - commandsFinal.push(commandNew); - } - setCommandsCurrent(commandsFinal); - setCommandsCurrentInited(true); - }; - if (!commandsCurrentInited && userNameInited) { - initCommandsCurrent(); - } - }, [ - userNameInited, - commandsCurrentInited, - commandsCurrent, - hypertronsConfig, - userName, - ]); - - const ExecCommand = (command: Command) => { - const textarea = document.getElementById( - 'new_comment_field' - ) as HTMLTextAreaElement; - if (textarea) { - const commentCurrent = textarea.value; - let commandExec; - switch (command.command) { - case '/start-vote': - commandExec = `${command.command} A,B,C,D`; - break; - case '/vote': - commandExec = `${command.command} A`; - break; - case '/rerun': - commandExec = `${command.command} CI`; - break; - case '/complete-checklist': - commandExec = `${command.command} 1 #1`; - break; - default: - commandExec = command.command; - break; - } - const commentNew = `${commentCurrent}${commandExec} `; - // @ts-ignore - Object.getOwnPropertyDescriptor( - window.HTMLTextAreaElement.prototype, - 'value' - ).set.call(textarea, commentNew); - fire(textarea, 'change'); - toggleIsCalloutVisible(); - } - }; - - return ( -
0 ? 'block' : 'none', - }} - > - - {isCalloutVisible && ( - - - {getMessageByLocale('hypertrons_tab_title', settings.locale)} - - - {getMessageByLocale('hypertrons_tab_description', settings.locale)} -   - - {getMessageByLocale('golbal_link', settings.locale)} - - - - {commandsCurrent.map((command, index) => { - const styleIndex = index % (LabelStyles.length - 1); - return ( -
{ - ExecCommand(command); - }} - > - {command.command} -
- ); - })} -
-
- )} -
- ); -}; - -export default HypertronsView; From 5967d418746a494f94a262a92d4ecbb4352fd2c7 Mon Sep 17 00:00:00 2001 From: Lam Tang Date: Sun, 4 Dec 2022 20:17:20 +0800 Subject: [PATCH 02/10] temporarily remove code for reading hypertron-crx config in `.github/hypertrons.json` --- src/Perceptor.tsx | 18 +++--------------- src/api/github.ts | 24 ------------------------ src/utils/settings.ts | 11 +---------- 3 files changed, 4 insertions(+), 49 deletions(-) delete mode 100644 src/api/github.ts diff --git a/src/Perceptor.tsx b/src/Perceptor.tsx index bdda9ae7..5d0c8201 100644 --- a/src/Perceptor.tsx +++ b/src/Perceptor.tsx @@ -1,13 +1,11 @@ import { utils, isRepo } from 'github-url-detection'; -import { loadSettings, mergeSettings } from './utils/settings'; -import { getConfigFromGithub } from './api/github'; +import { loadSettings } from './utils/settings'; import PerceptorBase from './PerceptorBase'; import logger from './utils/logger'; export class Perceptor extends PerceptorBase { public static Features: Map = new Map(); public settings: any; - public hypertronsConfig: any; public async run(): Promise { logger.info('start.'); @@ -19,19 +17,9 @@ export class Perceptor extends PerceptorBase { private async checkSettings(): Promise { logger.info('loading settings ...'); if (isRepo()) { - logger.info( - 'Detected that this is a repo page, trying to load configuration file from the repo ...' - ); const owner = utils.getRepositoryInfo(window.location)!.owner; const repo = utils.getRepositoryInfo(window.location)!.name; - const configHypertrons = await getConfigFromGithub(owner, repo); - logger.info('The configurations are: ', configHypertrons); - this.hypertronsConfig = configHypertrons; - if ('hypertrons-crx' in configHypertrons) { - this.settings = await mergeSettings(configHypertrons['hypertrons-crx']); - } else { - this.settings = await loadSettings(); - } + this.settings = await loadSettings(); } else { this.settings = await loadSettings(); } @@ -61,7 +49,7 @@ export class Perceptor extends PerceptorBase { } logger.info('running ', featureId); const feature = new Feature(); - await feature.run(this.hypertronsConfig); + await feature.run(); }, this); } } diff --git a/src/api/github.ts b/src/api/github.ts deleted file mode 100644 index e899427c..00000000 --- a/src/api/github.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Octokit } from '@octokit/core'; -import { loadMetaData } from '../utils/metadata'; - -export const getConfigFromGithub = async (owner: string, repo: string) => { - const metaData = await loadMetaData(); - let octokit; - if (metaData.token !== '') { - octokit = new Octokit({ auth: metaData.token }); - } else { - octokit = new Octokit(); - } - try { - const response = await octokit.request( - 'GET /repos/{owner}/{repo}/contents/.github/hypertrons.json', - { owner, repo } - ); - const res = response.data as any; - res.content = Buffer.from(res.content, 'base64').toString('ascii'); - return JSON.parse(res.content); - } catch (error: unknown) { - console.error(error); - return {}; - } -}; diff --git a/src/utils/settings.ts b/src/utils/settings.ts index 882aba5f..083cc027 100644 --- a/src/utils/settings.ts +++ b/src/utils/settings.ts @@ -1,4 +1,4 @@ -import { chromeGet, chromeSet, isNull } from './utils'; +import { chromeGet, isNull } from './utils'; class Settings { isEnabled: boolean | undefined; @@ -59,13 +59,4 @@ export const loadSettings = async () => { return settings; }; -export const mergeSettings = async (data: { [key: string]: any }) => { - const settings = await loadSettings(); - if (!isNull(data)) { - settings.loadFromJson(data); - await chromeSet('settings', settings.toJson()); - } - return settings; -}; - export default Settings; From ef635b79bef2bb15a775339a74348a4dbd386565 Mon Sep 17 00:00:00 2001 From: Lam Tang Date: Sun, 4 Dec 2022 21:03:56 +0800 Subject: [PATCH 03/10] temporarily remove version check and notification --- src/mock/background.data.ts | 9 -- src/pages/Background/index.ts | 97 ------------------ src/pages/Options/Options.tsx | 183 +--------------------------------- src/services/background.ts | 41 -------- src/services/common.ts | 34 ------- src/utils/settings.ts | 6 -- src/utils/utils.ts | 26 ----- 7 files changed, 2 insertions(+), 394 deletions(-) delete mode 100644 src/services/background.ts diff --git a/src/mock/background.data.ts b/src/mock/background.data.ts index 75447366..d2c175b9 100644 --- a/src/mock/background.data.ts +++ b/src/mock/background.data.ts @@ -12,12 +12,3 @@ export const updateInformation = { url: 'https://github.com/hypertrons/hypertrons-crx/releases', }, }; - -export const notificationInformation = { - id: 2021052301, - content: { - zh: '欢迎使用 Hypertrons-crx !', - en: 'Welcome to Hypertrons-crx !', - }, - is_published: true, -}; diff --git a/src/pages/Background/index.ts b/src/pages/Background/index.ts index 048312b9..e69de29b 100644 --- a/src/pages/Background/index.ts +++ b/src/pages/Background/index.ts @@ -1,97 +0,0 @@ -import { - chromeSet, - compareVersion, - getMessageByLocale, -} from '../../utils/utils'; -import { createNotification } from '../../services/background'; -import { checkUpdate } from '../../services/common'; -import { loadSettings } from '../../utils/settings'; -import { loadMetaData } from '../../utils/metadata'; - -export enum BackgroundTasks { - update = 'check_for_updates', -} - -// in develop-version, we can do this every 0.1 min, but not in store-version -if (process.env.NODE_ENV !== 'production') { - chrome.alarms.create(BackgroundTasks.update, { periodInMinutes: 0.1 }); -} else { - chrome.alarms.create(BackgroundTasks.update, { periodInMinutes: 10 }); -} - -chrome.alarms.onAlarm.addListener(async (alarm) => { - const name = alarm.name; - - const settings = await loadSettings(); - const metaData = await loadMetaData(); - - if (!settings.isEnabled) { - return; - } - - if (name === BackgroundTasks.update) { - if (settings.checkForUpdates) { - const [currentVersion, latestVersion, updateUrl] = await checkUpdate(); - if (compareVersion(currentVersion, latestVersion) === -1) { - const timeNow = new Date().valueOf(); - const duration = timeNow - metaData.timeLastNoticeNewUpdate; - console.log(duration); - if (duration >= 24 * 60 * 60 * 1000) { - // only notice people once within 24 hours - metaData.updateUrl = updateUrl; - metaData.timeLastNoticeNewUpdate = timeNow; - await chromeSet('meta_data', metaData.toJson()); - createNotification('check_for_updates', { - type: 'basic', - iconUrl: 'main.png', - title: getMessageByLocale( - 'notification_title_newUpdate', - settings.locale - ), - message: getMessageByLocale( - 'notification_message_newUpdate', - settings.locale - ).replace('%v', latestVersion), - }); - } - } - } - } -}); - -chrome.notifications.onClicked.addListener(async function (notificationId) { - switch (notificationId) { - case 'check_for_updates': - const metaData = await loadMetaData(); - window.open(metaData.updateUrl); - break; - default: - break; - } - chrome.notifications.clear(notificationId); -}); - -chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { - const type = message.task_type; - if (type === 'get_username_from_cookie') { - chrome.cookies.get( - { - url: 'https://github.com', - name: 'dotcom_user', - }, - function (cookie) { - let message; - if (cookie) { - message = cookie.value; - } else { - message = null; - } - sendResponse({ - message: message, - }); - } - ); - } - // must return true in async mode - return true; -}); diff --git a/src/pages/Options/Options.tsx b/src/pages/Options/Options.tsx index 074e14dd..ab6f95f8 100644 --- a/src/pages/Options/Options.tsx +++ b/src/pages/Options/Options.tsx @@ -20,41 +20,22 @@ import { DialogFooter, PrimaryButton, } from 'office-ui-fabric-react'; -import { - getMessageByLocale, - chromeSet, - compareVersion, -} from '../../utils/utils'; -import { checkUpdate, checkIsTokenAvailabe } from '../../services/common'; +import { getMessageByLocale, chromeSet } from '../../utils/utils'; +import { checkIsTokenAvailabe } from '../../services/common'; import Settings, { loadSettings } from '../../utils/settings'; import MetaData, { loadMetaData } from '../../utils/metadata'; -import { getNotificationInformation } from '../../services/background'; import { HYPERTRONS_CRX_WEBSITE } from '../../constant'; import './Options.css'; -export enum UpdateStatus { - undefine = -1, - no = 0, - yes = 1, -} - const Options: React.FC = () => { const [settings, setSettings] = useState(new Settings()); const [metaData, setMetaData] = useState(new MetaData()); const [inited, setInited] = useState(false); const [version, setVersion] = useState('0.0.0'); - const [checkingUpdate, setCheckingUpdate] = useState(false); const [token, setToken] = useState(''); const [checkingToken, setCheckingToken] = useState(false); const [showDialogToken, setShowDialogToken] = useState(false); const [showDialogTokenError, setShowDialogTokenError] = useState(false); - const [showDialogNotification, setShowDialogNotification] = useState(false); - const [notificationId, setNotificationId] = useState(0); - const [notification, setNotification] = useState(''); - const [updateStatus, setUpdateStatus] = useState(UpdateStatus.undefine); - const [updateUrl, setUpdateUrl] = useState( - 'https://github.com/hypertrons/hypertrons-crx/releases' - ); const tokenCurrent = metaData.token; const locale = settings.locale; @@ -76,19 +57,6 @@ const Options: React.FC = () => { if (tempMetaData.token !== '') { setToken(tempMetaData.token); } - const notificationInformation = await getNotificationInformation(); - if ( - notificationInformation.is_published && - tempMetaData.idLastNotication < notificationInformation.id - ) { - if (locale === 'zh_CN') { - setNotification(notificationInformation.content.zh); - } else { - setNotification(notificationInformation.content.en); - } - setNotificationId(notificationInformation.id); - setShowDialogNotification(true); - } }; if (!inited) { initMetaData(); @@ -120,64 +88,12 @@ const Options: React.FC = () => { await chromeSet('settings', settings.toJson()); }; - const checkUpdateManually = async () => { - setUpdateStatus(UpdateStatus.undefine); - setCheckingUpdate(true); - const [currentVersion, latestVersion, updateUrl] = await checkUpdate(); - if (compareVersion(currentVersion, latestVersion) === -1) { - setUpdateUrl(updateUrl); - setUpdateStatus(UpdateStatus.yes); - } else { - setUpdateStatus(UpdateStatus.no); - } - setCheckingUpdate(false); - }; - if (!inited) { return
; } return ( - {showDialogNotification && ( - - )} {showDialogToken && ( - - - -

- {getMessageByLocale('options_update_title', settings.locale)} -

-
-
- -

- {getMessageByLocale('options_update_toolTip', settings.locale)}. -

- { - settings.checkForUpdates = checked; - await saveSettings(settings); - }} - /> - {checkingUpdate && ( - - - - )} - {updateStatus === UpdateStatus.yes && ( - - {getMessageByLocale( - 'options_update_btn_updateStatusYes', - settings.locale - )} - - {getMessageByLocale( - 'options_update_btn_getUpdate', - settings.locale - )} - - - )} - {updateStatus === UpdateStatus.no && ( - - {getMessageByLocale( - 'options_update_btn_updateStatusNo', - settings.locale - )} - - )} - { - await checkUpdateManually(); - }} - > - {getMessageByLocale( - 'options_update_btn_checkUpdate', - settings.locale - )} - -
-
{ - let result = null; - if (process.env.NODE_ENV !== 'production') { - await sleep(1000); - result = updateInformation; - } else { - const response = await fetch(url_update, { mode: 'cors' }); - result = await response.json(); - } - return result; -}; - -export const getNotificationInformation = async () => { - let result = null; - if (process.env.NODE_ENV !== 'production') { - await sleep(1000); - result = notificationInformation; - } else { - const response = await fetch(url_notification, { mode: 'cors' }); - result = await response.json(); - } - return result; -}; - -export const createNotification = ( - id: string, - options: chrome.notifications.NotificationOptions, - callback: any = null -) => { - return chrome.notifications.create(id, options, callback); -}; diff --git a/src/services/common.ts b/src/services/common.ts index 315f0b46..fb17b9bd 100644 --- a/src/services/common.ts +++ b/src/services/common.ts @@ -1,37 +1,3 @@ -import { getUpdateInfor } from './background'; -import { getBrowserType } from '../utils/utils'; - -export const checkUpdate = async () => { - const currentVersion = (await chrome.management.getSelf()).version; - const browserType = getBrowserType(); - const updateInformation = await getUpdateInfor(); - let latestVersion; - let updateUrl; - - if (chrome.runtime.getManifest().key) { - // the store-version installation - if (browserType === 'Edge') { - latestVersion = updateInformation['edge']['latest_version']; - updateUrl = updateInformation['edge']['url']; - // edge can also install crx from chrome store - if ((await chrome.management.getSelf()).updateUrl) { - const update_url = (await chrome.management.getSelf()).updateUrl; - if (update_url!.search('google') !== -1) { - latestVersion = updateInformation['chrome']['latest_version']; - updateUrl = updateInformation['chrome']['url']; - } - } - } else { - latestVersion = updateInformation['chrome']['latest_version']; - updateUrl = updateInformation['chrome']['url']; - } - } else { - latestVersion = updateInformation['develop']['latest_version']; - updateUrl = updateInformation['develop']['url']; - } - return [currentVersion, latestVersion, updateUrl]; -}; - export const checkIsTokenAvailabe = async (token: string) => { const response = await fetch(`https://api.github.com/user`, { headers: { Authorization: `token ${token}` }, diff --git a/src/utils/settings.ts b/src/utils/settings.ts index 083cc027..f41e731f 100644 --- a/src/utils/settings.ts +++ b/src/utils/settings.ts @@ -2,14 +2,12 @@ import { chromeGet, isNull } from './utils'; class Settings { isEnabled: boolean | undefined; - checkForUpdates: boolean | undefined; developerNetwork: boolean | undefined; projectNetwork: boolean | undefined; locale: string; constructor() { this.isEnabled = true; - this.checkForUpdates = true; this.developerNetwork = true; this.projectNetwork = true; const language = chrome.i18n.getUILanguage(); @@ -24,9 +22,6 @@ class Settings { if ('isEnabled' in data) { this.isEnabled = data['isEnabled']; } - if ('checkForUpdates' in data) { - this.checkForUpdates = data['checkForUpdates']; - } if ('developerNetwork' in data) { this.developerNetwork = data['developerNetwork']; } @@ -41,7 +36,6 @@ class Settings { toJson(): { [key: string]: any } { const result: { [key: string]: any } = {}; result['isEnabled'] = this.isEnabled; - result['checkForUpdates'] = this.checkForUpdates; result['developerNetwork'] = this.developerNetwork; result['projectNetwork'] = this.projectNetwork; result['locale'] = this.locale; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 4c554290..347e81cc 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -63,32 +63,6 @@ export function getMessageI18n(key: string) { export const isPerceptor = (): boolean => window.location.search.includes('perceptor'); -export const compareVersion = (version_1: string, version_2: string) => { - const v1 = version_1.split('.'); - const v2 = version_2.split('.'); - const len = Math.max(v1.length, v2.length); - - while (v1.length < len) { - v1.push('0'); - } - while (v2.length < len) { - v2.push('0'); - } - - for (let i = 0; i < len; i++) { - const num_1 = parseInt(v1[i]); - const num_2 = parseInt(v2[i]); - - if (num_1 > num_2) { - return 1; - } else if (num_1 < num_2) { - return -1; - } - } - - return 0; -}; - export const getBrowserType = () => { var userAgent = navigator.userAgent; var isOpera = userAgent.indexOf('Opera') > -1; From 571e7867dac66f2cca7217fd455a52b72bb34da6 Mon Sep 17 00:00:00 2001 From: Lam Tang Date: Sun, 4 Dec 2022 21:24:53 +0800 Subject: [PATCH 04/10] temporarily remove github token related code --- src/pages/Options/Options.tsx | 201 ---------------------------------- src/pages/Popup/Popup.tsx | 58 +--------- src/services/common.ts | 6 - src/utils/metadata.ts | 42 ------- 4 files changed, 1 insertion(+), 306 deletions(-) delete mode 100644 src/services/common.ts diff --git a/src/pages/Options/Options.tsx b/src/pages/Options/Options.tsx index ab6f95f8..d247e3af 100644 --- a/src/pages/Options/Options.tsx +++ b/src/pages/Options/Options.tsx @@ -3,25 +3,13 @@ import { TooltipHost, Stack, Toggle, - DefaultButton, Checkbox, Text, Link, - Spinner, - MessageBar, - MessageBarType, - Dialog, - DialogType, - TextField, ChoiceGroup, IChoiceGroupOption, - Image, - ImageFit, - DialogFooter, - PrimaryButton, } from 'office-ui-fabric-react'; import { getMessageByLocale, chromeSet } from '../../utils/utils'; -import { checkIsTokenAvailabe } from '../../services/common'; import Settings, { loadSettings } from '../../utils/settings'; import MetaData, { loadMetaData } from '../../utils/metadata'; import { HYPERTRONS_CRX_WEBSITE } from '../../constant'; @@ -32,11 +20,6 @@ const Options: React.FC = () => { const [metaData, setMetaData] = useState(new MetaData()); const [inited, setInited] = useState(false); const [version, setVersion] = useState('0.0.0'); - const [token, setToken] = useState(''); - const [checkingToken, setCheckingToken] = useState(false); - const [showDialogToken, setShowDialogToken] = useState(false); - const [showDialogTokenError, setShowDialogTokenError] = useState(false); - const tokenCurrent = metaData.token; const locale = settings.locale; const localeOptions: IChoiceGroupOption[] = [ @@ -54,9 +37,6 @@ const Options: React.FC = () => { const initMetaData = async () => { const tempMetaData = await loadMetaData(); setMetaData(tempMetaData); - if (tempMetaData.token !== '') { - setToken(tempMetaData.token); - } }; if (!inited) { initMetaData(); @@ -94,118 +74,6 @@ const Options: React.FC = () => { return ( - {showDialogToken && ( - - )}

PERCEPTOR

{`version ${version}`} @@ -339,75 +207,6 @@ const Options: React.FC = () => { />
- - - -

- {getMessageByLocale('options_token_title', settings.locale)} -

-
-
- -

- {getMessageByLocale('options_token_toolTip', settings.locale)} : -

- {tokenCurrent !== '' && ( - - - - {metaData.name} - - - )} - { - setShowDialogToken(true); - }} - style={{ - width: 120, - }} - > - {getMessageByLocale( - 'options_token_btn_setToken', - settings.locale - )} - -
-
{ const [settings, setSettings] = useState(new Settings()); - const [metaData, setMetaData] = useState(new MetaData()); const [inited, setInited] = useState(false); useEffect(() => { @@ -28,14 +19,6 @@ const Popup: React.FC = () => { } }, [inited, settings]); - useEffect(() => { - const initMetaData = async () => { - const temp = await loadMetaData(); - setMetaData(temp); - }; - initMetaData(); - }, []); - const saveSettings = async (settings: Settings) => { setSettings(settings); await chromeSet('settings', settings.toJson()); @@ -73,45 +56,6 @@ const Popup: React.FC = () => { }} /> - {metaData.token !== '' && ( - - - - {metaData.name} - - - )} - {metaData.token === '' && ( - { - chrome.runtime.openOptionsPage(); - }} - style={{ - width: 120, - }} - > - {getMessageByLocale('options_token_title', settings.locale)} - - )} ); diff --git a/src/services/common.ts b/src/services/common.ts deleted file mode 100644 index fb17b9bd..00000000 --- a/src/services/common.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const checkIsTokenAvailabe = async (token: string) => { - const response = await fetch(`https://api.github.com/user`, { - headers: { Authorization: `token ${token}` }, - }); - return await response.json(); -}; diff --git a/src/utils/metadata.ts b/src/utils/metadata.ts index 4eee7edb..085a87f7 100644 --- a/src/utils/metadata.ts +++ b/src/utils/metadata.ts @@ -1,48 +1,13 @@ import { chromeGet, isNull } from './utils'; class MetaData { - timeLastNoticeNewUpdate: number; - idLastNotication: number; - updateUrl: string; - token: string; - avatar: string; - name: string; - id: string; showTeachingBubble: boolean; constructor() { - this.timeLastNoticeNewUpdate = new Date().valueOf() - 24 * 60 * 60 * 1000; - this.idLastNotication = 0; - this.updateUrl = 'https://github.com/hypertrons/hypertrons-crx'; - this.token = ''; - this.avatar = ''; - this.name = ''; - this.id = ''; this.showTeachingBubble = true; } loadFromJson(data: { [key: string]: any }): void { - if ('timeLastNoticeNewUpdate' in data) { - this.timeLastNoticeNewUpdate = data['timeLastNoticeNewUpdate']; - } - if ('idLastNotication' in data) { - this.idLastNotication = data['idLastNotication']; - } - if ('updateUrl' in data) { - this.updateUrl = data['updateUrl']; - } - if ('token' in data) { - this.token = data['token']; - } - if ('avatar' in data) { - this.avatar = data['avatar']; - } - if ('name' in data) { - this.name = data['name']; - } - if ('id' in data) { - this.id = data['id']; - } if ('showTeachingBubble' in data) { this.showTeachingBubble = data['showTeachingBubble']; } @@ -50,13 +15,6 @@ class MetaData { toJson(): { [key: string]: any } { const result: { [key: string]: any } = {}; - result['timeLastNoticeNewUpdate'] = this.timeLastNoticeNewUpdate; - result['idLastNotication'] = this.idLastNotication; - result['updateUrl'] = this.updateUrl; - result['token'] = this.token; - result['avatar'] = this.avatar; - result['name'] = this.name; - result['id'] = this.id; result['showTeachingBubble'] = this.showTeachingBubble; return result; } From 4c3d2677f8da86dfe0a56bbe3d1be86f3868fc35 Mon Sep 17 00:00:00 2001 From: Lam Tang Date: Sun, 4 Dec 2022 21:42:45 +0800 Subject: [PATCH 05/10] temporarily remove mock related code --- scripts/bump-version.cjs | 5 - src/api/developer.ts | 18 +- src/api/repo.ts | 13 +- src/mock/background.data.ts | 14 - src/mock/developer.data.ts | 1072 --------------------- src/mock/repo.data.ts | 1752 ----------------------------------- src/utils/request.ts | 12 - utils/env.js | 1 - webpack.config.js | 1 - 9 files changed, 8 insertions(+), 2880 deletions(-) delete mode 100644 src/mock/background.data.ts delete mode 100644 src/mock/developer.data.ts delete mode 100644 src/mock/repo.data.ts diff --git a/scripts/bump-version.cjs b/scripts/bump-version.cjs index 684739a9..8e8f89e7 100644 --- a/scripts/bump-version.cjs +++ b/scripts/bump-version.cjs @@ -19,11 +19,6 @@ async function bump({ version, deploy }) { } update_info.develop.latest_version = version; writeJson(infoPath, update_info); - - // update background.data.ts - processFile('src/mock/background.data.ts', (content) => - content.replace(/(latest_version)\:.*?,/g, `$1: '${version}',`) - ); } module.exports = { bump }; diff --git a/src/api/developer.ts b/src/api/developer.ts index 28dcaa51..d6e3ddaf 100644 --- a/src/api/developer.ts +++ b/src/api/developer.ts @@ -1,9 +1,5 @@ import { HYPERTRONS_OSS_XLAB_ENDPOINT, OSS_XLAB_ENDPOINT } from '../constant'; -import request, { mockSuccessRes } from '../utils/request'; -import { - developerCollabrationData, - participatedProjectsData, -} from '../mock/developer.data'; +import request from '../utils/request'; // metric names and their implementation names in OpenDigger const metricNameMap = new Map([ @@ -30,17 +26,13 @@ export const getOpenrank = async (user: string) => { // the two requests below will be deprecated once their OpenDigger implementations are ready export const getDeveloperCollabration = async (developer: string) => { - return ( - mockSuccessRes(developerCollabrationData) || - (await request(`${HYPERTRONS_OSS_XLAB_ENDPOINT}/actor/${developer}.json`)) + return await request( + `${HYPERTRONS_OSS_XLAB_ENDPOINT}/actor/${developer}.json` ); }; export const getParticipatedProjects = async (developer: string) => { - return ( - mockSuccessRes(participatedProjectsData) || - (await request( - `${HYPERTRONS_OSS_XLAB_ENDPOINT}/actor/${developer}_top.json` - )) + return await request( + `${HYPERTRONS_OSS_XLAB_ENDPOINT}/actor/${developer}_top.json` ); }; diff --git a/src/api/repo.ts b/src/api/repo.ts index 25d352ce..44da0794 100644 --- a/src/api/repo.ts +++ b/src/api/repo.ts @@ -1,6 +1,5 @@ import { HYPERTRONS_OSS_XLAB_ENDPOINT, OSS_XLAB_ENDPOINT } from '../constant'; -import request, { mockSuccessRes } from '../utils/request'; -import { repoCorrelationData, developersByRepo } from '../mock/repo.data'; +import request from '../utils/request'; // metric names and their implementation names in OpenDigger const metricNameMap = new Map([ @@ -87,15 +86,9 @@ export const getMergedCodeSum = async (repo: string) => { // the two requests below will be deprecated once their OpenDigger implementations are ready export const getRepoCorrelation = async (repo: string) => { - return ( - mockSuccessRes(repoCorrelationData) || - (await request(`${HYPERTRONS_OSS_XLAB_ENDPOINT}/repo/${repo}.json`)) - ); + return await request(`${HYPERTRONS_OSS_XLAB_ENDPOINT}/repo/${repo}.json`); }; export const getDevelopersByRepo = async (repo: string) => { - return ( - mockSuccessRes(developersByRepo) || - (await request(`${HYPERTRONS_OSS_XLAB_ENDPOINT}/repo/${repo}_top.json`)) - ); + return await request(`${HYPERTRONS_OSS_XLAB_ENDPOINT}/repo/${repo}_top.json`); }; diff --git a/src/mock/background.data.ts b/src/mock/background.data.ts deleted file mode 100644 index d2c175b9..00000000 --- a/src/mock/background.data.ts +++ /dev/null @@ -1,14 +0,0 @@ -export const updateInformation = { - chrome: { - latest_version: '1.8.2', - url: 'https://github.com/hypertrons/hypertrons-crx/releases', - }, - edge: { - latest_version: '1.8.2', - url: 'https://github.com/hypertrons/hypertrons-crx/releases', - }, - develop: { - latest_version: '1.8.2', - url: 'https://github.com/hypertrons/hypertrons-crx/releases', - }, -}; diff --git a/src/mock/developer.data.ts b/src/mock/developer.data.ts deleted file mode 100644 index e9064a88..00000000 --- a/src/mock/developer.data.ts +++ /dev/null @@ -1,1072 +0,0 @@ -export const developerCollabrationData = { - nodes: [ - { - name: 'pissang', - value: 71.56, - }, - { - name: 'plainheart', - value: 83.03, - }, - { - name: 'susiwen8', - value: 116.23, - }, - { - name: '100pah', - value: 32.36, - }, - { - name: 'Ovilia', - value: 33.29, - }, - { - name: 'Bilge', - value: 106.29, - }, - { - name: 'wenfangdu', - value: 96.82, - }, - { - name: 'cheqianxiao', - value: 6.1, - }, - { - name: 'fxxjdedd', - value: 18.39, - }, - { - name: 'yufeng04', - value: 9.01, - }, - { - name: 'MiltonCobo', - value: 4.16, - }, - { - name: 'villebro', - value: 117.02, - }, - { - name: 'twittwer', - value: 18.25, - }, - { - name: 'chfw', - value: 44.08, - }, - { - name: 'realeve', - value: 11.02, - }, - { - name: 'symlons', - value: 5.0, - }, - { - name: 'daima1111', - value: 2.83, - }, - { - name: 'lz1998', - value: 72.74, - }, - { - name: 'leosxie', - value: 5.51, - }, - { - name: 'Sweet-KK', - value: 5.88, - }, - { - name: 'Nick22nd', - value: 14.48, - }, - { - name: 'lzxb', - value: 40.77, - }, - { - name: 'lifront', - value: 2.83, - }, - { - name: 'anoosurf', - value: 5.86, - }, - { - name: 'leeoniya', - value: 98.1, - }, - { - name: 'Clarkkkk', - value: 20.45, - }, - { - name: 'xiaoyueguang', - value: 7.33, - }, - { - name: 'dirslashls', - value: 10.45, - }, - { - name: 'hustcc', - value: 224.09, - }, - { - name: 'q604265262', - value: 2.83, - }, - { - name: 'qortex', - value: 37.5, - }, - ], - edges: [ - { - source: 'pissang', - target: 'plainheart', - weight: 24.88, - }, - { - source: 'plainheart', - target: 'susiwen8', - weight: 9.01, - }, - { - source: 'plainheart', - target: '100pah', - weight: 1.83, - }, - { - source: 'plainheart', - target: 'Ovilia', - weight: 4.87, - }, - { - source: 'plainheart', - target: 'Bilge', - weight: 3.66, - }, - { - source: 'plainheart', - target: 'wenfangdu', - weight: 1.76, - }, - { - source: 'plainheart', - target: 'cheqianxiao', - weight: 0.59, - }, - { - source: 'plainheart', - target: 'villebro', - weight: 0.59, - }, - { - source: 'plainheart', - target: 'realeve', - weight: 1.01, - }, - { - source: 'plainheart', - target: 'symlons', - weight: 1.22, - }, - { - source: 'plainheart', - target: 'lz1998', - weight: 1.45, - }, - { - source: 'plainheart', - target: 'leosxie', - weight: 0.5, - }, - { - source: 'plainheart', - target: 'anoosurf', - weight: 0.92, - }, - { - source: 'plainheart', - target: 'xiaoyueguang', - weight: 0.63, - }, - { - source: 'plainheart', - target: 'qortex', - weight: 0.5, - }, - { - source: 'pissang', - target: 'susiwen8', - weight: 24.11, - }, - { - source: 'susiwen8', - target: '100pah', - weight: 6.04, - }, - { - source: 'susiwen8', - target: 'Ovilia', - weight: 0.5, - }, - { - source: 'susiwen8', - target: 'Bilge', - weight: 0.59, - }, - { - source: 'susiwen8', - target: 'wenfangdu', - weight: 1.84, - }, - { - source: 'susiwen8', - target: 'cheqianxiao', - weight: 0.63, - }, - { - source: 'susiwen8', - target: 'chfw', - weight: 2.83, - }, - { - source: 'susiwen8', - target: 'Nick22nd', - weight: 1.32, - }, - { - source: 'susiwen8', - target: 'anoosurf', - weight: 0.73, - }, - { - source: 'susiwen8', - target: 'dirslashls', - weight: 1.22, - }, - { - source: 'susiwen8', - target: 'qortex', - weight: 0.63, - }, - { - source: 'pissang', - target: '100pah', - weight: 9.13, - }, - { - source: '100pah', - target: 'Ovilia', - weight: 1.22, - }, - { - source: '100pah', - target: 'chfw', - weight: 1.41, - }, - { - source: '100pah', - target: 'Clarkkkk', - weight: 0.71, - }, - { - source: '100pah', - target: 'dirslashls', - weight: 0.63, - }, - { - source: 'pissang', - target: 'Ovilia', - weight: 7.4, - }, - { - source: 'Ovilia', - target: 'Bilge', - weight: 4.54, - }, - { - source: 'Ovilia', - target: 'fxxjdedd', - weight: 0.73, - }, - { - source: 'Ovilia', - target: 'villebro', - weight: 1.06, - }, - { - source: 'Ovilia', - target: 'chfw', - weight: 1.14, - }, - { - source: 'Ovilia', - target: 'symlons', - weight: 0.67, - }, - { - source: 'Ovilia', - target: 'xiaoyueguang', - weight: 0.63, - }, - { - source: 'Ovilia', - target: 'dirslashls', - weight: 2.01, - }, - { - source: 'pissang', - target: 'Bilge', - weight: 4.04, - }, - { - source: 'Bilge', - target: 'wenfangdu', - weight: 0.5, - }, - { - source: 'pissang', - target: 'wenfangdu', - weight: 3.53, - }, - { - source: 'pissang', - target: 'cheqianxiao', - weight: 3.4, - }, - { - source: 'cheqianxiao', - target: 'realeve', - weight: 0.59, - }, - { - source: 'cheqianxiao', - target: 'q604265262', - weight: 0.94, - }, - { - source: 'pissang', - target: 'fxxjdedd', - weight: 2.86, - }, - { - source: 'pissang', - target: 'yufeng04', - weight: 2.6, - }, - { - source: 'pissang', - target: 'MiltonCobo', - weight: 2.3, - }, - { - source: 'pissang', - target: 'villebro', - weight: 2.25, - }, - { - source: 'pissang', - target: 'twittwer', - weight: 2.18, - }, - { - source: 'pissang', - target: 'chfw', - weight: 2.16, - }, - { - source: 'pissang', - target: 'realeve', - weight: 2.09, - }, - { - source: 'realeve', - target: 'hustcc', - weight: 0.59, - }, - { - source: 'realeve', - target: 'q604265262', - weight: 0.74, - }, - { - source: 'pissang', - target: 'symlons', - weight: 2.0, - }, - { - source: 'pissang', - target: 'daima1111', - weight: 2.0, - }, - { - source: 'pissang', - target: 'lz1998', - weight: 1.86, - }, - { - source: 'pissang', - target: 'leosxie', - weight: 1.85, - }, - { - source: 'pissang', - target: 'Sweet-KK', - weight: 1.77, - }, - { - source: 'pissang', - target: 'Nick22nd', - weight: 1.64, - }, - { - source: 'pissang', - target: 'lzxb', - weight: 1.56, - }, - { - source: 'pissang', - target: 'lifront', - weight: 1.56, - }, - { - source: 'pissang', - target: 'anoosurf', - weight: 1.56, - }, - { - source: 'pissang', - target: 'leeoniya', - weight: 1.55, - }, - { - source: 'pissang', - target: 'Clarkkkk', - weight: 1.53, - }, - { - source: 'pissang', - target: 'xiaoyueguang', - weight: 1.53, - }, - { - source: 'pissang', - target: 'dirslashls', - weight: 1.51, - }, - { - source: 'pissang', - target: 'hustcc', - weight: 1.49, - }, - { - source: 'pissang', - target: 'q604265262', - weight: 1.46, - }, - { - source: 'pissang', - target: 'qortex', - weight: 1.41, - }, - ], -}; - -export const participatedProjectsData = { - nodes: [ - { - name: 'apache/echarts', - value: 28.19, - }, - { - name: 'ecomfe/zrender', - value: 14.3, - }, - { - name: 'apache/echarts-doc', - value: 4.47, - }, - { - name: 'ecomfe/echarts-gl', - value: 4.47, - }, - { - name: 'ecomfe/echarts-liquidfill', - value: 3.61, - }, - { - name: 'iendeavor/object-visualizer', - value: 2.65, - }, - { - name: 'ecomfe/echarts-wordcloud', - value: 2.45, - }, - { - name: 'leeoniya/uPlot', - value: 2.24, - }, - { - name: 'apache/echarts-examples', - value: 1.73, - }, - { - name: 'hustcc/echarts-for-react', - value: 1.73, - }, - { - name: 'ecomfe/awesome-echarts', - value: 1.73, - }, - { - name: 'apache/echarts-www', - value: 1.0, - }, - { - name: 'JohnCoene/echarts4r', - value: 1.0, - }, - { - name: 'ecomfe/echarts-gallery-feedback', - value: 1.0, - }, - { - name: 'ecomfe/vue-echarts', - value: 1.0, - }, - ], - edges: [ - { - source: 'apache/echarts', - target: 'ecomfe/zrender', - weight: 9.49, - }, - { - source: 'apache/echarts', - target: 'apache/echarts-doc', - weight: 3.86, - }, - { - source: 'apache/echarts', - target: 'ecomfe/echarts-gl', - weight: 3.86, - }, - { - source: 'apache/echarts', - target: 'ecomfe/echarts-liquidfill', - weight: 3.2, - }, - { - source: 'apache/echarts', - target: 'iendeavor/object-visualizer', - weight: 2.42, - }, - { - source: 'apache/echarts', - target: 'ecomfe/echarts-wordcloud', - weight: 2.25, - }, - { - source: 'apache/echarts', - target: 'leeoniya/uPlot', - weight: 2.07, - }, - { - source: 'apache/echarts', - target: 'apache/echarts-examples', - weight: 1.63, - }, - { - source: 'apache/echarts', - target: 'hustcc/echarts-for-react', - weight: 1.63, - }, - { - source: 'apache/echarts', - target: 'ecomfe/awesome-echarts', - weight: 1.63, - }, - { - source: 'apache/echarts', - target: 'apache/echarts-www', - weight: 0.97, - }, - { - source: 'apache/echarts', - target: 'JohnCoene/echarts4r', - weight: 0.97, - }, - { - source: 'apache/echarts', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.97, - }, - { - source: 'apache/echarts', - target: 'ecomfe/vue-echarts', - weight: 0.97, - }, - { - source: 'ecomfe/zrender', - target: 'apache/echarts-doc', - weight: 3.41, - }, - { - source: 'ecomfe/zrender', - target: 'ecomfe/echarts-gl', - weight: 3.41, - }, - { - source: 'ecomfe/zrender', - target: 'ecomfe/echarts-liquidfill', - weight: 2.88, - }, - { - source: 'ecomfe/zrender', - target: 'iendeavor/object-visualizer', - weight: 2.23, - }, - { - source: 'ecomfe/zrender', - target: 'ecomfe/echarts-wordcloud', - weight: 2.09, - }, - { - source: 'ecomfe/zrender', - target: 'leeoniya/uPlot', - weight: 1.93, - }, - { - source: 'ecomfe/zrender', - target: 'apache/echarts-examples', - weight: 1.54, - }, - { - source: 'ecomfe/zrender', - target: 'hustcc/echarts-for-react', - weight: 1.54, - }, - { - source: 'ecomfe/zrender', - target: 'ecomfe/awesome-echarts', - weight: 1.54, - }, - { - source: 'ecomfe/zrender', - target: 'apache/echarts-www', - weight: 0.93, - }, - { - source: 'ecomfe/zrender', - target: 'JohnCoene/echarts4r', - weight: 0.93, - }, - { - source: 'ecomfe/zrender', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.93, - }, - { - source: 'ecomfe/zrender', - target: 'ecomfe/vue-echarts', - weight: 0.93, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/echarts-gl', - weight: 2.24, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/echarts-liquidfill', - weight: 2.0, - }, - { - source: 'apache/echarts-doc', - target: 'iendeavor/object-visualizer', - weight: 1.66, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/echarts-wordcloud', - weight: 1.58, - }, - { - source: 'apache/echarts-doc', - target: 'leeoniya/uPlot', - weight: 1.49, - }, - { - source: 'apache/echarts-doc', - target: 'apache/echarts-examples', - weight: 1.25, - }, - { - source: 'apache/echarts-doc', - target: 'hustcc/echarts-for-react', - weight: 1.25, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/awesome-echarts', - weight: 1.25, - }, - { - source: 'apache/echarts-doc', - target: 'apache/echarts-www', - weight: 0.82, - }, - { - source: 'apache/echarts-doc', - target: 'JohnCoene/echarts4r', - weight: 0.82, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.82, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/vue-echarts', - weight: 0.82, - }, - { - source: 'ecomfe/echarts-gl', - target: 'ecomfe/echarts-liquidfill', - weight: 2.0, - }, - { - source: 'ecomfe/echarts-gl', - target: 'iendeavor/object-visualizer', - weight: 1.66, - }, - { - source: 'ecomfe/echarts-gl', - target: 'ecomfe/echarts-wordcloud', - weight: 1.58, - }, - { - source: 'ecomfe/echarts-gl', - target: 'leeoniya/uPlot', - weight: 1.49, - }, - { - source: 'ecomfe/echarts-gl', - target: 'apache/echarts-examples', - weight: 1.25, - }, - { - source: 'ecomfe/echarts-gl', - target: 'hustcc/echarts-for-react', - weight: 1.25, - }, - { - source: 'ecomfe/echarts-gl', - target: 'ecomfe/awesome-echarts', - weight: 1.25, - }, - { - source: 'ecomfe/echarts-gl', - target: 'apache/echarts-www', - weight: 0.82, - }, - { - source: 'ecomfe/echarts-gl', - target: 'JohnCoene/echarts4r', - weight: 0.82, - }, - { - source: 'ecomfe/echarts-gl', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.82, - }, - { - source: 'ecomfe/echarts-gl', - target: 'ecomfe/vue-echarts', - weight: 0.82, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'iendeavor/object-visualizer', - weight: 1.53, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'ecomfe/echarts-wordcloud', - weight: 1.46, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'leeoniya/uPlot', - weight: 1.38, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'apache/echarts-examples', - weight: 1.17, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'hustcc/echarts-for-react', - weight: 1.17, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'ecomfe/awesome-echarts', - weight: 1.17, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'apache/echarts-www', - weight: 0.78, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'JohnCoene/echarts4r', - weight: 0.78, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.78, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'ecomfe/vue-echarts', - weight: 0.78, - }, - { - source: 'iendeavor/object-visualizer', - target: 'ecomfe/echarts-wordcloud', - weight: 1.27, - }, - { - source: 'iendeavor/object-visualizer', - target: 'leeoniya/uPlot', - weight: 1.21, - }, - { - source: 'iendeavor/object-visualizer', - target: 'apache/echarts-examples', - weight: 1.05, - }, - { - source: 'iendeavor/object-visualizer', - target: 'hustcc/echarts-for-react', - weight: 1.05, - }, - { - source: 'iendeavor/object-visualizer', - target: 'ecomfe/awesome-echarts', - weight: 1.05, - }, - { - source: 'iendeavor/object-visualizer', - target: 'apache/echarts-www', - weight: 0.73, - }, - { - source: 'iendeavor/object-visualizer', - target: 'JohnCoene/echarts4r', - weight: 0.73, - }, - { - source: 'iendeavor/object-visualizer', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.73, - }, - { - source: 'iendeavor/object-visualizer', - target: 'ecomfe/vue-echarts', - weight: 0.73, - }, - { - source: 'ecomfe/echarts-wordcloud', - target: 'leeoniya/uPlot', - weight: 1.17, - }, - { - source: 'ecomfe/echarts-wordcloud', - target: 'apache/echarts-examples', - weight: 1.01, - }, - { - source: 'ecomfe/echarts-wordcloud', - target: 'hustcc/echarts-for-react', - weight: 1.01, - }, - { - source: 'ecomfe/echarts-wordcloud', - target: 'ecomfe/awesome-echarts', - weight: 1.01, - }, - { - source: 'ecomfe/echarts-wordcloud', - target: 'apache/echarts-www', - weight: 0.71, - }, - { - source: 'ecomfe/echarts-wordcloud', - target: 'JohnCoene/echarts4r', - weight: 0.71, - }, - { - source: 'ecomfe/echarts-wordcloud', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.71, - }, - { - source: 'ecomfe/echarts-wordcloud', - target: 'ecomfe/vue-echarts', - weight: 0.71, - }, - { - source: 'leeoniya/uPlot', - target: 'apache/echarts-examples', - weight: 0.98, - }, - { - source: 'leeoniya/uPlot', - target: 'hustcc/echarts-for-react', - weight: 0.98, - }, - { - source: 'leeoniya/uPlot', - target: 'ecomfe/awesome-echarts', - weight: 0.98, - }, - { - source: 'leeoniya/uPlot', - target: 'apache/echarts-www', - weight: 0.69, - }, - { - source: 'leeoniya/uPlot', - target: 'JohnCoene/echarts4r', - weight: 0.69, - }, - { - source: 'leeoniya/uPlot', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.69, - }, - { - source: 'leeoniya/uPlot', - target: 'ecomfe/vue-echarts', - weight: 0.69, - }, - { - source: 'apache/echarts-examples', - target: 'hustcc/echarts-for-react', - weight: 0.87, - }, - { - source: 'apache/echarts-examples', - target: 'ecomfe/awesome-echarts', - weight: 0.87, - }, - { - source: 'apache/echarts-examples', - target: 'apache/echarts-www', - weight: 0.63, - }, - { - source: 'apache/echarts-examples', - target: 'JohnCoene/echarts4r', - weight: 0.63, - }, - { - source: 'apache/echarts-examples', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.63, - }, - { - source: 'apache/echarts-examples', - target: 'ecomfe/vue-echarts', - weight: 0.63, - }, - { - source: 'hustcc/echarts-for-react', - target: 'ecomfe/awesome-echarts', - weight: 0.87, - }, - { - source: 'hustcc/echarts-for-react', - target: 'apache/echarts-www', - weight: 0.63, - }, - { - source: 'hustcc/echarts-for-react', - target: 'JohnCoene/echarts4r', - weight: 0.63, - }, - { - source: 'hustcc/echarts-for-react', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.63, - }, - { - source: 'hustcc/echarts-for-react', - target: 'ecomfe/vue-echarts', - weight: 0.63, - }, - { - source: 'ecomfe/awesome-echarts', - target: 'apache/echarts-www', - weight: 0.63, - }, - { - source: 'ecomfe/awesome-echarts', - target: 'JohnCoene/echarts4r', - weight: 0.63, - }, - { - source: 'ecomfe/awesome-echarts', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.63, - }, - { - source: 'ecomfe/awesome-echarts', - target: 'ecomfe/vue-echarts', - weight: 0.63, - }, - { - source: 'apache/echarts-www', - target: 'JohnCoene/echarts4r', - weight: 0.5, - }, - { - source: 'apache/echarts-www', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.5, - }, - { - source: 'apache/echarts-www', - target: 'ecomfe/vue-echarts', - weight: 0.5, - }, - { - source: 'JohnCoene/echarts4r', - target: 'ecomfe/echarts-gallery-feedback', - weight: 0.5, - }, - { - source: 'JohnCoene/echarts4r', - target: 'ecomfe/vue-echarts', - weight: 0.5, - }, - { - source: 'ecomfe/echarts-gallery-feedback', - target: 'ecomfe/vue-echarts', - weight: 0.5, - }, - ], -}; diff --git a/src/mock/repo.data.ts b/src/mock/repo.data.ts deleted file mode 100644 index 99ebbd56..00000000 --- a/src/mock/repo.data.ts +++ /dev/null @@ -1,1752 +0,0 @@ -export const repoCorrelationData = { - nodes: [ - { - name: 'apache/echarts', - value: 1259.55, - }, - { - name: 'apache/echarts-doc', - value: 69.77, - }, - { - name: 'ecomfe/zrender', - value: 111.79, - }, - { - name: 'ant-design/ant-design', - value: 4464.67, - }, - { - name: 'microsoft/vscode', - value: 18606.76, - }, - { - name: 'hustcc/echarts-for-react', - value: 114.49, - }, - { - name: 'ecomfe/echarts-gl', - value: 94.86, - }, - { - name: 'antvis/G6', - value: 811.77, - }, - { - name: 'ecomfe/vue-echarts', - value: 129.13, - }, - { - name: 'ecomfe/echarts-liquidfill', - value: 42.78, - }, - { - name: 'apache/echarts-examples', - value: 14.95, - }, - { - name: 'vueComponent/ant-design-vue', - value: 1478.32, - }, - { - name: 'apache-superset/superset-ui', - value: 303.38, - }, - { - name: 'apache/superset', - value: 2312.64, - }, - { - name: 'ElemeFE/element', - value: 1381.47, - }, - { - name: 'xieziyu/ngx-echarts', - value: 91.76, - }, - { - name: 'plainheart/issue-pr-bot-test', - value: 21.06, - }, - { - name: 'element-plus/element-plus', - value: 1539.23, - }, - { - name: 'vuejs/vue-cli', - value: 1200.77, - }, - { - name: 'DefinitelyTyped/DefinitelyTyped', - value: 8541.83, - }, - { - name: 'vitejs/vite', - value: 3144.0, - }, - { - name: 'microsoft/TypeScript', - value: 5005.21, - }, - { - name: 'antvis/G2', - value: 597.01, - }, - { - name: 'webpack/webpack', - value: 1959.62, - }, - { - name: 'pmndrs/react-three-fiber', - value: 382.92, - }, - { - name: 'electron/electron', - value: 3549.94, - }, - { - name: 'airbnb/visx', - value: 309.94, - }, - { - name: 'umijs/qiankun', - value: 819.21, - }, - { - name: 'apache/incubator-echarts-doc', - value: 21.49, - }, - { - name: 'go-echarts/go-echarts', - value: 105.23, - }, - { - name: 'ecomfe/echarts-for-weixin', - value: 150.2, - }, - ], - edges: [ - { - source: 'apache/echarts', - target: 'apache/echarts-doc', - weight: 35.91, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/zrender', - weight: 11.73, - }, - { - source: 'apache/echarts-doc', - target: 'ant-design/ant-design', - weight: 3.47, - }, - { - source: 'apache/echarts-doc', - target: 'microsoft/vscode', - weight: 6.06, - }, - { - source: 'apache/echarts-doc', - target: 'hustcc/echarts-for-react', - weight: 1.25, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/echarts-gl', - weight: 2.24, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/vue-echarts', - weight: 0.82, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/echarts-liquidfill', - weight: 3.52, - }, - { - source: 'apache/echarts-doc', - target: 'apache/echarts-examples', - weight: 5.68, - }, - { - source: 'apache/echarts-doc', - target: 'plainheart/issue-pr-bot-test', - weight: 4.72, - }, - { - source: 'apache/echarts-doc', - target: 'vuejs/vue-cli', - weight: 0.83, - }, - { - source: 'apache/echarts-doc', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 4.26, - }, - { - source: 'apache/echarts-doc', - target: 'microsoft/TypeScript', - weight: 0.78, - }, - { - source: 'apache/echarts-doc', - target: 'antvis/G2', - weight: 0.79, - }, - { - source: 'apache/echarts-doc', - target: 'pmndrs/react-three-fiber', - weight: 3.7, - }, - { - source: 'apache/echarts-doc', - target: 'electron/electron', - weight: 0.9, - }, - { - source: 'apache/echarts-doc', - target: 'airbnb/visx', - weight: 3.95, - }, - { - source: 'apache/echarts-doc', - target: 'go-echarts/go-echarts', - weight: 3.0, - }, - { - source: 'apache/echarts-doc', - target: 'ecomfe/echarts-for-weixin', - weight: 2.1, - }, - { - source: 'apache/echarts', - target: 'ecomfe/zrender', - weight: 22.74, - }, - { - source: 'ecomfe/zrender', - target: 'ant-design/ant-design', - weight: 2.9, - }, - { - source: 'ecomfe/zrender', - target: 'microsoft/vscode', - weight: 2.27, - }, - { - source: 'ecomfe/zrender', - target: 'hustcc/echarts-for-react', - weight: 1.54, - }, - { - source: 'ecomfe/zrender', - target: 'ecomfe/echarts-gl', - weight: 3.39, - }, - { - source: 'ecomfe/zrender', - target: 'ecomfe/vue-echarts', - weight: 0.93, - }, - { - source: 'ecomfe/zrender', - target: 'ecomfe/echarts-liquidfill', - weight: 2.87, - }, - { - source: 'ecomfe/zrender', - target: 'apache/echarts-examples', - weight: 6.15, - }, - { - source: 'ecomfe/zrender', - target: 'plainheart/issue-pr-bot-test', - weight: 4.65, - }, - { - source: 'ecomfe/zrender', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 3.29, - }, - { - source: 'ecomfe/zrender', - target: 'vitejs/vite', - weight: 0.71, - }, - { - source: 'ecomfe/zrender', - target: 'microsoft/TypeScript', - weight: 0.59, - }, - { - source: 'ecomfe/zrender', - target: 'webpack/webpack', - weight: 0.93, - }, - { - source: 'ecomfe/zrender', - target: 'pmndrs/react-three-fiber', - weight: 1.97, - }, - { - source: 'ecomfe/zrender', - target: 'airbnb/visx', - weight: 2.03, - }, - { - source: 'ecomfe/zrender', - target: 'umijs/qiankun', - weight: 0.78, - }, - { - source: 'ecomfe/zrender', - target: 'go-echarts/go-echarts', - weight: 1.75, - }, - { - source: 'apache/echarts', - target: 'ant-design/ant-design', - weight: 21.08, - }, - { - source: 'ant-design/ant-design', - target: 'microsoft/vscode', - weight: 35.86, - }, - { - source: 'ant-design/ant-design', - target: 'hustcc/echarts-for-react', - weight: 5.55, - }, - { - source: 'ant-design/ant-design', - target: 'antvis/G6', - weight: 26.52, - }, - { - source: 'ant-design/ant-design', - target: 'apache/echarts-examples', - weight: 1.25, - }, - { - source: 'ant-design/ant-design', - target: 'vueComponent/ant-design-vue', - weight: 47.93, - }, - { - source: 'ant-design/ant-design', - target: 'apache-superset/superset-ui', - weight: 1.41, - }, - { - source: 'ant-design/ant-design', - target: 'apache/superset', - weight: 1.65, - }, - { - source: 'ant-design/ant-design', - target: 'ElemeFE/element', - weight: 10.94, - }, - { - source: 'ant-design/ant-design', - target: 'element-plus/element-plus', - weight: 19.29, - }, - { - source: 'ant-design/ant-design', - target: 'vuejs/vue-cli', - weight: 10.85, - }, - { - source: 'ant-design/ant-design', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 29.04, - }, - { - source: 'ant-design/ant-design', - target: 'vitejs/vite', - weight: 39.85, - }, - { - source: 'ant-design/ant-design', - target: 'microsoft/TypeScript', - weight: 32.77, - }, - { - source: 'ant-design/ant-design', - target: 'antvis/G2', - weight: 32.04, - }, - { - source: 'ant-design/ant-design', - target: 'webpack/webpack', - weight: 22.95, - }, - { - source: 'ant-design/ant-design', - target: 'pmndrs/react-three-fiber', - weight: 3.5, - }, - { - source: 'ant-design/ant-design', - target: 'electron/electron', - weight: 8.48, - }, - { - source: 'ant-design/ant-design', - target: 'airbnb/visx', - weight: 4.59, - }, - { - source: 'ant-design/ant-design', - target: 'umijs/qiankun', - weight: 26.27, - }, - { - source: 'ant-design/ant-design', - target: 'apache/incubator-echarts-doc', - weight: 2.4, - }, - { - source: 'ant-design/ant-design', - target: 'go-echarts/go-echarts', - weight: 1.94, - }, - { - source: 'ant-design/ant-design', - target: 'ecomfe/echarts-for-weixin', - weight: 2.06, - }, - { - source: 'apache/echarts', - target: 'microsoft/vscode', - weight: 14.59, - }, - { - source: 'microsoft/vscode', - target: 'antvis/G6', - weight: 5.09, - }, - { - source: 'microsoft/vscode', - target: 'ecomfe/echarts-liquidfill', - weight: 0.67, - }, - { - source: 'microsoft/vscode', - target: 'apache/echarts-examples', - weight: 1.7, - }, - { - source: 'microsoft/vscode', - target: 'vueComponent/ant-design-vue', - weight: 9.2, - }, - { - source: 'microsoft/vscode', - target: 'apache/superset', - weight: 5.01, - }, - { - source: 'microsoft/vscode', - target: 'ElemeFE/element', - weight: 9.44, - }, - { - source: 'microsoft/vscode', - target: 'xieziyu/ngx-echarts', - weight: 1.96, - }, - { - source: 'microsoft/vscode', - target: 'element-plus/element-plus', - weight: 4.96, - }, - { - source: 'microsoft/vscode', - target: 'vuejs/vue-cli', - weight: 31.99, - }, - { - source: 'microsoft/vscode', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 183.45, - }, - { - source: 'microsoft/vscode', - target: 'vitejs/vite', - weight: 56.13, - }, - { - source: 'microsoft/vscode', - target: 'microsoft/TypeScript', - weight: 419.87, - }, - { - source: 'microsoft/vscode', - target: 'antvis/G2', - weight: 4.4, - }, - { - source: 'microsoft/vscode', - target: 'webpack/webpack', - weight: 61.36, - }, - { - source: 'microsoft/vscode', - target: 'pmndrs/react-three-fiber', - weight: 9.96, - }, - { - source: 'microsoft/vscode', - target: 'electron/electron', - weight: 160.42, - }, - { - source: 'microsoft/vscode', - target: 'airbnb/visx', - weight: 7.82, - }, - { - source: 'microsoft/vscode', - target: 'umijs/qiankun', - weight: 3.85, - }, - { - source: 'microsoft/vscode', - target: 'go-echarts/go-echarts', - weight: 4.05, - }, - { - source: 'apache/echarts', - target: 'hustcc/echarts-for-react', - weight: 11.01, - }, - { - source: 'hustcc/echarts-for-react', - target: 'ecomfe/echarts-gl', - weight: 1.25, - }, - { - source: 'hustcc/echarts-for-react', - target: 'antvis/G6', - weight: 1.72, - }, - { - source: 'hustcc/echarts-for-react', - target: 'ecomfe/vue-echarts', - weight: 0.63, - }, - { - source: 'hustcc/echarts-for-react', - target: 'ecomfe/echarts-liquidfill', - weight: 1.17, - }, - { - source: 'hustcc/echarts-for-react', - target: 'apache/echarts-examples', - weight: 0.87, - }, - { - source: 'hustcc/echarts-for-react', - target: 'vuejs/vue-cli', - weight: 0.78, - }, - { - source: 'hustcc/echarts-for-react', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 0.67, - }, - { - source: 'hustcc/echarts-for-react', - target: 'antvis/G2', - weight: 8.32, - }, - { - source: 'hustcc/echarts-for-react', - target: 'webpack/webpack', - weight: 0.59, - }, - { - source: 'apache/echarts', - target: 'ecomfe/echarts-gl', - weight: 9.15, - }, - { - source: 'ecomfe/echarts-gl', - target: 'ecomfe/vue-echarts', - weight: 3.39, - }, - { - source: 'ecomfe/echarts-gl', - target: 'ecomfe/echarts-liquidfill', - weight: 2.0, - }, - { - source: 'ecomfe/echarts-gl', - target: 'apache/echarts-examples', - weight: 1.25, - }, - { - source: 'ecomfe/echarts-gl', - target: 'ElemeFE/element', - weight: 1.41, - }, - { - source: 'apache/echarts', - target: 'antvis/G6', - weight: 8.9, - }, - { - source: 'antvis/G6', - target: 'ecomfe/vue-echarts', - weight: 0.78, - }, - { - source: 'antvis/G6', - target: 'vueComponent/ant-design-vue', - weight: 12.19, - }, - { - source: 'antvis/G6', - target: 'apache/superset', - weight: 0.71, - }, - { - source: 'antvis/G6', - target: 'ElemeFE/element', - weight: 3.85, - }, - { - source: 'antvis/G6', - target: 'element-plus/element-plus', - weight: 0.9, - }, - { - source: 'antvis/G6', - target: 'vuejs/vue-cli', - weight: 2.04, - }, - { - source: 'antvis/G6', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 2.31, - }, - { - source: 'antvis/G6', - target: 'vitejs/vite', - weight: 9.34, - }, - { - source: 'antvis/G6', - target: 'microsoft/TypeScript', - weight: 1.68, - }, - { - source: 'antvis/G6', - target: 'antvis/G2', - weight: 33.71, - }, - { - source: 'antvis/G6', - target: 'webpack/webpack', - weight: 2.08, - }, - { - source: 'antvis/G6', - target: 'electron/electron', - weight: 2.91, - }, - { - source: 'antvis/G6', - target: 'airbnb/visx', - weight: 0.63, - }, - { - source: 'antvis/G6', - target: 'umijs/qiankun', - weight: 4.86, - }, - { - source: 'apache/echarts', - target: 'ecomfe/vue-echarts', - weight: 8.47, - }, - { - source: 'ecomfe/vue-echarts', - target: 'ecomfe/echarts-liquidfill', - weight: 0.78, - }, - { - source: 'ecomfe/vue-echarts', - target: 'apache/echarts-examples', - weight: 0.63, - }, - { - source: 'ecomfe/vue-echarts', - target: 'vueComponent/ant-design-vue', - weight: 4.66, - }, - { - source: 'ecomfe/vue-echarts', - target: 'ElemeFE/element', - weight: 4.56, - }, - { - source: 'ecomfe/vue-echarts', - target: 'element-plus/element-plus', - weight: 2.05, - }, - { - source: 'ecomfe/vue-echarts', - target: 'vuejs/vue-cli', - weight: 0.94, - }, - { - source: 'ecomfe/vue-echarts', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 1.04, - }, - { - source: 'ecomfe/vue-echarts', - target: 'vitejs/vite', - weight: 3.19, - }, - { - source: 'ecomfe/vue-echarts', - target: 'microsoft/TypeScript', - weight: 1.17, - }, - { - source: 'ecomfe/vue-echarts', - target: 'umijs/qiankun', - weight: 1.14, - }, - { - source: 'apache/echarts', - target: 'ecomfe/echarts-liquidfill', - weight: 8.47, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'apache/echarts-examples', - weight: 1.17, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 1.25, - }, - { - source: 'ecomfe/echarts-liquidfill', - target: 'ecomfe/echarts-for-weixin', - weight: 1.4, - }, - { - source: 'apache/echarts', - target: 'apache/echarts-examples', - weight: 8.39, - }, - { - source: 'apache/echarts-examples', - target: 'plainheart/issue-pr-bot-test', - weight: 3.2, - }, - { - source: 'apache/echarts-examples', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 1.27, - }, - { - source: 'apache/echarts-examples', - target: 'pmndrs/react-three-fiber', - weight: 1.53, - }, - { - source: 'apache/echarts-examples', - target: 'airbnb/visx', - weight: 1.57, - }, - { - source: 'apache/echarts-examples', - target: 'go-echarts/go-echarts', - weight: 1.39, - }, - { - source: 'apache/echarts', - target: 'vueComponent/ant-design-vue', - weight: 8.14, - }, - { - source: 'vueComponent/ant-design-vue', - target: 'ElemeFE/element', - weight: 14.96, - }, - { - source: 'vueComponent/ant-design-vue', - target: 'element-plus/element-plus', - weight: 31.08, - }, - { - source: 'vueComponent/ant-design-vue', - target: 'vuejs/vue-cli', - weight: 13.91, - }, - { - source: 'vueComponent/ant-design-vue', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 3.95, - }, - { - source: 'vueComponent/ant-design-vue', - target: 'vitejs/vite', - weight: 54.04, - }, - { - source: 'vueComponent/ant-design-vue', - target: 'microsoft/TypeScript', - weight: 4.12, - }, - { - source: 'vueComponent/ant-design-vue', - target: 'antvis/G2', - weight: 14.29, - }, - { - source: 'vueComponent/ant-design-vue', - target: 'webpack/webpack', - weight: 3.3, - }, - { - source: 'vueComponent/ant-design-vue', - target: 'electron/electron', - weight: 5.5, - }, - { - source: 'vueComponent/ant-design-vue', - target: 'umijs/qiankun', - weight: 14.35, - }, - { - source: 'apache/echarts', - target: 'apache-superset/superset-ui', - weight: 7.88, - }, - { - source: 'apache-superset/superset-ui', - target: 'apache/superset', - weight: 142.13, - }, - { - source: 'apache-superset/superset-ui', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 2.52, - }, - { - source: 'apache-superset/superset-ui', - target: 'airbnb/visx', - weight: 3.64, - }, - { - source: 'apache-superset/superset-ui', - target: 'apache/incubator-echarts-doc', - weight: 2.45, - }, - { - source: 'apache/echarts', - target: 'apache/superset', - weight: 7.85, - }, - { - source: 'apache/superset', - target: 'vuejs/vue-cli', - weight: 0.63, - }, - { - source: 'apache/superset', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 3.98, - }, - { - source: 'apache/superset', - target: 'microsoft/TypeScript', - weight: 2.9, - }, - { - source: 'apache/superset', - target: 'airbnb/visx', - weight: 4.27, - }, - { - source: 'apache/superset', - target: 'umijs/qiankun', - weight: 1.01, - }, - { - source: 'apache/superset', - target: 'apache/incubator-echarts-doc', - weight: 2.54, - }, - { - source: 'apache/echarts', - target: 'ElemeFE/element', - weight: 7.41, - }, - { - source: 'ElemeFE/element', - target: 'element-plus/element-plus', - weight: 57.64, - }, - { - source: 'ElemeFE/element', - target: 'vuejs/vue-cli', - weight: 6.0, - }, - { - source: 'ElemeFE/element', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 0.75, - }, - { - source: 'ElemeFE/element', - target: 'vitejs/vite', - weight: 12.08, - }, - { - source: 'ElemeFE/element', - target: 'microsoft/TypeScript', - weight: 5.95, - }, - { - source: 'ElemeFE/element', - target: 'antvis/G2', - weight: 5.56, - }, - { - source: 'ElemeFE/element', - target: 'webpack/webpack', - weight: 2.31, - }, - { - source: 'ElemeFE/element', - target: 'electron/electron', - weight: 0.93, - }, - { - source: 'ElemeFE/element', - target: 'umijs/qiankun', - weight: 14.37, - }, - { - source: 'ElemeFE/element', - target: 'ecomfe/echarts-for-weixin', - weight: 0.83, - }, - { - source: 'apache/echarts', - target: 'xieziyu/ngx-echarts', - weight: 7.33, - }, - { - source: 'xieziyu/ngx-echarts', - target: 'microsoft/TypeScript', - weight: 3.62, - }, - { - source: 'apache/echarts', - target: 'plainheart/issue-pr-bot-test', - weight: 7.21, - }, - { - source: 'apache/echarts', - target: 'element-plus/element-plus', - weight: 7.15, - }, - { - source: 'element-plus/element-plus', - target: 'vuejs/vue-cli', - weight: 12.07, - }, - { - source: 'element-plus/element-plus', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 1.13, - }, - { - source: 'element-plus/element-plus', - target: 'vitejs/vite', - weight: 58.98, - }, - { - source: 'element-plus/element-plus', - target: 'microsoft/TypeScript', - weight: 6.05, - }, - { - source: 'element-plus/element-plus', - target: 'antvis/G2', - weight: 2.84, - }, - { - source: 'element-plus/element-plus', - target: 'webpack/webpack', - weight: 4.81, - }, - { - source: 'element-plus/element-plus', - target: 'electron/electron', - weight: 1.03, - }, - { - source: 'element-plus/element-plus', - target: 'umijs/qiankun', - weight: 5.75, - }, - { - source: 'element-plus/element-plus', - target: 'ecomfe/echarts-for-weixin', - weight: 0.87, - }, - { - source: 'apache/echarts', - target: 'vuejs/vue-cli', - weight: 7.04, - }, - { - source: 'vuejs/vue-cli', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 12.21, - }, - { - source: 'vuejs/vue-cli', - target: 'vitejs/vite', - weight: 52.51, - }, - { - source: 'vuejs/vue-cli', - target: 'microsoft/TypeScript', - weight: 23.85, - }, - { - source: 'vuejs/vue-cli', - target: 'webpack/webpack', - weight: 19.12, - }, - { - source: 'vuejs/vue-cli', - target: 'electron/electron', - weight: 8.39, - }, - { - source: 'vuejs/vue-cli', - target: 'airbnb/visx', - weight: 0.5, - }, - { - source: 'vuejs/vue-cli', - target: 'umijs/qiankun', - weight: 5.88, - }, - { - source: 'apache/echarts', - target: 'DefinitelyTyped/DefinitelyTyped', - weight: 6.74, - }, - { - source: 'DefinitelyTyped/DefinitelyTyped', - target: 'vitejs/vite', - weight: 36.81, - }, - { - source: 'DefinitelyTyped/DefinitelyTyped', - target: 'microsoft/TypeScript', - weight: 432.3, - }, - { - source: 'DefinitelyTyped/DefinitelyTyped', - target: 'webpack/webpack', - weight: 67.0, - }, - { - source: 'DefinitelyTyped/DefinitelyTyped', - target: 'pmndrs/react-three-fiber', - weight: 14.66, - }, - { - source: 'DefinitelyTyped/DefinitelyTyped', - target: 'electron/electron', - weight: 39.66, - }, - { - source: 'DefinitelyTyped/DefinitelyTyped', - target: 'airbnb/visx', - weight: 8.8, - }, - { - source: 'DefinitelyTyped/DefinitelyTyped', - target: 'umijs/qiankun', - weight: 1.73, - }, - { - source: 'DefinitelyTyped/DefinitelyTyped', - target: 'apache/incubator-echarts-doc', - weight: 1.05, - }, - { - source: 'DefinitelyTyped/DefinitelyTyped', - target: 'go-echarts/go-echarts', - weight: 1.97, - }, - { - source: 'DefinitelyTyped/DefinitelyTyped', - target: 'ecomfe/echarts-for-weixin', - weight: 1.61, - }, - { - source: 'apache/echarts', - target: 'vitejs/vite', - weight: 6.58, - }, - { - source: 'vitejs/vite', - target: 'microsoft/TypeScript', - weight: 77.45, - }, - { - source: 'vitejs/vite', - target: 'antvis/G2', - weight: 6.94, - }, - { - source: 'vitejs/vite', - target: 'webpack/webpack', - weight: 32.69, - }, - { - source: 'vitejs/vite', - target: 'pmndrs/react-three-fiber', - weight: 1.81, - }, - { - source: 'vitejs/vite', - target: 'electron/electron', - weight: 11.98, - }, - { - source: 'vitejs/vite', - target: 'airbnb/visx', - weight: 0.59, - }, - { - source: 'vitejs/vite', - target: 'umijs/qiankun', - weight: 9.05, - }, - { - source: 'vitejs/vite', - target: 'go-echarts/go-echarts', - weight: 0.59, - }, - { - source: 'vitejs/vite', - target: 'ecomfe/echarts-for-weixin', - weight: 0.93, - }, - { - source: 'apache/echarts', - target: 'microsoft/TypeScript', - weight: 6.31, - }, - { - source: 'microsoft/TypeScript', - target: 'antvis/G2', - weight: 2.21, - }, - { - source: 'microsoft/TypeScript', - target: 'webpack/webpack', - weight: 92.27, - }, - { - source: 'microsoft/TypeScript', - target: 'pmndrs/react-three-fiber', - weight: 10.57, - }, - { - source: 'microsoft/TypeScript', - target: 'electron/electron', - weight: 68.63, - }, - { - source: 'microsoft/TypeScript', - target: 'airbnb/visx', - weight: 4.43, - }, - { - source: 'microsoft/TypeScript', - target: 'umijs/qiankun', - weight: 0.67, - }, - { - source: 'apache/echarts', - target: 'antvis/G2', - weight: 6.28, - }, - { - source: 'antvis/G2', - target: 'webpack/webpack', - weight: 2.49, - }, - { - source: 'antvis/G2', - target: 'electron/electron', - weight: 2.21, - }, - { - source: 'antvis/G2', - target: 'umijs/qiankun', - weight: 5.49, - }, - { - source: 'antvis/G2', - target: 'ecomfe/echarts-for-weixin', - weight: 0.78, - }, - { - source: 'apache/echarts', - target: 'webpack/webpack', - weight: 5.66, - }, - { - source: 'webpack/webpack', - target: 'pmndrs/react-three-fiber', - weight: 3.78, - }, - { - source: 'webpack/webpack', - target: 'electron/electron', - weight: 27.49, - }, - { - source: 'webpack/webpack', - target: 'airbnb/visx', - weight: 2.16, - }, - { - source: 'webpack/webpack', - target: 'umijs/qiankun', - weight: 6.35, - }, - { - source: 'webpack/webpack', - target: 'ecomfe/echarts-for-weixin', - weight: 1.36, - }, - { - source: 'apache/echarts', - target: 'pmndrs/react-three-fiber', - weight: 5.26, - }, - { - source: 'pmndrs/react-three-fiber', - target: 'electron/electron', - weight: 1.52, - }, - { - source: 'pmndrs/react-three-fiber', - target: 'airbnb/visx', - weight: 3.4, - }, - { - source: 'pmndrs/react-three-fiber', - target: 'go-echarts/go-echarts', - weight: 2.68, - }, - { - source: 'apache/echarts', - target: 'electron/electron', - weight: 5.11, - }, - { - source: 'electron/electron', - target: 'airbnb/visx', - weight: 0.5, - }, - { - source: 'electron/electron', - target: 'umijs/qiankun', - weight: 1.93, - }, - { - source: 'apache/echarts', - target: 'airbnb/visx', - weight: 4.93, - }, - { - source: 'airbnb/visx', - target: 'go-echarts/go-echarts', - weight: 2.8, - }, - { - source: 'apache/echarts', - target: 'umijs/qiankun', - weight: 4.66, - }, - { - source: 'umijs/qiankun', - target: 'ecomfe/echarts-for-weixin', - weight: 0.92, - }, - { - source: 'apache/echarts', - target: 'apache/incubator-echarts-doc', - weight: 4.64, - }, - { - source: 'apache/echarts', - target: 'go-echarts/go-echarts', - weight: 4.52, - }, - { - source: 'apache/echarts', - target: 'ecomfe/echarts-for-weixin', - weight: 4.5, - }, - ], -}; - -export const developersByRepo = { - nodes: [ - { - name: 'pissang', - value: 28.74, - }, - { - name: 'plainheart', - value: 21.4, - }, - { - name: 'Ovilia', - value: 18.17, - }, - { - name: 'susiwen8', - value: 15.58, - }, - { - name: 'Bilge', - value: 8.06, - }, - { - name: 'yufeng04', - value: 6.34, - }, - { - name: 'zhoufanglu', - value: 6.32, - }, - { - name: 'Nick22nd', - value: 6.02, - }, - { - name: 'gsi7', - value: 5.74, - }, - { - name: 'villebro', - value: 5.68, - }, - { - name: 'twittwer', - value: 5.01, - }, - { - name: 'symlons', - value: 5.0, - }, - { - name: 'fajiaopaopao', - value: 4.12, - }, - { - name: 'TheLostDory', - value: 4.12, - }, - { - name: 'leosxie', - value: 4.09, - }, - { - name: 'Rainy-Bear', - value: 3.87, - }, - { - name: 'xxLion', - value: 3.87, - }, - { - name: 'qortex', - value: 3.77, - }, - { - name: 'yang-mengyue', - value: 3.74, - }, - { - name: 'baokeyu123', - value: 3.74, - }, - { - name: 'facingcheer', - value: 3.74, - }, - { - name: 'wf123537200', - value: 3.61, - }, - { - name: 'Clarkkkk', - value: 3.61, - }, - { - name: '14glwu', - value: 3.61, - }, - { - name: 'mumu1349562746', - value: 3.61, - }, - { - name: 'KehaoWu', - value: 3.61, - }, - { - name: 'dileepyelleti', - value: 3.61, - }, - { - name: 'Sweet-KK', - value: 3.46, - }, - { - name: 'fezhangyao', - value: 3.46, - }, - { - name: 'zpinocchio', - value: 3.46, - }, - ], - edges: [ - { - source: 'pissang', - target: 'plainheart', - weight: 26.63, - }, - { - source: 'pissang', - target: 'Ovilia', - weight: 8.83, - }, - { - source: 'pissang', - target: 'susiwen8', - weight: 25.23, - }, - { - source: 'pissang', - target: 'Bilge', - weight: 5.93, - }, - { - source: 'pissang', - target: 'yufeng04', - weight: 2.78, - }, - { - source: 'pissang', - target: 'zhoufanglu', - weight: 3.09, - }, - { - source: 'pissang', - target: 'Nick22nd', - weight: 1.94, - }, - { - source: 'pissang', - target: 'gsi7', - weight: 3.26, - }, - { - source: 'pissang', - target: 'villebro', - weight: 2.95, - }, - { - source: 'pissang', - target: 'twittwer', - weight: 2.4, - }, - { - source: 'pissang', - target: 'symlons', - weight: 2.48, - }, - { - source: 'pissang', - target: 'leosxie', - weight: 1.98, - }, - { - source: 'pissang', - target: 'Rainy-Bear', - weight: 2.12, - }, - { - source: 'pissang', - target: 'qortex', - weight: 1.73, - }, - { - source: 'pissang', - target: 'yang-mengyue', - weight: 0.87, - }, - { - source: 'pissang', - target: 'wf123537200', - weight: 0.5, - }, - { - source: 'pissang', - target: 'Clarkkkk', - weight: 2.09, - }, - { - source: 'pissang', - target: '14glwu', - weight: 0.87, - }, - { - source: 'pissang', - target: 'mumu1349562746', - weight: 1.8, - }, - { - source: 'pissang', - target: 'KehaoWu', - weight: 1.12, - }, - { - source: 'pissang', - target: 'Sweet-KK', - weight: 2.19, - }, - { - source: 'pissang', - target: 'zpinocchio', - weight: 0.71, - }, - { - source: 'plainheart', - target: 'Ovilia', - weight: 5.38, - }, - { - source: 'plainheart', - target: 'susiwen8', - weight: 10.11, - }, - { - source: 'plainheart', - target: 'Bilge', - weight: 4.31, - }, - { - source: 'plainheart', - target: 'zhoufanglu', - weight: 3.67, - }, - { - source: 'plainheart', - target: 'gsi7', - weight: 0.5, - }, - { - source: 'plainheart', - target: 'villebro', - weight: 0.71, - }, - { - source: 'plainheart', - target: 'symlons', - weight: 1.57, - }, - { - source: 'plainheart', - target: 'TheLostDory', - weight: 1.5, - }, - { - source: 'plainheart', - target: 'leosxie', - weight: 0.5, - }, - { - source: 'plainheart', - target: 'xxLion', - weight: 1.0, - }, - { - source: 'plainheart', - target: 'qortex', - weight: 0.5, - }, - { - source: 'plainheart', - target: 'yang-mengyue', - weight: 0.87, - }, - { - source: 'plainheart', - target: 'baokeyu123', - weight: 1.21, - }, - { - source: 'plainheart', - target: 'facingcheer', - weight: 2.12, - }, - { - source: 'plainheart', - target: 'wf123537200', - weight: 0.5, - }, - { - source: 'plainheart', - target: 'KehaoWu', - weight: 1.0, - }, - { - source: 'Ovilia', - target: 'susiwen8', - weight: 0.5, - }, - { - source: 'Ovilia', - target: 'Bilge', - weight: 5.88, - }, - { - source: 'Ovilia', - target: 'zhoufanglu', - weight: 1.32, - }, - { - source: 'Ovilia', - target: 'villebro', - weight: 1.0, - }, - { - source: 'Ovilia', - target: 'symlons', - weight: 1.0, - }, - { - source: 'Ovilia', - target: 'fajiaopaopao', - weight: 0.87, - }, - { - source: 'Ovilia', - target: 'baokeyu123', - weight: 0.71, - }, - { - source: 'Ovilia', - target: 'wf123537200', - weight: 0.5, - }, - { - source: 'Ovilia', - target: '14glwu', - weight: 1.12, - }, - { - source: 'Ovilia', - target: 'KehaoWu', - weight: 1.0, - }, - { - source: 'Ovilia', - target: 'dileepyelleti', - weight: 0.87, - }, - { - source: 'Ovilia', - target: 'zpinocchio', - weight: 1.57, - }, - { - source: 'susiwen8', - target: 'Bilge', - weight: 0.71, - }, - { - source: 'susiwen8', - target: 'Nick22nd', - weight: 1.94, - }, - { - source: 'susiwen8', - target: 'gsi7', - weight: 0.87, - }, - { - source: 'susiwen8', - target: 'fajiaopaopao', - weight: 1.41, - }, - { - source: 'susiwen8', - target: 'TheLostDory', - weight: 0.71, - }, - { - source: 'susiwen8', - target: 'Rainy-Bear', - weight: 1.0, - }, - { - source: 'susiwen8', - target: 'xxLion', - weight: 1.0, - }, - { - source: 'susiwen8', - target: 'qortex', - weight: 0.5, - }, - { - source: 'susiwen8', - target: 'facingcheer', - weight: 0.71, - }, - { - source: 'susiwen8', - target: 'fezhangyao', - weight: 1.58, - }, - { - source: 'Bilge', - target: 'zpinocchio', - weight: 0.71, - }, - ], -}; diff --git a/src/utils/request.ts b/src/utils/request.ts index d3bc9cfc..9651cf5b 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,5 +1,4 @@ // @ts-ignore -import ENV from '../../utils/env'; import { ErrorCode } from '../constant'; /** @@ -19,15 +18,4 @@ const request = async (url: string) => { }; }; -export const mockSuccessRes = (data: any) => { - if (!ENV.MOCK) { - return null; - } - return { - status: 200, - statusText: 'ok', - data: data, - }; -}; - export default request; diff --git a/utils/env.js b/utils/env.js index af9a55bb..c7081d21 100644 --- a/utils/env.js +++ b/utils/env.js @@ -2,5 +2,4 @@ export default { NODE_ENV: process.env.NODE_ENV || 'development', PORT: process.env.PORT || 3000, - MOCK: process.env.MOCK || false, }; diff --git a/webpack.config.js b/webpack.config.js index 3eff18e5..7cfa9266 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -127,7 +127,6 @@ let options = { new webpack.EnvironmentPlugin({ NODE_ENV: env.NODE_ENV, PORT: env.PORT, - MOCK: env.MOCK, }), new CopyWebpackPlugin({ patterns: [ From 7ad352fa63c302717f828f9ba8b90411db92196f Mon Sep 17 00:00:00 2001 From: Lam Tang Date: Sun, 4 Dec 2022 21:44:26 +0800 Subject: [PATCH 06/10] remove DynamicRadar --- .../DynamicRadar/ControlBar/ControlBar.tsx | 94 --------------- src/components/DynamicRadar/DynamicRadar.tsx | 110 ------------------ src/components/DynamicRadar/Radar/Radar.tsx | 105 ----------------- .../DynamicRadar/SimpleTable/SimpleTable.tsx | 85 -------------- 4 files changed, 394 deletions(-) delete mode 100644 src/components/DynamicRadar/ControlBar/ControlBar.tsx delete mode 100644 src/components/DynamicRadar/DynamicRadar.tsx delete mode 100644 src/components/DynamicRadar/Radar/Radar.tsx delete mode 100644 src/components/DynamicRadar/SimpleTable/SimpleTable.tsx diff --git a/src/components/DynamicRadar/ControlBar/ControlBar.tsx b/src/components/DynamicRadar/ControlBar/ControlBar.tsx deleted file mode 100644 index 5868d623..00000000 --- a/src/components/DynamicRadar/ControlBar/ControlBar.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import React, { useState } from 'react'; -import { Stack, Slider, IconButton } from '@fluentui/react'; -import { - IStyleFunctionOrObject, - ISliderStyleProps, - ISliderStyles, -} from '@fluentui/react'; - -interface ControlBarProps { - theme: 'light' | 'dark'; - play: Function; - pause: Function; - setIndex: Function; - sliderValue: number; - sliderMax: number; -} - -const ControlBar: React.FC = (props) => { - const { theme, play, pause, setIndex, sliderValue, sliderMax } = props; - const [ifPlay, setIfPlay] = useState(false); - - const sliderStyle: IStyleFunctionOrObject = - { - thumb: { - background: theme == 'light' ? 'darkblue' : '#58a6ff', - borderRadius: 0, - height: '14px', - top: '-5px', - width: '6px', - borderWidth: '0px', - }, - activeSection: { - background: theme == 'light' ? 'rgb(200, 198, 196)' : '#58a6ff', - }, - inactiveSection: { - background: theme == 'light' ? 'rgb(237, 235, 233)' : 'white', - }, - }; - - const previous = () => { - setIndex((idx: number) => (idx - 1 < 0 ? 0 : idx - 1)); - }; - - const next = () => { - setIndex((idx: number) => (idx + 1 > sliderMax ? sliderMax : idx + 1)); - }; - - return ( -
- - { - ifPlay ? pause() : play(); - setIfPlay(!ifPlay); - }} - /> - - - setIndex(value)} - /> - - - -
- ); -}; - -export default ControlBar; diff --git a/src/components/DynamicRadar/DynamicRadar.tsx b/src/components/DynamicRadar/DynamicRadar.tsx deleted file mode 100644 index 6def690e..00000000 --- a/src/components/DynamicRadar/DynamicRadar.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import React, { useEffect, useState, useRef } from 'react'; -import { Stack } from '@fluentui/react'; -import Radar from './Radar/Radar'; -import SimpleTable from './SimpleTable/SimpleTable'; -import ControlBar from './ControlBar/ControlBar'; - -const LEFT_TOP_WIDTH_PERCENT = '70%'; -const RIGHT_TOP_WIDTH_PERCENT = '30%'; -const TOP_HEIGHT_PERCENT = 0.9; - -interface DynamicRadarDataItem { - date: string; - values: number[]; -} - -interface DynamicRadarProps { - theme: 'light' | 'dark'; - width: number; - height: number; - indicators: string[]; - data: DynamicRadarDataItem[]; -} - -const DynamicRadar: React.FC = (props) => { - const { theme, width, height, indicators, data } = props; - const [idx, setIdx] = useState(0); - const timer: { current: NodeJS.Timeout | null } = useRef(null); - const maxScales = findMaxScales(indicators, data); - - const tick = () => { - setIdx((idx) => (idx + 1 > data.length - 1 ? 0 : idx + 1)); - }; - - const play = () => { - clearInterval(timer.current as NodeJS.Timeout); - timer.current = setInterval(tick, 500); - }; - - const pause = () => { - clearInterval(timer.current as NodeJS.Timeout); - }; - - useEffect(() => { - console.log('DynamicRadar (re)rendered!'); - }); - - return ( - - -
- -
- - - -
- -
- ); -}; - -const findMaxScales = (indicators: string[], data: DynamicRadarDataItem[]) => { - let maxScales = new Array(indicators.length).fill(0); - data.forEach((item) => { - let values = item.values; - for (let i = 0; i < indicators.length; i++) { - if (values[i] > maxScales[i]) { - maxScales[i] = values[i]; - } - } - }); - return maxScales.map((v) => Math.ceil(v * 1.1)); -}; - -export default DynamicRadar; diff --git a/src/components/DynamicRadar/Radar/Radar.tsx b/src/components/DynamicRadar/Radar/Radar.tsx deleted file mode 100644 index a3ab2f0b..00000000 --- a/src/components/DynamicRadar/Radar/Radar.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import React, { useEffect, useRef } from 'react'; -import * as echarts from 'echarts'; - -interface RadarProps { - theme: 'light' | 'dark'; - height: number; - indicators: string[]; - maxScales: number[]; - values: number[]; -} - -const Radar: React.FC = (props) => { - const { theme, height, indicators, maxScales, values } = props; - const divEL = useRef(null); - - const option = { - legend: undefined, - tooltip: undefined, - radar: { - shape: 'circle', - indicator: indicators.map((item: any, index: any) => { - return { name: item, max: maxScales[index] }; - }), - center: ['50%', '50%'], - splitNumber: 3, - name: { - textStyle: { - color: theme === 'light' ? '#010409' : '#f0f6fc', - fontSize: 13, - textShadowColor: theme === 'light' ? '#010409' : '#f0f6fc', - textShadowBlur: 0.01, - textShadowOffsetX: 0.01, - textShadowOffsetY: 0.01, - }, - }, - splitArea: { - areaStyle: { - color: [theme == 'light' ? 'darkblue' : '#58a6ff'], - opacity: 1, - }, - }, - axisLine: { - lineStyle: { - width: 2, - color: 'white', - opacity: 0.4, - }, - }, - splitLine: { - lineStyle: { - color: 'white', - width: 1.5, - opacity: 0.4, - }, - }, - }, - series: [ - { - type: 'radar', - symbol: 'none', - itemStyle: {}, - lineStyle: { - width: 1.5, - color: 'white', - opacity: 1, - shadowBlur: 4, - shadowColor: 'white', - shadowOffsetX: 0.5, - shadowOffsetY: 0.5, - }, - areaStyle: { - color: 'white', - opacity: 0.8, - }, - data: [ - { - value: values, - }, - ], - }, - ], - animation: true, - animationDurationUpdate: 200, - }; - useEffect(() => { - let chartDOM = divEL.current; - const instance = echarts.init(chartDOM as any); - - return () => { - instance.dispose(); - }; - }, []); - - useEffect(() => { - let chartDOM = divEL.current; - const instance = echarts.getInstanceByDom(chartDOM as any); - if (instance) { - instance.setOption(option); - } - }, [indicators, values]); - - return
; -}; - -export default Radar; diff --git a/src/components/DynamicRadar/SimpleTable/SimpleTable.tsx b/src/components/DynamicRadar/SimpleTable/SimpleTable.tsx deleted file mode 100644 index 45feeba8..00000000 --- a/src/components/DynamicRadar/SimpleTable/SimpleTable.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import React from 'react'; -import { Stack } from '@fluentui/react'; - -interface SimpleTableProps { - theme: 'light' | 'dark'; - title: string; - keys: string[]; - values: number[]; -} - -const SimpleTable: React.FC = (props) => { - const { theme, title, keys, values } = props; - - const tableContainerStyle: React.CSSProperties = { - width: '90%', - marginLeft: '5%', - marginRight: '5%', - }; - - const tableTitleStyle: React.CSSProperties = { - margin: 0, - marginBottom: 5, - color: theme == 'light' ? '#010409' : '#f0f6fc', - }; - - const tableLineStyle: React.CSSProperties = { - height: '2px', - backgroundColor: theme == 'light' ? 'darkblue' : '#58a6ff', - marginTop: '1px', - marginBottom: '1px', - }; - - const tableKeyStyle: React.CSSProperties = { - fontSize: 15, - color: theme == 'light' ? '#010409' : '#f0f6fc', - fontWeight: 'bold', - }; - - const tableValueStyle: React.CSSProperties = { - fontSize: 15, - color: theme == 'light' ? '#010409' : '#f0f6fc', - fontStyle: 'italic', - }; - - return ( -
- - -

{title}

-
-
-
- {keys.map((item: any, index: any) => { - return ( - -
{item}
-
{numFormat(values[index], 1)}
-
- ); - })} -
-
- ); -}; - -const numFormat = (num: number, digits: number) => { - let si = [ - { value: 1, symbol: '' }, - { value: 1e3, symbol: 'k' }, - ]; - let rx = /\.0+$|(\.[0-9]*[1-9])0+$/; - let i; - for (i = si.length - 1; i > 0; i--) { - if (num >= si[i].value) { - break; - } - } - return (num / si[i].value).toFixed(digits).replace(rx, '$1') + si[i].symbol; -}; - -export default SimpleTable; From 3f1bbd1083f1da4245c8221469f9b6a6779f8887 Mon Sep 17 00:00:00 2001 From: Lam Tang Date: Sun, 4 Dec 2022 21:49:53 +0800 Subject: [PATCH 07/10] temporarily clear Popup page --- src/pages/Popup/Popup.css | 45 --------------------------- src/pages/Popup/Popup.tsx | 64 --------------------------------------- src/pages/Popup/index.css | 3 -- src/pages/Popup/index.jsx | 13 -------- 4 files changed, 125 deletions(-) delete mode 100644 src/pages/Popup/Popup.css delete mode 100644 src/pages/Popup/Popup.tsx delete mode 100644 src/pages/Popup/index.css diff --git a/src/pages/Popup/Popup.css b/src/pages/Popup/Popup.css deleted file mode 100644 index e7ce4768..00000000 --- a/src/pages/Popup/Popup.css +++ /dev/null @@ -1,45 +0,0 @@ -.App { - position: absolute; - top: 0px; - bottom: 0px; - left: 0px; - right: 0px; - text-align: center; - height: 100%; - padding: 10px; - background-color: #282c34; -} - -.App-logo { - height: 30vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - height: 100%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/pages/Popup/Popup.tsx b/src/pages/Popup/Popup.tsx deleted file mode 100644 index 5daa42fb..00000000 --- a/src/pages/Popup/Popup.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { Stack, Toggle } from 'office-ui-fabric-react'; -import './Popup.css'; -import Settings, { loadSettings } from '../../utils/settings'; -import { chromeSet, getMessageByLocale } from '../../utils/utils'; - -const Popup: React.FC = () => { - const [settings, setSettings] = useState(new Settings()); - const [inited, setInited] = useState(false); - - useEffect(() => { - const initSettings = async () => { - const temp = await loadSettings(); - setSettings(temp); - setInited(true); - }; - if (!inited) { - initSettings(); - } - }, [inited, settings]); - - const saveSettings = async (settings: Settings) => { - setSettings(settings); - await chromeSet('settings', settings.toJson()); - }; - - if (!inited) { - return
; - } - - return ( - - - - { - settings.isEnabled = checked; - await saveSettings(settings); - }} - /> - - - - ); -}; - -export default Popup; diff --git a/src/pages/Popup/index.css b/src/pages/Popup/index.css deleted file mode 100644 index dc973b91..00000000 --- a/src/pages/Popup/index.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - min-width: 200px; -} diff --git a/src/pages/Popup/index.jsx b/src/pages/Popup/index.jsx index 78a4b5c8..e69de29b 100644 --- a/src/pages/Popup/index.jsx +++ b/src/pages/Popup/index.jsx @@ -1,13 +0,0 @@ -// initializeIcons() should only be called once per app and must be called before rendering any components. -import { initializeIcons } from '@fluentui/react/lib/Icons'; -initializeIcons(); - -import React from 'react'; -import { render } from 'react-dom'; - -import Popup from './Popup'; -import './index.css'; - -render(, window.document.querySelector('#app-container')); - -if (module.hot) module.hot.accept(); From c953d131c1678a01dfef05297904207721f564ad Mon Sep 17 00:00:00 2001 From: Lam Tang Date: Sun, 4 Dec 2022 21:53:59 +0800 Subject: [PATCH 08/10] remove utils.test.ts --- src/utils/utils.test.ts | 56 ----------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 src/utils/utils.test.ts diff --git a/src/utils/utils.test.ts b/src/utils/utils.test.ts deleted file mode 100644 index dab195d3..00000000 --- a/src/utils/utils.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import $ from 'jquery'; -import { elementExists, getMetaContent, isNull } from './utils'; - -describe('Test elementExists', () => { - test('Element Exists', () => { - const ele = $('

'); - expect(elementExists(ele)).toBe(true); - }); - test('Element NOT Exists', () => { - const ele = null; - expect(elementExists(ele)).toBe(false); - }); -}); - -describe('Test getMetaContent', () => { - test('Meta Content Exists', () => { - const metaTag = document.createElement('meta'); - metaTag.name = 'user-login'; - metaTag.content = 'Tom'; - document.getElementsByTagName('head')[0].appendChild(metaTag); - expect(getMetaContent('user-login')).toBe('Tom'); - }); - test('Meta Tag NOT Exists', () => { - expect(getMetaContent('NOT_EXITS_TAG')).toBe(null); - }); - test('Meta Content NOT Exists', () => { - const metaTag = document.createElement('meta'); - metaTag.name = 'user-login-with-empty-content'; - metaTag.content = ''; - document.getElementsByTagName('head')[0].appendChild(metaTag); - expect(getMetaContent('user-login-with-empty-content')).toBe(null); - }); -}); - -describe('Test isNull', () => { - test('If the object is null', () => { - const obj = null; - expect(isNull(obj)).toBe(true); - }); - test('If the object is undefined', () => { - const obj = undefined; - expect(isNull(obj)).toBe(true); - }); - test('If the object is empty string', () => { - const obj = ''; - expect(isNull(obj)).toBe(true); - }); - test('If the object is empty array', () => { - const obj: never[] = []; - expect(isNull(obj)).toBe(true); - }); - test('If the object is NOT null', () => { - const obj = ['hello world']; - expect(isNull(obj)).toBe(false); - }); -}); From ae2ad4fb9ce6715790c402e84ed796da7a2ae0d6 Mon Sep 17 00:00:00 2001 From: Lam Tang Date: Sun, 4 Dec 2022 22:06:53 +0800 Subject: [PATCH 09/10] remove code or packages that are not used --- package.json | 2 - src/utils/utils.ts | 41 --------------- yarn.lock | 128 --------------------------------------------- 3 files changed, 171 deletions(-) diff --git a/package.json b/package.json index 2a4da675..2d3e901b 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,8 @@ "@fluentui/react": "^8.62.0", "@fluentui/react-hooks": "^8.3.13", "@hot-loader/react-dom": "^17.0.2", - "@octokit/core": "^3.5.1", "@uifabric/icons": "^7.6.2", "buffer": "^6.0.3", - "delegated-events": "^1.1.2", "echarts": "^5.3.0", "github-url-detection": "^5.8.0", "jquery": "^3.6.0", diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 347e81cc..fd9abac2 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -12,14 +12,6 @@ export function elementExists(obj: null | JQuery) { return obj !== null && obj.length > 0; } -export function getMetaContent(index: any) { - const ele = document.getElementsByTagName('meta')[index]; - if (ele && ele.content) { - return ele.content; - } - return null; -} - export function isNull(object: any) { if ( object === null || @@ -56,42 +48,9 @@ export function getMessageByLocale(key: string, locale: string) { return messages_locale[locale][key]['message']; } -export function getMessageI18n(key: string) { - return chrome.i18n.getMessage(key); -} - export const isPerceptor = (): boolean => window.location.search.includes('perceptor'); -export const getBrowserType = () => { - var userAgent = navigator.userAgent; - var isOpera = userAgent.indexOf('Opera') > -1; - var isEdge = userAgent.indexOf('Edge') > -1; - var isFF = userAgent.indexOf('Firefox') > -1; - var isSafari = - userAgent.indexOf('Safari') > -1 && userAgent.indexOf('Chrome') === -1; - var isChrome = - userAgent.indexOf('Chrome') > -1 && userAgent.indexOf('Safari') > -1; - - if (isOpera) { - return 'Opera'; - } else if (isEdge) { - return 'Edge'; - } else if (isFF) { - return 'FireFox'; - } else if (isSafari) { - return 'Safari'; - } else if (isChrome) { - return 'Chrome'; - } else { - return 'Unknown'; - } -}; - -export async function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); -} - export function runsWhen(rules: any[]) { return (constructor: Function) => { constructor.prototype.include = rules; diff --git a/yarn.lock b/yarn.lock index d70c8b51..3ad8af58 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1242,77 +1242,6 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@octokit/auth-token@^2.4.4": - version "2.5.0" - resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36" - integrity sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g== - dependencies: - "@octokit/types" "^6.0.3" - -"@octokit/core@^3.5.1": - version "3.6.0" - resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.6.0.tgz#3376cb9f3008d9b3d110370d90e0a1fcd5fe6085" - integrity sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q== - dependencies: - "@octokit/auth-token" "^2.4.4" - "@octokit/graphql" "^4.5.8" - "@octokit/request" "^5.6.3" - "@octokit/request-error" "^2.0.5" - "@octokit/types" "^6.0.3" - before-after-hook "^2.2.0" - universal-user-agent "^6.0.0" - -"@octokit/endpoint@^6.0.1": - version "6.0.12" - resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.12.tgz#3b4d47a4b0e79b1027fb8d75d4221928b2d05658" - integrity sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA== - dependencies: - "@octokit/types" "^6.0.3" - is-plain-object "^5.0.0" - universal-user-agent "^6.0.0" - -"@octokit/graphql@^4.5.8": - version "4.8.0" - resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.8.0.tgz#664d9b11c0e12112cbf78e10f49a05959aa22cc3" - integrity sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg== - dependencies: - "@octokit/request" "^5.6.0" - "@octokit/types" "^6.0.3" - universal-user-agent "^6.0.0" - -"@octokit/openapi-types@^12.10.0": - version "12.10.1" - resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-12.10.1.tgz#57b5cc6c7b4e55d8642c93d06401fb1af4839899" - integrity sha512-P+SukKanjFY0ZhsK6wSVnQmxTP2eVPPE8OPSNuxaMYtgVzwJZgfGdwlYjf4RlRU4vLEw4ts2fsE2icG4nZ5ddQ== - -"@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677" - integrity sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg== - dependencies: - "@octokit/types" "^6.0.3" - deprecation "^2.0.0" - once "^1.4.0" - -"@octokit/request@^5.6.0", "@octokit/request@^5.6.3": - version "5.6.3" - resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0" - integrity sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A== - dependencies: - "@octokit/endpoint" "^6.0.1" - "@octokit/request-error" "^2.1.0" - "@octokit/types" "^6.16.1" - is-plain-object "^5.0.0" - node-fetch "^2.6.7" - universal-user-agent "^6.0.0" - -"@octokit/types@^6.0.3", "@octokit/types@^6.16.1": - version "6.40.0" - resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.40.0.tgz#f2e665196d419e19bb4265603cf904a820505d0e" - integrity sha512-MFZOU5r8SwgJWDMhrLUSvyJPtVsqA6VnbVI3TNbsmw+Jnvrktzvq2fYES/6RiJA/5Ykdwq4mJmtlYUfW7CGjmw== - dependencies: - "@octokit/openapi-types" "^12.10.0" - "@plasmohq/edge-addons-api@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@plasmohq/edge-addons-api/-/edge-addons-api-1.0.1.tgz#509243c24df1089a933941f5b2e4103522eab1ae" @@ -2055,11 +1984,6 @@ batch@0.6.1: resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" integrity sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw== -before-after-hook@^2.2.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e" - integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ== - big.js@^5.2.2: version "5.2.2" resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" @@ -2592,13 +2516,6 @@ del@^4.1.1: pify "^4.0.1" rimraf "^2.6.3" -delegated-events@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/delegated-events/-/delegated-events-1.1.2.tgz#741a4ba320718096fb8f7db4ddfaadcb0daa5986" - integrity sha512-PjEw4Z5mrvXimyf60HGqMJ3BMcqqWZpBqSDGnEMBdkAtF4P7ltoa6N+UJXhbMMUxPLYFtykCmRs6Ra8I8pwzPQ== - dependencies: - selector-set "^1.1.5" - depd@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" @@ -2609,11 +2526,6 @@ depd@~1.1.2: resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== -deprecation@^2.0.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" - integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== - destroy@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" @@ -3491,11 +3403,6 @@ is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" -is-plain-object@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" - integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== - is-stream@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" @@ -3914,13 +3821,6 @@ no-case@^3.0.4: lower-case "^2.0.2" tslib "^2.0.3" -node-fetch@^2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - node-forge@^1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" @@ -4684,11 +4584,6 @@ select-hose@^2.0.0: resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" integrity sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg== -selector-set@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/selector-set/-/selector-set-1.1.5.tgz#60c135aea482b6f46a2d95ad72058927690a8634" - integrity sha512-6SQw6yMew5iOZ8/cDHDEnJWRM4ot2mxP6szZyF5ptrBogw4AcS4EXRj/8BUfgAMwVfdL84qpModlBMOl2NVrsQ== - selfsigned@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.0.1.tgz#8b2df7fa56bf014d19b6007655fff209c0ef0a56" @@ -5017,11 +4912,6 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - ts-loader@^9.2.6: version "9.3.1" resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.3.1.tgz#fe25cca56e3e71c1087fe48dc67f4df8c59b22d4" @@ -5083,11 +4973,6 @@ unicode-property-aliases-ecmascript@^2.0.0: resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.0.0.tgz#0a36cb9a585c4f6abd51ad1deddb285c165297c8" integrity sha512-5Zfuy9q/DFr4tfO7ZPeVXb1aPoeQSdeFMLpYuFebehDAhbuevLs5yxSZmIFN1tP5F9Wl4IpJrYojg85/zgyZHQ== -universal-user-agent@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" - integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w== - universalify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" @@ -5158,11 +5043,6 @@ wbuf@^1.1.0, wbuf@^1.7.3: dependencies: minimalistic-assert "^1.0.0" -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== - webpack-cli@^4.9.2: version "4.10.0" resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.10.0.tgz#37c1d69c8d85214c5a65e589378f53aec64dab31" @@ -5284,14 +5164,6 @@ websocket-extensions@>=0.1.1: resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" From 81e78c87555f7ca05b600fc198124402025a9690 Mon Sep 17 00:00:00 2001 From: Lam Tang Date: Mon, 5 Dec 2022 14:09:41 +0800 Subject: [PATCH 10/10] temporarily remove TeachingBubble --- src/anchors/PerceptorTabAnchor.tsx | 8 -- src/pages/Options/Options.tsx | 14 ---- src/utils/metadata.ts | 33 -------- .../DeveloperNetworkView.tsx | 3 - .../TeachingBubbleWrapperView.tsx | 80 ------------------- 5 files changed, 138 deletions(-) delete mode 100644 src/utils/metadata.ts delete mode 100644 src/views/TeachingBubbleWrapperView/TeachingBubbleWrapperView.tsx diff --git a/src/anchors/PerceptorTabAnchor.tsx b/src/anchors/PerceptorTabAnchor.tsx index e39f0b30..30a1f369 100644 --- a/src/anchors/PerceptorTabAnchor.tsx +++ b/src/anchors/PerceptorTabAnchor.tsx @@ -2,9 +2,6 @@ import $ from 'jquery'; import { utils } from 'github-url-detection'; import { isPerceptor, runsWhen, isPublicRepo } from '../utils/utils'; import PerceptorBase from '../PerceptorBase'; -import { render } from 'react-dom'; -import React from 'react'; -import TeachingBubbleWrapper from '../views/TeachingBubbleWrapperView/TeachingBubbleWrapperView'; import logger from '../utils/logger'; @runsWhen([isPublicRepo]) @@ -74,10 +71,6 @@ class PerceptorTabAnchor extends PerceptorBase { } } - // Deal with teaching bubble - const teaching_bubble = document.createElement('div'); - $('.js-repo-pjax-container').prepend(teaching_bubble); - // Update perceptorLink.attr( 'href', @@ -92,7 +85,6 @@ class PerceptorTabAnchor extends PerceptorBase { '' ); - render(, teaching_bubble); insightsTab.after(perceptorTab); } } diff --git a/src/pages/Options/Options.tsx b/src/pages/Options/Options.tsx index d247e3af..532c752d 100644 --- a/src/pages/Options/Options.tsx +++ b/src/pages/Options/Options.tsx @@ -4,24 +4,20 @@ import { Stack, Toggle, Checkbox, - Text, Link, ChoiceGroup, IChoiceGroupOption, } from 'office-ui-fabric-react'; import { getMessageByLocale, chromeSet } from '../../utils/utils'; import Settings, { loadSettings } from '../../utils/settings'; -import MetaData, { loadMetaData } from '../../utils/metadata'; import { HYPERTRONS_CRX_WEBSITE } from '../../constant'; import './Options.css'; const Options: React.FC = () => { const [settings, setSettings] = useState(new Settings()); - const [metaData, setMetaData] = useState(new MetaData()); const [inited, setInited] = useState(false); const [version, setVersion] = useState('0.0.0'); - const locale = settings.locale; const localeOptions: IChoiceGroupOption[] = [ { key: 'en', @@ -33,16 +29,6 @@ const Options: React.FC = () => { }, ]; - useEffect(() => { - const initMetaData = async () => { - const tempMetaData = await loadMetaData(); - setMetaData(tempMetaData); - }; - if (!inited) { - initMetaData(); - } - }, [inited, locale, metaData]); - useEffect(() => { const initSettings = async () => { const temp = await loadSettings(); diff --git a/src/utils/metadata.ts b/src/utils/metadata.ts deleted file mode 100644 index 085a87f7..00000000 --- a/src/utils/metadata.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { chromeGet, isNull } from './utils'; - -class MetaData { - showTeachingBubble: boolean; - - constructor() { - this.showTeachingBubble = true; - } - - loadFromJson(data: { [key: string]: any }): void { - if ('showTeachingBubble' in data) { - this.showTeachingBubble = data['showTeachingBubble']; - } - } - - toJson(): { [key: string]: any } { - const result: { [key: string]: any } = {}; - result['showTeachingBubble'] = this.showTeachingBubble; - return result; - } -} - -export const loadMetaData = async () => { - const metaData = new MetaData(); - let obj = await chromeGet('meta_data'); - if (isNull(obj)) { - obj = {}; - } - metaData.loadFromJson(obj); - return metaData; -}; - -export default MetaData; diff --git a/src/views/DeveloperNetworkView/DeveloperNetworkView.tsx b/src/views/DeveloperNetworkView/DeveloperNetworkView.tsx index a2445d2b..d863acea 100644 --- a/src/views/DeveloperNetworkView/DeveloperNetworkView.tsx +++ b/src/views/DeveloperNetworkView/DeveloperNetworkView.tsx @@ -15,7 +15,6 @@ import { import { getMessageByLocale } from '../../utils/utils'; import Settings, { loadSettings } from '../../utils/settings'; import Graph from '../../components/Graph/Graph'; -import TeachingBubbleWrapperView from '../TeachingBubbleWrapperView/TeachingBubbleWrapperView'; import ErrorPage from '../../components/ExceptionPage/ErrorPage'; interface DeveloperNetworkViewProps { @@ -200,8 +199,6 @@ const DeveloperNetworkView: React.FC = ({ - -