Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 31 additions & 0 deletions admin/src/pages/Logs/components/ExportBtn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";

import React from "react";
import PropTypes from "prop-types";

import { Button } from "@strapi/design-system";

const downloadFile = (data, filename) => {
const jsonBlob = new Blob([data], { type: "application/json" });
const url = URL.createObjectURL(jsonBlob);
const a = document.createElement("a");
a.href = url;
a.download = filename;
a.click();
URL.revokeObjectURL(url);
};

const ExportBtn = ({ list }) => {
const jsonData = JSON.stringify(list);
return (
<Button onClick={() => downloadFile(jsonData, "logs.json")}>
Export Logs
</Button>
);
};

// PropTypes for component props
ExportBtn.propTypes = {
list: PropTypes.array.isRequired,
};
export default ExportBtn;
2 changes: 2 additions & 0 deletions admin/src/pages/Logs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import InteractiveLogRows from "./components/InteractiveLogRows";
import TablePagination from "./components/TablePagination";
import filterSchema from "./utils/filterSchema";
import TableFilters from "./components/TableFilters";
import ExportBtn from "./components/ExportBtn"

const ProtectedLogs = () => (
<CheckPagePermissions permissions={PERMISSIONS.readLogs}>
Expand Down Expand Up @@ -182,6 +183,7 @@ const Logs = () => {
})}
/>
<TableFilters displayedFilters={filterSchema()} />
<ExportBtn list={entries.results} />
</>
}
/>
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"styled-components": "^5.3.6"
},
"author": {
"name": "HDDTHR",
"url": "https://github.com/HDDTHR"
"name": "Marje3PSUT",
"url": "https://github.com/Marje3PSUT"
},
"maintainers": [
{
"name": "HDDTHR",
"url": "https://github.com/HDDTHR"
"name": "Marje3PSUT",
"url": "https://github.com/Marje3PSUT"
}
],
"engines": {
Expand Down