-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: add access denied UI #27335
Merged
Merged
feat: add access denied UI #27335
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useActions } from 'kea' | ||
import { Link } from 'lib/lemon-ui/Link' | ||
import notFoundAstrohog from 'public/not-found-astrohog.png' | ||
|
||
import { supportLogic } from '../Support/supportLogic' | ||
|
||
export interface AccessDeniedProps { | ||
object: string | ||
} | ||
|
||
export function AccessDenied({ object }: AccessDeniedProps): JSX.Element { | ||
const { openSupportForm } = useActions(supportLogic) | ||
|
||
return ( | ||
<div className="flex flex-col items-center max-w-2xl p-4 my-24 mx-auto text-center"> | ||
<img src={notFoundAstrohog} className="w-64 h-64 bg-no-repeat bg-center" /> | ||
<h1 className="text-3xl font-bold mt-4 mb-0">Access denied</h1> | ||
<p className="text-sm mt-3 mb-0"> | ||
You do not have access to this {object}. Please contact the creator of this {object} or{' '} | ||
<Link onClick={() => openSupportForm({ kind: 'support' })}>support</Link> if you think this is a | ||
mistake. | ||
</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,6 +287,7 @@ export const featureFlagLogic = kea<featureFlagLogicType>([ | |
errors?: any | ||
) => ({ filters, active, errors }), | ||
setScheduledChangeOperation: (changeType: ScheduledChangeOperationType) => ({ changeType }), | ||
setAccessDeniedToFeatureFlag: true, | ||
}), | ||
forms(({ actions, values }) => ({ | ||
featureFlag: { | ||
|
@@ -449,6 +450,7 @@ export const featureFlagLogic = kea<featureFlagLogicType>([ | |
}, | ||
}, | ||
], | ||
accessDeniedToFeatureFlag: [false, { setAccessDeniedToFeatureFlag: () => true }], | ||
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. Do any of these cause a flashed screen before the endpoint returns, or are they all covered by page loaders? 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. Yeah a bit, def room to improve. |
||
propertySelectErrors: [ | ||
null as any, | ||
{ | ||
|
@@ -527,8 +529,12 @@ export const featureFlagLogic = kea<featureFlagLogicType>([ | |
try { | ||
const retrievedFlag: FeatureFlagType = await api.featureFlags.get(props.id) | ||
return variantKeyToIndexFeatureFlagPayloads(retrievedFlag) | ||
} catch (e) { | ||
actions.setFeatureFlagMissing() | ||
} catch (e: any) { | ||
if (e.status === 403 && e.code === 'permission_denied') { | ||
actions.setAccessDeniedToFeatureFlag() | ||
} else { | ||
actions.setFeatureFlagMissing() | ||
} | ||
throw e | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is needed because it calls
resonse.json()
so downstream functions can't pull out the body response.