@@ -105,10 +105,11 @@ export class Projects extends auth.Component<ISettingsProps, ProjectsState> {
105
105
chgGallery ( scr : pxt . CodeCard , action ?: pxt . CodeCardAction ) {
106
106
let editor : string = ( action && action . editor ) || "blocks" ;
107
107
if ( editor == "js" ) editor = "ts" ;
108
- pxt . tickEvent ( "projects.gallery" , { name : scr . name , cardType : scr . cardType , editor } ) ;
109
108
const url = action ? action . url : scr . url ;
109
+ const type = action ?. cardType || scr . cardType
110
110
const editorPref = editor + "prj" ;
111
- switch ( scr . cardType ) {
111
+ pxt . tickEvent ( "projects.gallery" , { name : scr . name , cardType : type , editor } ) ;
112
+ switch ( type ) {
112
113
case "template" :
113
114
const prj = pxt . Util . clone ( pxt . appTarget . blocksprj ) ;
114
115
prj . config . dependencies = { } ; // clear all dependencies
@@ -122,6 +123,7 @@ export class Projects extends auth.Component<ISettingsProps, ProjectsState> {
122
123
this . props . parent . startActivity ( "tutorial" , url , scr . name , editorPref ) ;
123
124
break ;
124
125
case "sharedExample" :
126
+ console . log ( "shared example" )
125
127
let id = pxt . github . normalizeRepoId ( url ) || pxt . Cloud . parseScriptId ( url ) ;
126
128
if ( ! id ) {
127
129
core . errorNotification ( lf ( "Sorry, the project url looks invalid." ) ) ;
@@ -863,12 +865,13 @@ export class ProjectsDetail extends data.Component<ProjectsDetailProps, Projects
863
865
this . linkRef = React . createRef < HTMLAnchorElement > ( ) ;
864
866
}
865
867
866
- protected isLink ( ) {
868
+ protected isLink ( actionType ?: pxt . CodeCardType ) {
867
869
const { cardType, url, youTubeId, youTubePlaylistId } = this . props ;
870
+ const type = actionType || cardType ;
868
871
869
- return isCodeCardWithLink ( cardType ) && ( youTubeId || youTubePlaylistId || url ) ;
872
+ return isCodeCardWithLink ( type ) && ( youTubeId || youTubePlaylistId || url ) ;
870
873
871
- function isCodeCardWithLink ( value : string ) {
874
+ function isCodeCardWithLink ( value : pxt . CodeCardType ) {
872
875
switch ( value ) {
873
876
case "file" :
874
877
case "example" :
@@ -899,10 +902,12 @@ export class ProjectsDetail extends data.Component<ProjectsDetailProps, Projects
899
902
let clickLabel = lf ( "Show Instructions" ) ;
900
903
if ( cardType == "tutorial" )
901
904
clickLabel = lf ( "Start Tutorial" ) ;
902
- else if ( cardType == "codeExample" || cardType == "example" || cardType == "sharedExample" )
905
+ else if ( cardType == "codeExample" || cardType == "example" )
903
906
clickLabel = lf ( "Open Example" ) ;
904
907
else if ( cardType == "forumUrl" )
905
908
clickLabel = lf ( "Open in Forum" ) ;
909
+ else if ( cardType == "sharedExample" )
910
+ clickLabel = lf ( "Open in Editor" ) ;
906
911
else if ( cardType == "template" )
907
912
clickLabel = lf ( "New Project" ) ;
908
913
else if ( youTubeId )
@@ -916,30 +921,34 @@ export class ProjectsDetail extends data.Component<ProjectsDetailProps, Projects
916
921
switch ( type ) {
917
922
case "tutorial" :
918
923
case "example" :
919
- case "sharedExample" :
920
924
if ( action && action . editor ) return action . editor ;
921
925
return "blocks" ;
922
926
case "codeExample" :
923
927
if ( action && action . editor ) return action . editor ;
924
928
return "js" ;
929
+ case "sharedExample" :
930
+ return action ?. editor ;
925
931
default :
926
932
return null ;
927
933
}
928
934
}
929
935
930
- protected getActionIcon ( onClick : any , type : string , editor ?: pxt . CodeCardEditorType ) : JSX . Element {
936
+ protected getActionIcon ( onClick : any , type : pxt . CodeCardType , editor ?: pxt . CodeCardEditorType ) : JSX . Element {
931
937
const { youTubeId, youTubePlaylistId } = this . props ;
932
938
let icon = "file text" ;
933
939
switch ( type ) {
934
940
case "tutorial" :
935
941
case "example" :
936
- case "sharedExample" :
937
942
icon = "xicon blocks"
938
943
if ( editor ) icon = `xicon ${ editor } ` ;
939
944
break ;
940
945
case "codeExample" :
941
946
icon = `xicon ${ editor || "js" } ` ;
942
947
break ;
948
+ case "sharedExample" :
949
+ icon = "pencil"
950
+ if ( editor ) icon = `xicon ${ editor } ` ;
951
+ break ;
943
952
case "forumUrl" :
944
953
icon = "comments"
945
954
break ;
@@ -951,7 +960,7 @@ export class ProjectsDetail extends data.Component<ProjectsDetailProps, Projects
951
960
if ( youTubeId || youTubePlaylistId ) icon = "youtube" ;
952
961
break ;
953
962
}
954
- return this . isLink ( ) && type != "forumExample" // TODO (shakao) migrate forumurl to otherAction json in md
963
+ return this . isLink ( type ) && type != "forumExample" // TODO (shakao) migrate forumurl to otherAction json in md
955
964
? < sui . Link role = "button" className = "link button attached" icon = { icon } href = { this . getUrl ( ) } target = "_blank" tabIndex = { - 1 } />
956
965
: < sui . Item role = "button" className = "button attached" icon = { icon } onClick = { onClick } tabIndex = { - 1 } />
957
966
}
@@ -969,7 +978,7 @@ export class ProjectsDetail extends data.Component<ProjectsDetailProps, Projects
969
978
}
970
979
}
971
980
972
- protected getActionCard ( text : string , type : string , onClick : any , autoFocus ?: boolean , action ?: pxt . CodeCardAction , key ?: string ) : JSX . Element {
981
+ protected getActionCard ( text : string , type : pxt . CodeCardType , onClick : any , autoFocus ?: boolean , action ?: pxt . CodeCardAction , key ?: string ) : JSX . Element {
973
982
const editor = this . getActionEditor ( type , action ) ;
974
983
const title = this . getActionTitle ( editor ) ;
975
984
return < div className = { `card-action ui items ${ editor || "" } ` } key = { key } >
@@ -991,7 +1000,7 @@ export class ProjectsDetail extends data.Component<ProjectsDetailProps, Projects
991
1000
onClick = { onClick }
992
1001
onKeyDown = { sui . fireClickOnEnter }
993
1002
autoFocus = { autoFocus }
994
- title = { lf ( "Open in {0}" , title ) }
1003
+ title = { lf ( "Open in {0}" , title || lf ( "Editor" ) ) }
995
1004
/> }
996
1005
</ div >
997
1006
}
@@ -1092,9 +1101,10 @@ export class ProjectsDetail extends data.Component<ProjectsDetailProps, Projects
1092
1101
{ this . getActionCard ( clickLabel , cardType , this . handleDetailClick , true ) }
1093
1102
{ otherActions && otherActions . map ( ( el , i ) => {
1094
1103
let onClick = this . handleActionClick ( el ) ;
1095
- return this . getActionCard ( clickLabel , el . cardType || cardType , onClick , false , el , `action${ i } ` ) ;
1104
+ let label = el . cardType ? this . getClickLabel ( el . cardType ) : clickLabel ;
1105
+ return this . getActionCard ( label , el . cardType || cardType , onClick , false , el , `action${ i } ` ) ;
1096
1106
} ) }
1097
- { cardType === "forumUrl" &&
1107
+ { cardType === "forumUrl" && ( ! otherActions || otherActions . length == 0 ) &&
1098
1108
// TODO (jwunderl) temporarily disabled in electron re: https://github.com/microsoft/pxt-arcade/issues/2346;
1099
1109
// reenable CORS issue is fixed.
1100
1110
! pxt . BrowserUtils . isPxtElectron ( ) &&
0 commit comments