mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-11 00:39:00 +08:00
feat: split the logic of columns and formatting load in logs
This commit is contained in:
parent
93a0a838a6
commit
4d11cbfb75
@ -166,26 +166,23 @@ function LogsExplorer(): JSX.Element {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const migratedQuery = migrateOptionsQuery(
|
if (!preferences) {
|
||||||
preferences
|
return;
|
||||||
? {
|
}
|
||||||
selectColumns: preferences.columns || [],
|
const migratedQuery = migrateOptionsQuery({
|
||||||
maxLines:
|
selectColumns: preferences.columns || [],
|
||||||
preferences.formatting?.maxLines || defaultOptionsQuery.maxLines,
|
maxLines: preferences.formatting?.maxLines || defaultOptionsQuery.maxLines,
|
||||||
format: preferences.formatting?.format || defaultOptionsQuery.format,
|
format: preferences.formatting?.format || defaultOptionsQuery.format,
|
||||||
fontSize:
|
fontSize: preferences.formatting?.fontSize || defaultOptionsQuery.fontSize,
|
||||||
preferences.formatting?.fontSize || defaultOptionsQuery.fontSize,
|
version: preferences.formatting?.version,
|
||||||
version: preferences.formatting?.version,
|
});
|
||||||
}
|
|
||||||
: defaultOptionsQuery,
|
|
||||||
);
|
|
||||||
// Only redirect if the query was actually modified
|
// Only redirect if the query was actually modified
|
||||||
if (
|
if (
|
||||||
!isEqual(migratedQuery, {
|
!isEqual(migratedQuery, {
|
||||||
selectColumns: preferences?.columns || [],
|
selectColumns: preferences?.columns,
|
||||||
maxLines: preferences?.formatting?.maxLines || defaultOptionsQuery.maxLines,
|
maxLines: preferences?.formatting?.maxLines,
|
||||||
format: preferences?.formatting?.format || defaultOptionsQuery.format,
|
format: preferences?.formatting?.format,
|
||||||
fontSize: preferences?.formatting?.fontSize || defaultOptionsQuery.fontSize,
|
fontSize: preferences?.formatting?.fontSize,
|
||||||
version: preferences?.formatting?.version,
|
version: preferences?.formatting?.version,
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
|
@ -21,13 +21,21 @@ async function preferencesLoader<T>(config: {
|
|||||||
result: await config[source](),
|
result: await config[source](),
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
// Find the first result with columns
|
|
||||||
const validResult = results.find(({ result }) => result.columns.length);
|
// Find valid columns and formatting independently
|
||||||
if (validResult) {
|
const validColumnsResult = results.find(
|
||||||
return validResult.result;
|
({ result }) => result.columns?.length,
|
||||||
}
|
);
|
||||||
// fallback to default
|
const validFormattingResult = results.find(({ result }) => result.formatting);
|
||||||
return config.default();
|
|
||||||
|
// Combine valid results or fallback to default
|
||||||
|
const finalResult = {
|
||||||
|
columns: validColumnsResult?.result.columns || config.default().columns,
|
||||||
|
formatting:
|
||||||
|
validFormattingResult?.result.formatting || config.default().formatting,
|
||||||
|
};
|
||||||
|
|
||||||
|
return finalResult as T;
|
||||||
};
|
};
|
||||||
|
|
||||||
return findValidLoader();
|
return findValidLoader();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user