mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 01:49:05 +08:00
fix: use correct keys in dashboard list (#7283)
* fix: use correct keys in dashboard list * fix: use correct keys in dashboard list
This commit is contained in:
parent
a9618886b9
commit
5dba1f3dbb
@ -186,16 +186,14 @@ function DashboardsList(): JSX.Element {
|
||||
|
||||
const sortDashboardsByCreatedAt = (dashboards: Dashboard[]): void => {
|
||||
const sortedDashboards = dashboards.sort(
|
||||
(a, b) =>
|
||||
new Date(b.created_at).getTime() - new Date(a.created_at).getTime(),
|
||||
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),
|
||||
);
|
||||
setDashboards(sortedDashboards);
|
||||
};
|
||||
|
||||
const sortDashboardsByUpdatedAt = (dashboards: Dashboard[]): void => {
|
||||
const sortedDashboards = dashboards.sort(
|
||||
(a, b) =>
|
||||
new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime(),
|
||||
(a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime(),
|
||||
);
|
||||
setDashboards(sortedDashboards);
|
||||
};
|
||||
@ -260,16 +258,16 @@ function DashboardsList(): JSX.Element {
|
||||
|
||||
const data: Data[] =
|
||||
dashboards?.map((e) => ({
|
||||
createdAt: e.created_at,
|
||||
createdAt: e.createdAt,
|
||||
description: e.data.description || '',
|
||||
id: e.uuid,
|
||||
lastUpdatedTime: e.updated_at,
|
||||
lastUpdatedTime: e.updatedAt,
|
||||
name: e.data.title,
|
||||
tags: e.data.tags || [],
|
||||
key: e.uuid,
|
||||
createdBy: e.created_by,
|
||||
createdBy: e.createdBy,
|
||||
isLocked: !!e.isLocked || false,
|
||||
lastUpdatedBy: e.updated_by,
|
||||
lastUpdatedBy: e.updatedBy,
|
||||
image: e.data.image || Base64Icons[0],
|
||||
variables: e.data.variables,
|
||||
widgets: e.data.widgets,
|
||||
@ -978,10 +976,10 @@ function DashboardsList(): JSX.Element {
|
||||
{visibleColumns.createdBy && (
|
||||
<div className="user">
|
||||
<Typography.Text className="user-tag">
|
||||
{dashboards?.[0]?.created_by?.substring(0, 1).toUpperCase()}
|
||||
{dashboards?.[0]?.createdBy?.substring(0, 1).toUpperCase()}
|
||||
</Typography.Text>
|
||||
<Typography.Text className="dashboard-created-by">
|
||||
{dashboards?.[0]?.created_by}
|
||||
{dashboards?.[0]?.createdBy}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
)}
|
||||
@ -990,16 +988,16 @@ function DashboardsList(): JSX.Element {
|
||||
{visibleColumns.updatedAt && (
|
||||
<Typography.Text className="formatted-time">
|
||||
<CalendarClock size={14} />
|
||||
{onLastUpdated(dashboards?.[0]?.updated_at || '')}
|
||||
{onLastUpdated(dashboards?.[0]?.updatedAt || '')}
|
||||
</Typography.Text>
|
||||
)}
|
||||
{visibleColumns.updatedBy && (
|
||||
<div className="user">
|
||||
<Typography.Text className="user-tag">
|
||||
{dashboards?.[0]?.updated_by?.substring(0, 1).toUpperCase()}
|
||||
{dashboards?.[0]?.updatedBy?.substring(0, 1).toUpperCase()}
|
||||
</Typography.Text>
|
||||
<Typography.Text className="dashboard-created-by">
|
||||
{dashboards?.[0]?.updated_by}
|
||||
{dashboards?.[0]?.updatedBy}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
)}
|
||||
|
@ -140,7 +140,7 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element {
|
||||
let isAuthor = false;
|
||||
|
||||
if (selectedDashboard && user && user.email) {
|
||||
isAuthor = selectedDashboard?.created_by === user?.email;
|
||||
isAuthor = selectedDashboard?.createdBy === user?.email;
|
||||
}
|
||||
|
||||
let permissions: ComponentTypes[] = ['add_panel'];
|
||||
@ -152,7 +152,7 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element {
|
||||
const { notifications } = useNotifications();
|
||||
|
||||
const userRole: ROLES | null =
|
||||
selectedDashboard?.created_by === user?.email
|
||||
selectedDashboard?.createdBy === user?.email
|
||||
? (USER_ROLES.AUTHOR as ROLES)
|
||||
: user.role;
|
||||
|
||||
@ -364,14 +364,14 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element {
|
||||
{(isAuthor || user.role === USER_ROLES.ADMIN) && (
|
||||
<Tooltip
|
||||
title={
|
||||
selectedDashboard?.created_by === 'integration' &&
|
||||
selectedDashboard?.createdBy === 'integration' &&
|
||||
'Dashboards created by integrations cannot be unlocked'
|
||||
}
|
||||
>
|
||||
<Button
|
||||
type="text"
|
||||
icon={<LockKeyhole size={14} />}
|
||||
disabled={selectedDashboard?.created_by === 'integration'}
|
||||
disabled={selectedDashboard?.createdBy === 'integration'}
|
||||
onClick={handleLockDashboardToggle}
|
||||
data-testid="lock-unlock-dashboard"
|
||||
>
|
||||
@ -443,7 +443,7 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element {
|
||||
</section>
|
||||
<section className="delete-dashboard">
|
||||
<DeleteButton
|
||||
createdBy={selectedDashboard?.created_by || ''}
|
||||
createdBy={selectedDashboard?.createdBy || ''}
|
||||
name={selectedDashboard?.data.title || ''}
|
||||
id={String(selectedDashboard?.uuid) || ''}
|
||||
isLocked={isDashboardLocked}
|
||||
|
@ -11,7 +11,7 @@ export const useUpdateDashboard = (): UseUpdateDashboard => {
|
||||
return useMutation(update, {
|
||||
onSuccess: (data) => {
|
||||
if (data.payload) {
|
||||
updatedTimeRef.current = dayjs(data.payload.updated_at);
|
||||
updatedTimeRef.current = dayjs(data.payload.updatedAt);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -5,10 +5,10 @@ export const dashboardSuccessResponse = {
|
||||
{
|
||||
id: 1,
|
||||
uuid: '1',
|
||||
created_at: '2022-11-16T13:29:47.064874419Z',
|
||||
created_by: null,
|
||||
updated_at: '2024-05-21T06:41:30.546630961Z',
|
||||
updated_by: 'thor@avengers.io',
|
||||
createdAt: '2022-11-16T13:29:47.064874419Z',
|
||||
createdBy: null,
|
||||
updatedAt: '2024-05-21T06:41:30.546630961Z',
|
||||
updatedBy: 'thor@avengers.io',
|
||||
isLocked: 0,
|
||||
data: {
|
||||
collapsableRowsMigrated: true,
|
||||
@ -25,10 +25,10 @@ export const dashboardSuccessResponse = {
|
||||
{
|
||||
id: 2,
|
||||
uuid: '2',
|
||||
created_at: '2022-11-16T13:20:47.064874419Z',
|
||||
created_by: null,
|
||||
updated_at: '2024-05-21T06:42:30.546630961Z',
|
||||
updated_by: 'captain-america@avengers.io',
|
||||
createdAt: '2022-11-16T13:20:47.064874419Z',
|
||||
createdBy: null,
|
||||
updatedAt: '2024-05-21T06:42:30.546630961Z',
|
||||
updatedBy: 'captain-america@avengers.io',
|
||||
isLocked: 0,
|
||||
data: {
|
||||
collapsableRowsMigrated: true,
|
||||
@ -55,10 +55,10 @@ export const getDashboardById = {
|
||||
data: {
|
||||
id: 1,
|
||||
uuid: '1',
|
||||
created_at: '2022-11-16T13:29:47.064874419Z',
|
||||
created_by: 'integration',
|
||||
updated_at: '2024-05-21T06:41:30.546630961Z',
|
||||
updated_by: 'thor@avengers.io',
|
||||
createdAt: '2022-11-16T13:29:47.064874419Z',
|
||||
createdBy: 'integration',
|
||||
updatedAt: '2024-05-21T06:41:30.546630961Z',
|
||||
updatedBy: 'thor@avengers.io',
|
||||
isLocked: true,
|
||||
data: {
|
||||
collapsableRowsMigrated: true,
|
||||
@ -80,10 +80,10 @@ export const getNonIntegrationDashboardById = {
|
||||
data: {
|
||||
id: 1,
|
||||
uuid: '1',
|
||||
created_at: '2022-11-16T13:29:47.064874419Z',
|
||||
created_by: 'thor',
|
||||
updated_at: '2024-05-21T06:41:30.546630961Z',
|
||||
updated_by: 'thor@avengers.io',
|
||||
createdAt: '2022-11-16T13:29:47.064874419Z',
|
||||
createdBy: 'thor',
|
||||
updatedAt: '2024-05-21T06:41:30.546630961Z',
|
||||
updatedBy: 'thor@avengers.io',
|
||||
isLocked: true,
|
||||
data: {
|
||||
collapsableRowsMigrated: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user