diff --git a/client/components/dropdown/dropdown.jsx b/client/components/dropdown/dropdown.jsx index e06015eae..f87fc9a46 100644 --- a/client/components/dropdown/dropdown.jsx +++ b/client/components/dropdown/dropdown.jsx @@ -22,7 +22,7 @@ import _ from 'lodash'; // use react context to keep track of the menu depth (menus in menus) const MenuDepthContext = React.createContext(0); -const Dropdown = ({ groupName, className = null, icon, children, color = null, customTrigger, ...props })=>{ +const Dropdown = ({ groupName, className = null, icon, children, color = null, customTrigger, disabled = false, ...props })=>{ const reactId = useId(); const safeId = reactId.replace(/[^a-zA-Z0-9_-]/g, ''); const menuId = `${_.kebabCase(groupName)}-${safeId}-menu`; @@ -41,7 +41,7 @@ const Dropdown = ({ groupName, className = null, icon, children, color = null, c useEffect(()=>{ triggerRef.current?.setAttribute('style', `anchor-name: ${anchorName}`); menuRef.current?.setAttribute('style', `position-anchor: ${anchorName}`); - }, [anchorName]); + }, [anchorName, disabled]); // hide popover with click inside iframe (not supported by light dismiss) useEffect(()=>{ @@ -91,8 +91,23 @@ const Dropdown = ({ groupName, className = null, icon, children, color = null, c document.querySelectorAll('.menu-list:popover-open').forEach((openMenu)=>openMenu.hidePopover()); }; + if(disabled){ + return ( +
  • + +
  • + ); + } + return ( -
  • +
  • +
  • + ); + })} + + ); + }; - if(diffSecs > 60) diffString = `about ${Math.floor(diffSecs / 60)} minutes ago`; - if(diffSecs > (60 * 60)) diffString = `about ${Math.floor(diffSecs / (60 * 60))} hours ago`; - if(diffSecs > (24 * 60 * 60)) diffString = `about ${Math.floor(diffSecs / (24 * 60 * 60))} days ago`; - if(diffSecs > (7 * 24 * 60 * 60)) diffString = `about ${Math.floor(diffSecs / (7 * 24 * 60 * 60))} weeks ago`; - - return
    {this.replaceContent(item);}} > - - v{item.version} : {diffString} -
    ; - })} - ; - }, - - renderEditorButtons : function(){ - if(!this.props.showEditButtons) return; + const renderEditorButtons =()=>{ + if(!showEditButtons) return; return (
    - {this.props.view !== 'meta' && this.props.view !== 'settings' && <>
    - - -
    - - -
    }
    - - - - -
    ); - }, + }; - render : function(){ - return
    - {this.renderSnippetGroups()} - {this.renderEditorButtons()} -
    ; - } -}); + return
    + {renderSnippetGroups()} + {renderEditorButtons()} +
    ; +}; -export default Snippetbar; +export default SnippetBar; -const SnippetGroup = createReactClass({ - displayName : 'SnippetGroup', - getDefaultProps : function() { - return { - brew : {}, - groupName : '', - icon : 'fas fa-rocket', - snippets : [], - onSnippetClick : function(){}, - }; - }, - handleSnippetClick : function(e, snippet){ - this.props.onSnippetClick(execute(snippet.gen, this.props)); - }, - renderSnippets : function(snippets){ +const SnippetGroup = (props)=>{ + const { + brew = {}, + groupName = '', + icon = 'fas fa-rocket', + snippets = [], + onSnippetClick = function(){}, + } = props; + + const handleSnippetClick = (e, snippet)=>{ + onSnippetClick(execute(snippet.gen, props)); + }; + const renderSnippets = (snippets)=>{ return _.map(snippets, (snippet)=>{ if(!snippet.subsnippets){ return (
  • -