diff --git a/openbas-front/package.json b/openbas-front/package.json index 186753f56a..11e927bcd8 100644 --- a/openbas-front/package.json +++ b/openbas-front/package.json @@ -73,7 +73,6 @@ "seamless-immutable": "7.1.4", "usehooks-ts": "3.1.0", "uuid": "11.0.3", - "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz", "zod": "3.24.1", "zustand": "5.0.1" }, diff --git a/openbas-front/src/admin/components/common/injects/InjectsListButtons.tsx b/openbas-front/src/admin/components/common/injects/InjectsListButtons.tsx index 164642b2da..341d1f49db 100644 --- a/openbas-front/src/admin/components/common/injects/InjectsListButtons.tsx +++ b/openbas-front/src/admin/components/common/injects/InjectsListButtons.tsx @@ -3,13 +3,8 @@ import { ToggleButton, ToggleButtonGroup, Tooltip } from '@mui/material'; import { makeStyles } from '@mui/styles'; import { FunctionComponent, useContext } from 'react'; -import type { TagHelper } from '../../../../actions/helper'; import type { InjectOutputType } from '../../../../actions/injects/Inject'; -import ButtonPopover from '../../../../components/common/ButtonPopover'; import { useFormatter } from '../../../../components/i18n'; -import { useHelper } from '../../../../store'; -import { exportData } from '../../../../utils/Environment'; -import useExportToXLS from '../../../../utils/hooks/useExportToXLS'; import { InjectContext, ViewModeContext } from '../Context'; import ImportUploaderInjectFromXls from './ImportUploaderInjectFromXls'; @@ -41,41 +36,10 @@ const InjectsListButtons: FunctionComponent = ({ const classes = useStyles(); const { t } = useFormatter(); const injectContext = useContext(InjectContext); - const viewModeContext = useContext(ViewModeContext); - // Fetching data - const { tagsMap } = useHelper((helper: TagHelper) => ({ - tagsMap: helper.getTagsMap(), - })); - - const exportInjects = exportData( - 'inject', - [ - 'inject_type', - 'inject_title', - 'inject_description', - 'inject_depends_duration', - 'inject_enabled', - 'inject_tags', - 'inject_content', - ], - selectedInjects, - tagsMap, - ); - const exportInjectsToXLS = useExportToXLS({ data: exportInjects, fileName: `${t('Injects')}` }); - - const entries = [ - { label: 'Export injects', action: exportInjectsToXLS }, - ]; - return (
- { - data: T[]; - fileName: string; -} - -const useExportToXLS = ({ data, fileName }: UseExportToXLSProps) => { - return useCallback(() => { - const workbook = XLSX.utils.book_new(); - const worksheet = XLSX.utils.json_to_sheet(data); - XLSX.utils.book_append_sheet(workbook, worksheet, fileName); - const xlsData = XLSX.write(workbook, { bookType: 'xls', type: 'binary' }); - const buffer = new ArrayBuffer(xlsData.length); - const view = new Uint8Array(buffer); - for (let i = 0; i < xlsData.length; i += 1) { - view[i] = xlsData.charCodeAt(i); - } - fileDownload(new Blob([buffer], { type: 'application/vnd.ms-excel' }), `${fileName}.xls`); - }, [data, fileName]); -}; - -export default useExportToXLS; diff --git a/openbas-front/yarn.lock b/openbas-front/yarn.lock index 47c1600ccd..1ac8230aff 100644 --- a/openbas-front/yarn.lock +++ b/openbas-front/yarn.lock @@ -9500,7 +9500,6 @@ __metadata: uuid: "npm:11.0.3" vite: "npm:6.0.9" vitest: "npm:2.1.1" - xlsx: "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz" zod: "npm:3.24.1" zustand: "npm:5.0.1" languageName: unknown @@ -12487,15 +12486,6 @@ __metadata: languageName: node linkType: hard -"xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz": - version: 0.20.3 - resolution: "xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz" - bin: - xlsx: ./bin/xlsx.njs - checksum: 10c0/eb20749e56ffa23ffc4a5a6fd983524e0406308e53992e24112424de9f30ec64d7dd80e8e56363e39c3853687f7b4151f97a6f5373050b23c0c2758796803b6b - languageName: node - linkType: hard - "xml-name-validator@npm:^5.0.0": version: 5.0.0 resolution: "xml-name-validator@npm:5.0.0"