Skip to content

Commit

Permalink
[ENG-1412, 1413, 1414] Fixes CSV upload modal bugs (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
vsreekanti authored Jul 28, 2022
1 parent ca96bd0 commit 28faf76
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
19 changes: 17 additions & 2 deletions src/ui/common/src/components/integrations/dialogs/csvDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,33 @@ export const CSVDialog: React.FC<Props> = ({ setDialogConfig, setErrMsg }) => {
const allRows = file.data.split(/\r?\n/);
const parsedHeader = ['id'];
parsedHeader.push(...allRows[0].split(/,/));

const width = 25;
const parsedColumns = parsedHeader.map((headerName) => {
let hideColumn = false;
if (headerName === 'id') {
hideColumn = true;
}

return {
field: headerName,
headerName: headerName,
width: width * headerName.length,
hide: hideColumn,
};
});

const parsedRows = allRows.slice(1).map((line, id) => {
const row = line.split(/,/);
const parsedRow = { id: id };
parsedHeader.forEach((headerName, i) => (parsedRow[headerName] = row[i]));
const parsedRow = {};
parsedHeader.forEach((headerName, i) => {
if (headerName === 'id') {
parsedRow[headerName] = id;
} else {
parsedRow[headerName] = row[i - 1];
}
});

return parsedRow;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const AddTableDialog: React.FC<AddTableDialogProps> = ({
};

return (
<Dialog open={true} onClose={onCloseDialog}>
<Dialog open={true} onClose={onCloseDialog} fullWidth maxWidth="lg">
<DialogTitle>{dialogHeader}</DialogTitle>
<DialogContent>
{serviceDialog}
Expand Down
5 changes: 4 additions & 1 deletion src/ui/common/src/components/pages/integration/id/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ const IntegrationDetailsPage: React.FC<IntegrationDetailsPageProps> = ({
user={user}
integrationId={selectedIntegration.id}
onCloseDialog={() => setShowDialog(false)}
onConnect={() => forceLoadTableList()}
onConnect={() => {
forceLoadTableList();
setShowDialog(false);
}}
/>
)}
</Box>
Expand Down

0 comments on commit 28faf76

Please sign in to comment.