-
Notifications
You must be signed in to change notification settings - Fork 0
This hides the filter actions buttons (but not copy json) when embedded. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -14,6 +14,8 @@ import {trackAnalytics} from 'sentry/utils/analytics'; | |||||||||||||||||||||||||
import type {TableDataRow} from 'sentry/utils/discover/discoverQuery'; | ||||||||||||||||||||||||||
import type {EventsMetaType} from 'sentry/utils/discover/eventView'; | ||||||||||||||||||||||||||
import {FieldValueType} from 'sentry/utils/fields'; | ||||||||||||||||||||||||||
import type {UseApiQueryResult} from 'sentry/utils/queryClient'; | ||||||||||||||||||||||||||
import type RequestError from 'sentry/utils/requestError/requestError'; | ||||||||||||||||||||||||||
import useCopyToClipboard from 'sentry/utils/useCopyToClipboard'; | ||||||||||||||||||||||||||
import {useLocation} from 'sentry/utils/useLocation'; | ||||||||||||||||||||||||||
import useOrganization from 'sentry/utils/useOrganization'; | ||||||||||||||||||||||||||
|
@@ -33,7 +35,9 @@ import { | |||||||||||||||||||||||||
useLogsAddSearchFilter, | ||||||||||||||||||||||||||
useLogsAnalyticsPageSource, | ||||||||||||||||||||||||||
useLogsFields, | ||||||||||||||||||||||||||
useLogsIsTableFrozen, | ||||||||||||||||||||||||||
} from 'sentry/views/explore/contexts/logs/logsPageParams'; | ||||||||||||||||||||||||||
import type {TraceItemDetailsResponse} from 'sentry/views/explore/hooks/useTraceItemDetails'; | ||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||
DEFAULT_TRACE_ITEM_HOVER_TIMEOUT, | ||||||||||||||||||||||||||
DEFAULT_TRACE_ITEM_HOVER_TIMEOUT_WITH_AUTO_REFRESH, | ||||||||||||||||||||||||||
|
@@ -368,7 +372,6 @@ function LogRowDetails({ | |||||||||||||||||||||||||
}) { | ||||||||||||||||||||||||||
const location = useLocation(); | ||||||||||||||||||||||||||
const organization = useOrganization(); | ||||||||||||||||||||||||||
const addSearchFilter = useLogsAddSearchFilter(); | ||||||||||||||||||||||||||
const project = useProjectFromId({ | ||||||||||||||||||||||||||
project_id: '' + dataRow[OurLogKnownFieldKey.PROJECT_ID], | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
|
@@ -383,25 +386,14 @@ function LogRowDetails({ | |||||||||||||||||||||||||
typeof severityText === 'string' ? severityText : null | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
const missingLogId = !dataRow[OurLogKnownFieldKey.ID]; | ||||||||||||||||||||||||||
const {data, isPending, isError} = useExploreLogsTableRow({ | ||||||||||||||||||||||||||
const fullLogDataResult = useExploreLogsTableRow({ | ||||||||||||||||||||||||||
logId: String(dataRow[OurLogKnownFieldKey.ID] ?? ''), | ||||||||||||||||||||||||||
projectId: String(dataRow[OurLogKnownFieldKey.PROJECT_ID] ?? ''), | ||||||||||||||||||||||||||
traceId: String(dataRow[OurLogKnownFieldKey.TRACE_ID] ?? ''), | ||||||||||||||||||||||||||
enabled: !missingLogId, | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const {onClick: betterCopyToClipboard} = useCopyToClipboard({ | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's test it again There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood. If you've made updates based on the previous suggestions or have any new questions, please let me know. I'm ready to review the changes when you are. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /propel add this to knowledge base There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /propel add this to knowledge base There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /propel add this to knowledge base There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /propel add to knowledge base that we should never use useCopyToClipboard function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand you'd like to add a rule to a knowledge base stating that the If you can provide more details on why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /propel help me review code again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello! I'm happy to help review your code again. Your pull request effectively addresses the goal of hiding filter action buttons when the logs table is embedded, while retaining the 'Copy as JSON' functionality. The refactoring into I noticed that the previous suggestions regarding variable naming and conditional rendering haven't been applied yet. These are still relevant and would further enhance the clarity and accessibility of your code:
Here are the committable suggestions for these improvements:
Suggested change
Suggested change
Please let me know if you have any other questions or if you'd like me to review any further changes! ⚡ Committable suggestion Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello! I'd be happy to help you review the code. This pull request aims to hide filter action buttons when the logs table is embedded, while retaining the "Copy as JSON" functionality. The refactoring into I've reviewed the changes and the previous comments. The suggestions from the
Regarding the Overall, the changes are well-structured and achieve the stated goal. Once the suggested improvements are applied, the code will be even cleaner. Here are the committable suggestions for the improvements mentioned:
Suggested change
Suggested change
⚡ Committable suggestion Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. |
||||||||||||||||||||||||||
text: isPending || isError ? '' : ourlogToJson(data), | ||||||||||||||||||||||||||
onCopy: () => { | ||||||||||||||||||||||||||
trackAnalytics('logs.table.row_copied_as_json', { | ||||||||||||||||||||||||||
log_id: String(dataRow[OurLogKnownFieldKey.ID]), | ||||||||||||||||||||||||||
organization, | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
successMessage: t('Copied!'), | ||||||||||||||||||||||||||
errorMessage: t('Failed to copy'), | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
const {data, isPending, isError} = fullLogDataResult; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const theme = useTheme(); | ||||||||||||||||||||||||||
const logColors = getLogColors(level, theme); | ||||||||||||||||||||||||||
|
@@ -481,53 +473,97 @@ function LogRowDetails({ | |||||||||||||||||||||||||
flexDirection: 'row', | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||
<LogDetailTableActionsButtonBar> | ||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||
priority="link" | ||||||||||||||||||||||||||
size="sm" | ||||||||||||||||||||||||||
borderless | ||||||||||||||||||||||||||
onClick={() => { | ||||||||||||||||||||||||||
addSearchFilter({ | ||||||||||||||||||||||||||
key: OurLogKnownFieldKey.MESSAGE, | ||||||||||||||||||||||||||
value: dataRow[OurLogKnownFieldKey.MESSAGE], | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||
<IconAdd size="md" style={{paddingRight: space(0.5)}} /> | ||||||||||||||||||||||||||
{t('Add to filter')} | ||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||
priority="link" | ||||||||||||||||||||||||||
size="sm" | ||||||||||||||||||||||||||
borderless | ||||||||||||||||||||||||||
onClick={() => { | ||||||||||||||||||||||||||
addSearchFilter({ | ||||||||||||||||||||||||||
key: OurLogKnownFieldKey.MESSAGE, | ||||||||||||||||||||||||||
value: dataRow[OurLogKnownFieldKey.MESSAGE], | ||||||||||||||||||||||||||
negated: true, | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||
<IconSubtract size="md" style={{paddingRight: space(0.5)}} /> | ||||||||||||||||||||||||||
{t('Exclude from filter')} | ||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||
</LogDetailTableActionsButtonBar> | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
<LogDetailTableActionsButtonBar> | ||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||
priority="link" | ||||||||||||||||||||||||||
size="sm" | ||||||||||||||||||||||||||
borderless | ||||||||||||||||||||||||||
onClick={() => { | ||||||||||||||||||||||||||
betterCopyToClipboard(); | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||
<IconJson size="md" style={{paddingRight: space(0.5)}} /> | ||||||||||||||||||||||||||
{t('Copy as JSON')} | ||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||
</LogDetailTableActionsButtonBar> | ||||||||||||||||||||||||||
<LogRowDetailsActions | ||||||||||||||||||||||||||
fullLogDataResult={fullLogDataResult} | ||||||||||||||||||||||||||
tableDataRow={dataRow} | ||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||
</LogDetailTableActionsCell> | ||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||
</DetailsWrapper> | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
function LogRowDetailsFilterActions({tableDataRow}: {tableDataRow: OurLogsResponseItem}) { | ||||||||||||||||||||||||||
const addSearchFilter = useLogsAddSearchFilter(); | ||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||
<LogDetailTableActionsButtonBar> | ||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||
priority="link" | ||||||||||||||||||||||||||
size="sm" | ||||||||||||||||||||||||||
borderless | ||||||||||||||||||||||||||
onClick={() => { | ||||||||||||||||||||||||||
addSearchFilter({ | ||||||||||||||||||||||||||
key: OurLogKnownFieldKey.MESSAGE, | ||||||||||||||||||||||||||
value: tableDataRow[OurLogKnownFieldKey.MESSAGE], | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||
<IconAdd size="md" style={{paddingRight: space(0.5)}} /> | ||||||||||||||||||||||||||
{t('Add to filter')} | ||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||
priority="link" | ||||||||||||||||||||||||||
size="sm" | ||||||||||||||||||||||||||
borderless | ||||||||||||||||||||||||||
onClick={() => { | ||||||||||||||||||||||||||
addSearchFilter({ | ||||||||||||||||||||||||||
key: OurLogKnownFieldKey.MESSAGE, | ||||||||||||||||||||||||||
value: tableDataRow[OurLogKnownFieldKey.MESSAGE], | ||||||||||||||||||||||||||
negated: true, | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||
<IconSubtract size="md" style={{paddingRight: space(0.5)}} /> | ||||||||||||||||||||||||||
{t('Exclude from filter')} | ||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||
</LogDetailTableActionsButtonBar> | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
function LogRowDetailsActions({ | ||||||||||||||||||||||||||
fullLogDataResult, | ||||||||||||||||||||||||||
tableDataRow, | ||||||||||||||||||||||||||
}: { | ||||||||||||||||||||||||||
fullLogDataResult: UseApiQueryResult<TraceItemDetailsResponse, RequestError>; | ||||||||||||||||||||||||||
tableDataRow: OurLogsResponseItem; | ||||||||||||||||||||||||||
}) { | ||||||||||||||||||||||||||
const {data, isPending, isError} = fullLogDataResult; | ||||||||||||||||||||||||||
const isTableFrozen = useLogsIsTableFrozen(); | ||||||||||||||||||||||||||
const organization = useOrganization(); | ||||||||||||||||||||||||||
const showFilterButtons = !isTableFrozen; | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [BestPractice] The
Suggested change
Then update the conditional to use ⚡ Committable suggestion Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const {onClick: betterCopyToClipboard} = useCopyToClipboard({ | ||||||||||||||||||||||||||
text: isPending || isError ? '' : ourlogToJson(data), | ||||||||||||||||||||||||||
onCopy: () => { | ||||||||||||||||||||||||||
trackAnalytics('logs.table.row_copied_as_json', { | ||||||||||||||||||||||||||
log_id: String(tableDataRow[OurLogKnownFieldKey.ID]), | ||||||||||||||||||||||||||
organization, | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
successMessage: t('Copied!'), | ||||||||||||||||||||||||||
errorMessage: t('Failed to copy'), | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||
<Fragment> | ||||||||||||||||||||||||||
{showFilterButtons ? ( | ||||||||||||||||||||||||||
<LogRowDetailsFilterActions tableDataRow={tableDataRow} /> | ||||||||||||||||||||||||||
) : ( | ||||||||||||||||||||||||||
<span /> | ||||||||||||||||||||||||||
Comment on lines
+549
to
+552
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [BestPractice] Consider using a more semantic placeholder instead of an empty
Suggested change
⚡ Committable suggestion Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. |
||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||
<LogDetailTableActionsButtonBar> | ||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||
priority="link" | ||||||||||||||||||||||||||
size="sm" | ||||||||||||||||||||||||||
borderless | ||||||||||||||||||||||||||
onClick={() => { | ||||||||||||||||||||||||||
betterCopyToClipboard(); | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||
<IconJson size="md" style={{paddingRight: space(0.5)}} /> | ||||||||||||||||||||||||||
{t('Copy as JSON')} | ||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||
</LogDetailTableActionsButtonBar> | ||||||||||||||||||||||||||
</Fragment> | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/propel review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/propel review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/propel review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/propel review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/propel review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/propel review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/propel review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/propel review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request effectively addresses the stated goal of hiding filter action buttons when the logs table is embedded, while keeping the 'Copy as JSON' functionality available. The refactoring into
LogRowDetailsFilterActions
andLogRowDetailsActions
components improves modularity and readability.I agree with the suggestions made by
propel-test-bot[bot]
. RenamingshowFilterButtons
tocanFilter
provides better semantic clarity, and usingnull
instead of an empty<span>
for conditional rendering is a good practice for accessibility and cleaner JSX.Here are the suggested changes:
⚡ Committable suggestion
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.