@cccsaurora/howler-ui 2.13.0-dev.141 → 2.13.0-dev.144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ import { type ButtonProps } from '@mui/material';
2
+ import { type FC } from 'react';
3
+ declare const ActionButton: FC<{
4
+ actionId: string;
5
+ hitId: string;
6
+ label: string;
7
+ } & ButtonProps>;
8
+ export default ActionButton;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Button } from '@mui/material';
3
+ import api from '@cccsaurora/howler-ui/api';
4
+ import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
5
+ import useMyActionFunctions from '@cccsaurora/howler-ui/components/routes/action/useMyActionFunctions';
6
+ import { useEffect, useState } from 'react';
7
+ import { useTranslation } from 'react-i18next';
8
+ const ActionButton = ({ actionId, hitId, label, ...otherProps }) => {
9
+ const { t } = useTranslation();
10
+ const { dispatchApi } = useMyApi();
11
+ const { executeAction } = useMyActionFunctions();
12
+ const [action, setAction] = useState(null);
13
+ useEffect(() => {
14
+ dispatchApi(api.search.action.post({ query: `action_id:${actionId}`, rows: 1 })).then(result => setAction(result.items[0]));
15
+ }, [actionId, dispatchApi]);
16
+ return (_jsx(Button, { variant: otherProps.variant ?? 'outlined', disabled: !action, onClick: () => executeAction(actionId, `howler.id:${hitId}`), color: otherProps.color ?? 'primary', children: label ?? action?.name ?? t('loading') }));
17
+ };
18
+ export default ActionButton;
@@ -10,6 +10,7 @@ import { capitalize, get, groupBy, isObject } from 'lodash-es';
10
10
  import howlerPluginStore from '@cccsaurora/howler-ui/plugins/store';
11
11
  import { useMemo } from 'react';
12
12
  import { usePluginStore } from 'react-pluggable';
13
+ import ActionButton from '../ActionButton';
13
14
  import JSONViewer from '../json/JSONViewer';
14
15
  const FETCH_RESULTS = {};
15
16
  export const useHelpers = () => {
@@ -147,6 +148,17 @@ export const useHelpers = () => {
147
148
  }) })] }) }));
148
149
  }
149
150
  },
151
+ {
152
+ keyword: 'action',
153
+ documentation: 'Execute a howler action given a specific action ID (from the URL when viewing the action, i.e. yaIKVqiKhWpyCsWdqsE4D)',
154
+ componentCallback: (actionId, hitId, context) => {
155
+ if (!actionId || !hitId) {
156
+ console.warn('Missing parameters for the action button.');
157
+ return null;
158
+ }
159
+ return _jsx(ActionButton, { actionId: actionId, hitId: hitId, ...(context.hash ?? {}) });
160
+ }
161
+ },
150
162
  ...howlerPluginStore.plugins.flatMap(plugin => pluginStore.executeFunction(`${plugin}.helpers`))
151
163
  ], [pluginStore]);
152
164
  return allHelpers;
