From dbaeefc807ad78b95b53c569ddf40edbd7e4976c Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 17 May 2021 09:20:16 +0100 Subject: [PATCH] Display different modal messages for publish to gist cases --- .../src/lib/file-explorer-context-menu.tsx | 8 ++--- .../file-explorer/src/lib/file-explorer.tsx | 34 ++++++++++++++++++- .../file-explorer/src/lib/types/index.ts | 3 ++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer-context-menu.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer-context-menu.tsx index 2deb23e96a..13915aab02 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer-context-menu.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer-context-menu.tsx @@ -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) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index d450022a66..c883cb848a 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -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} /> } diff --git a/libs/remix-ui/file-explorer/src/lib/types/index.ts b/libs/remix-ui/file-explorer/src/lib/types/index.ts index 9f3f584e4d..3234818913 100644 --- a/libs/remix-ui/file-explorer/src/lib/types/index.ts +++ b/libs/remix-ui/file-explorer/src/lib/types/index.ts @@ -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,