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

Fix activity dashboard for preview #782

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion frontend/i18n/en/activity.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"learnMore": "<externalLink href='$t(learnMoreLink)'>Learn more about where we get this data.</externalLink>",
"noData": {
"allData": "No data could be fetched for this plugin. <externalLink href='$t(learnMoreLink)'>Learn more.</externalLink>",
"monthlyInstalls": "There is not yet enough data to display for this plugin"
"monthlyInstalls": "There is not yet enough data to display for this plugin",
"preview": "Activity not available for previews"
},
"monthlyInstalls": {
"title": "Monthly installs in past year",
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/components/ActivityDashboard/ActivityDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useMemo } from 'react';

import { I18n } from '@/components/I18n';
import { Text } from '@/components/Text';
import { PREVIEW } from '@/constants/env';
import { usePluginState } from '@/context/plugin';
import { usePluginMetrics } from '@/hooks';

Expand All @@ -10,7 +11,9 @@ import { EmptyState } from './EmptyState';

export function ActivityDashboard() {
const { plugin } = usePluginState();
const { data: metrics, isLoading } = usePluginMetrics(plugin?.name);
const { data: metrics, isLoading } = usePluginMetrics(
PREVIEW ? undefined : plugin?.name,
);

const isEmpty = useMemo(() => {
if (isLoading) {
Expand All @@ -33,7 +36,11 @@ export function ActivityDashboard() {
<div>
{isEmpty ? (
<EmptyState className="h-[75px] screen-495:h-[125px]">
<I18n i18nKey="activity:noData.allData" />
<I18n
i18nKey={
PREVIEW ? 'activity:noData.preview' : 'activity:noData.allData'
}
/>
</EmptyState>
) : (
<>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/AppBar/AppBarPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export function AppBarPreview() {
<div className="screen-1150:hidden">{renderRightColumn()}</div>
</div>

<div className="hidden: screen-1425:flex items-center space-x-sds-xl col-span-3">
<div className="hidden screen-1425:flex items-center space-x-sds-xl col-span-3">
<AppBarPreviewCenterColumn />
</div>

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/pages/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export async function getStaticProps({
'pageTitles',
'pluginPage',
'pluginData',
'preview',
'activity',
] as I18nNamespace[]);

// Return default data to prevent Next.js error if the plugin path is not defined.
Expand Down