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

[Fleet] Show a warning in assets tab for permission errors #141153

Merged
merged 3 commits into from
Sep 20, 2022
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React, { useEffect, useState } from 'react';
import { Redirect } from 'react-router-dom';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiSpacer } from '@elastic/eui';
import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiSpacer, EuiCallOut } from '@elastic/eui';
import { groupBy } from 'lodash';

import type { ResolvedSimpleSavedObject } from '@kbn/core/public';
Expand Down Expand Up @@ -52,6 +52,7 @@ export const AssetsPage = ({ packageInfo }: AssetsPanelProps) => {
const [assetSavedObjects, setAssetsSavedObjects] = useState<undefined | AssetSavedObject[]>();
const [fetchError, setFetchError] = useState<undefined | Error>();
const [isLoading, setIsLoading] = useState<boolean>(true);
const [hasPermissionError, setHasPermissionError] = useState<boolean>(true);

useEffect(() => {
const fetchAssetSavedObjects = async () => {
Expand Down Expand Up @@ -94,6 +95,7 @@ export const AssetsPage = ({ packageInfo }: AssetsPanelProps) => {
// Ignore privilege errors
.catch((e: any) => {
if (e?.body?.statusCode === 403) {
setHasPermissionError(true);
return { resolved_objects: [] };
} else {
throw e;
Expand Down Expand Up @@ -161,6 +163,23 @@ export const AssetsPage = ({ packageInfo }: AssetsPanelProps) => {
</h2>
</EuiTitle>
);
} else if (hasPermissionError) {
content = (
<EuiCallOut
color="warning"
title={
<FormattedMessage
id="xpack.fleet.epm.packageDetails.assets.assetsPermissionErrorTitle"
defaultMessage="Permission errors"
/>
}
>
<FormattedMessage
id="xpack.fleet.epm.packageDetails.assets.assetsPermissionError"
defaultMessage="You do not have permission to retrieve the Kibana saved object for that integration. Contact your administrator."
/>
</EuiCallOut>
);
} else if (assetSavedObjects === undefined || assetSavedObjects.length === 0) {
if (customAssetsExtension) {
// If a UI extension for custom asset entries is defined, render the custom component here despite
Expand Down