Skip to content

Commit

Permalink
[AppConfig]: format codebase to match prettier rules (#318)
Browse files Browse the repository at this point in the history
* feat: add format script on packages

* fix: format platform codebase

* fix: format genetics codebase

* fix: format platform/sections codebase

* fix: format ui package codebase

* feat: update turbo config
  • Loading branch information
carcruz authored Jan 30, 2024
1 parent 970f0d3 commit b6f640c
Show file tree
Hide file tree
Showing 466 changed files with 4,261 additions and 6,468 deletions.
4 changes: 2 additions & 2 deletions apps/genetics/src/client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import config from './config';
import { ApolloClient, InMemoryCache } from '@apollo/client';
import config from "./config";
import { ApolloClient, InMemoryCache } from "@apollo/client";

const client = new ApolloClient({
uri: config.apiUrl,
Expand Down
2 changes: 1 addition & 1 deletion apps/genetics/src/components/ColocForGeneTable/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './ColocForGeneTable';
export { default } from "./ColocForGeneTable";
6 changes: 3 additions & 3 deletions apps/genetics/src/components/ColocQTLGeneTissueTable/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ColocQTLGeneTissueTableCmp from './ColocQTLGeneTissueTable';
import ColocQTLGeneTissueTableCmp from "./ColocQTLGeneTissueTable";

export { getTableColumns } from './ColumnRenderers';
export { getTableColumns } from "./ColumnRenderers";

export { useColocTable } from './useColocTable';
export { useColocTable } from "./useColocTable";

export default ColocQTLGeneTissueTableCmp;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { descending } from 'd3';
import { getPhenotypeId, getSpliceId } from '../../utils';
import { descending } from "d3";
import { getPhenotypeId, getSpliceId } from "../../utils";

export const useColocTable = data => {
const uniqueStudyGenePhenotypes = data.reduce((acc, d) => {
Expand All @@ -21,42 +21,37 @@ export const useColocTable = data => {
}, {})
);

const dataByPhenotypeId = uniquePhenotypeIds.map(
({ phenotypeId, gene, qtlStudyName }) => ({
phenotypeId,
gene,
qtlStudyName,
...uniqueTissues.reduce((acc, t) => {
const items = data
.filter(
d =>
d.gene.id === gene.id &&
d.qtlStudyName === qtlStudyName &&
d.tissue.id === t.id
)
.map(d => ({
h3: d.h3,
h4: d.h4,
log2h4h3: d.log2h4h3,
beta: d.beta,
splice: getSpliceId(d.phenotypeId),
}))
.sort((a, b) => descending(a.log2h4h3, b.log2h4h3));
const dataByPhenotypeId = uniquePhenotypeIds.map(({ phenotypeId, gene, qtlStudyName }) => ({
phenotypeId,
gene,
qtlStudyName,
...uniqueTissues.reduce((acc, t) => {
const items = data
.filter(
d => d.gene.id === gene.id && d.qtlStudyName === qtlStudyName && d.tissue.id === t.id
)
.map(d => ({
h3: d.h3,
h4: d.h4,
log2h4h3: d.log2h4h3,
beta: d.beta,
splice: getSpliceId(d.phenotypeId),
}))
.sort((a, b) => descending(a.log2h4h3, b.log2h4h3));

// there could be multiple loci for gene-tissue, so pick
// by highest log2h4h3 value (this should not happen due
// to deduplication on index variants)
if (items.length > 1) {
console.info(
`Multiple entries found: ${gene.symbol}, ${qtlStudyName}, ${phenotypeId}`,
items
);
}
acc[t.id] = items.length > 0 ? items[0] : null;
return acc;
}, {}),
})
);
// there could be multiple loci for gene-tissue, so pick
// by highest log2h4h3 value (this should not happen due
// to deduplication on index variants)
if (items.length > 1) {
console.info(
`Multiple entries found: ${gene.symbol}, ${qtlStudyName}, ${phenotypeId}`,
items
);
}
acc[t.id] = items.length > 0 ? items[0] : null;
return acc;
}, {}),
}));

return {
uniqueTissues,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export const tissueComparator = t => (a, b) => {
if (a[t] && b[t]) {
return a[t].log2h4h3 > b[t].log2h4h3
? 1
: a[t].log2h4h3 === b[t].log2h4h3
? 0
: -1;
return a[t].log2h4h3 > b[t].log2h4h3 ? 1 : a[t].log2h4h3 === b[t].log2h4h3 ? 0 : -1;
} else if (a[t] && !b[t]) {
return 1;
} else if (!a[t] && b[t]) {
Expand Down
4 changes: 2 additions & 2 deletions apps/genetics/src/components/ExternalLink/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as ExternalLink } from './ExternalLink';
export { default as XRefLinks } from './XRefLinks';
export { default as ExternalLink } from "./ExternalLink";
export { default as XRefLinks } from "./XRefLinks";
2 changes: 1 addition & 1 deletion apps/genetics/src/components/Search/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './Search';
export { default } from "./Search";
40 changes: 20 additions & 20 deletions apps/genetics/src/components/theme.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { lighten, darken } from 'polished';
import { lighten, darken } from "polished";

const PRIMARY = '#0091eb';
const SECONDARY = '#ff6350';
const PRIMARY = "#0091eb";
const SECONDARY = "#ff6350";
// const TERTIARY = '#00a252';
const GREY = {
50: '#fafafa',
100: '#f5f5f5',
200: '#eeeeee',
300: '#e0e0e0',
400: '#bdbdbd',
500: '#9e9e9e',
600: '#757575',
700: '#616161',
800: '#424242',
900: '#212121',
A100: '#d5d5d5',
A200: '#aaaaaa',
A400: '#303030',
A700: '#616161',
50: "#fafafa",
100: "#f5f5f5",
200: "#eeeeee",
300: "#e0e0e0",
400: "#bdbdbd",
500: "#9e9e9e",
600: "#757575",
700: "#616161",
800: "#424242",
900: "#212121",
A100: "#d5d5d5",
A200: "#aaaaaa",
A400: "#303030",
A700: "#616161",
};

const theme = {
Expand Down Expand Up @@ -48,13 +48,13 @@ const theme = {
},
gecko: {
color: GREY[500],
backgroundColor: 'white',
backgroundColor: "white",
finemappingColor: GREY[600],
colorSelected: PRIMARY,
backgroundColorSelected: 'white',
backgroundColorSelected: "white",
finemappingColorSelected: darken(0.3, PRIMARY),
colorChained: SECONDARY,
backgroundColorChained: 'white',
backgroundColorChained: "white",
finemappingColorChained: darken(0.3, SECONDARY),
connectorColor: GREY[300],
connectorColorSelected: lighten(0.2, PRIMARY),
Expand Down
11 changes: 5 additions & 6 deletions apps/genetics/src/config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const config = {
apiUrl:
window.configApiUrl ?? 'https://api.genetics.opentargets.org/graphql',
// window.configApiUrl ?? 'https://api.genetics.dev.opentargets.xyz/graphql',
apiUrl: window.configApiUrl ?? "https://api.genetics.opentargets.org/graphql",
// window.configApiUrl ?? 'https://api.genetics.dev.opentargets.xyz/graphql',
googleTagManagerID: window.configGoogleTagManagerID ?? null,
helpdeskEmail: window.configHelpdeskEmail ?? '[email protected]',
helpdeskEmail: window.configHelpdeskEmail ?? "[email protected]",
profile: window.configProfile ?? {},
platformUrl: window.configPlatformUrl
? window.configPlatformUrl.replace(/\/$/, '')
: 'https://platform.opentargets.org',
? window.configPlatformUrl.replace(/\/$/, "")
: "https://platform.opentargets.org",
};

export default config;
18 changes: 9 additions & 9 deletions apps/genetics/src/configuration.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import pkg from '../package.json';
import pkg from "../package.json";

const defaults = {
REACT_APP_GRAPHQL_API_URL: 'https://genetics-api.opentargets.io',
REACT_APP_PLATFORM_URL: 'https://platform.opentargets.org/',
REACT_APP_GIT_REVISION: '2222ccc',
REACT_APP_CONTACT_URL: 'mailto:[email protected]',
REACT_APP_GRAPHQL_API_URL: "https://genetics-api.opentargets.io",
REACT_APP_PLATFORM_URL: "https://platform.opentargets.org/",
REACT_APP_GIT_REVISION: "2222ccc",
REACT_APP_CONTACT_URL: "mailto:[email protected]",
};

const envVarOrDefault = envVarName =>
process.env[envVarName] ? process.env[envVarName] : defaults[envVarName];

export const packageVersion = pkg.version;
export const graphqlApiUrl = envVarOrDefault('REACT_APP_GRAPHQL_API_URL');
export const platformUrl = envVarOrDefault('REACT_APP_PLATFORM_URL');
export const gitRevision = envVarOrDefault('REACT_APP_GIT_REVISION');
export const contactUrl = envVarOrDefault('REACT_APP_CONTACT_URL');
export const graphqlApiUrl = envVarOrDefault("REACT_APP_GRAPHQL_API_URL");
export const platformUrl = envVarOrDefault("REACT_APP_PLATFORM_URL");
export const gitRevision = envVarOrDefault("REACT_APP_GIT_REVISION");
export const contactUrl = envVarOrDefault("REACT_APP_CONTACT_URL");
82 changes: 41 additions & 41 deletions apps/genetics/src/constants.js
Original file line number Diff line number Diff line change
@@ -1,102 +1,102 @@
import { faBook, faEnvelope } from '@fortawesome/free-solid-svg-icons';
import { faBook, faEnvelope } from "@fortawesome/free-solid-svg-icons";
import {
faDiscourse,
faTwitterSquare,
faLinkedin,
faGithubSquare,
faYoutubeSquare,
} from '@fortawesome/free-brands-svg-icons';
} from "@fortawesome/free-brands-svg-icons";

import { contactUrl as contactUrlConfig } from './configuration';
import config from './config';
import { contactUrl as contactUrlConfig } from "./configuration";
import config from "./config";

export const pvalThreshold = 4.94e-322;

export const contactUrl = contactUrlConfig;

export const naLabel = 'N/A';
export const naLabel = "N/A";

export const mainMenuItems = [
// Documentation
{
name: 'Documentation',
url: 'https://genetics-docs.opentargets.org',
name: "Documentation",
url: "https://genetics-docs.opentargets.org",
external: true,
},
// Data downloads
{
name: 'Data downloads',
url: 'https://genetics-docs.opentargets.org/data-access/data-download',
name: "Data downloads",
url: "https://genetics-docs.opentargets.org/data-access/data-download",
external: true,
},
// API
// TODO: update config
{
name: 'API',
url: '/api',
name: "API",
url: "/api",
// url: config.apiUrl.split('/graphql')[0],
external: false,
},
// Community
{
name: 'Community',
url: 'https://community.opentargets.org/',
name: "Community",
url: "https://community.opentargets.org/",
external: true,
},
];

export const externalLinks = {
about: [
{
label: 'Community forum',
url: 'https://community.opentargets.org/',
label: "Community forum",
url: "https://community.opentargets.org/",
},
{
label: 'Privacy notice',
url: 'https://www.ebi.ac.uk/data-protection/privacy-notice/open-targets',
label: "Privacy notice",
url: "https://www.ebi.ac.uk/data-protection/privacy-notice/open-targets",
},
{
label: 'Terms of use',
label: "Terms of use",
url: `https://genetics-docs.opentargets.org/terms-of-use`,
},
],
license: {
label: 'Open Targets Genetics',
url: 'https://genetics.opentargets.org/',
label: "Open Targets Genetics",
url: "https://genetics.opentargets.org/",
},
network: [
{ label: 'Science', url: 'https://www.opentargets.org/science' },
{ label: 'Publications', url: 'https://www.opentargets.org/publications' },
{ label: 'Platform', url: 'https://platform.opentargets.org/' },
{ label: 'Jobs', url: 'https://www.opentargets.org/jobs' },
{ label: 'Blog', url: 'https://blog.opentargets.org' },
{ label: "Science", url: "https://www.opentargets.org/science" },
{ label: "Publications", url: "https://www.opentargets.org/publications" },
{ label: "Platform", url: "https://platform.opentargets.org/" },
{ label: "Jobs", url: "https://www.opentargets.org/jobs" },
{ label: "Blog", url: "https://blog.opentargets.org" },
],
partners: [
{ label: 'Bristol Myers Squibb', url: 'https://www.bms.com' },
{ label: 'EMBL-EBI', url: 'http://www.ebi.ac.uk' },
{ label: 'Genentech', url: 'https://www.gene.com' },
{ label: 'GSK', url: 'http://www.gsk.com' },
{ label: 'Pfizer', url: 'https://pfizer.com/' },
{ label: 'Sanofi', url: 'https://www.sanofi.com' },
{ label: 'Wellcome Sanger Institute', url: 'http://www.sanger.ac.uk' },
{ label: "Bristol Myers Squibb", url: "https://www.bms.com" },
{ label: "EMBL-EBI", url: "http://www.ebi.ac.uk" },
{ label: "Genentech", url: "https://www.gene.com" },
{ label: "GSK", url: "http://www.gsk.com" },
{ label: "Pfizer", url: "https://pfizer.com/" },
{ label: "Sanofi", url: "https://www.sanofi.com" },
{ label: "Wellcome Sanger Institute", url: "http://www.sanger.ac.uk" },
],
help: [
{
label: 'Documentation',
label: "Documentation",
icon: faBook,
url: 'https://genetics-docs.opentargets.org',
url: "https://genetics-docs.opentargets.org",
},
{
label: 'Community',
label: "Community",
icon: faDiscourse,
url: 'https://community.opentargets.org',
url: "https://community.opentargets.org",
external: true,
}
},
],
social: [
{ icon: faTwitterSquare, url: 'https://twitter.com/opentargets' },
{ icon: faLinkedin, url: 'https://www.linkedin.com/company/open-targets' },
{ icon: faYoutubeSquare, url: 'https://www.youtube.com/opentargets' },
{ icon: faGithubSquare, url: 'https://github.com/opentargets' },
{ icon: faTwitterSquare, url: "https://twitter.com/opentargets" },
{ icon: faLinkedin, url: "https://www.linkedin.com/company/open-targets" },
{ icon: faYoutubeSquare, url: "https://www.youtube.com/opentargets" },
{ icon: faGithubSquare, url: "https://github.com/opentargets" },
],
};
21 changes: 9 additions & 12 deletions apps/genetics/src/hooks/useDebounce.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { useEffect, useState } from 'react';
import { useEffect, useState } from "react";

function useDebounce(value, delay) {
const [debouncedValue, setDebouncedValue] = useState(value);

useEffect(
() => {
const handler = setTimeout(() => {
if (debouncedValue !== value) setDebouncedValue(value);
}, delay);
return () => {
clearTimeout(handler);
};
},
[value, delay, debouncedValue]
);
useEffect(() => {
const handler = setTimeout(() => {
if (debouncedValue !== value) setDebouncedValue(value);
}, delay);
return () => {
clearTimeout(handler);
};
}, [value, delay, debouncedValue]);

return debouncedValue;
}
Expand Down
Loading

0 comments on commit b6f640c

Please sign in to comment.