@@ -94,7 +94,11 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
94
94
  }, spacing: layout !== HitLayout.COMFY ? 1 : 2, divider: _jsx(Divider, { orientation: "horizontal", sx: [
95
95
  layout !== HitLayout.COMFY && { marginTop: '4px !important' },
96
96
  { mr: `${theme.spacing(-1)} !important` }
97
- ] }), children: [_jsxs(Typography, { variant: compressed ? 'body1' : 'h6', fontWeight: compressed && 'bold', sx: { alignSelf: 'start', '& a': { color: 'text.primary' } }, children: [analyticId ? (_jsx(Link, { to: `/analytics/${analyticId}`, onClick: e => e.stopPropagation(), children: hit.howler.analytic })) : (hit.howler.analytic), hit.howler.detection && ': ', hit.howler.detection] }), hit.howler?.rationale && (_jsxs(Typography, { flex: 1, variant: textVariant, color: ESCALATION_COLORS[hit.howler.escalation] + '.main', sx: { fontWeight: 'bold' }, children: [t('hit.header.rationale'), ": ", hit.howler.rationale] })), hit.howler?.outline && (_jsxs(_Fragment, { children: [_jsxs(Grid, { container: true, spacing: layout !== HitLayout.COMFY ? 1 : 2, sx: { ml: `${theme.spacing(-1)} !important` }, children: [hit.howler.outline.threat && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.threat", value: hit.howler.outline.threat }) })), hit.howler.outline.target && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.target", value: hit.howler.outline.target }) }))] }), hit.howler.outline.indicators?.length > 0 && (_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Typography, { component: "span", variant: textVariant, children: [t('hit.header.indicators'), ":"] }), _jsx(Grid, { container: true, spacing: 0.5, sx: { mt: `${theme.spacing(-0.5)} !important`, ml: `${theme.spacing(0.25)} !important` }, children: uniq(hit.howler.outline.indicators).map((_indicator, index) => {
97
+ ] }), children: [_jsxs(Typography, { variant: compressed ? 'body1' : 'h6', fontWeight: compressed && 'bold', sx: { alignSelf: 'start', '& a': { color: 'text.primary' } }, children: [analyticId ? (_jsx(Link, { to: `/analytics/${analyticId}`, onAuxClick: e => {
98
+ e.stopPropagation();
99
+ }, onClick: e => {
100
+ e.stopPropagation();
101
+ }, children: hit.howler.analytic })) : (hit.howler.analytic), hit.howler.detection && ': ', hit.howler.detection] }), hit.howler?.rationale && (_jsxs(Typography, { flex: 1, variant: textVariant, color: ESCALATION_COLORS[hit.howler.escalation] + '.main', sx: { fontWeight: 'bold' }, children: [t('hit.header.rationale'), ": ", hit.howler.rationale] })), hit.howler?.outline && (_jsxs(_Fragment, { children: [_jsxs(Grid, { container: true, spacing: layout !== HitLayout.COMFY ? 1 : 2, sx: { ml: `${theme.spacing(-1)} !important` }, children: [hit.howler.outline.threat && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.threat", value: hit.howler.outline.threat }) })), hit.howler.outline.target && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.target", value: hit.howler.outline.target }) }))] }), hit.howler.outline.indicators?.length > 0 && (_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Typography, { component: "span", variant: textVariant, children: [t('hit.header.indicators'), ":"] }), _jsx(Grid, { container: true, spacing: 0.5, sx: { mt: `${theme.spacing(-0.5)} !important`, ml: `${theme.spacing(0.25)} !important` }, children: uniq(hit.howler.outline.indicators).map((_indicator, index) => {
98
102
  return (_jsx(Grid, { item: true, children: _jsxs(Stack, { direction: "row", children: [_jsx(PluginTypography, { context: "indicators", variant: textVariant, value: _indicator, children: _indicator }), index < hit.howler.outline.indicators.length - 1 && (_jsx(Typography, { variant: textVariant, children: ',' }))] }) }, _indicator));
99
103
  }) })] })), hit.howler.outline.summary && (_jsx(Wrapper, { i18nKey: "hit.header.summary", value: hit.howler.outline.summary, paragraph: true, textOverflow: "wrap", sx: [compressed && { marginTop: `0 !important` }] }))] }))] }), _jsxs(Stack, { direction: "column", spacing: layout !== HitLayout.COMFY ? 0.5 : 1, alignSelf: "stretch", sx: [
100
104
  { minWidth: 0, alignItems: { sm: 'end', md: 'start' }, flex: 1, pl: 1 },
@@ -45,7 +45,7 @@ const Item = memo(({ hit, onClick }) => {
45
45
  }
46
46
  }, []);
47
47
  // Search result list item renderer.
48
- return (_jsx(Box, { id: hit.howler.id, onMouseUp: e => checkMiddleClick(e, hit.howler.id), onClick: ev => onClick(ev, hit), sx: [
48
+ return (_jsx(Box, { id: hit.howler.id, onAuxClick: e => checkMiddleClick(e, hit.howler.id), onClick: ev => onClick(ev, hit), sx: [
49
49
  {
50
50
  mb: 2,
51
51
  cursor: 'pointer',
package/package.json CHANGED
@@ -96,7 +96,7 @@
96
96
  "internal-slot": "1.0.7"
97
97
  },
98
98
  "type": "module",
99
- "version": "2.13.0-dev.141",
99
+ "version": "2.13.0-dev.144",
100
100
  "exports": {
101
101
  "./i18n": "./i18n.js",
102
102
  "./index.css": "./index.css",