mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
a08f401452
* refactor: empty state global config file added and empty state component refactor * refactor: empty state component refactor * chore: empty state refactor * chore: empty state config file updated * chore: empty state action button permission logic updated * chore: empty state config file updated * chore: cycle and module empty filter state updated * chore: empty state asset updated * chore: empty state config file updated * chore: empty state config file updated * chore: empty state component improvement * chore: empty state action button improvement * fix: merge conflict
87 lines
3.3 KiB
TypeScript
87 lines
3.3 KiB
TypeScript
import React, { Fragment, ReactElement } from "react";
|
|
import { observer } from "mobx-react-lite";
|
|
import { useRouter } from "next/router";
|
|
import { Tab } from "@headlessui/react";
|
|
// hooks
|
|
import { useApplication, useEventTracker, useProject, useWorkspace } from "hooks/store";
|
|
// layouts
|
|
import { AppLayout } from "layouts/app-layout";
|
|
// components
|
|
import { CustomAnalytics, ScopeAndDemand } from "components/analytics";
|
|
import { PageHead } from "components/core";
|
|
import { EmptyState } from "components/empty-state";
|
|
import { WorkspaceAnalyticsHeader } from "components/headers";
|
|
// type
|
|
import { NextPageWithLayout } from "lib/types";
|
|
// constants
|
|
import { ANALYTICS_TABS } from "constants/analytics";
|
|
import { EmptyStateType } from "constants/empty-state";
|
|
|
|
const AnalyticsPage: NextPageWithLayout = observer(() => {
|
|
const router = useRouter();
|
|
const { analytics_tab } = router.query;
|
|
// store hooks
|
|
const {
|
|
commandPalette: { toggleCreateProjectModal },
|
|
} = useApplication();
|
|
const { setTrackElement } = useEventTracker();
|
|
const { workspaceProjectIds } = useProject();
|
|
const { currentWorkspace } = useWorkspace();
|
|
// derived values
|
|
const pageTitle = currentWorkspace?.name ? `${currentWorkspace?.name} - Analytics` : undefined;
|
|
|
|
return (
|
|
<>
|
|
<PageHead title={pageTitle} />
|
|
{workspaceProjectIds && workspaceProjectIds.length > 0 ? (
|
|
<div className="flex h-full flex-col overflow-hidden bg-custom-background-100">
|
|
<Tab.Group as={Fragment} defaultIndex={analytics_tab === "custom" ? 1 : 0}>
|
|
<Tab.List as="div" className="flex space-x-2 border-b border-custom-border-200 px-0 md:px-5 py-0 md:py-3">
|
|
{ANALYTICS_TABS.map((tab) => (
|
|
<Tab
|
|
key={tab.key}
|
|
className={({ selected }) =>
|
|
`rounded-0 w-full md:w-max md:rounded-3xl border-b md:border border-custom-border-200 focus:outline-none px-0 md:px-4 py-2 text-xs hover:bg-custom-background-80 ${
|
|
selected
|
|
? "border-custom-primary-100 text-custom-primary-100 md:bg-custom-background-80 md:text-custom-text-200 md:border-custom-border-200"
|
|
: "border-transparent"
|
|
}`
|
|
}
|
|
onClick={() => {
|
|
router.query.analytics_tab = tab.key;
|
|
router.push(router);
|
|
}}
|
|
>
|
|
{tab.title}
|
|
</Tab>
|
|
))}
|
|
</Tab.List>
|
|
<Tab.Panels as={Fragment}>
|
|
<Tab.Panel as={Fragment}>
|
|
<ScopeAndDemand fullScreen />
|
|
</Tab.Panel>
|
|
<Tab.Panel as={Fragment}>
|
|
<CustomAnalytics fullScreen />
|
|
</Tab.Panel>
|
|
</Tab.Panels>
|
|
</Tab.Group>
|
|
</div>
|
|
) : (
|
|
<EmptyState
|
|
type={EmptyStateType.WORKSPACE_ANALYTICS}
|
|
primaryButtonOnClick={() => {
|
|
setTrackElement("Analytics empty state");
|
|
toggleCreateProjectModal(true);
|
|
}}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
});
|
|
|
|
AnalyticsPage.getLayout = function getLayout(page: ReactElement) {
|
|
return <AppLayout header={<WorkspaceAnalyticsHeader />}>{page}</AppLayout>;
|
|
};
|
|
|
|
export default AnalyticsPage;
|