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

Austenem/CAT-1085 Add sample workspace banner #3677

Merged
merged 3 commits into from
Feb 3, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG-add-sample-workspace-banner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add an info banner to template pages without sample workspaces.
64 changes: 37 additions & 27 deletions context/app/static/js/pages/Template/Template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@ import { DEFAULT_JOB_TYPE } from 'js/components/workspaces/constants';
import { useAppContext } from 'js/components/Contexts';
import { buildSearchLink } from 'js/components/search/store';

const sampleWorkspacesDescription =
'Sample workspaces are provided to help you get started with this template and to better understand the types of data that are compatible with it.';

interface SampleWorkspacesInfoBannerProps {
hasSampleWorkspaces: boolean;
}
function SampleWorkspacesInfoBanner({ hasSampleWorkspaces }: SampleWorkspacesInfoBannerProps) {
if (!hasSampleWorkspaces) {
return <IconPanel status="info">No sample workspaces are currently available for this template.</IconPanel>;
}

if (isAuthenticated) {
return <IconPanel status="info">{sampleWorkspacesDescription}</IconPanel>;
}

return (
<LogInPanel trackingInfo={{ category: WorkspacesEventCategories.WorkspaceTemplateDetailPage }}>
{sampleWorkspacesDescription} Please <InternalLink href="/login">log in</InternalLink> to explore a sample
workspace.
</LogInPanel>
);
}

interface ExampleAccordionProps {
example: TemplateExample;
templateKey: string;
Expand Down Expand Up @@ -170,33 +193,20 @@ function Template({ templateKey }: TemplatePageProps) {
)}
</Stack>
</Stack>
{template.examples && (
<Stack spacing={1}>
<Typography variant="h4">Sample Workspaces</Typography>
{isAuthenticated ? (
<IconPanel status="info">
Sample workspaces are provided to help you get started with this template and to better understand the
types of data that are compatible with it.
</IconPanel>
) : (
<LogInPanel trackingInfo={{ category: WorkspacesEventCategories.WorkspaceTemplateDetailPage }}>
Sample workspaces are available to help you get started with this template and better understand the types
of compatible data. Please <InternalLink href="/login">log in</InternalLink> to explore a sample
workspace.
</LogInPanel>
)}
{template.examples.map((example, idx) => (
<ExampleAccordion
key={example.title}
example={example}
templateKey={templateKey}
templateName={template.title}
jobType={template.job_types?.[0]}
defaultExpanded={idx === 0}
/>
))}
</Stack>
)}
<Stack spacing={1}>
<Typography variant="h4">Sample Workspaces</Typography>
<SampleWorkspacesInfoBanner hasSampleWorkspaces={template.examples?.length > 0} />
{template.examples?.map((example, idx) => (
<ExampleAccordion
key={example.title}
example={example}
templateKey={templateKey}
templateName={template.title}
jobType={template.job_types?.[0]}
defaultExpanded={idx === 0}
/>
))}
</Stack>
</Stack>
);
}
Expand Down
Loading