parent
e976d37ab1
commit
e7dd6f07e3
@ -1,8 +1,9 @@ |
||||
{ |
||||
"extends": "../../tsconfig.base.json", |
||||
"compilerOptions": { |
||||
"jsx": "react", |
||||
"types": ["node"], |
||||
"esModuleInterop": true |
||||
}, |
||||
"include": ["**/*.ts"] |
||||
"include": ["**/*.ts", "src/lib/code-parser.tsx"] |
||||
} |
@ -1,2 +1,3 @@ |
||||
export * from './lib/providers/FileSystemProvider' |
||||
export * from './lib/contexts' |
||||
export { fileState, fileStateType } from './lib/types/index' |
@ -0,0 +1,56 @@ |
||||
// eslint-disable-next-line no-use-before-define
|
||||
import React, { useEffect, useState } from 'react' |
||||
import { FileType, fileState, fileStateType } from '../types' |
||||
import FileStateCustom from './filestates/file-state-custom' |
||||
import FileStateError from './filestates/file-state-error' |
||||
import FileStateWarning from './filestates/file-state-warning' |
||||
// import FileStateModified from './filestates/file-state-modified'
|
||||
// import FileStateUntracked from './filestates/file-state-untracked'
|
||||
|
||||
export type fileStateProps = { |
||||
file: FileType, |
||||
fileState: fileState[] |
||||
} |
||||
|
||||
export const FileState = (props: fileStateProps) => { |
||||
const [state, setState] = useState<fileState>(undefined) |
||||
useEffect(() => { |
||||
console.log(props.file) |
||||
console.log(props.fileState) |
||||
setState(props.fileState.find((st) => st.path === props.file.path)) |
||||
}, [props.fileState]) |
||||
|
||||
const getTags = function () { |
||||
if (state) { |
||||
const types = state.fileStateType |
||||
const elements: any[] = [] |
||||
|
||||
for (const type of types) { |
||||
switch (type) { |
||||
case fileStateType.Modified: |
||||
//elements.push(<FileStateModified key={type}/>)
|
||||
break |
||||
case fileStateType.Untracked: |
||||
//elements.push(<FileStateUntracked key={type}/>)
|
||||
break |
||||
case fileStateType.Error: |
||||
elements.push(<FileStateError fileState={state} key={type} />) |
||||
break |
||||
case fileStateType.Warning: |
||||
elements.push(<FileStateWarning fileState={state} key={type} />) |
||||
break |
||||
case fileStateType.Custom: |
||||
elements.push(<FileStateCustom fileState={state} key={type} />) |
||||
break |
||||
} |
||||
} |
||||
return elements |
||||
} |
||||
} |
||||
|
||||
return <> |
||||
{getTags()} |
||||
</> |
||||
} |
||||
|
||||
export default FileState |
@ -0,0 +1,13 @@ |
||||
// eslint-disable-next-line no-use-before-define
|
||||
import React from 'react' |
||||
import { fileState } from '../../types' |
||||
|
||||
const FileStateError = (props: { |
||||
fileState: fileState |
||||
}) => { |
||||
return <><span className={`${props.fileState.fileStateIconClass}pr-2`}> |
||||
{props.fileState.fileStateIcon} |
||||
</span></> |
||||
} |
||||
|
||||
export default FileStateError |
@ -0,0 +1,11 @@ |
||||
// eslint-disable-next-line no-use-before-define
|
||||
import React from 'react' |
||||
import { fileState } from '../../types' |
||||
|
||||
const FileStateError = (props: { |
||||
fileState: fileState |
||||
}) => { |
||||
return <><span className={`${props.fileState.fileStateIconClass} text-danger pr-2`}>⬤</span></> |
||||
} |
||||
|
||||
export default FileStateError |
@ -0,0 +1,11 @@ |
||||
// eslint-disable-next-line no-use-before-define
|
||||
import React from 'react' |
||||
import { fileState } from '../../types' |
||||
|
||||
const FileStateWarning = (props: { |
||||
fileState: fileState |
||||
}) => { |
||||
return <><span className={`${props.fileState.fileStateIconClass} text-warning pr-2`}>⬤</span></> |
||||
} |
||||
|
||||
export default FileStateWarning |
Loading…
Reference in new issue