11import insertSVGstr from '../style/icon/insertsnippet.svg' ;
2- import carrotSVGstr from '../style/icon/jupyter_snippetarrow .svg' ;
2+ import launchEditorSVGstr from '../style/icon/jupyter_launcher .svg' ;
33import { SearchBar } from './SearchBar' ;
44import { showPreview } from './PreviewSnippet' ;
55import {
@@ -8,16 +8,15 @@ import {
88} from './CodeSnippetContentsService' ;
99// import { CodeSnippetWidget } from './CodeSnippetWidget';
1010
11- import { Clipboard , Dialog , showDialog } from '@jupyterlab/apputils' ;
11+ import { /** Clipboard,*/ Dialog , showDialog } from '@jupyterlab/apputils' ;
1212import { CodeCell , MarkdownCell } from '@jupyterlab/cells' ;
1313import { CodeEditor } from '@jupyterlab/codeeditor' ;
1414import { PathExt } from '@jupyterlab/coreutils' ;
1515// import { ServerConnection } from '@jupyterlab/services';
1616import { DocumentWidget } from '@jupyterlab/docregistry' ;
1717import { FileEditor } from '@jupyterlab/fileeditor' ;
1818import { Notebook , NotebookPanel } from '@jupyterlab/notebook' ;
19- import { copyIcon } from '@jupyterlab/ui-components' ;
20- import { LabIcon } from '@jupyterlab/ui-components' ;
19+ import { /**copyIcon,*/ LabIcon , addIcon } from '@jupyterlab/ui-components' ;
2120import { IEditorServices } from '@jupyterlab/codeeditor' ;
2221
2322import { IExpandableActionButton } from '@elyra/ui-components' ;
@@ -46,7 +45,7 @@ const DISPLAY_NAME_CLASS = 'expandableContainer-name';
4645const ELYRA_BUTTON_CLASS = 'jp-button' ;
4746const BUTTON_CLASS = 'expandableContainer-button' ;
4847const TITLE_CLASS = 'expandableContainer-title' ;
49- const ACTION_BUTTONS_WRAPPER_CLASS = 'elyra- expandableContainer-action-buttons' ;
48+ const ACTION_BUTTONS_WRAPPER_CLASS = 'expandableContainer-action-buttons' ;
5049const ACTION_BUTTON_CLASS = 'expandableContainer-actionButton' ;
5150
5251/**
@@ -72,9 +71,9 @@ const insertIcon = new LabIcon({
7271 svgstr : insertSVGstr
7372} ) ;
7473
75- const previewIcon = new LabIcon ( {
76- name : 'custom-ui-compnents:preview ' ,
77- svgstr : carrotSVGstr
74+ const launchEditorIcon = new LabIcon ( {
75+ name : 'custom-ui-compnents:launchEditor ' ,
76+ svgstr : launchEditorSVGstr
7877} ) ;
7978
8079/**
@@ -270,25 +269,28 @@ export class CodeSnippetDisplay extends React.Component<
270269 . getElementsByClassName ( 'drag-hover' )
271270 [ _id ] . classList . add ( 'drag-hover-clicked' ) ;
272271 }
273- if (
274- document
275- . getElementsByClassName ( CODE_SNIPPET_ITEM )
276- [ _id ] . classList . contains ( 'codeSnippet-item-clicked' )
277- ) {
278- document
279- . getElementsByClassName ( CODE_SNIPPET_ITEM )
280- [ _id ] . classList . remove ( 'codeSnippet-item-clicked' ) ;
281- } else {
282- document
283- . getElementsByClassName ( CODE_SNIPPET_ITEM )
284- [ _id ] . classList . add ( 'codeSnippet-item-clicked' ) ;
285- }
272+ // if (
273+ // document
274+ // .getElementsByClassName(CODE_SNIPPET_ITEM)
275+ // [_id].classList.contains('codeSnippet-item-clicked')
276+ // ) {
277+ // document
278+ // .getElementsByClassName(CODE_SNIPPET_ITEM)
279+ // [_id].classList.remove('codeSnippet-item-clicked');
280+ // } else {
281+ // document
282+ // .getElementsByClassName(CODE_SNIPPET_ITEM)
283+ // [_id].classList.add('codeSnippet-item-clicked');
284+ // }
286285 } ;
287286
288287 // Bold text in snippet name based on search
289- private boldNameOnSearch = ( filter : string , displayed : string ) : any => {
288+ private boldNameOnSearch = (
289+ filter : string ,
290+ displayed : string
291+ ) : JSX . Element => {
290292 const name : string = displayed ;
291- if ( filter !== '' ) {
293+ if ( filter !== '' && displayed . includes ( filter ) ) {
292294 const startIndex : number = name . indexOf ( filter ) ;
293295 const endIndex : number = startIndex + filter . length ;
294296 const start = name . substring ( 0 , startIndex ) ;
@@ -302,7 +304,7 @@ export class CodeSnippetDisplay extends React.Component<
302304 </ span >
303305 ) ;
304306 }
305- return name ;
307+ return < span > { name } </ span > ;
306308 } ;
307309
308310 private handleDragSnippet (
@@ -472,15 +474,16 @@ export class CodeSnippetDisplay extends React.Component<
472474 ) : JSX . Element => {
473475 const buttonClasses = [ ELYRA_BUTTON_CLASS , BUTTON_CLASS ] . join ( ' ' ) ;
474476 const displayName = '[' + codeSnippet . language + '] ' + codeSnippet . name ;
477+ const tags = codeSnippet . tags ;
475478
476479 const actionButtons = [
477- {
478- title : 'Copy' ,
479- icon : copyIcon ,
480- onClick : ( ) : void => {
481- Clipboard . copyToSystem ( codeSnippet . code . join ( '\n' ) ) ;
482- }
483- } ,
480+ // {
481+ // title: 'Copy',
482+ // icon: copyIcon,
483+ // onClick: (): void => {
484+ // Clipboard.copyToSystem(codeSnippet.code.join('\n'));
485+ // }
486+ // },
484487 {
485488 title : 'Insert' ,
486489 icon : insertIcon ,
@@ -489,20 +492,19 @@ export class CodeSnippetDisplay extends React.Component<
489492 }
490493 } ,
491494 {
492- title : 'Preview ' ,
493- icon : previewIcon ,
495+ title : 'Launch Editor ' ,
496+ icon : launchEditorIcon ,
494497 onClick : ( ) : void => {
495- showPreview (
496- {
497- id : parseInt ( id , 10 ) ,
498- title : displayName ,
499- body : new PreviewHandler ( ) ,
500- codeSnippet : codeSnippet
501- } ,
502- this . props . openCodeSnippetEditor ,
503- this . props . editorServices
504- ) ;
505- this . snippetClicked ( id ) ;
498+ // showPreview(
499+ // {
500+ // id: parseInt(id, 10),
501+ // title: displayName,
502+ // body: new PreviewHandler(codeSnippet),
503+ // codeSnippet: codeSnippet
504+ // }
505+ // );
506+ this . props . openCodeSnippetEditor ( codeSnippet ) ;
507+ // this.snippetClicked(id);
506508 }
507509 }
508510 ] ;
@@ -528,9 +530,18 @@ export class CodeSnippetDisplay extends React.Component<
528530 this . handleDragSnippet ( event ) ;
529531 } }
530532 > </ div >
531- < div >
532- < div key = { displayName } className = { TITLE_CLASS } >
533- < span
533+ < div className = { 'jp-codeSnippet-metadata' } >
534+ < div
535+ key = { displayName }
536+ className = { TITLE_CLASS }
537+ // onMouseOver={() => {
538+ // this.dragHoverStyle(id);
539+ // }}
540+ // onMouseOut={() => {
541+ // this.dragHoverStyleRemove(id);
542+ // }}
543+ >
544+ < div
534545 id = { id }
535546 title = { codeSnippet . name }
536547 className = { DISPLAY_NAME_CLASS }
@@ -553,7 +564,7 @@ export class CodeSnippetDisplay extends React.Component<
553564 } }
554565 >
555566 { this . boldNameOnSearch ( this . state . filterValue , displayName ) }
556- </ span >
567+ </ div >
557568 < div className = { ACTION_BUTTONS_WRAPPER_CLASS } >
558569 { actionButtons . map ( ( btn : IExpandableActionButton ) => {
559570 return (
@@ -571,18 +582,33 @@ export class CodeSnippetDisplay extends React.Component<
571582 < btn . icon . react
572583 tag = "span"
573584 elementPosition = "center"
574- width = "16px"
585+ width = "21px"
586+ height = "21px"
575587 />
576588 </ button >
577589 ) ;
578590 } ) }
579591 </ div >
580592 </ div >
593+ < div className = { 'jp-codeSnippet-description' } >
594+ < p > { `${ codeSnippet . description } ` } </ p >
595+ </ div >
596+ < div className = { 'jp-codeSnippet-tags' } >
597+ { tags ? tags . map ( ( tag : string ) => this . renderTag ( tag , id ) ) : null }
598+ </ div >
581599 </ div >
582600 </ div >
583601 ) ;
584602 } ;
585603
604+ private renderTag ( tag : string , id : string ) : JSX . Element {
605+ return (
606+ < div className = { 'tag applied-tag' } key = { tag + '-' + id } >
607+ < label className = { 'tag-header' } > { tag } </ label >
608+ </ div >
609+ ) ;
610+ }
611+
586612 static getDerivedStateFromProps (
587613 props : ICodeSnippetDisplayProps ,
588614 state : ICodeSnippetDisplayState
@@ -616,8 +642,19 @@ export class CodeSnippetDisplay extends React.Component<
616642 render ( ) : React . ReactElement {
617643 return (
618644 < div >
645+ < header className = { CODE_SNIPPETS_HEADER_CLASS } >
646+ < span className = { 'jp-codeSnippet-title' } > { 'Snippets' } </ span >
647+ < addIcon . react
648+ className = { 'jp-createSnippetBtn' }
649+ tag = "span"
650+ right = "7px"
651+ top = "5px"
652+ />
653+ </ header >
619654 < SearchBar onFilter = { this . filterSnippets } />
620- < header className = { CODE_SNIPPETS_HEADER_CLASS } > { 'Snippets' } </ header >
655+ < div className = { 'jp-codeSnippet-filter' } >
656+ < button > Filter</ button >
657+ </ div >
621658 < div className = { CODE_SNIPPETS_CONTAINER } >
622659 < div >
623660 { this . state . codeSnippets . map ( ( codeSnippet , id ) =>
0 commit comments