Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FE,BE: Add download button #4323

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@
setSearchParams(searchParams);
};

const handleDownload = () => {
const download = (filename: string, content: Blob) => {
// create anchor tag to download file
const url = URL.createObjectURL(content);
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', filename);
document.body.appendChild(link);

// download file
link.click();

// clean up
document.body.removeChild(link);
URL.revokeObjectURL(url);
};

const jsonString = JSON.stringify(messages);
const content = new Blob([jsonString], { type: 'application/json' })

Check warning on line 72 in kafka-ui-react-app/src/components/Topics/Topic/Messages/MessagesTable.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

Insert `;`
download("download.json", content);

Check warning on line 73 in kafka-ui-react-app/src/components/Topics/Topic/Messages/MessagesTable.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

Replace `"download.json"` with `'download.json'`
}

Check warning on line 74 in kafka-ui-react-app/src/components/Topics/Topic/Messages/MessagesTable.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

Insert `;`

return (
<div style={{ position: 'relative' }}>
{previewFor !== null && (
Expand Down Expand Up @@ -136,6 +158,7 @@
>
Next →
</Button>
<Button buttonType="secondary" buttonSize="L" onClick={handleDownload}>Download</Button>

Check warning on line 161 in kafka-ui-react-app/src/components/Topics/Topic/Messages/MessagesTable.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

Replace `·buttonType="secondary"·buttonSize="L"·onClick={handleDownload}>Download` with `⏎············buttonType="secondary"⏎············buttonSize="L"⏎············onClick={handleDownload}⏎··········>⏎············Download⏎··········`
</S.Pages>
</S.Pagination>
</div>
Expand Down
Loading