Skip to content

Commit

Permalink
refactor: import exported modules rather files (#394)
Browse files Browse the repository at this point in the history
* refactor: not import files directly but import exported modules

* fix: unique key lost in React component
  • Loading branch information
tyn1998 authored Jul 7, 2022
1 parent 0022263 commit 211a287
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src/pages/ContentScripts/DeveloperActiInflTrend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
getMessageByLocale,
} from '../../utils/utils';
import PerceptorBase from './PerceptorBase';
import { inject2Perceptor } from './Perceptor';
import Settings, { loadSettings } from '../../utils/settings';
import { getDeveloperActiInfl } from '../../api/developer';
import Bars from '../../components/Bars/index';
Expand Down Expand Up @@ -136,4 +135,4 @@ class DeveloperActiInflTrend extends PerceptorBase {
}
}

inject2Perceptor(DeveloperActiInflTrend);
export default DeveloperActiInflTrend;
3 changes: 1 addition & 2 deletions src/pages/ContentScripts/DeveloperNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from '../../api/developer';
import { runsWhen, getMessageByLocale } from '../../utils/utils';
import PerceptorBase from './PerceptorBase';
import { inject2Perceptor } from './Perceptor';
import Settings, { loadSettings } from '../../utils/settings';
import Graph from '../../components/Graph/Graph';
import TeachingBubbleWrapper from './TeachingBubbleWrapper';
Expand Down Expand Up @@ -386,4 +385,4 @@ class DeveloperNetwork extends PerceptorBase {
}
}

inject2Perceptor(DeveloperNetwork);
export default DeveloperNetwork;
4 changes: 2 additions & 2 deletions src/pages/ContentScripts/Hypertrons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
} from '../../services/hypertrons';
import { getMessageByLocale, runsWhen } from '../../utils/utils';
import PerceptorBase from './PerceptorBase';
import { inject2Perceptor } from './Perceptor';
import logger from '../../utils/logger';
import Settings, { loadSettings } from '../../utils/settings';
import { getConfigFromGithub } from '../../api/github';
Expand Down Expand Up @@ -206,6 +205,7 @@ const HypertronsTabView: React.FC<HypertronsTabViewProps> = ({
const styleIndex = index % (LabelStyles.length - 1);
return (
<div
key={`command_${index}`}
// @ts-ignore
style={Label2Style(LabelStyles[styleIndex])}
className="IssueLabel hx_IssueLabel"
Expand Down Expand Up @@ -260,4 +260,4 @@ class Hypertrons extends PerceptorBase {
}
}

inject2Perceptor(Hypertrons);
export default Hypertrons;
3 changes: 1 addition & 2 deletions src/pages/ContentScripts/PerceptorLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { render } from 'react-dom';
import $ from 'jquery';
import { isPerceptor, runsWhen } from '../../utils/utils';
import PerceptorBase from './PerceptorBase';
import { inject2Perceptor } from './Perceptor';

const PerceptorLayoutView: React.FC = () => {
return <div />;
Expand All @@ -26,4 +25,4 @@ class PerceptorLayout extends PerceptorBase {
}
}

inject2Perceptor(PerceptorLayout);
export default PerceptorLayout;
3 changes: 1 addition & 2 deletions src/pages/ContentScripts/PerceptorTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as pageDetect from 'github-url-detection';
import { utils } from 'github-url-detection';
import { isPerceptor, runsWhen, isPublicRepo } from '../../utils/utils';
import PerceptorBase from './PerceptorBase';
import { inject2Perceptor } from './Perceptor';
import { render } from 'react-dom';
import React from 'react';
import TeachingBubbleWrapper from './TeachingBubbleWrapper';
Expand Down Expand Up @@ -97,4 +96,4 @@ class PerceptorTab extends PerceptorBase {
}
}

inject2Perceptor(PerceptorTab);
export default PerceptorTab;
3 changes: 1 addition & 2 deletions src/pages/ContentScripts/ProjectNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { isPerceptor, runsWhen } from '../../utils/utils';
import { getRepoCorrelation, getDevelopersByRepo } from '../../api/repo';
import { getMessageByLocale } from '../../utils/utils';
import PerceptorBase from './PerceptorBase';
import { inject2Perceptor } from './Perceptor';
import Settings, { loadSettings } from '../../utils/settings';
import ErrorPage from '../../components/ExceptionPage/ErrorPage';

Expand Down Expand Up @@ -282,4 +281,4 @@ class ProjectNetwork extends PerceptorBase {
}
}

inject2Perceptor(ProjectNetwork);
export default ProjectNetwork;
3 changes: 1 addition & 2 deletions src/pages/ContentScripts/RepoActiInflTrend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
getMessageByLocale,
} from '../../utils/utils';
import PerceptorBase from './PerceptorBase';
import { inject2Perceptor } from './Perceptor';
import Settings, { loadSettings } from '../../utils/settings';
import { utils } from 'github-url-detection';
import { getRepoActiInfl } from '../../api/repo';
Expand Down Expand Up @@ -156,4 +155,4 @@ class RepoActiInflTrend extends PerceptorBase {
}
}

inject2Perceptor(RepoActiInflTrend);
export default RepoActiInflTrend;
28 changes: 19 additions & 9 deletions src/pages/ContentScripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
import { initializeIcons } from '@fluentui/react/lib/Icons';
initializeIcons();

import './DeveloperActiInflTrend';
import './RepoActiInflTrend';
import './PerceptorTab';
import './PerceptorLayout';
import './DeveloperNetwork';
import './ProjectNetwork';
import './Hypertrons';
import './content.styles.css';
import { Perceptor } from './Perceptor';
import { loadSettings } from '../../utils/settings';
import { inject2Perceptor, Perceptor } from './Perceptor';

import DeveloperActiInflTrend from './DeveloperActiInflTrend';
import RepoActiInflTrend from './RepoActiInflTrend';
import PerceptorTab from './PerceptorTab';
import PerceptorLayout from './PerceptorLayout';
import DeveloperNetwork from './DeveloperNetwork';
import ProjectNetwork from './ProjectNetwork';
import Hypertrons from './Hypertrons';

import './content.styles.css';

inject2Perceptor(DeveloperActiInflTrend);
inject2Perceptor(RepoActiInflTrend);
inject2Perceptor(PerceptorTab);
inject2Perceptor(PerceptorLayout);
inject2Perceptor(DeveloperNetwork);
inject2Perceptor(ProjectNetwork);
inject2Perceptor(Hypertrons);

async function mainInject() {
const settings = await loadSettings();
Expand Down

0 comments on commit 211a287

Please sign in to comment.