Skip to content
Merged
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
87 changes: 59 additions & 28 deletions frontend/src/components/common/TableCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,78 @@ export default function TableCell(props) {
value = null,
isTruncate = false,
isCopyToClipboard = false,
job,
isList = false,
id,
ulKey = null,
} = props;

const tableId = job ? `table-user-${job.id}` : `table-user-${value}`;
const tableKey = job ? `table-user-${job.id}` : `table-user-${value}`;

return (
<div>
{isCopyToClipboard ? (
<CopyToClipboardButton
showOnHover
id={tableId}
key={tableKey}
text={value}
className={`d-block p-2 ${
isTruncate ? `text-truncate` : `text-break`
}`}
>
{value}
</CopyToClipboardButton>
) : (
<div className="d-flex justify-content-center">
<span className="d-block text-break pb-2" id={tableId} key={tableKey}>
{value}
</span>
</div>
)}
let cell = (
<div className="d-flex justify-content-center">
<span
className={`d-block p-2 ${isTruncate ? `text-truncate` : `text-break`}`}
id={id}
>
{value}
</span>
</div>
);

if (isCopyToClipboard) {
cell = (
<CopyToClipboardButton
showOnHover
id={id}
text={value}
className={`d-block p-2 ${isTruncate ? `text-truncate` : `text-break`}`}
>
{value}
</CopyToClipboardButton>
);
}

if (isList) {
cell = (
<ul className="d-flex flex-column text-left" key={ulKey}>
{value?.sort().map((val, index) => (
<li
className="mb-1 pb-2"
key={`${id}__${val}`}
id={`${id}__${index}`}
>
<div className="d-flex align-items-start">
<CopyToClipboardButton
id={`${id}__${index}`}
showOnHover
text={val}
className={`d-block ${
isTruncate ? `text-truncate` : `text-break`
}`}
>
{val}
</CopyToClipboardButton>
</div>
</li>
))}
</ul>
);
}

return <div>{cell}</div>;
}

TableCell.propTypes = {
value: PropTypes.string,
value: PropTypes.any,
isTruncate: PropTypes.bool,
isCopyToClipboard: PropTypes.bool,
job: PropTypes.object,
isList: PropTypes.bool,
id: PropTypes.string.isRequired,
ulKey: PropTypes.string,
};

