- 
                Notifications
    You must be signed in to change notification settings 
- Fork 7
feat: add auth fallback logic for when official Coder components are not mounted #128
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            58 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      9db4173
              
                wip: commit progress on fallback UI
              
              
                Parkreiner 50d9008
              
                chore: move dep to peer dependencies
              
              
                Parkreiner c57d4c9
              
                wip: commit more progress
              
              
                Parkreiner e567260
              
                wip: more progress
              
              
                Parkreiner 61ee528
              
                refactor: consolidate card logic
              
              
                Parkreiner 9b16cc2
              
                fix: update component tracking hooks
              
              
                Parkreiner 344593d
              
                fix: add a11y landmark to auth fallback
              
              
                Parkreiner 2041f17
              
                wip: commit more style progress
              
              
                Parkreiner 43cfd52
              
                wip: commit more progress
              
              
                Parkreiner 560d009
              
                wip: more progress
              
              
                Parkreiner 98faa12
              
                wip: cleanup current approach
              
              
                Parkreiner a73b1b1
              
                wip: commit progress on observer approach
              
              
                Parkreiner 0011dd2
              
                wip: fix infinite loop for mutation logic
              
              
                Parkreiner b8bc1ef
              
                fix: prevent padding patches from firing too often
              
              
                Parkreiner 2112995
              
                fix: improve scoping of style overrides
              
              
                Parkreiner d04274c
              
                chore: finish intial version of fallback stylling
              
              
                Parkreiner ae85984
              
                fix: tidy up types
              
              
                Parkreiner 6e18204
              
                wip: create initial version of dialog form
              
              
                Parkreiner f097f9b
              
                wip: commit progress on modal
              
              
                Parkreiner e1a70dd
              
                chore: finish styling for modal wrapper
              
              
                Parkreiner c4101f6
              
                fix: update padding for FormDialog
              
              
                Parkreiner f8bb852
              
                wip: start extracting out auth form
              
              
                Parkreiner 98c96af
              
                fix: add missing barrel export file
              
              
                Parkreiner a404ddb
              
                fix: make sure that auth form isn't dismissed early
              
              
                Parkreiner af2f383
              
                fix: update auth imports
              
              
                Parkreiner 5b04628
              
                fix: update spacing for auth modal
              
              
                Parkreiner 8ae3d14
              
                refactor: clean up auth provider for clarity
              
              
                Parkreiner 1b1f8c4
              
                docs: rewrite comment for clarity
              
              
                Parkreiner 1ea39e0
              
                fix: improve granularity between official Coder components and user c…
              
              
                Parkreiner 9236ca4
              
                fix: update all internal consumers of useCoderAuth
              
              
                Parkreiner b90ebd0
              
                wip: commit initial version of useCoderQuery helper hook
              
              
                Parkreiner 12a7b3e
              
                refactor: rename hooks to avoid confusion
              
              
                Parkreiner c146788
              
                fix: update exports for plugin
              
              
                Parkreiner e7e7755
              
                docs: fill in incomplete sentence
              
              
                Parkreiner 8493080
              
                wip: commit initial version of useMutation wrapper
              
              
                Parkreiner 8087e19
              
                refactor: extract retry factor into global constant
              
              
                Parkreiner 20fa328
              
                merge
              
              
                Parkreiner ca257ae
              
                fix: add explicit return type to useCoderMutation
              
              
                Parkreiner a92ec05
              
                wip: start extracting auth logic into better reusable components
              
              
                Parkreiner 028c6b7
              
                fix: update card to have better styling for body
              
              
                Parkreiner aea9345
              
                wip: commit progress on style refactoring
              
              
                Parkreiner ceb65e1
              
                fix: update vertical padding for card wrapper
              
              
                Parkreiner 8d1343f
              
                chore: delete CoderAuthWrapper component
              
              
                Parkreiner 91e0702
              
                fix: update styling for auth fallback
              
              
                Parkreiner b644eec
              
                chore: shrink size of PR
              
              
                Parkreiner b127195
              
                fix: update imports
              
              
                Parkreiner 7118896
              
                docs: add comment about description setup
              
              
                Parkreiner b364e0c
              
                fix: remove risk of runtime render errors in auth form
              
              
                Parkreiner 39f9a06
              
                fix: update imports
              
              
                Parkreiner 1148eae
              
                fix: update font sizes to use relative units
              
              
                Parkreiner 5aca4f7
              
                fix: update peer dependencies for react-dom
              
              
                Parkreiner b04482e
              
                refactor: clean up auth revalidation logic
              
              
                Parkreiner 063006c
              
                wip: start updating tests for new code changes
              
              
                Parkreiner 1702755
              
                fix: adding missing test case for auth card
              
              
                Parkreiner 1d928bb
              
                wip: commit progress on auth form test updates
              
              
                Parkreiner 34f027f
              
                fix: removal vetigal properties
              
              
                Parkreiner e0a4760
              
                fix: get all CoderAuthForm tests passing
              
              
                Parkreiner 15a4e22
              
                fix: update import for auth hook in test
              
              
                Parkreiner 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 hidden or 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
    
  
  
    
              
              
        
          
          
            63 changes: 63 additions & 0 deletions
          
          63 
        
  plugins/backstage-plugin-coder/src/components/A11yInfoCard/A11yInfoCard.tsx
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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,63 @@ | ||
| /** | ||
| * @file A slightly different take on Backstage's official InfoCard component, | ||
| * with better support for accessibility. | ||
| * | ||
| * Does not support all of InfoCard's properties just yet. | ||
| */ | ||
| import React, { type HTMLAttributes, type ReactNode, forwardRef } from 'react'; | ||
| import { makeStyles } from '@material-ui/core'; | ||
|  | ||
| export type A11yInfoCardProps = Readonly< | ||
| HTMLAttributes<HTMLDivElement> & { | ||
| headerContent?: ReactNode; | ||
| } | ||
| >; | ||
|  | ||
| const useStyles = makeStyles(theme => ({ | ||
| root: { | ||
| color: theme.palette.type, | ||
| backgroundColor: theme.palette.background.paper, | ||
| padding: theme.spacing(2), | ||
| borderRadius: theme.shape.borderRadius, | ||
| boxShadow: theme.shadows[1], | ||
| }, | ||
|  | ||
| headerContent: { | ||
| // Ideally wouldn't be using hard-coded font sizes, but couldn't figure out | ||
| // how to use the theme.typography property, especially since not all | ||
| // sub-properties have font sizes defined | ||
| fontSize: '1.5rem', | ||
| color: theme.palette.text.primary, | ||
| fontWeight: 700, | ||
| borderBottom: `1px solid ${theme.palette.divider}`, | ||
|  | ||
| // Margins and padding are a bit wonky to support full-bleed layouts | ||
| marginLeft: `-${theme.spacing(2)}px`, | ||
| marginRight: `-${theme.spacing(2)}px`, | ||
| padding: `0 ${theme.spacing(2)}px ${theme.spacing(2)}px`, | ||
| }, | ||
| })); | ||
|  | ||
| // Card should be treated as equivalent to Backstage's official InfoCard | ||
| // component; had to make custom version so that it could forward properties for | ||
| // accessibility/screen reader support | ||
| export const A11yInfoCard = forwardRef<HTMLDivElement, A11yInfoCardProps>( | ||
| (props, ref) => { | ||
| const { className, children, headerContent, ...delegatedProps } = props; | ||
| const styles = useStyles(); | ||
|  | ||
| return ( | ||
| <div | ||
| ref={ref} | ||
| className={`${styles.root} ${className ?? ''}`} | ||
| {...delegatedProps} | ||
| > | ||
| {headerContent !== undefined && ( | ||
| <div className={styles.headerContent}>{headerContent}</div> | ||
| )} | ||
|  | ||
| {children} | ||
| </div> | ||
| ); | ||
| }, | ||
| ); | 
        
          
          
            1 change: 1 addition & 0 deletions
          
          1 
        
  plugins/backstage-plugin-coder/src/components/A11yInfoCard/index.ts
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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 @@ | ||
| export * from './A11yInfoCard'; | 
        
          
          
            27 changes: 0 additions & 27 deletions
          
          27 
        
  plugins/backstage-plugin-coder/src/components/Card/Card.tsx
  
  
      
      
   
        
      
      
    This file was deleted.
      
      Oops, something went wrong.
      
    
  This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or 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 hidden or 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.
Needed to bring in React DOM as a peer dependency so I could start using React portals