Unverified Commit 72e908d3 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[dev-overlay] Disable error feedback in UI if `NEXT_TELEMETRY_DISABLED` is set (#76423)

parent 6e276347
...@@ -275,6 +275,9 @@ export function getDefineEnv({ ...@@ -275,6 +275,9 @@ export function getDefineEnv({
'process.env.__NEXT_ASSET_PREFIX': config.assetPrefix, 'process.env.__NEXT_ASSET_PREFIX': config.assetPrefix,
'process.env.__NEXT_EXPERIMENTAL_AUTH_INTERRUPTS': 'process.env.__NEXT_EXPERIMENTAL_AUTH_INTERRUPTS':
!!config.experimental.authInterrupts, !!config.experimental.authInterrupts,
'process.env.__NEXT_TELEMETRY_DISABLED': Boolean(
process.env.NEXT_TELEMETRY_DISABLED
),
...(isNodeOrEdgeCompilation ...(isNodeOrEdgeCompilation
? { ? {
// Fix bad-actors in the npm ecosystem (e.g. `node-formidable`) // Fix bad-actors in the npm ecosystem (e.g. `node-formidable`)
......
...@@ -11,6 +11,7 @@ export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) { ...@@ -11,6 +11,7 @@ export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) {
const [votedMap, setVotedMap] = useState<Record<string, boolean>>({}) const [votedMap, setVotedMap] = useState<Record<string, boolean>>({})
const voted = votedMap[errorCode] const voted = votedMap[errorCode]
const hasVoted = voted !== undefined const hasVoted = voted !== undefined
const disabled = process.env.__NEXT_TELEMETRY_DISABLED
const handleFeedback = useCallback( const handleFeedback = useCallback(
async (wasHelpful: boolean) => { async (wasHelpful: boolean) => {
...@@ -63,17 +64,29 @@ export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) { ...@@ -63,17 +64,29 @@ export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) {
</a> </a>
</p> </p>
<button <button
aria-disabled={disabled ? 'true' : undefined}
aria-label="Mark as helpful" aria-label="Mark as helpful"
onClick={() => handleFeedback(true)} onClick={disabled ? undefined : () => handleFeedback(true)}
className={cx('feedback-button', voted === true && 'voted')} className={cx('feedback-button', voted === true && 'voted')}
title={
disabled
? 'Feedback disabled due to setting NEXT_TELEMETRY_DISABLED'
: undefined
}
type="button" type="button"
> >
<ThumbsUp aria-hidden="true" /> <ThumbsUp aria-hidden="true" />
</button> </button>
<button <button
aria-disabled={disabled ? 'true' : undefined}
aria-label="Mark as not helpful" aria-label="Mark as not helpful"
onClick={() => handleFeedback(false)} onClick={disabled ? undefined : () => handleFeedback(false)}
className={cx('feedback-button', voted === false && 'voted')} className={cx('feedback-button', voted === false && 'voted')}
title={
disabled
? 'Feedback disabled due to setting NEXT_TELEMETRY_DISABLED'
: undefined
}
type="button" type="button"
> >
<ThumbsDown <ThumbsDown
...@@ -130,7 +143,7 @@ export const styles = ` ...@@ -130,7 +143,7 @@ export const styles = `
} }
} }
.feedback-button:disabled { .feedback-button[aria-disabled='true'] {
opacity: 0.7; opacity: 0.7;
cursor: not-allowed; cursor: not-allowed;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment