feat: replaceResource

This commit is contained in:
cha0s 2022-03-20 14:16:58 -05:00
parent 9206fc2851
commit 67ad77dfd7
4 changed files with 15 additions and 3 deletions

View File

@ -31,6 +31,7 @@
"@avocado/resource-persea": "^3.0.0",
"@flecks/core": "^1.4.1",
"@flecks/react": "^1.4.1",
"@flecks/redux": "^1.4.1",
"natsort": "^2.0.2"
},
"devDependencies": {

View File

@ -1,9 +1,11 @@
import {Code} from '@avocado/react';
import {useJsonPatcher} from '@avocado/resource-persea';
import {Context, replaceResource} from '@avocado/resource-persea';
import {
PropTypes,
React,
useContext,
} from '@flecks/react';
import {useDispatch} from '@flecks/redux';
import locals from './component.module.scss';
@ -11,14 +13,17 @@ const ScriptComponent = ({
path,
resource,
}) => {
const patch = useJsonPatcher();
const dispatch = useDispatch();
const {uri, uuid} = useContext(Context);
return (
<Code
className={locals.code}
code={resource}
fontSize={14}
name={path}
onChange={patch.onChange(path)}
onChange={(event, value) => {
dispatch(replaceResource({uri, project: uuid, value}));
}}
/>
);
};

View File

@ -1 +1,2 @@
export * from './json';
export * from './replace';

View File

@ -0,0 +1,5 @@
import {createAction} from '@flecks/redux';
export const replaceResource = createAction('@avocado/resource/replaceResource');
export default () => {};