Users: Fix "Last active" displaying incorrect value instead of "Never" (#115825)
This commit is contained in:
@@ -5340,6 +5340,7 @@ export type OrgUserDto = {
|
||||
};
|
||||
authLabels?: string[];
|
||||
avatarUrl?: string;
|
||||
created?: string;
|
||||
email?: string;
|
||||
isDisabled?: boolean;
|
||||
isExternallySynced?: boolean;
|
||||
@@ -6118,6 +6119,7 @@ export type ChangeUserPasswordCommand = {
|
||||
export type UserSearchHitDto = {
|
||||
authLabels?: string[];
|
||||
avatarUrl?: string;
|
||||
created?: string;
|
||||
email?: string;
|
||||
id?: number;
|
||||
isAdmin?: boolean;
|
||||
|
||||
@@ -151,7 +151,7 @@ type OrgUserDTO struct {
|
||||
Role string `json:"role"`
|
||||
LastSeenAt time.Time `json:"lastSeenAt"`
|
||||
Updated time.Time `json:"-"`
|
||||
Created time.Time `json:"-"`
|
||||
Created time.Time `json:"created"`
|
||||
LastSeenAtAge string `json:"lastSeenAtAge"`
|
||||
AccessControl map[string]bool `json:"accessControl,omitempty"`
|
||||
IsDisabled bool `json:"isDisabled"`
|
||||
|
||||
@@ -146,6 +146,7 @@ type UserSearchHitDTO struct {
|
||||
LastSeenAtAge string `json:"lastSeenAtAge"`
|
||||
AuthLabels []string `json:"authLabels"`
|
||||
AuthModule AuthModuleConversion `json:"-"`
|
||||
Created time.Time `json:"created" xorm:"created"`
|
||||
}
|
||||
|
||||
type GetUserProfileQuery struct {
|
||||
|
||||
@@ -541,7 +541,7 @@ func (ss *sqlStore) Search(ctx context.Context, query *user.SearchUsersQuery) (*
|
||||
sess.Limit(query.Limit, offset)
|
||||
}
|
||||
|
||||
sess.Cols("u.id", "u.uid", "u.email", "u.name", "u.login", "u.is_admin", "u.is_disabled", "u.last_seen_at", "user_auth.auth_module", "u.is_provisioned")
|
||||
sess.Cols("u.id", "u.uid", "u.email", "u.name", "u.login", "u.is_admin", "u.is_disabled", "u.last_seen_at", "user_auth.auth_module", "u.is_provisioned", "u.created")
|
||||
|
||||
if len(query.SortOpts) > 0 {
|
||||
for i := range query.SortOpts {
|
||||
|
||||
Generated
+8
@@ -6002,6 +6002,10 @@
|
||||
"avatarUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"created": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -8903,6 +8907,10 @@
|
||||
"avatarUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"created": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
Generated
+8
@@ -18489,6 +18489,10 @@
|
||||
"avatarUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"created": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -23410,6 +23414,10 @@
|
||||
"avatarUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"created": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -115,12 +115,15 @@ export const OrgUsersTable = ({
|
||||
{
|
||||
id: 'lastSeenAtAge',
|
||||
header: 'Last active',
|
||||
cell: ({ cell: { value } }: Cell<'lastSeenAtAge'>) => {
|
||||
cell: ({ cell: { value }, row: { original } }: Cell<'lastSeenAtAge'>) => {
|
||||
// If lastSeenAt is before created, user has never logged in
|
||||
const neverLoggedIn =
|
||||
original.lastSeenAt && original.created && new Date(original.lastSeenAt) < new Date(original.created);
|
||||
return (
|
||||
<>
|
||||
{value && (
|
||||
<>
|
||||
{value === '10 years' ? (
|
||||
{neverLoggedIn ? (
|
||||
<Text color={'disabled'}>
|
||||
<Trans i18nKey="admin.org-uers.last-seen-never">Never</Trans>
|
||||
</Text>
|
||||
|
||||
@@ -135,12 +135,19 @@ export const UsersTable = ({
|
||||
content: 'Time since user was seen using Grafana',
|
||||
iconName: 'question-circle',
|
||||
},
|
||||
cell: ({ cell: { value } }: Cell<'lastSeenAtAge'>) => {
|
||||
cell: ({
|
||||
cell: { value },
|
||||
row: {
|
||||
original: { lastSeenAt, created },
|
||||
},
|
||||
}: Cell<'lastSeenAtAge'>) => {
|
||||
// The user has never logged in if lastSeenAt is before its creation date.
|
||||
const neverLoggedIn = lastSeenAt && created && new Date(lastSeenAt) < new Date(created);
|
||||
return (
|
||||
<>
|
||||
{value && (
|
||||
<>
|
||||
{value === '10 years' ? (
|
||||
{neverLoggedIn ? (
|
||||
<Text color={'disabled'}>
|
||||
<Trans i18nKey="admin.users-table.last-seen-never">Never</Trans>
|
||||
</Text>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Role } from './accessControl';
|
||||
export interface OrgUser extends WithAccessControlMetadata {
|
||||
avatarUrl: string;
|
||||
email: string;
|
||||
created?: string;
|
||||
lastSeenAt: string;
|
||||
lastSeenAtAge: string;
|
||||
login: string;
|
||||
@@ -49,6 +50,7 @@ export interface UserDTO extends WithAccessControlMetadata {
|
||||
theme?: string;
|
||||
avatarUrl?: string;
|
||||
orgId?: number;
|
||||
created?: string;
|
||||
lastSeenAt?: string;
|
||||
lastSeenAtAge?: string;
|
||||
licensedRole?: string;
|
||||
|
||||
Generated
+8
@@ -8018,6 +8018,10 @@
|
||||
"avatarUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"created": {
|
||||
"format": "date-time",
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -12938,6 +12942,10 @@
|
||||
"avatarUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"created": {
|
||||
"format": "date-time",
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user