TableCell.defaultProps = {
value: null,
isTruncate: false,
isCopyToClipboard: false,
job: null,
isList: false,
ulKey: null,
};
3 changes: 2 additions & 1 deletion frontend/src/components/common/TableCellCollapse.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ export function TableCellCollapse({ values, label }) {
</Button>
<Collapse isOpen={isOpen} id="table-cell-collapse">
<ul className="d-flex flex-column align-items-start p-3">
{values?.sort().map((value) => (
{values?.sort().map((value, index) => (
<li className="pb-2" key={value}>
<CopyToClipboardButton
id={`table-cell-collapse__${index}`}
showOnHover
text={value}
className="d-block text-break"
Expand Down
43 changes: 0 additions & 43 deletions frontend/src/components/common/TableCellList.jsx

This file was deleted.

36 changes: 30 additions & 6 deletions frontend/src/components/jobs/table/jobTableColumns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ export const jobTableColumns = [
id: "user",
accessor: "user.username",
Cell: ({ value, row: { original: job } }) => (
<TableCell job={job} isCopyToClipboard isTruncate value={value} />
<div>
<TableCell
id={`table-cell-user__${job.id}`}
isCopyToClipboard
isTruncate
value={value}
/>
</div>
),
disableSortBy: true,
Filter: DefaultColumnFilter,
Expand All @@ -84,7 +91,12 @@ export const jobTableColumns = [
id: "name",
accessor: (job) => job.observable_name || job.file_name,
Cell: ({ value, row: { original: job } }) => (
<TableCell job={job} value={value} isCopyToClipboard isTruncate />
<TableCell
id={`table-cell-name__${job.id}`}
value={value}
isCopyToClipboard
isTruncate
/>
),
disableSortBy: true,
Filter: DefaultColumnFilter,
Expand All @@ -94,7 +106,12 @@ export const jobTableColumns = [
id: "md5",
accessor: "md5",
Cell: ({ value, row: { original: job } }) => (
<TableCell job={job} isCopyToClipboard isTruncate value={value} />
<TableCell
id={`table-cell-md5__${job.id}`}
isCopyToClipboard
isTruncate
value={value}
/>
),
disableSortBy: true,
Filter: DefaultColumnFilter,
Expand All @@ -103,9 +120,14 @@ export const jobTableColumns = [
Header: "Type",
id: "is_sample",
accessor: (job) => job.is_sample,
Cell: ({ value }) => (value ? JobTypes.FILE : JobTypes.OBSERVABLE),
Cell: ({ value, row: { original: job } }) => (
<TableCell
id={`table-cell-type__${job.id}`}
value={value ? JobTypes.FILE : JobTypes.OBSERVABLE}
/>
),
disableSortBy: true,
maxWidth: 100,
maxWidth: 110,
Filter: ({
column: { filterValue: isSampleStr, setFilter, id, selectOptions },
}) => {
Expand Down Expand Up @@ -174,7 +196,9 @@ export const jobTableColumns = [
selectOptions: Object.values(ObservableClassifications)
.sort()
.concat(Object.values(FileMimeTypes).sort()),
Cell: ({ value }) => <TableCell value={value} />,
Cell: ({ value, row: { original: job } }) => (
<TableCell id={`table-cell-type__${job.id}`} value={value} />
),
},
{
Header: "TLP",
Expand Down
57 changes: 42 additions & 15 deletions frontend/src/components/plugins/tables/pluginTableColumns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
} from "./pluginActionsButtons";
import { JobTypes } from "../../../constants/jobConst";
import TableCell from "../../common/TableCell";
import TableCellList from "../../common/TableCellList";
import { TableCellCollapse } from "../../common/TableCellCollapse";

/* This function is available in the certego-ui, but it doesn't works:
Expand Down Expand Up @@ -90,8 +89,13 @@ const pluginTableColumns = [
Header: "Name",
id: "name",
accessor: "name",
Cell: ({ value }) => (
<TableCell isCopyToClipboard isTruncate value={value} />
Cell: ({ value, row: { original: plugin } }) => (
<TableCell
id={`table-cell-name__${plugin.id}`}
isCopyToClipboard
isTruncate
value={value}
/>
),
Filter: DefaultColumnFilter,
minWidth: 150,
Expand Down Expand Up @@ -145,8 +149,14 @@ export const analyzersTableColumns = [
}
return supported;
},
Cell: ({ value }) => (
<TableCellList value={value} ulKey={value} size={25} />
Cell: ({ value, row: { original: plugin } }) => (
<TableCell
id={`table-cell-supported_types__${plugin.id}`}
ulKey={value}
value={value}
size={25}
isList
/>
),
disableSortBy: true,
Filter: SelectColumnFilter,
Expand Down Expand Up @@ -281,8 +291,14 @@ export const pivotTableColumns = [
Header: "Playbook to execute",
id: "playbook",
accessor: "playbooks_choice",
Cell: ({ value }) => (
<TableCellList value={value} ulKey={value} size={20} />
Cell: ({ value, row: { original: plugin } }) => (
<TableCell
id={`table-cell-playbook__${plugin.id}`}
ulKey={value}
value={value}
size={20}
isList
/>
),
Filter: SelectColumnFilter,
maxWidth: 145,
Expand Down Expand Up @@ -338,8 +354,14 @@ export const playbookTableColumns = [
Header: "Supported types",
id: "supported_types",
accessor: "type",
Cell: ({ value }) => (
<TableCellList value={value} ulKey={value} size={20} />
Cell: ({ value, row: { original: plugin } }) => (
<TableCell
id={`table-cell-supported_types__${plugin.id}`}
ulKey={value}
value={value}
size={20}
isList
/>
),
disableSortBy: true,
Filter: SelectColumnFilter,
Expand Down Expand Up @@ -436,12 +458,12 @@ export const visualizerTableColumns = [
Header: "Playbook connected to",
id: "playbooks",
accessor: (row) => row.playbooks,
Cell: ({ value }) => (
<TableCellList
Cell: ({ value, row: { original: plugin } }) => (
<TableCell
id={`table-cell-visualizers-playbook__${plugin.id}`}
ulKey={`visualizers-playbooks__${value}`}
value={value}
idPrefix="table-user-"
keyPrefix="table-user-"
isList
/>
),
Filter: SelectColumnFilter,
Expand Down Expand Up @@ -485,8 +507,13 @@ export const ingestorTableColumns = [
Header: "Playbook to execute",
id: "playbook",
accessor: "playbooks_choice",
Cell: ({ value }) => (
<TableCell isCopyToClipboard isTruncate value={value} />
Cell: ({ value, row: { original: plugin } }) => (
<TableCell
id={`table-cell-playbook__${plugin.id}`}
isCopyToClipboard
isTruncate
value={value}
/>
),
Filter: SelectColumnFilter,
maxWidth: 200,
Expand Down
Loading