Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Logs / Metrics UI] Link handling / stop page reloads #58478

Merged
merged 36 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ae6879e
Add a hook for seamlessly handling onClick and href props of links, b…
Kerry350 Feb 25, 2020
5055b69
Merge remote-tracking branch 'upstream/master' into 58007-stop-link-p…
Kerry350 Feb 25, 2020
650824f
Swap over other context menu links and view source config button
Kerry350 Feb 25, 2020
6ce8122
User management link
Kerry350 Feb 25, 2020
fb717ac
Merge remote-tracking branch 'upstream/master' into 58007-stop-link-p…
Kerry350 Feb 26, 2020
e662472
Convert more links
Kerry350 Feb 26, 2020
394f2c1
Typecheck errors
Kerry350 Feb 26, 2020
9804f8e
Merge remote-tracking branch 'upstream/master' into 58007-stop-link-p…
Kerry350 Feb 27, 2020
c931d25
Don't re-encode colours twice in TSVB links
Kerry350 Feb 27, 2020
b1cd841
Amend types
Kerry350 Feb 27, 2020
976edb8
Fix createTSVBLink tests
Kerry350 Feb 27, 2020
cc6814e
Fix log entry actions menu tests
Kerry350 Feb 27, 2020
f0eb180
Fix chart context menu tests
Kerry350 Feb 27, 2020
3da1b2f
Fix create uptime link tests
Kerry350 Feb 27, 2020
2d8ecd9
Merge remote-tracking branch 'upstream/master' into 58007-stop-link-p…
Kerry350 Feb 28, 2020
51c23c5
Typecheck
Kerry350 Feb 28, 2020
61788d6
Fix getUptimeLink generation when dealing with array values that have…
Kerry350 Mar 1, 2020
a52e4e1
Merge remote-tracking branch 'upstream/master' into 58007-stop-link-p…
Kerry350 Mar 1, 2020
d3621bb
Merge branch 'master' into 58007-stop-link-page-reloads
elasticmachine Mar 2, 2020
a71cd05
Add tests for useLinkProps
Kerry350 Mar 2, 2020
1098833
Merge branch '58007-stop-link-page-reloads' of github.com:Kerry350/ki…
Kerry350 Mar 2, 2020
8ac69e7
Merge branch 'master' into 58007-stop-link-page-reloads
elasticmachine Mar 3, 2020
ee8dedf
Merge remote-tracking branch 'upstream/master' into 58007-stop-link-p…
Kerry350 Mar 4, 2020
d117a74
Merge remote-tracking branch 'upstream/master' into 58007-stop-link-p…
Kerry350 Mar 5, 2020
4d804a7
Update x-pack/plugins/infra/public/hooks/use_link_props.tsx
Kerry350 Mar 5, 2020
fb54d71
Update x-pack/plugins/infra/public/components/navigation/routed_tabs.tsx
Kerry350 Mar 5, 2020
a46990c
Update x-pack/plugins/infra/public/components/navigation/routed_tabs.tsx
Kerry350 Mar 5, 2020
4ff794b
Add comment clarifying behaviour of internal linking
Kerry350 Mar 5, 2020
2b3caeb
Simplify uptime link within node context menu
Kerry350 Mar 5, 2020
4df03bf
Update x-pack/plugins/infra/public/components/logging/log_entry_flyou…
Kerry350 Mar 5, 2020
26bed45
Merge branch '58007-stop-link-page-reloads' of github.com:Kerry350/ki…
Kerry350 Mar 5, 2020
7c691d5
Stricter typings for arrays of strings in log item field values
Kerry350 Mar 5, 2020
c50c60f
Make tests a little more accurate
Kerry350 Mar 5, 2020
e3640c2
Merge remote-tracking branch 'upstream/master' into 58007-stop-link-p…
Kerry350 Mar 9, 2020
c942eac
Change the mechanism for differentiating between internal and externa…
Kerry350 Mar 9, 2020
1342cdd
Syntax tweaks and test amendments
Kerry350 Mar 9, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,40 @@ import { EuiButton } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';
import { encode } from 'rison-node';
import url from 'url';
import { stringify } from 'query-string';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { TimeRange } from '../../../../common/http_api/shared/time_range';
import { url as urlUtils } from '../../../../../../../src/plugins/kibana_utils/public';
import { useLinkProps, LinkDescriptor } from '../../../hooks/use_link_props';

export const AnalyzeInMlButton: React.FunctionComponent<{
jobId: string;
partition?: string;
timeRange: TimeRange;
}> = ({ jobId, partition, timeRange }) => {
const prependBasePath = useKibana().services.http?.basePath?.prepend;
if (!prependBasePath) {
return null;
}
const pathname = prependBasePath('/app/ml');
const linkProps = useLinkProps(
typeof partition === 'string'
? getPartitionSpecificSingleMetricViewerLinkDescriptor(jobId, partition, timeRange)
: getOverallAnomalyExplorerLinkDescriptor(jobId, timeRange)
);
const buttonLabel = (
<FormattedMessage
id="xpack.infra.logs.analysis.analyzeInMlButtonLabel"
defaultMessage="Analyze in ML"
/>
);
return typeof partition === 'string' ? (
<EuiButton
fill={false}
size="s"
href={getPartitionSpecificSingleMetricViewerLink(pathname, jobId, partition, timeRange)}
>
<EuiButton fill={false} size="s" {...linkProps}>
{buttonLabel}
</EuiButton>
) : (
<EuiButton
fill={true}
size="s"
href={getOverallAnomalyExplorerLink(pathname, jobId, timeRange)}
>
<EuiButton fill={true} size="s" {...linkProps}>
{buttonLabel}
</EuiButton>
);
};

const getOverallAnomalyExplorerLink = (pathname: string, jobId: string, timeRange: TimeRange) => {
const getOverallAnomalyExplorerLinkDescriptor = (
jobId: string,
timeRange: TimeRange
): LinkDescriptor => {
const { from, to } = convertTimeRangeToParams(timeRange);

const _g = encode({
Expand All @@ -62,20 +54,18 @@ const getOverallAnomalyExplorerLink = (pathname: string, jobId: string, timeRang
},
});

const hash = `/explorer?${stringify(urlUtils.encodeQuery({ _g }), { encode: false })}`;

return url.format({
pathname,
hash,
});
return {
app: 'ml',
hash: '/explorer',
search: { _g },
};
};

const getPartitionSpecificSingleMetricViewerLink = (
pathname: string,
const getPartitionSpecificSingleMetricViewerLinkDescriptor = (
jobId: string,
partition: string,
timeRange: TimeRange
) => {
): LinkDescriptor => {
const { from, to } = convertTimeRangeToParams(timeRange);

const _g = encode({
Expand All @@ -95,15 +85,11 @@ const getPartitionSpecificSingleMetricViewerLink = (
},
});

const hash = `/timeseriesexplorer?${stringify(urlUtils.encodeQuery({ _g, _a }), {
sort: false,
encode: false,
})}`;

return url.format({
pathname,
hash,
});
return {
app: 'ml',
hash: '/timeseriesexplorer',
search: { _g, _a },
};
};

const convertTimeRangeToParams = (timeRange: TimeRange): { from: string; to: string } => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
import { EuiButton, EuiButtonProps } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';
import { useLinkProps } from '../../../hooks/use_link_props';

export const UserManagementLink: React.FunctionComponent<EuiButtonProps> = props => (
<EuiButton href="kibana#/management/security/users" color="primary" fill {...props}>
<FormattedMessage
id="xpack.infra.logs.analysis.userManagementButtonLabel"
defaultMessage="Manage users"
/>
</EuiButton>
);
export const UserManagementLink: React.FunctionComponent<EuiButtonProps> = props => {
const linkProps = useLinkProps({
app: 'kibana',
hash: '/management/security/users',
});
return (
<EuiButton color="primary" fill {...linkProps} {...props}>
<FormattedMessage
id="xpack.infra.logs.analysis.userManagementButtonLabel"
defaultMessage="Manage users"
/>
</EuiButton>
);
};
Loading