-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
727e866
commit 1eae0e6
Showing
7 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
Check failure on line 1 in assets/js/common/ActivityLogOverview/ActivityLogOverview.jsx GitHub Actions / Static Code Analysis
|
||
|
||
export default function ActivityLogOverview() { | ||
return <div>ActivityLogOverview</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ActivityLogOverview from './ActivityLogOverview'; | ||
|
||
export default ActivityLogOverview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { networkClient } from '@lib/network'; | ||
|
||
export const getActivityLog = () => networkClient.get(`/activity_log`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
|
||
import { logError } from '@lib/log'; | ||
|
||
import Table from '@common/Table'; | ||
import { getActivityLog } from '../../lib/api/activityLogs'; | ||
import ActivityLogOverview from '../../common/ActivityLogOverview/ActivityLogOverview'; | ||
|
||
export default function ActivityLogPage() { | ||
const [activityLog, setActivityLog] = useState([]); | ||
// const [isLoading, setIsLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
getActivityLog() | ||
.then((response) => { | ||
setActivityLog(response.data); | ||
// setIsLoading(false); | ||
}) | ||
.catch((e) => logError(e)); | ||
}, []); | ||
|
||
const config = { | ||
pagination: true, | ||
usePadding: false, | ||
columns: [ | ||
{ | ||
title: 'Time', | ||
key: 'occurred_on', | ||
}, | ||
{ | ||
title: 'Event Type', | ||
key: 'type', | ||
}, | ||
{ | ||
title: 'Resource', | ||
key: 'metadata', | ||
render: ({ resource_type }, { type }) => { | ||
if (['resource_tagging', 'resource_untagging'].includes(type)) { | ||
return resource_type; | ||
} | ||
return 'Resource unavailable'; | ||
}, | ||
}, | ||
{ | ||
title: 'User', | ||
key: 'actor', | ||
}, | ||
{ | ||
title: 'Message', | ||
key: 'metadata', | ||
render: (content, { type }) => { | ||
if (type === 'resource_tagging') { | ||
const { added_tag, resource_id } = content; | ||
return `Tag "${added_tag}" added to "${resource_id}"`; | ||
} | ||
|
||
if (type === 'resource_untagging') { | ||
const { removed_tag, resource_id } = content; | ||
return `Tag "${removed_tag}" removed to "${resource_id}"`; | ||
} | ||
|
||
return 'message unavailable'; | ||
}, | ||
}, | ||
], | ||
collapsibleDetailRenderer: ({ metadata }) => { | ||
Check failure on line 66 in assets/js/pages/ActivityLogPage/ActivityLogPage.jsx GitHub Actions / Static Code Analysis
|
||
return <pre>{JSON.stringify(metadata, null, 2)}</pre>; | ||
}, | ||
}; | ||
|
||
return ( | ||
<> | ||
<ActivityLogOverview /> | ||
<Table config={config} data={activityLog} /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ActivityLogPage from './ActivityLogPage'; | ||
|
||
export default ActivityLogPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters