Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf1b357d

Browse files
feat: support session audit log (#16703)
Related to#15139Demo:<img width="1213" alt="Screenshot 2025-02-25 at 16 27 12"src="https://github.com/user-attachments/assets/9995a68d-5cd4-4b95-9523-dfd5bf4ff48d"/>---------Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
1 parent2971957 commitf1b357d

File tree

3 files changed

+85
-12
lines changed

3 files changed

+85
-12
lines changed

‎site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ interface AuditLogDescriptionProps {
1111
exportconstAuditLogDescription:FC<AuditLogDescriptionProps>=({
1212
auditLog,
1313
})=>{
14-
lettarget=auditLog.resource_target.trim();
15-
letuser=auditLog.user?.username.trim();
16-
1714
if(auditLog.resource_type==="workspace_build"){
1815
return<BuildAuditDescriptionauditLog={auditLog}/>;
1916
}
17+
if(auditLog.additional_fields?.connection_type){
18+
return<AppSessionAuditLogDescriptionauditLog={auditLog}/>;
19+
}
20+
21+
lettarget=auditLog.resource_target.trim();
22+
letuser=auditLog.user?.username.trim();
2023

2124
// SSH key entries have no links
2225
if(auditLog.resource_type==="git_ssh_key"){
@@ -57,3 +60,19 @@ export const AuditLogDescription: FC<AuditLogDescriptionProps> = ({
5760
</span>
5861
);
5962
};
63+
64+
functionAppSessionAuditLogDescription({ auditLog}:AuditLogDescriptionProps){
65+
const{ connection_type, workspace_owner, workspace_name}=
66+
auditLog.additional_fields;
67+
68+
return(
69+
<>
70+
{connection_type} session to{workspace_owner}'s{" "}
71+
<Linkcomponent={RouterLink}to={`${auditLog.resource_link}`}>
72+
<strong>{workspace_name}</strong>
73+
</Link>{" "}
74+
workspace{" "}
75+
<strong>{auditLog.action==="disconnect" ?"closed" :"opened"}</strong>
76+
</>
77+
);
78+
}

‎site/src/pages/AuditPage/AuditLogRow/AuditLogRow.stories.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,43 @@ export const NoUserAgent: Story = {
159159
},
160160
},
161161
};
162+
163+
exportconstWithConnectionType:Story={
164+
args:{
165+
showOrgDetails:true,
166+
auditLog:{
167+
id:"725ea2f2-faae-4bdd-a821-c2384a67d89c",
168+
request_id:"a486c1cb-6acb-41c9-9bce-1f4f24a2e8ff",
169+
time:"2025-02-24T10:20:08.054072Z",
170+
ip:"fd7a:115c:a1e0:4fa5:9ccd:27e4:5d72:c66a",
171+
user_agent:"",
172+
resource_type:"workspace_agent",
173+
resource_id:"813311fb-bad3-4a92-98cd-09ee57e73d6e",
174+
resource_target:"main",
175+
resource_icon:"",
176+
action:"disconnect",
177+
diff:{},
178+
status_code:255,
179+
additional_fields:{
180+
reason:"process exited with error status: -1",
181+
build_number:"1",
182+
build_reason:"initiator",
183+
workspace_id:"6a7cfb32-d208-47bb-91d0-ec54b69912b6",
184+
workspace_name:"test2",
185+
connection_type:"SSH",
186+
workspace_owner:"admin",
187+
},
188+
description:"{user} disconnected workspace agent {target}",
189+
resource_link:"",
190+
is_deleted:false,
191+
organization_id:"0e6fa63f-b625-4a6f-ab5b-a8217f8c80b3",
192+
organization:{
193+
id:"0e6fa63f-b625-4a6f-ab5b-a8217f8c80b3",
194+
name:"coder",
195+
display_name:"Coder",
196+
icon:"",
197+
},
198+
user:null,
199+
},
200+
},
201+
};

‎site/src/pages/AuditPage/AuditLogRow/AuditLogRow.tsx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ export const AuditLogRow: FC<AuditLogRowProps> = ({
128128
</Stack>
129129

130130
<Stackdirection="row"alignItems="center">
131+
<StatusPillcode={auditLog.status_code}/>
132+
131133
{/* With multi-org, there is not enough space so show
132134
everything in a tooltip. */}
133135
{showOrgDetails ?(
@@ -169,6 +171,12 @@ export const AuditLogRow: FC<AuditLogRowProps> = ({
169171
</Link>
170172
</div>
171173
)}
174+
{auditLog.additional_fields?.reason&&(
175+
<div>
176+
<h4css={styles.auditLogInfoHeader}>Reason:</h4>
177+
<div>{auditLog.additional_fields?.reason}</div>
178+
</div>
179+
)}
172180
</div>
173181
}
174182
>
@@ -203,13 +211,6 @@ export const AuditLogRow: FC<AuditLogRowProps> = ({
203211
)}
204212
</Stack>
205213
)}
206-
207-
<Pill
208-
css={styles.httpStatusPill}
209-
type={httpStatusColor(auditLog.status_code)}
210-
>
211-
{auditLog.status_code.toString()}
212-
</Pill>
213214
</Stack>
214215
</Stack>
215216
</Stack>
@@ -218,7 +219,7 @@ export const AuditLogRow: FC<AuditLogRowProps> = ({
218219
{shouldDisplayDiff ?(
219220
<div>{<DropdownArrowclose={isDiffOpen}/>}</div>
220221
) :(
221-
<divcss={styles.columnWithoutDiff}></div>
222+
<divcss={styles.columnWithoutDiff}/>
222223
)}
223224
</Stack>
224225

@@ -232,6 +233,19 @@ export const AuditLogRow: FC<AuditLogRowProps> = ({
232233
);
233234
};
234235

236+
functionStatusPill({ code}:{code:number}){
237+
constisHttp=code>=100;
238+
239+
return(
240+
<Pill
241+
css={styles.statusCodePill}
242+
type={isHttp ?httpStatusColor(code) :code===0 ?"success" :"error"}
243+
>
244+
{code.toString()}
245+
</Pill>
246+
);
247+
}
248+
235249
conststyles={
236250
auditLogCell:{
237251
padding:"0 !important",
@@ -287,7 +301,7 @@ const styles = {
287301
width:"100%",
288302
},
289303

290-
httpStatusPill:{
304+
statusCodePill:{
291305
fontSize:10,
292306
height:20,
293307
paddingLeft:10,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp