Skip to content

Commit

Permalink
Fix activity dashboard for preview (#782)
Browse files Browse the repository at this point in the history
* Fix activity dashboard for preview

* Update preview i18n for activity dashboard
  • Loading branch information
codemonkey800 authored Nov 30, 2022
1 parent 3d68fca commit 6e5ad4b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
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

0 comments on commit 6e5ad4b

Please sign in to comment.