@@ -23,6 +23,7 @@ import CollapsibleList from '../../containers/CollapsibleList';
2323
2424export class OrbImportWithMeta extends orb . OrbImport {
2525 logo_url : string ;
26+ url : string ;
2627
2728 constructor (
2829 alias : string ,
@@ -31,12 +32,14 @@ export class OrbImportWithMeta extends orb.OrbImport {
3132 manifest : OrbImportManifest ,
3233 version : string ,
3334 logo_url : string ,
35+ url : string ,
3436 description ?: string ,
3537 display ?: OrbDisplayMeta ,
3638 ) {
3739 super ( alias , namespace , orb , version , manifest , description , display ) ;
3840
3941 this . logo_url = logo_url ;
42+ this . url = url ;
4043 }
4144}
4245
@@ -116,11 +119,13 @@ const OrbDefinitionContainer = (props: {
116119const OrbDefinitionsMenu = ( props : OrbDefinitionProps ) => {
117120 const orbs = useStoreState ( ( state ) => state . definitions . orbs ) ;
118121 const importOrb = useStoreActions ( ( actions ) => actions . importOrb ) ;
122+ const unimportOrb = useStoreActions ( ( actions ) => actions . unimportOrb ) ;
119123 const [ orb , setOrb ] = useState < OrbImportWithMeta > ( ) ;
124+ const [ error , setError ] = useState ( false ) ;
120125
121126 useEffect ( ( ) => {
122- loadOrb ( `${ props . namespace } /${ props . name } @${ props . version } ` ) . then (
123- ( { manifest } ) => {
127+ loadOrb ( `${ props . namespace } /${ props . name } @${ props . version } ` )
128+ . then ( ( { manifest } ) => {
124129 setOrb (
125130 new OrbImportWithMeta (
126131 props . name ,
@@ -129,11 +134,14 @@ const OrbDefinitionsMenu = (props: OrbDefinitionProps) => {
129134 manifest ,
130135 props . version ,
131136 props . logo_url ,
137+ props . url ,
132138 props . description ,
133139 ) ,
134140 ) ;
135- } ,
136- ) ;
141+ } )
142+ . catch ( ( ) => {
143+ setError ( true ) ;
144+ } ) ;
137145 } , [ setOrb , props ] ) ;
138146
139147 const inProject = Object . values ( orbs ) . find (
@@ -151,8 +159,8 @@ const OrbDefinitionsMenu = (props: OrbDefinitionProps) => {
151159 < h2 className = "text-circle-gray-400" > { props . version } </ h2 >
152160 < a
153161 className = "flex ml-auto cursor-pointer tracking-wide hover:underline leading-6 text-sm text-circle-blue font-medium"
154- href = { orb ?. display ?. source_url }
155- target = "circleci_docs "
162+ href = { orb ?. url }
163+ target = "circleci_devhub "
156164 onClick = { ( e ) => {
157165 e . stopPropagation ( ) ;
158166 } }
@@ -195,7 +203,16 @@ const OrbDefinitionsMenu = (props: OrbDefinitionProps) => {
195203 </ div >
196204 < Footer >
197205 { inProject ? (
198- < Button variant = "dangerous" > Remove Orb from Config</ Button >
206+ < Button
207+ onClick = { ( ) => {
208+ if ( orb ) {
209+ unimportOrb ( orb ) ;
210+ }
211+ } }
212+ variant = "dangerous"
213+ >
214+ Remove Orb from Config
215+ </ Button >
199216 ) : (
200217 < Button
201218 onClick = { ( ) => {
@@ -210,6 +227,11 @@ const OrbDefinitionsMenu = (props: OrbDefinitionProps) => {
210227 ) }
211228 </ Footer >
212229 </ div >
230+ ) : error ? (
231+ < p className = "font-medium pl-3 py-4 text-circle-red-dangerous" >
232+ Error loading orb. It likely uses an advanced feature not yet
233+ supported. Sorry for the inconvenience!
234+ </ p >
213235 ) : (
214236 < div className = "flex m-auto" >
215237 < Loading />
0 commit comments