Skip to content

Commit

Permalink
merge cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jas Kuner committed Oct 8, 2020
1 parent 8dd59c1 commit 8a5cfd8
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 35 deletions.
6 changes: 1 addition & 5 deletions build_scripts/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ module.exports = {
host: '0.0.0.0',
port: 8080,
disableHostCheck: true,
hot: !helpers.isProduction,
proxy: {
context: ['/graphql', '/files'],
target: 'http://localhost:3000'
}
hot: !helpers.isProduction
}
}
25 changes: 0 additions & 25 deletions src/browser/AppInit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,31 +134,6 @@ const client = new ApolloClient({
link: uploadLink
})

// @todo: will clean this Apollo stuff up in next PR
// typePolicies allow apollo cache to use these fields as 'id'
// for automated cache updates when updating a single existing entity
const apolloCache = new InMemoryCache({
typePolicies: {
RelateFile: {
keyFields: ['name', 'directory']
}
}
})

// apollo-upload-client
// https://www.apollographql.com/blog/file-uploads-with-apollo-server-2-0-5db2f3f60675/
const uploadLink = createUploadLink({
uri: '/graphql',
headers: {
'keep-alive': 'true'
}
})

const client = new ApolloClient({
cache: apolloCache,
link: uploadLink
})

const AppInit = () => {
return (
<Provider store={store}>
Expand Down
2 changes: 2 additions & 0 deletions src/browser/modules/App/keyboardShortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Bus } from 'suber'
export const isMac = /Mac|iPad/.test(navigator.platform)
const modKey = isMac ? 'metaKey' : 'ctrlKey'

export const isWindows = /Win32/.test(navigator.platform)

type ModifierKey = 'metaKey' | 'altKey' | 'ctrlKey'
const printModifiers: Record<ModifierKey, string> = {
altKey: isMac ? '⌥' : 'alt',
Expand Down
5 changes: 5 additions & 0 deletions src/browser/modules/Editor/ProjectFilesButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
PROJECT_FILES_UNMOUNTED
} from 'browser/modules/Sidebar/project-files.constants'
import { useMutation } from '@apollo/client'
import { isWindows } from '../App/keyboardShortcuts'

const PROJECT_EDITOR_BUTTON_TITLE = 'Project File'
const PROJECT_SAVE_EDITOR_BUTTON_TITLE = 'Save Project File'
Expand Down Expand Up @@ -157,6 +158,9 @@ const ProjectFileButton = ({
[editorValue()],
activeRelateFile.name
),
destination: isWindows
? `${activeRelateFile.directory}\\${activeRelateFile.name}`
: `${activeRelateFile.directory}/${activeRelateFile.name}`,
overwrite: true
}
})
Expand Down Expand Up @@ -196,6 +200,7 @@ const ProjectFileButton = ({
const mapStateToProps = (state: any) => {
return {
isDrawerOpen: state.drawer === PROJECT_FILES_DRAWER_NAME,
// currently only Desktop specific
isRelateAvailable:
state.app.relateUrl &&
state.app.relateApiToken &&
Expand Down
2 changes: 1 addition & 1 deletion src/browser/modules/Sidebar/ProjectFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const ProjectFiles = ({ bus, projectId }: ProjectFiles) => {
fileUpload: new File(
[fileContents],
`${fileName}${CYPHER_FILE_EXTENSION}`
)
) // no destination; only saving to Project root at this point
},
update: (cache, result) =>
updateCacheAddProjectFile(cache, result, projectId)
Expand Down
8 changes: 5 additions & 3 deletions src/browser/modules/Sidebar/ProjectsFilesScripts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { withBus } from 'react-suber'
import { connect } from 'react-redux'
import MyScripts from '@relate-by-ui/saved-scripts'
import { useQuery, useMutation, ApolloError } from '@apollo/client'
import path from 'path'
import { filter, size, omit } from 'lodash-es'

import * as editor from 'shared/modules/editor/editorDuck'
Expand All @@ -43,6 +42,7 @@ import {
} from './project-files.constants'
import Render from 'browser-components/Render'
import { Bus } from 'suber'
import { isWindows } from 'browser/modules/App/keyboardShortcuts'

interface ProjectFilesError {
apolloErrors: (ApolloError | undefined)[]
Expand Down Expand Up @@ -121,7 +121,7 @@ function ProjectFilesScripts(props: ProjectFilesScripts): JSX.Element {
const [removeFile, { error: removeProjectFileError }] = useMutation(
DELETE_PROJECT_FILE
)
const [projectFiles, setProjectFiles] = useState<IFavorite[]>([])
const [projectFiles, setProjectFiles] = useState<Favorite[]>([])

useEffect(() => {
let isStillMounted = true
Expand Down Expand Up @@ -170,7 +170,9 @@ function ProjectFilesScripts(props: ProjectFilesScripts): JSX.Element {
title: 'Project Files',
onRemoveScript: async (favorite: Favorite) => {
const directory = favorite.path.substring(1) // remove SLASH from path
const filePath = path.join(directory, favorite.name)
const filePath = isWindows
? `${directory}\\${favorite.name}`
: `${directory}/${favorite.name}`
try {
const { data } = await removeFile({
variables: ProjectFileMutationVars(filePath, props.projectId),
Expand Down
1 change: 1 addition & 0 deletions src/browser/modules/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const mapStateToProps = (state: any) => {
neo4jConnectionState: connectionState,
loadSync: useBrowserSync(state),
showStaticScripts: state.settings.showSampleScripts,
// currently only Desktop specific
isRelateAvailable:
state.app.relateUrl &&
state.app.relateApiToken &&
Expand Down
2 changes: 1 addition & 1 deletion src/browser/modules/Sidebar/project-files.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const getProjectFileContents = (
'X-API-Token': apiToken,
'X-Client-Id': clientId
})
.then(body => body.text())
.then(body => body.text()) // currently cypher/text file specific
.catch(e => console.log(`Unable to get file ${name}\n`, e))

const NEW_LINE = '\n'
Expand Down

0 comments on commit 8a5cfd8

Please sign in to comment.