@cccsaurora/howler-ui 3.2.0-dev.1791.1 → 3.2.0-dev.1794.1
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.
|
@@ -15,6 +15,15 @@ import HitTimestamp from './elements/HitTimestamp';
|
|
|
15
15
|
import HitBannerTooltip from './HitBannerTooltip';
|
|
16
16
|
import { HitLayout } from './HitLayout';
|
|
17
17
|
import RelatedRecords from './related/RelatedRecords';
|
|
18
|
+
const isHttpUrl = (value) => {
|
|
19
|
+
try {
|
|
20
|
+
const { protocol } = new URL(value);
|
|
21
|
+
return protocol === 'http:' || protocol === 'https:';
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
18
27
|
const Wrapper = ({ compressed, hit, textVariant, i18nKey, value, field, ...typographyProps }) => {
|
|
19
28
|
const { t } = useTranslation();
|
|
20
29
|
const children = (_jsxs(Stack, { direction: "row", spacing: 1, flex: 1, sx: { lineHeight: '20px', '& .iconify': { maxHeight: '20px' } }, children: [_jsxs(Typography, { variant: textVariant, noWrap: compressed, fontWeight: "bold", textOverflow: compressed ? 'ellipsis' : 'wrap', ...typographyProps, sx: [
|
|
@@ -30,8 +39,20 @@ const HitBanner = ({ hit, lazy = false, layout = HitLayout.NORMAL, showAssigned
|
|
|
30
39
|
const compressed = useMemo(() => layout === HitLayout.DENSE, [layout]);
|
|
31
40
|
const textVariant = useMemo(() => (layout === HitLayout.COMFY ? 'body1' : 'caption'), [layout]);
|
|
32
41
|
const providerColor = getProviderColor(hit?.event?.provider);
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
const indicators = uniq(hit.howler.outline?.indicators ?? []);
|
|
43
|
+
return (_jsx(Box, { sx: { width: '100%', ml: 0, overflow: 'hidden', color: 'text.primary' }, children: _jsxs(Stack, { spacing: layout !== HitLayout.COMFY ? 0.25 : 1, children: [_jsxs(Stack, { direction: "row", spacing: 0.5, flexWrap: "wrap", alignItems: "center", children: [_jsx(HitBannerTooltip, { hit: hit, children: _jsx(Chip, { sx: { backgroundColor: providerColor, color: theme.palette.getContrastText(providerColor) }, label: hit.organization?.name ?? _jsx(Trans, { i18nKey: "unknown" }) }) }), _jsx(AnalyticLink, { lazy: lazy, hit: hit }), _jsx("div", { style: { flex: 1 } }), _jsx(EscalationChip, { hit: hit, layout: layout }), ['in-progress', 'on-hold'].includes(hit.howler.status ?? '') && (_jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status, color: "primary" })), _jsx(HitTimestamp, { hit: hit, layout: layout }), _jsx(Assigned, { hit: hit, layout: layout, showAssigned: showAssigned }), (hit.howler.related?.length ?? 0) > 0 && _jsx(RelatedRecords, { hit: hit }), howlerPluginStore.plugins.flatMap(plugin => (_jsx(Fragment, { children: pluginStore.executeFunction(`${plugin}.status`, { hit, layout }) }, plugin)))] }), hit.howler?.rationale && (_jsx(Wrapper, { fontWeight: "bold", color: getEscalationColor(hit.howler.escalation) + '.main', compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.rationale", value: hit.howler.rationale, field: "howler.rationale" })), hit.howler?.outline && (_jsxs(_Fragment, { children: [hit.howler.outline.threat && (_jsx(Wrapper, { compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.threat", value: hit.howler.outline.threat, field: "howler.outline.threat" })), hit.howler.outline.target && (_jsx(Wrapper, { compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.target", value: hit.howler.outline.target, field: "howler.outline.target" })), indicators.length > 0 && (_jsxs(Stack, { direction: "row", spacing: layout !== HitLayout.COMFY ? 0.25 : 1, sx: { minWidth: 0 }, children: [_jsxs(Typography, { component: "span", variant: textVariant, fontWeight: "bold", pr: 1, children: [t('hit.header.indicators'), ":"] }), _jsx(Grid, { container: true, spacing: 0.5, sx: { flex: 1, minWidth: 0 }, children: indicators.map((indicator, index) => {
|
|
44
|
+
const isUrl = isHttpUrl(indicator);
|
|
45
|
+
const indicatorValue = (_jsx(Box, { tabIndex: isUrl ? 0 : undefined, sx: { minWidth: 0, maxWidth: '100%' }, children: _jsx(PluginTypography, { context: "indicators", variant: textVariant, value: indicator, sx: isUrl
|
|
46
|
+
? {
|
|
47
|
+
display: '-webkit-box',
|
|
48
|
+
overflow: 'hidden',
|
|
49
|
+
overflowWrap: 'anywhere',
|
|
50
|
+
textOverflow: 'ellipsis',
|
|
51
|
+
WebkitBoxOrient: 'vertical',
|
|
52
|
+
WebkitLineClamp: 2
|
|
53
|
+
}
|
|
54
|
+
: { overflowWrap: 'anywhere' }, children: indicator }) }));
|
|
55
|
+
return (_jsx(Grid, { sx: { flexBasis: '100%', minWidth: 0, maxWidth: '100%' }, children: _jsxs(Stack, { direction: "row", sx: { minWidth: 0 }, children: [isUrl ? _jsx(Tooltip, { title: indicator, children: indicatorValue }) : indicatorValue, index < indicators.length - 1 && _jsx(Typography, { variant: textVariant, children: ',' })] }) }, indicator));
|
|
35
56
|
}) })] })), hit.howler.outline.summary && (_jsx(Wrapper, { compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.summary", value: hit.howler.outline.summary, textOverflow: "wrap", sx: [compressed && { marginTop: `0 !important` }], field: "howler.outline.summary" })), hit.howler.links?.[0]?.href && (_jsx(Chip, { icon: _jsx(OpenInNew, {}), label: hit.howler.links[0].title || t('hit.header.link'), size: layout !== HitLayout.COMFY ? 'small' : 'medium', component: "a", href: hit.howler.links[0].href, target: "_blank", rel: "noopener noreferrer", sx: { [`.${chipClasses.label}`]: { cursor: 'pointer !important' }, alignSelf: 'start' }, onClick: e => {
|
|
36
57
|
e.stopPropagation();
|
|
37
58
|
} }))] }))] }) }));
|
|
@@ -130,6 +130,37 @@ describe('HitBanner', () => {
|
|
|
130
130
|
expect(screen.getByText('Summary value')).toBeInTheDocument();
|
|
131
131
|
expect(screen.getByRole('link', { name: 'Open source link' })).toHaveAttribute('href', 'https://example.com');
|
|
132
132
|
});
|
|
133
|
+
it('truncates HTTP indicator URLs and makes their tooltip keyboard reachable', async () => {
|
|
134
|
+
const user = userEvent.setup();
|
|
135
|
+
const indicator = 'https://example.example.com/v2/r03/__https://example.example.com/sites/security/documents/very-long-document-name?query=very-long-value-example';
|
|
136
|
+
const hit = createBannerHit({
|
|
137
|
+
howler: {
|
|
138
|
+
...createBannerHit().howler,
|
|
139
|
+
outline: { ...createBannerHit().howler.outline, indicators: [indicator] }
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
renderHitBanner({ hit });
|
|
143
|
+
const indicatorText = screen.getByText(indicator);
|
|
144
|
+
expect(indicatorText).toHaveStyle({ WebkitLineClamp: '2', overflow: 'hidden', textOverflow: 'ellipsis' });
|
|
145
|
+
const indicatorWrapper = indicatorText.closest('[tabindex="0"]');
|
|
146
|
+
expect(indicatorWrapper).toBeInTheDocument();
|
|
147
|
+
await user.tab();
|
|
148
|
+
expect(indicatorWrapper).toHaveFocus();
|
|
149
|
+
await user.hover(indicatorText);
|
|
150
|
+
expect(await screen.findByRole('tooltip')).toHaveTextContent(indicator);
|
|
151
|
+
});
|
|
152
|
+
it('wraps non-URL indicators and does not add a tooltip', () => {
|
|
153
|
+
const indicator = 'a-very-long-unbroken-indicator-value';
|
|
154
|
+
const hit = createBannerHit({
|
|
155
|
+
howler: {
|
|
156
|
+
...createBannerHit().howler,
|
|
157
|
+
outline: { ...createBannerHit().howler.outline, indicators: [indicator] }
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
renderHitBanner({ hit });
|
|
161
|
+
expect(screen.getByText(indicator)).toHaveStyle({ overflowWrap: 'anywhere' });
|
|
162
|
+
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
|
163
|
+
});
|
|
133
164
|
it.each(['in-progress', 'on-hold'])('renders the status chip for %s', status => {
|
|
134
165
|
const hit = createBannerHit({ howler: { ...createBannerHit().howler, status } });
|
|
135
166
|
renderHitBanner({ hit });
|
package/package.json
CHANGED