How to use the @kui-shell/plugin-editor.lockIcon function in @kui-shell/plugin-editor

To help you get started, we’ve selected a few @kui-shell/plugin-editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / kui / plugins / plugin-openwhisk-editor-extensions / src / preload.ts View on Github external
if (!Capabilities.isHeadless()) {
    const { Models } = await import('@kui-shell/core/api/models')
    const { persisters } = await import('./lib/cmds/new')

    const getEntity = (tab: Tabs.Tab) => {
      const entity = Models.Selection.current(tab)
      entity['persister'] = persisters.actions
      debug('getEntity', entity)
      return entity
    }

    const { gotoReadonlyView, fetchAction } = await import('./lib/cmds/new')

    registerFetcher(fetchAction())

    const unlock = lockIcon({
      getEntity,
      mode: 'unlock',
      label: 'Edit',
      // icon: 'fas fa-lock',
      tooltip: 'Click to edit', // TODO externalize string
      direct: edit({
        getEntity,
        lock: ({ getEntity }) => lockIcon({ getEntity, direct: gotoReadonlyView({ getEntity }) })
      })
    })

    setTimeout(async () => {
      const { addActionMode } = await import('@kui-shell/plugin-openwhisk')
      addActionMode(unlock, 'unshift')
    })
  }