Skip to content

Commit 74a0db4

Browse files
Merge pull request #743 from contentstack/bugfix/audit-log
bugfix: streamline audit and execution logs processing and enhance UI components
2 parents 4023f25 + 36f51d7 commit 74a0db4

File tree

7 files changed

+45
-37
lines changed

7 files changed

+45
-37
lines changed

api/src/services/migration.service.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -901,14 +901,6 @@ const getLogs = async (req: Request): Promise<any> => {
901901
const filterOptions = Array?.from(new Set(logEntries?.map((log) => log?.level)));
902902
const auditStartIndex = logEntries?.findIndex?.(log => log?.message?.includes("Starting audit process"));
903903
const auditEndIndex = logEntries?.findIndex?.(log => log?.message?.includes("Audit process completed"));
904-
if (auditStartIndex === -1 || auditEndIndex === -1) {
905-
logger.warn("Audit markers not found in logs. Skipping audit-related slicing.");
906-
} else {
907-
logEntries = [
908-
...logEntries.slice(0, auditStartIndex),
909-
...logEntries.slice(auditEndIndex + 1)
910-
];
911-
}
912904
logEntries = logEntries?.slice?.(1, logEntries?.length - 2);
913905
if (filter !== "all") {
914906
const filters = filter?.split("-") ?? [];

ui/src/components/AuditFilterModal/index.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
border-bottom: 1px solid #e5e7eb;
2121
display: flex;
2222
align-items: center;
23-
justify-content: space-between;
23+
justify-content: flex-start;
24+
gap: 12px;
25+
.close-btn {
26+
margin-left: auto;
27+
}
2428
}
2529

2630
.tableFilterModalStories__suggestion-item {
@@ -82,4 +86,4 @@
8286
.text-size {
8387
font-size: $size-font-medium;
8488
line-height: $line-height-reset;
85-
}
89+
}

ui/src/components/AuditFilterModal/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const AuditFilterModal = ({
1717
onApply,
1818
selectedLevels,
1919
setFilterValue,
20-
selectedFileType
20+
selectedFileType,
2121
}: AuditFilterModalProps) => {
2222
const modalRef = useRef<HTMLDivElement>(null);
2323

@@ -71,7 +71,7 @@ const AuditFilterModal = ({
7171
<div className="tableFilterModalStories" ref={modalRef}>
7272
<div className="tableFilterModalStories__header">
7373
<span className="text-size">
74-
{selectedFileType?.includes?.('Entries') ? 'Display Type' : 'Field Type'}
74+
{selectedFileType?.includes?.(auditLogsConstants.filterModal.entries) ? auditLogsConstants.filterModal.displayType : auditLogsConstants.filterModal.selectFieldType}
7575
</span>
7676
<div className="close-btn">
7777
<Icon version="v2" icon="CloseNoborder" size="medium" onClick={closeModal} />

ui/src/components/AuditLogs/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const AuditLogs: React.FC = () => {
7272
{ label: 'Entries', value: 'Entries_Select_feild' }
7373
];
7474
setFileOptions(predefinedOptions);
75+
handleFileChange(predefinedOptions?.[0]);
7576
}
7677
};
7778
const handleStackChange = async (selectedOption: StackOption | null) => {
@@ -148,10 +149,7 @@ const AuditLogs: React.FC = () => {
148149
setTableUid((prevUid) => prevUid + 1);
149150
}
150151
};
151-
const handleSearchChange = (value: string) => {
152-
setSearchText(value);
153-
setTableUid((prevUid) => prevUid + 1);
154-
};
152+
155153
const ColumnFilter = () => {
156154
const closeModal = () => {
157155
setIsFilterDropdownOpen(false);
@@ -408,8 +406,8 @@ const AuditLogs: React.FC = () => {
408406
columnSelector={false}
409407
canSearch={true}
410408
searchPlaceholder={auditLogsConstants?.placeholders?.searchLogs}
411-
searchValue={searchText}
412-
onSearchChangeEvent={handleSearchChange}
409+
searchValue={searchText ?? ''}
410+
onSearchChangeEvent={(value: string) => setSearchText(value)}
413411
withExportCta={{
414412
component: exportCtaComponent,
415413
showExportCta: true

ui/src/components/FilterModal/FilterModal.scss

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@
1212
max-height: 350px;
1313
overflow: hidden;
1414
font-family: 'Inter', sans-serif;
15+
top: 100%;
16+
left: 0;
17+
margin-top: 8px;
18+
19+
&.position-bottom {
20+
top: auto;
21+
bottom: 0;
22+
left: 0;
23+
margin-top: 0;
24+
margin-bottom: 8px;
25+
}
26+
27+
&.position-right {
28+
left: auto;
29+
right: 0;
30+
}
31+
1532
}
1633

1734
.tableFilterModalStories__header {
@@ -27,12 +44,6 @@
2744
padding: 8px 16px;
2845
}
2946

30-
.tableFilterModalStories__body{
31-
overflow: scroll;
32-
max-height: 250px;
33-
overflow-x: hidden;
34-
}
35-
3647
.Checkbox {
3748
display: flex;
3849
align-items: center;

ui/src/components/FilterModal/FilterModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ const FilterModal = ({
3636
<div className="tableFilterModalStories__suggestion-item">
3737
<Checkbox
3838
checked={selectedLevels?.some?.((v) => v?.value === item?.value) || false}
39-
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
39+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
4040
updateValue?.({ value: item, isChecked: e?.target?.checked })
41-
}
41+
}}
4242
version="v2"
4343
label={item?.label || ''}
4444
className="text-size"
@@ -52,7 +52,7 @@ const FilterModal = ({
5252

5353
{/* Modal Footer */}
5454
<div className="tableFilterModalStories__footer">
55-
<Button buttonType="tertiary" version="v2" onClick={clearAll}>
55+
<Button buttonType="tertiary" version="v2" onClick={clearAll} disabled={selectedLevels?.length === 0}>
5656
Clear All
5757
</Button>
5858
<ButtonGroup>

ui/src/utilities/constants.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ export const VALIDATION_DOCUMENTATION_URL: { [key: string]: string } = {
121121

122122

123123
export const auditLogsConstants = {
124-
executeTestMigration: 'Try executing Test Migration',
125-
selectModuleMessage: 'Select Module to See the Logs',
126-
queryChangeMessage: 'Try Changing the Search Query to find what you are looking for',
127-
noResult: 'No Matching Result Found',
128-
noLogs: 'No Logs Found',
124+
executeTestMigration: 'Try executing the migration',
125+
selectModuleMessage: 'Select a module to see the logs',
126+
queryChangeMessage: 'Try changing the search query to find what you are looking for.',
127+
noResult: 'No matching result found',
128+
noLogs: 'No logs',
129129
filterIcon: {
130130
filterOn: 'filterWithAppliedIcon Icon--v2 Icon--medium',
131131
filterOff: 'filterWithAppliedIcon Icon--v2 Icon--medium Icon--disabled'
@@ -144,7 +144,10 @@ export const auditLogsConstants = {
144144
filterModal: {
145145
noFilterAvailable: 'No Filters Available',
146146
clearAll: 'Clear All',
147-
apply: 'Apply'
147+
apply: 'Apply',
148+
displayType: 'Display Type',
149+
selectFieldType: 'Select Field Data Type',
150+
entries: 'Entries',
148151
}
149152
};
150153

@@ -166,12 +169,12 @@ export const EXECUTION_LOGS_UI_TEXT = {
166169
SEARCH_PLACEHOLDER: 'Search Execution Logs',
167170
SELECT_PLACEHOLDER: 'Select a stack',
168171
EMPTY_STATE_DESCRIPTION: {
169-
NO_RESULT: 'Try Changing the Search Query to find what you are looking for',
170-
NO_LOGS: 'Try executing Test Migration'
172+
NO_RESULT: 'Try changing the search query to find what you are looking for.',
173+
NO_LOGS: 'Try executing the migration'
171174
},
172175
EMPTY_STATE_HEADING: {
173-
NO_LOGS: 'No Logs Found',
174-
NO_MATCH: 'No Matching Result Found'
176+
NO_LOGS: 'No logs',
177+
NO_MATCH: 'No matching result found'
175178
},
176179
EMPTY_STATE_ICON: {
177180
NO_LOGS: 'NoDataEmptyState',

0 commit comments

Comments
 (0)