1
+ import Button from "@material-ui/core/Button"
2
+ import Link from "@material-ui/core/Link"
1
3
import Table from "@material-ui/core/Table"
2
4
import TableBody from "@material-ui/core/TableBody"
3
5
import TableCell from "@material-ui/core/TableCell"
@@ -8,12 +10,14 @@ import { AuditLogRow } from "components/AuditLogRow/AuditLogRow"
8
10
import { ChooseOne , Cond } from "components/Conditionals/ChooseOne"
9
11
import { EmptyState } from "components/EmptyState/EmptyState"
10
12
import { Margins } from "components/Margins/Margins"
13
+ import ArrowRightAltOutlined from "@material-ui/icons/ArrowRightAltOutlined"
11
14
import {
12
15
PageHeader ,
13
16
PageHeaderSubtitle ,
14
17
PageHeaderTitle ,
15
18
} from "components/PageHeader/PageHeader"
16
19
import { PaginationWidget } from "components/PaginationWidget/PaginationWidget"
20
+ import { Paywall } from "components/Paywall/Paywall"
17
21
import { SearchBarWithFilter } from "components/SearchBarWithFilter/SearchBarWithFilter"
18
22
import { Stack } from "components/Stack/Stack"
19
23
import { TableLoader } from "components/TableLoader/TableLoader"
@@ -46,6 +50,7 @@ export interface AuditPageViewProps {
46
50
onFilter : ( filter : string ) => void
47
51
paginationRef : PaginationMachineRef
48
52
isNonInitialPage : boolean
53
+ isAuditLogVisible : boolean
49
54
}
50
55
51
56
export const AuditPageView : FC < AuditPageViewProps > = ( {
@@ -55,6 +60,7 @@ export const AuditPageView: FC<AuditPageViewProps> = ({
55
60
onFilter,
56
61
paginationRef,
57
62
isNonInitialPage,
63
+ isAuditLogVisible,
58
64
} ) => {
59
65
const { t } = useTranslation ( "auditLog" )
60
66
const isLoading = auditLogs === undefined || count === undefined
@@ -72,53 +78,88 @@ export const AuditPageView: FC<AuditPageViewProps> = ({
72
78
< PageHeaderSubtitle > { Language . subtitle } </ PageHeaderSubtitle >
73
79
</ PageHeader >
74
80
75
- < SearchBarWithFilter
76
- docs = "https://coder.com/docs/coder-oss/latest/admin/audit-logs#filtering-logs"
77
- filter = { filter }
78
- onFilter = { onFilter }
79
- presetFilters = { presetFilters }
80
- />
81
+ < ChooseOne >
82
+ < Cond condition = { isAuditLogVisible } >
83
+ < SearchBarWithFilter
84
+ docs = "https://coder.com/docs/coder-oss/latest/admin/audit-logs#filtering-logs"
85
+ filter = { filter }
86
+ onFilter = { onFilter }
87
+ presetFilters = { presetFilters }
88
+ />
81
89
82
- < TableContainer >
83
- < Table >
84
- < TableBody >
85
- < ChooseOne >
86
- < Cond condition = { isLoading } >
87
- < TableLoader />
88
- </ Cond >
89
- < Cond condition = { isEmpty } >
90
+ < TableContainer >
91
+ < Table >
92
+ < TableBody >
90
93
< ChooseOne >
91
- < Cond condition = { isNonInitialPage } >
92
- < TableRow >
93
- < TableCell colSpan = { 999 } >
94
- < EmptyState message = { t ( "table.emptyPage" ) } />
95
- </ TableCell >
96
- </ TableRow >
94
+ < Cond condition = { isLoading } >
95
+ < TableLoader />
96
+ </ Cond >
97
+ < Cond condition = { isEmpty } >
98
+ < ChooseOne >
99
+ < Cond condition = { isNonInitialPage } >
100
+ < TableRow >
101
+ < TableCell colSpan = { 999 } >
102
+ < EmptyState message = { t ( "table.emptyPage" ) } />
103
+ </ TableCell >
104
+ </ TableRow >
105
+ </ Cond >
106
+ < Cond >
107
+ < TableRow >
108
+ < TableCell colSpan = { 999 } >
109
+ < EmptyState message = { t ( "table.noLogs" ) } />
110
+ </ TableCell >
111
+ </ TableRow >
112
+ </ Cond >
113
+ </ ChooseOne >
97
114
</ Cond >
98
115
< Cond >
99
- < TableRow >
100
- < TableCell colSpan = { 999 } >
101
- < EmptyState message = { t ( "table.noLogs" ) } />
102
- </ TableCell >
103
- </ TableRow >
116
+ { auditLogs && (
117
+ < Timeline
118
+ items = { auditLogs }
119
+ getDate = { ( log ) => new Date ( log . time ) }
120
+ row = { ( log ) => (
121
+ < AuditLogRow key = { log . id } auditLog = { log } />
122
+ ) }
123
+ />
124
+ ) }
104
125
</ Cond >
105
126
</ ChooseOne >
106
- </ Cond >
107
- < Cond >
108
- { auditLogs && (
109
- < Timeline
110
- items = { auditLogs }
111
- getDate = { ( log ) => new Date ( log . time ) }
112
- row = { ( log ) => < AuditLogRow key = { log . id } auditLog = { log } /> }
113
- />
114
- ) }
115
- </ Cond >
116
- </ ChooseOne >
117
- </ TableBody >
118
- </ Table >
119
- </ TableContainer >
127
+ </ TableBody >
128
+ </ Table >
129
+ </ TableContainer >
130
+
131
+ < PaginationWidget numRecords = { count } paginationRef = { paginationRef } />
132
+ </ Cond >
120
133
121
- < PaginationWidget numRecords = { count } paginationRef = { paginationRef } />
134
+ < Cond >
135
+ < Paywall
136
+ message = "Audit logs"
137
+ description = "Audit Logs allows Auditors to monitor user operations in their deployment. To use this feature, you have to upgrade your account."
138
+ cta = {
139
+ < Stack direction = "row" alignItems = "center" >
140
+ < Link
141
+ underline = "none"
142
+ href = "https://coder.com/docs/coder-oss/latest/admin/upgrade"
143
+ target = "_blank"
144
+ rel = "noreferrer"
145
+ >
146
+ < Button size = "small" startIcon = { < ArrowRightAltOutlined /> } >
147
+ See how to upgrade
148
+ </ Button >
149
+ </ Link >
150
+ < Link
151
+ underline = "none"
152
+ href = "https://coder.com/docs/coder-oss/latest/admin/audit-logs"
153
+ target = "_blank"
154
+ rel = "noreferrer"
155
+ >
156
+ Read the docs
157
+ </ Link >
158
+ </ Stack >
159
+ }
160
+ />
161
+ </ Cond >
162
+ </ ChooseOne >
122
163
</ Margins >
123
164
)
124
165
}
0 commit comments