Skip to content

Commit

Permalink
Merge pull request #77 from globalfund/feat/1378
Browse files Browse the repository at this point in the history
Resolve Sonarcloud issues
  • Loading branch information
stephanoshadjipetrou authored Aug 19, 2024
2 parents 5b6e73f + 0c6eaa7 commit 33182a9
Show file tree
Hide file tree
Showing 36 changed files with 264 additions and 351 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ const SharePanel: React.FC<ChartBlockButtonToolbarProps> = (
if (url.endsWith("/")) {
url = url.slice(0, -1);
}
let chartType = props.chartType;
if (chartType) {
chartType = `|${chartType}`;
}
navigator.clipboard.writeText(
type === "code"
? ""
: `${url}#${props.hashId}${
props.chartType ? `|${props.chartType}` : ""
}`
type === "code" ? "" : `${url}#${props.hashId}${chartType}`
);
setFeedbackMessage(`${type} copied!`);
};
Expand Down
2 changes: 0 additions & 2 deletions src/app/components/charts/bar-series/data.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { appColors } from "app/theme";

export interface BarSeriesChartDataItem {
name: string;
values: number[];
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/charts/bar-series/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ export const BarSeriesChart: React.FC<BarSeriesChartProps> = (
show: true,
...chartTooltipCommonConfig(isTouch),
formatter: (params: any) => {
const html = ReactDOMServer.renderToString(<Tooltip {...params} />);
return html;
return ReactDOMServer.renderToString(<Tooltip {...params} />);
},
},
};
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/charts/bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,7 @@ export const BarChart: React.FC<BarChartProps> = (props: BarChartProps) => {
show: true,
...chartTooltipCommonConfig(isTouch),
formatter: (params: any) => {
const html = ReactDOMServer.renderToString(<Tooltip {...params} />);
return html;
return ReactDOMServer.renderToString(<Tooltip {...params} />);
},
},
};
Expand Down
15 changes: 7 additions & 8 deletions src/app/components/charts/expandable-horizontal-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ export const ExpandableHorizontalBar: React.FC<
show: true,
...chartTooltipCommonConfig(isTouch),
formatter: (params: any) => {
const html = ReactDOMServer.renderToString(<Tooltip {...params} />);
return html;
return ReactDOMServer.renderToString(<Tooltip {...params} />);
},
},
};
Expand Down Expand Up @@ -338,11 +337,11 @@ export const ExpandableHorizontalBar: React.FC<
item.items &&
item.items.length > 0
) {
item.items.forEach((item) => {
newData.push(item);
if (expandedBars.includes(item.name) && item.items) {
item.items.forEach((item) => {
newData.push(item);
item.items.forEach((subItem) => {
newData.push(subItem);
if (expandedBars.includes(subItem.name) && subItem.items) {
subItem.items.forEach((subSubItem) => {
newData.push(subSubItem);
});
}
});
Expand Down Expand Up @@ -390,7 +389,7 @@ export const ExpandableHorizontalBar: React.FC<
yAxis: {
data: xAxisKeys,
},
series: seriesData.map((values, index) => ({
series: seriesData.map((values) => ({
data: values,
})),
});
Expand Down
24 changes: 12 additions & 12 deletions src/app/components/charts/heatmap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ export function Heatmap(props: HeatmapProps) {
props.data
.filter((item) => item.parentRow === name)
.map((item) => {
const name = item.row;
const children = uniqBy(
const subName = item.row;
const subChildren = uniqBy(
props.data
.filter((subitem) => subitem.parentRow === name)
.filter((subitem) => subitem.parentRow === subName)
.map((subitem) => ({
name: subitem.row,
expanded: false,
Expand All @@ -90,9 +90,9 @@ export function Heatmap(props: HeatmapProps) {
"name"
);
return {
name,
expanded: expandedRows.includes(name),
children: children.length > 0 ? children : undefined,
name: subName,
expanded: expandedRows.includes(subName),
children: subChildren.length > 0 ? subChildren : undefined,
level: 1,
};
}),
Expand Down Expand Up @@ -125,10 +125,10 @@ export function Heatmap(props: HeatmapProps) {
props.data
.filter((item) => item.parentColumn === name)
.map((item) => {
const name = item.column;
const children = uniqBy(
const subName = item.column;
const subChildren = uniqBy(
props.data
.filter((subitem) => subitem.parentColumn === name)
.filter((subitem) => subitem.parentColumn === subName)
.map((subitem) => ({
name: subitem.column,
expanded: false,
Expand All @@ -137,10 +137,10 @@ export function Heatmap(props: HeatmapProps) {
"name"
);
return {
name,
level: 1,
expanded: expandedColumns.includes(name),
children: children.length > 0 ? children : undefined,
name: subName,
expanded: expandedColumns.includes(subName),
children: subChildren.length > 0 ? subChildren : undefined,
};
}),
"name"
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/charts/line/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,9 @@ export const LineChart: React.FC<LineChartProps> = (props: LineChartProps) => {
.forEach((value: number) => {
cumulative += value;
});
const html = ReactDOMServer.renderToString(
return ReactDOMServer.renderToString(
<Tooltip {...params} cumulative={cumulative} />
);
return html;
},
},
};
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/charts/pie/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ export const PieChart: React.FC<PieChartProps> = (props: PieChartProps) => {
show: true,
...chartTooltipCommonConfig(isTouch),
formatter: (params: any) => {
const html = ReactDOMServer.renderToString(<Tooltip {...params} />);
return html;
return ReactDOMServer.renderToString(<Tooltip {...params} />);
},
},
};
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/charts/radial/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,13 @@ export const RadialChart: React.FC<RadialChartProps> = (
show: true,
...chartTooltipCommonConfig(isTouch),
formatter: (params: any) => {
const html = ReactDOMServer.renderToString(
return ReactDOMServer.renderToString(
<Tooltip
{...params}
totalValue={totalValue}
label={props.tooltipLabel}
/>
);
return html;
},
},
};
Expand Down
2 changes: 0 additions & 2 deletions src/app/components/charts/sankey/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { appColors } from "app/theme";

interface SankeyChartNode {
name: string;
level: number;
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/charts/sankey/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,14 @@ export const SankeyChart: React.FC<SankeyChartProps> = (
</Box>
);
}
const html = ReactDOMServer.renderToString(
return ReactDOMServer.renderToString(
<SankeyChartTooltip
name={data.name}
data={props.data}
level={data.level}
totalValue={totalValue}
/>
);
return html;
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/charts/sankey/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export const SankeyChartTooltip: React.FC<SankeyChartTooltipProps> = (
}[] = [];
const items = props.data.links.filter((link) => link.source === props.name);
items.forEach((item) => {
const node = props.data.nodes.find((node) => node.name === item.target);
const node = props.data.nodes.find((n) => n.name === item.target);
const itemValue = props.data.links
.filter(
(link) => link.target === item.target && link.source === props.name
)
.reduce((acc, item) => acc + item.value, 0);
.reduce((acc, item2) => acc + item2.value, 0);
returnItems.push({
value: itemValue,
name: item.target,
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/charts/sunburst/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,9 @@ export const SunburstChart: React.FC<SunburstProps> = (
show: true,
...chartTooltipCommonConfig(isTouch),
formatter: (params: any) => {
const html = ReactDOMServer.renderToString(
return ReactDOMServer.renderToString(
<Tooltip {...params} label={props.tooltipLabel} />
);
return html;
},
},
};
Expand Down
6 changes: 2 additions & 4 deletions src/app/components/charts/treemap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,9 @@ export const Treemap: React.FC<TreemapProps> = (props: TreemapProps) => {
show: true,
...chartTooltipCommonConfig(isTouch),
formatter: (params: any) => {
const html = ReactDOMServer.renderToString(
return ReactDOMServer.renderToString(
<Tooltip {...params} total={total} />
);
return html;
},
},
};
Expand All @@ -183,10 +182,9 @@ export const Treemap: React.FC<TreemapProps> = (props: TreemapProps) => {
},
tooltip: {
formatter: (params: any) => {
const html = ReactDOMServer.renderToString(
return ReactDOMServer.renderToString(
<Tooltip {...params} total={total} />
);
return html;
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/search/components/results/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function SearchResults(props: SearchResultsProps) {
key={result.value}
scroll={(el) => {
const yCoordinate =
el.getBoundingClientRect().top + window.pageYOffset;
el.getBoundingClientRect().top + window.scrollY;
const yOffset = -130;
window.scrollTo({
top: yCoordinate + yOffset,
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/search/data.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
AllCategoriesIcon,
DocumentsIcon,
DonorsIcon,
// DocumentsIcon,
// DonorsIcon,
GrantsIcon,
LocationsIcon,
PartnersIcon,
ResultsIcon,
// PartnersIcon,
// ResultsIcon,
} from "app/components/search/icons";

export const categories = [
Expand Down
8 changes: 0 additions & 8 deletions src/app/components/table-container/TableContainer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ import { withRouter } from "storybook-addon-remix-react-router";
import {
TABLE_VARIATION_1_DATA,
TABLE_VARIATION_1_COLUMNS,
TABLE_VARIATION_2_DATA,
TABLE_VARIATION_2_COLUMNS,
TABLE_VARIATION_3_DATA,
TABLE_VARIATION_3_COLUMNS,
TABLE_VARIATION_4_DATA,
TABLE_VARIATION_4_COLUMNS,
TABLE_VARIATION_5_DATA,
TABLE_VARIATION_5_COLUMNS,
} from "app/components/table/data";

const Variant2Wrapper = (args: any) => {
Expand Down
20 changes: 10 additions & 10 deletions src/app/components/table-container/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ReactComponent as FullscreenIcon } from "app/assets/vectors/TableToolba
export const TableContainer: React.FC<TableContainerProps> = (
props: TableContainerProps
) => {
const [table, setTable] = React.useState<any>(null);
// const [table, setTable] = React.useState<any>(null);
const [columns, setColumns] = React.useState(
props.columns.map((column) => ({
...column,
Expand All @@ -42,15 +42,15 @@ export const TableContainer: React.FC<TableContainerProps> = (

const fullscreenRef = React.useRef<HTMLDivElement>(null);

React.useEffect(() => {
const element = document.getElementById("table");
if (element) {
const tabulatorTables = Tabulator.findTable("#table");
if (tabulatorTables.length > 0 && tabulatorTables[0]) {
setTable(tabulatorTables[0]);
}
}
}, []);
// React.useEffect(() => {
// const element = document.getElementById("table");
// if (element) {
// const tabulatorTables = Tabulator.findTable("#table");
// if (tabulatorTables.length > 0 && tabulatorTables[0]) {
// setTable(tabulatorTables[0]);
// }
// }
// }, []);

// const download = () => {
// if (table) {
Expand Down
Loading

0 comments on commit 33182a9

Please sign in to comment.