Listen to notifications and display modal

pull/5370/head
ioedeveloper 3 years ago
parent f7774d72bb
commit 61d3551b4e
  1. 32
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  2. 6
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx

@ -60,7 +60,7 @@ export const displayNotification = (title: string, message: string, labelOk: str
export const hideNotification = () => { export const hideNotification = () => {
return { return {
type: 'DISPLAY_NOTIFICATION' type: 'HIDE_NOTIFICATION'
} }
} }
@ -128,27 +128,25 @@ const createWorkspaceTemplate = async (workspaceName: string, setDefaults = true
const response: AxiosResponse = await axios.get(`https://api.github.com/gists/${gistId}`) const response: AxiosResponse = await axios.get(`https://api.github.com/gists/${gistId}`)
const data = response.data const data = response.data
console.log('data: ', data)
if (!data.files) { if (!data.files) {
dispatch(displayNotification('Gist load error', 'No files found', 'OK', null, () => {}, null)) return dispatch(displayNotification('Gist load error', 'No files found', 'OK', null, () => {}, null))
return
} }
// const obj = {} const obj = {}
// Object.keys(data.files).forEach((element) => { Object.keys(data.files).forEach((element) => {
// const path = element.replace(/\.\.\./g, '/') const path = element.replace(/\.\.\./g, '/')
// obj['/' + 'gist-' + gistId + '/' + path] = data.files[element] obj['/' + 'gist-' + gistId + '/' + path] = data.files[element]
// }) })
// fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => { plugin.fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => {
// if (!errorLoadingFile) { if (!errorLoadingFile) {
// const provider = fileManager.getProvider('workspace') const provider = plugin.fileManager.getProvider('workspace')
// provider.lastLoadedGistId = gistId provider.lastLoadedGistId = gistId
// } else { } else {
// // modalDialogCustom.alert('', errorLoadingFile.message || errorLoadingFile) displayNotification('', errorLoadingFile.message || errorLoadingFile, 'OK', null, () => {}, null)
// } }
// }) })
} catch (e) { } catch (e) {
dispatch(displayNotification('Gist load error', e.message, 'OK', null, () => {}, null)) dispatch(displayNotification('Gist load error', e.message, 'OK', null, () => {}, null))
console.error(e) console.error(e)

@ -56,6 +56,12 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
} }
}, [modals]) }, [modals])
useEffect(() => {
if (fs.notification.title) {
modal(fs.notification.title, fs.notification.message, fs.notification.labelOk, fs.notification.actionOk, fs.notification.labelCancel, fs.notification.actionCancel)
}
}, [fs.notification])
const handleHideModal = () => { const handleHideModal = () => {
setFocusModal(modal => { setFocusModal(modal => {
return { ...modal, hide: true, message: null } return { ...modal, hide: true, message: null }

Loading…
Cancel
Save