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

feat: application overview feedback #6416

Merged
merged 2 commits into from
Mar 4, 2024
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
67 changes: 49 additions & 18 deletions frontend/src/component/application/ApplicationOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { usePageTitle } from 'hooks/usePageTitle';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { Alert, Box, Divider, styled } from '@mui/material';
import { Alert, Box, Button, Divider, styled } from '@mui/material';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { useApplicationOverview } from 'hooks/api/getters/useApplicationOverview/useApplicationOverview';
import { ApplicationIssues } from './ApplicationIssues/ApplicationIssues';
Expand All @@ -10,6 +10,8 @@ import { Badge } from '../common/Badge/Badge';
import { useNavigate } from 'react-router-dom';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import { useEffect } from 'react';
import { useFeedback } from '../feedbackNew/useFeedback';
import { ReviewsOutlined } from '@mui/icons-material';

const StyledDivider = styled(Divider)(({ theme }) => ({
marginTop: theme.spacing(2),
Expand All @@ -33,6 +35,12 @@ const ProjectContainer = styled(Box)(({ theme }) => ({
alignSelf: 'stretch',
}));

const ApplicationHeader = styled('div')(({ theme }) => ({
display: 'flex',
justifyContent: 'space-between',
alignSelf: 'stretch',
}));

const useTracking = () => {
const { trackEvent } = usePlausibleTracker();
useEffect(() => {
Expand All @@ -51,29 +59,52 @@ const ApplicationOverview = () => {
const navigate = useNavigate();
const { data, loading } = useApplicationOverview(applicationName);

const { openFeedback } = useFeedback('applicationOverview', 'automatic');

const createFeedbackContext = () => {
openFeedback({
title: 'How easy was it to use the application overview page?',
positiveLabel:
'What do you like most about the new application overview page?',
areasForImprovementsLabel:
'What should be improved on the application overview page?',
});
};

return (
<ConditionallyRender
condition={!loading && data.environments.length === 0}
show={<Alert severity='warning'>No data available.</Alert>}
elseShow={
<ApplicationContainer>
<ProjectContainer>
Projects using this application
{data.projects.map((project) => (
<Badge
sx={{ cursor: 'pointer' }}
key={project}
onClick={(e) => {
e.preventDefault();
navigate(`/projects/${project}`);
}}
color='secondary'
icon={<TopicOutlinedIcon />}
>
{project}
</Badge>
))}
</ProjectContainer>
<ApplicationHeader>
<ProjectContainer>
Projects using this application
{data.projects.map((project) => (
<Badge
sx={{ cursor: 'pointer' }}
key={project}
onClick={(e) => {
e.preventDefault();
navigate(`/projects/${project}`);
}}
color='secondary'
icon={<TopicOutlinedIcon />}
>
{project}
</Badge>
))}
</ProjectContainer>
<Button
startIcon={<ReviewsOutlined />}
variant='outlined'
onClick={createFeedbackContext}
size='small'
>
Provide feedback
</Button>
</ApplicationHeader>

<StyledDivider />
<ApplicationIssues application={data} />
<ApplicationChart data={data} />
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/hooks/useSubmittedFeedback.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { createLocalStorage } from '../utils/createLocalStorage';

export type IFeedbackCategory = 'search' | 'newStrategyForm' | 'insights';
export type IFeedbackCategory =
| 'search'
| 'newStrategyForm'
| 'insights'
| 'applicationOverview';

export const useUserSubmittedFeedback = (category: IFeedbackCategory) => {
const key = `unleash-userSubmittedFeedback:${category}`;
Expand Down
Loading