Display different modal messages for publish to gist cases

pull/1185/head
ioedeveloper 4 years ago
parent e51bfffccb
commit dbaeefc807
  1. 8
      libs/remix-ui/file-explorer/src/lib/file-explorer-context-menu.tsx
  2. 34
      libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
  3. 3
      libs/remix-ui/file-explorer/src/lib/types/index.ts

@ -4,7 +4,7 @@ import { FileExplorerContextMenuProps } from './types'
import './css/file-explorer-context-menu.css'
export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) => {
const { actions, createNewFile, createNewFolder, deletePath, renamePath, hideContextMenu, publishToGist, runScript, emit, pageX, pageY, path, type, ...otherProps } = props
const { actions, createNewFile, createNewFolder, deletePath, renamePath, hideContextMenu, pushChangesToGist, publishFileToGist, publishFolderToGist, runScript, emit, pageX, pageY, path, type, ...otherProps } = props
const contextMenuRef = useRef(null)
useEffect(() => {
@ -50,13 +50,13 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
deletePath(path)
break
case 'Push changes to gist':
publishToGist(path, type)
pushChangesToGist(path, type)
break
case 'Publish folder to gist':
publishToGist(path, type)
publishFolderToGist(path, type)
break
case 'Publish file to gist':
publishToGist(path, type)
publishFileToGist(path, type)
break
case 'Run':
runScript(path)

@ -382,6 +382,36 @@ export const FileExplorer = (props: FileExplorerProps) => {
modal('Create a public gist', `Are you sure you want to anonymously publish all your files in the ${name} workspace as a public gist on github.com?`, 'OK', () => toGist(path, type), 'Cancel', () => {})
}
const pushChangesToGist = (path?: string, type?: string) => {
modal('Create a public gist', 'Are you sure you want to push changes to remote gist file on github.com?', {
label: 'OK',
fn: () => toGist(path, type)
}, {
label: 'Cancel',
fn: () => {}
})
}
const publishFolderToGist = (path?: string, type?: string) => {
modal('Create a public gist', `Are you sure you want to anonymously publish all your files in the ${path} folder as a public gist on github.com?`, {
label: 'OK',
fn: () => toGist(path, type)
}, {
label: 'Cancel',
fn: () => {}
})
}
const publishFileToGist = (path?: string, type?: string) => {
modal('Create a public gist', `Are you sure you want to anonymously publish ${path} file as a public gist on github.com?`, {
label: 'OK',
fn: () => toGist(path, type)
}, {
label: 'Cancel',
fn: () => {}
})
}
const toGist = (path?: string, type?: string) => {
const filesProvider = fileSystem.provider.provider
const proccedResult = function (error, data) {
@ -865,7 +895,9 @@ export const FileExplorer = (props: FileExplorerProps) => {
e.stopPropagation()
handleMouseOver(state.focusContext.element)
}}
publishToGist={publishToGist}
pushChangesToGist={pushChangesToGist}
publishFolderToGist={publishFolderToGist}
publishFileToGist={publishFileToGist}
/>
}
</div>

@ -37,6 +37,9 @@ export interface FileExplorerContextMenuProps {
renamePath: (path: string, type: string) => void,
hideContextMenu: () => void,
publishToGist?: (path?: string, type?: string) => void,
pushChangesToGist?: (path?: string, type?: string) => void,
publishFolderToGist?: (path?: string, type?: string) => void,
publishFileToGist?: (path?: string, type?: string) => void,
runScript?: (path: string) => void,
emit?: (id: string, path: string) => void,
pageX: number,

Loading…
Cancel
Save