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: add Request Dashboard button and improve dashboard list styles #6251

Merged
merged 2 commits into from
Oct 25, 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
justify-content: center;
width: 100%;

// overridding the request integration style to fix the spacing for dashboard list
.request-entity-container {
margin-bottom: 16px !important;
sharpshooter90 marked this conversation as resolved.
Show resolved Hide resolved
margin-top: 0 !important;
}

.integrations-content {
max-width: 100% !important;
width: 100% !important;
}

.dashboards-list-view-content {
width: calc(100% - 30px);
max-width: 836px;
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/container/ListOfDashboard/DashboardsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import { isCloudUser } from 'utils/app';

import DashboardTemplatesModal from './DashboardTemplates/DashboardTemplatesModal';
import ImportJSON from './ImportJSON';
import { RequestDashboardBtn } from './RequestDashboardBtn';
import { DeleteButton } from './TableComponents/DeleteButton';
import {
DashboardDynamicColumns,
Expand Down Expand Up @@ -692,6 +693,13 @@ function DashboardsList(): JSX.Element {
Create and manage dashboards for your workspace.
</Typography.Text>
</Flex>
{isCloudUser() && (
makeavish marked this conversation as resolved.
Show resolved Hide resolved
<div className="integrations-container">
sharpshooter90 marked this conversation as resolved.
Show resolved Hide resolved
<div className="integrations-content">
<RequestDashboardBtn />
</div>
</div>
)}
</div>

{isDashboardListLoading ||
Expand Down
95 changes: 95 additions & 0 deletions frontend/src/container/ListOfDashboard/RequestDashboardBtn.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import '../../pages/Integrations/Integrations.styles.scss';
sharpshooter90 marked this conversation as resolved.
Show resolved Hide resolved

import { LoadingOutlined } from '@ant-design/icons';
import { Button, Input, Space, Typography } from 'antd';
import logEvent from 'api/common/logEvent';
import { useNotifications } from 'hooks/useNotifications';
import { Check } from 'lucide-react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';

export function RequestDashboardBtn(): JSX.Element {
const [
isSubmittingRequestForDashboard,
setIsSubmittingRequestForDashboard,
] = useState(false);

const [requestedDashboardName, setRequestedDashboardName] = useState('');

const { notifications } = useNotifications();
const { t } = useTranslation(['common']);

const handleRequestDashboardSubmit = async (): Promise<void> => {
try {
setIsSubmittingRequestForDashboard(true);
const response = await logEvent('Dashboard Requested', {
screen: 'Dashboard list page',
dashboard: requestedDashboardName,
});

if (response.statusCode === 200) {
notifications.success({
message: 'Dashboard Request Submitted',
});

setIsSubmittingRequestForDashboard(false);
} else {
notifications.error({
message:
response.error ||
t('something_went_wrong', {
ns: 'common',
}),
});

setIsSubmittingRequestForDashboard(false);
}
} catch (error) {
notifications.error({
message: t('something_went_wrong', {
ns: 'common',
}),
});

setIsSubmittingRequestForDashboard(false);
}
};

return (
<div className="request-entity-container">
<Typography.Text>
Can&apos;t find the dashboard you need? Request a new Dashboard.
</Typography.Text>

<div className="form-section">
<Space.Compact style={{ width: '100%' }}>
<Input
placeholder="Enter dashboard name..."
style={{ width: 300, marginBottom: 0 }}
sharpshooter90 marked this conversation as resolved.
Show resolved Hide resolved
value={requestedDashboardName}
onChange={(e): void => setRequestedDashboardName(e.target.value)}
/>
<Button
className="periscope-btn primary"
icon={
isSubmittingRequestForDashboard ? (
<LoadingOutlined />
sharpshooter90 marked this conversation as resolved.
Show resolved Hide resolved
) : (
<Check size={12} />
)
}
type="primary"
onClick={handleRequestDashboardSubmit}
disabled={
isSubmittingRequestForDashboard ||
!requestedDashboardName ||
requestedDashboardName?.trim().length === 0
}
>
Submit
</Button>
</Space.Compact>
</div>
</div>
);
}
5 changes: 0 additions & 5 deletions frontend/src/pages/Integrations/Integrations.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
font-style: normal;
line-height: 28px; /* 155.556% */
letter-spacing: -0.09px;
font-family: Inter;
font-weight: 500;
}

Expand All @@ -25,7 +24,6 @@
font-style: normal;
line-height: 20px; /* 142.857% */
letter-spacing: -0.07px;
font-family: Inter;
font-weight: 400;
}

Expand Down Expand Up @@ -129,7 +127,6 @@

.heading {
color: var(--bg-vanilla-100);
font-family: Inter;
font-size: 14px;
font-style: normal;
font-weight: 500;
Expand All @@ -140,7 +137,6 @@

.description {
color: var(--bg-vanilla-400);
font-family: Inter;
font-size: 12px;
font-style: normal;
font-weight: 400;
Expand All @@ -163,7 +159,6 @@
background: var(--bg-ink-200);
box-shadow: none;
color: var(--bg-vanilla-400);
font-family: Inter;
font-size: 12px;
font-style: normal;
font-weight: 400;
Expand Down
Loading