@@ -242,6 +242,19 @@ def refresh_runs(
242242 )
243243
244244
245+ def generate_share_fields (
246+ project : str ,
247+ metrics : str ,
248+ selection : RunSelection ,
249+ show_headers : bool = True ,
250+ ) -> tuple [str , str ]:
251+ share_url = utils .generate_share_url (project , metrics , selection .selected )
252+ embed_code = utils .generate_embed_code (
253+ project , metrics , selection .selected , not show_headers
254+ )
255+ return share_url , embed_code
256+
257+
245258def generate_embed (
246259 project : str , metrics : str , selection : RunSelection , show_headers : bool = True
247260) -> str :
@@ -745,13 +758,22 @@ def configure(request: gr.Request):
745758 logo = fns .create_logo ()
746759 project_dd = fns .create_project_dropdown ()
747760
748- embed_code = gr .Code (
749- label = "Embed this view" ,
750- max_lines = 2 ,
751- lines = 2 ,
752- language = "html" ,
753- visible = bool (os .environ .get ("SPACE_HOST" )),
754- )
761+ with gr .Tabs (visible = bool (os .environ .get ("SPACE_HOST" ))):
762+ with gr .Tab ("Share" ):
763+ share_url = gr .Textbox (
764+ label = "Share this view" ,
765+ max_lines = 1 ,
766+ lines = 1 ,
767+ interactive = False ,
768+ buttons = ["copy" ],
769+ )
770+ with gr .Tab ("Embed" ):
771+ embed_code = gr .Code (
772+ label = "Embed this view" ,
773+ max_lines = 2 ,
774+ lines = 2 ,
775+ language = "html" ,
776+ )
755777 with gr .Group ():
756778 run_tb = gr .Textbox (label = "Runs" , placeholder = "Type to filter..." )
757779 run_group_by_dd = gr .Dropdown (label = "Group by..." , choices = [], value = None )
@@ -849,9 +871,9 @@ def configure(request: gr.Request):
849871 queue = False ,
850872 api_visibility = "private" ,
851873 ).then (
852- fn = generate_embed ,
874+ fn = generate_share_fields ,
853875 inputs = [project_dd , metric_filter_tb , run_selection_state , show_headers_cb ],
854- outputs = [embed_code ],
876+ outputs = [share_url , embed_code ],
855877 show_progress = "hidden" ,
856878 api_visibility = "private" ,
857879 queue = False ,
@@ -882,9 +904,9 @@ def configure(request: gr.Request):
882904 )
883905 gr .on (
884906 [metric_filter_tb .change , run_cb .change ],
885- fn = generate_embed ,
907+ fn = generate_share_fields ,
886908 inputs = [project_dd , metric_filter_tb , run_selection_state , show_headers_cb ],
887- outputs = embed_code ,
909+ outputs = [ share_url , embed_code ] ,
888910 show_progress = "hidden" ,
889911 api_visibility = "private" ,
890912 queue = False ,
@@ -920,9 +942,9 @@ def toggle_group_view(group_by_dd):
920942 api_visibility = "private" ,
921943 queue = False ,
922944 ).then (
923- fn = generate_embed ,
945+ fn = generate_share_fields ,
924946 inputs = [project_dd , metric_filter_tb , run_selection_state , show_headers_cb ],
925- outputs = embed_code ,
947+ outputs = [ share_url , embed_code ] ,
926948 show_progress = "hidden" ,
927949 api_visibility = "private" ,
928950 queue = False ,
0 commit comments