diff --git a/components/dashboard/src/Insights.tsx b/components/dashboard/src/Insights.tsx
index 4db31ed2b8427c..c9fa6d3e69069e 100644
--- a/components/dashboard/src/Insights.tsx
+++ b/components/dashboard/src/Insights.tsx
@@ -27,6 +27,7 @@ import { DownloadIcon } from "lucide-react";
import { Button } from "@podkit/buttons/Button";
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "@podkit/dropdown/DropDown";
import { useInstallationConfiguration } from "./data/installation/installation-config-query";
+import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
export const Insights = () => {
const toDate = useMemo(() => Timestamp.fromDate(new Date()), []);
@@ -49,6 +50,9 @@ export const Insights = () => {
const grouped = Object.groupBy(sessions, (ws) => ws.workspace?.id ?? "unknown");
const [page, setPage] = useState(0);
+ const isLackingPermissions =
+ errorMessage instanceof ApplicationError && errorMessage.code === ErrorCodes.PERMISSION_DENIED;
+
return (
<>
@@ -59,7 +63,7 @@ export const Insights = () => {
"md:flex-row md:items-center md:space-x-4 md:space-y-0",
)}
>
-
+
{
{errorMessage && (
- {errorMessage instanceof Error ? errorMessage.message : "An error occurred."}
+ {isLackingPermissions ? (
+ <>
+ You don't have Owner permissions to access this
+ organization's insights.
+ >
+ ) : errorMessage instanceof Error ? (
+ errorMessage.message
+ ) : (
+ "An error occurred."
+ )}
)}
@@ -151,8 +164,9 @@ export const Insights = () => {
type DownloadUsageProps = {
to: Timestamp;
+ disabled?: boolean;
};
-export const DownloadUsage = ({ to }: DownloadUsageProps) => {
+export const DownloadUsage = ({ to, disabled }: DownloadUsageProps) => {
const { data: org } = useCurrentOrg();
const { toast } = useToast();
// When we start the download, we disable the button for a short time
@@ -184,7 +198,7 @@ export const DownloadUsage = ({ to }: DownloadUsageProps) => {
return (
-