Skip to content

Commit 10c49da

Browse files
Replace usage menu item with insights on Dedicated (#20587)
* Replace usage menu item with insights on Dedicated Tool: gitpod/catfood.gitpod.cloud * Rename usage-related functions to insights in download module Tool: gitpod/catfood.gitpod.cloud
1 parent fb89d41 commit 10c49da

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

components/dashboard/src/insights/download/DownloadInsights.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const DownloadInsightsToast = ({ organizationId, from, to, organizationNa
5252
if (isLoading) {
5353
return (
5454
<div>
55-
<span>Preparing usage export</span>
55+
<span>Preparing insights export</span>
5656
<br />
5757
<span className="text-sm">Exporting page {progress}</span>
5858
</div>
@@ -64,15 +64,15 @@ export const DownloadInsightsToast = ({ organizationId, from, to, organizationNa
6464
<div className="flex flex-row items-start space-x-2">
6565
<AlertTriangle className="w-5 h-5 mt-0.5" />
6666
<div>
67-
<span>Error exporting your usage data:</span>
67+
<span>Error exporting your insights data:</span>
6868
<pre className="mt-2 whitespace-normal text-sm">{error.message}</pre>
6969
</div>
7070
</div>
7171
);
7272
}
7373

7474
if (!data || !data.blob || data.count === 0) {
75-
return <span>No usage data for the selected period.</span>;
75+
return <span>No insights data for the selected period.</span>;
7676
}
7777

7878
const readableSize = prettyBytes(data.blob.size);
@@ -81,7 +81,7 @@ export const DownloadInsightsToast = ({ organizationId, from, to, organizationNa
8181
return (
8282
<div className="flex flex-row items-start justify-between space-x-2">
8383
<div>
84-
<span>Usage export complete.</span>
84+
<span>Insights export complete.</span>
8585
<p className="dark:text-gray-500">
8686
{readableSize} &middot; {formattedCount} {data.count !== 1 ? "entries" : "entry"} exported
8787
</p>

components/dashboard/src/insights/download/download-sessions.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ type Args = Pick<ListWorkspaceSessionsRequest, "organizationId" | "from" | "to">
6767
onProgress?: (percentage: number) => void;
6868
};
6969

70-
export type DownloadUsageCSVResponse = {
70+
export type DownloadInsightsCSVResponse = {
7171
blob: Blob | null;
7272
filename: string;
7373
count: number;
7474
};
7575

76-
const downloadUsageCSV = async ({
76+
const downloadInsightsCSV = async ({
7777
organizationId,
7878
from,
7979
to,
8080
organizationName,
8181
signal,
8282
onProgress,
83-
}: Args): Promise<DownloadUsageCSVResponse> => {
83+
}: Args): Promise<DownloadInsightsCSVResponse> => {
8484
const start = dayjs(from?.toDate()).format("YYYYMMDD");
8585
const end = dayjs(to?.toDate()).format("YYYYMMDD");
8686
const filename = `gitpod-sessions-${organizationName}-${start}-${end}.csv`;
@@ -197,16 +197,16 @@ export const transformSessionRecord = (session: WorkspaceSession) => {
197197

198198
export const useDownloadSessionsCSV = (args: Args) => {
199199
const client = useQueryClient();
200-
const key = getDownloadUsageCSVQueryKey(args);
200+
const key = getDownloadInsightsCSVQueryKey(args);
201201

202202
const abort = useCallback(() => {
203203
client.removeQueries([key]);
204204
}, [client, key]);
205205

206-
const query = useQuery<DownloadUsageCSVResponse, Error>(
206+
const query = useQuery<DownloadInsightsCSVResponse, Error>(
207207
key,
208208
async ({ signal }) => {
209-
return downloadUsageCSV({ ...args, signal });
209+
return downloadInsightsCSV({ ...args, signal });
210210
},
211211
{
212212
retry: false,
@@ -221,6 +221,6 @@ export const useDownloadSessionsCSV = (args: Args) => {
221221
};
222222
};
223223

224-
const getDownloadUsageCSVQueryKey = (args: Args) => {
225-
return noPersistence(["usage-export", args]);
224+
const getDownloadInsightsCSVQueryKey = (args: Args) => {
225+
return noPersistence(["insights-export", args]);
226226
};

components/dashboard/src/menu/OrganizationSelector.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,23 @@ export default function OrganizationSelector() {
7777
separator: true,
7878
link: "/members",
7979
});
80-
linkEntries.push({
81-
title: "Usage",
82-
customContent: <LinkEntry>Usage</LinkEntry>,
83-
active: false,
84-
separator: false,
85-
link: "/usage",
86-
});
80+
if (isDedicated) {
81+
linkEntries.push({
82+
title: "Insights",
83+
customContent: <LinkEntry>Insights</LinkEntry>,
84+
active: false,
85+
separator: false,
86+
link: "/insights",
87+
});
88+
} else {
89+
linkEntries.push({
90+
title: "Usage",
91+
customContent: <LinkEntry>Usage</LinkEntry>,
92+
active: false,
93+
separator: false,
94+
link: "/usage",
95+
});
96+
}
8797
// Show billing if user is an owner of current org
8898
if (owner) {
8999
if (billingMode?.mode === "usage-based") {

0 commit comments

Comments
 (0)