* chore: analytics endpoint * added anlytics v2 * updated status icons * added area chart in workitems and en translations * active projects * chore: created analytics chart * chore: validation errors * improved radar-chart , added empty states , added projects summary * chore: added a new graph in advance analytics * integrated priority chart * chore: added csv exporter * added priority dropdown * integrated created vs resolved chart * custom x and y axis label in bar and area chart * added wrapper styles to legends * added filter components * fixed temp data imports * integrated filters in priority charts * added label to priority chart and updated duration filter * refactor * reverted to void onchange * fixed some contant exports * fixed type issues * fixed some type and build issues * chore: updated the filtering logic for analytics * updated default value to last_30_days * percentage value whole number and added some rules for axis options * fixed some translations * added - custom tick for radar, calc of insight cards, filter labels * chore: opitmised the analytics endpoint * replace old analytics path with new , updated labels of insight card, done some store fixes * chore: updated the export request * Enhanced ProjectSelect to support multi-select, improved state management, and optimized data fetching and component structure. * fix: round completion percentage calculation in ActiveProjectItem * added empty states in project insights * Added loader and empty state in created/resolved chart * added loaders * added icons in filters * added custom colors in customised charts * cleaned up some code * added some responsiveness * updated translations * updated serrchbar for the table * added work item modal in project analytics * fixed some of the layput issues in the peek view * chore: updated the base function for viewsets * synced tab to url * code cleanup * chore: updated the export logic * fixed project_ids filter * added icon in projectdropdown * updated export button position * export csv and emptystates icons * refactor * code refactor * updated loaders, moved color pallete to contants, added nullish collasece operator in neccessary places * removed uneccessary cn * fixed formatting issues * fixed empty project_ids in payload * improved null checks * optimized charts * modified relevant variables to observable.ref * fixed the duration type * optimized some code * updated query key in project-insight * updated query key in project-insight * updated formatting * chore: replaced analytics route with new one and done some optimizations * removed the old analytics --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
101 lines
3.8 KiB
TypeScript
101 lines
3.8 KiB
TypeScript
"use client";
|
|
|
|
import { useMemo } from "react";
|
|
import { observer } from "mobx-react";
|
|
import { useRouter, useSearchParams } from "next/navigation";
|
|
// plane package imports
|
|
import { EUserPermissions, EUserPermissionsLevel } from "@plane/constants";
|
|
import { useTranslation } from "@plane/i18n";
|
|
import { Tabs } from "@plane/ui";
|
|
// components
|
|
import AnalyticsFilterActions from "@/components/analytics-v2/analytics-filter-actions";
|
|
import { PageHead } from "@/components/core";
|
|
import { ComicBoxButton, DetailedEmptyState } from "@/components/empty-state";
|
|
// hooks
|
|
import { useCommandPalette, useEventTracker, useProject, useUserPermissions, useWorkspace } from "@/hooks/store";
|
|
import { useResolvedAssetPath } from "@/hooks/use-resolved-asset-path";
|
|
import { ANALYTICS_TABS } from "@/plane-web/components/analytics-v2/tabs";
|
|
|
|
const AnalyticsPage = observer(() => {
|
|
const router = useRouter();
|
|
const searchParams = useSearchParams();
|
|
// plane imports
|
|
const { t } = useTranslation();
|
|
// store hooks
|
|
const { toggleCreateProjectModal } = useCommandPalette();
|
|
const { setTrackElement } = useEventTracker();
|
|
const { workspaceProjectIds, loader } = useProject();
|
|
const { currentWorkspace } = useWorkspace();
|
|
const { allowPermissions } = useUserPermissions();
|
|
// helper hooks
|
|
const resolvedPath = useResolvedAssetPath({ basePath: "/empty-state/onboarding/analytics" });
|
|
// derived values
|
|
const pageTitle = currentWorkspace?.name
|
|
? t(`workspace_analytics.page_label`, { workspace: currentWorkspace?.name })
|
|
: undefined;
|
|
|
|
// permissions
|
|
const canPerformEmptyStateActions = allowPermissions(
|
|
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
|
EUserPermissionsLevel.WORKSPACE
|
|
);
|
|
|
|
const tabs = useMemo(
|
|
() =>
|
|
ANALYTICS_TABS.map((tab) => ({
|
|
key: tab.key,
|
|
label: t(tab.i18nKey),
|
|
content: <tab.content />,
|
|
onClick: () => {
|
|
router.push(`?tab=${tab.key}`);
|
|
},
|
|
})),
|
|
[router, t]
|
|
);
|
|
const defaultTab = searchParams.get("tab") || ANALYTICS_TABS[0].key;
|
|
|
|
return (
|
|
<>
|
|
<PageHead title={pageTitle} />
|
|
{workspaceProjectIds && (
|
|
<>
|
|
{workspaceProjectIds.length > 0 || loader === "init-loader" ? (
|
|
<div className="flex h-full overflow-hidden bg-custom-background-100 justify-between items-center ">
|
|
<Tabs
|
|
tabs={tabs}
|
|
storageKey={`analytics-page-${currentWorkspace?.id}`}
|
|
defaultTab={defaultTab}
|
|
size="md"
|
|
tabListContainerClassName="px-6 py-2 border-b border-custom-border-200 flex items-center justify-between"
|
|
tabListClassName="my-2 max-w-36"
|
|
tabPanelClassName="h-full w-full overflow-hidden overflow-y-auto"
|
|
storeInLocalStorage={false}
|
|
actions={<AnalyticsFilterActions />}
|
|
/>
|
|
</div>
|
|
) : (
|
|
<DetailedEmptyState
|
|
title={t("workspace_analytics.empty_state.general.title")}
|
|
description={t("workspace_analytics.empty_state.general.description")}
|
|
assetPath={resolvedPath}
|
|
customPrimaryButton={
|
|
<ComicBoxButton
|
|
label={t("workspace_analytics.empty_state.general.primary_button.text")}
|
|
title={t("workspace_analytics.empty_state.general.primary_button.comic.title")}
|
|
description={t("workspace_analytics.empty_state.general.primary_button.comic.description")}
|
|
onClick={() => {
|
|
setTrackElement("Analytics empty state");
|
|
toggleCreateProjectModal(true);
|
|
}}
|
|
disabled={!canPerformEmptyStateActions}
|
|
/>
|
|
}
|
|
/>
|
|
)}
|
|
</>
|
|
)}
|
|
</>
|
|
);
|
|
});
|
|
|
|
export default AnalyticsPage;
|