Skip to content

Commit dc6db64

Browse files
committed
Integrate create and delete env actions
1 parent 66264b1 commit dc6db64

File tree

7 files changed

+7
-18
lines changed

7 files changed

+7
-18
lines changed

packages/flowtest-electron/src/ipc/collection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
161161
ipcMain.handle('renderer:delete-environment', async (event, collectionPath, name) => {
162162
try {
163163
const envDir = path.join(collectionPath, 'environments');
164-
deleteFile(path.join(envDir, `${name}.env`));
165-
console.log(`Delete file: ${name}.env`);
164+
deleteFile(path.join(envDir, name));
165+
console.log(`Delete file: ${name}`);
166166
} catch (error) {
167167
return Promise.reject(error);
168168
}

src/components/molecules/flow/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ const Flow = ({ tabId, collectionId, flowData }) => {
156156

157157
useEffect(() => {
158158
// skip inital render
159-
if (isEqual(nodes, []) && isEqual(edges, [])) {
159+
if (flowData === undefined || (isEqual(nodes, []) && isEqual(edges, []))) {
160160
return;
161161
}
162162
if (flowData && isEqual(JSON.parse(JSON.stringify(nodes)), flowData.nodes) && isEqual(edges, flowData.edges)) {

src/components/molecules/modals/sidebar/NewLabelModal.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const NewLabelModal = ({ closeFn = () => null, open = false, pathName, collectio
3939
as='h3'
4040
className='pb-4 text-lg font-semibold text-center text-gray-900 border-b border-neutral-300'
4141
>
42-
Create a new folder
42+
{`Create a ${menuOption}`}
4343
</Dialog.Title>
4444
<div className='mt-6'>
4545
<input
@@ -97,7 +97,6 @@ const NewLabelModal = ({ closeFn = () => null, open = false, pathName, collectio
9797
// wont be needing it here but just putting it for testing
9898
console.log(`\n Creating a new collection by the name : ${labelValue} \n`);
9999
} else if (menuOption === DirectoryOptionsActions.addNewEnvironment.value) {
100-
console.log(`\n Creating a new environment file by the name : ${labelValue} \n`);
101100
createEnvironmentFile(labelValue, collectionId)
102101
.then((result) => {
103102
console.log(
@@ -106,7 +105,6 @@ const NewLabelModal = ({ closeFn = () => null, open = false, pathName, collectio
106105
})
107106
.catch((error) => {
108107
// TODO: show error in UI
109-
console.log(`\n \n \n RACHIIIIITT \n \n \n`);
110108
console.log(`Error creating new environment: ${error}`);
111109
closeFn();
112110
});

src/components/molecules/sidebar/content/Environment.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ const Environment = ({ collectionId, collection }) => {
4646
<div
4747
className='relative inline-block p-2 text-left transition duration-200 ease-out rounded rounded-l-none hover:bg-slate-200'
4848
onClick={() => {
49-
console.log(
50-
`Deleting environment: name = ${environment.name}, path = ${environment.pathname}, collectionId = ${collectionId}`,
51-
);
52-
deleteEnvironmentFile(environment.pathname, collectionId)
49+
deleteEnvironmentFile(environment.name, collectionId)
5350
.then((result) => {
5451
console.log(
5552
`Deleted environment: name = ${environment.name}, path = ${environment.pathname}, collectionId = ${collectionId}, result: ${result}`,

src/components/molecules/sidebar/content/Environments.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,10 @@ const Environments = ({ collections }) => {
1717
const clickFrom = clickFromElementDataSet?.clickFrom;
1818

1919
if (clickFrom && clickFrom === 'env-options-menu') {
20-
console.log(`\n Environments CLICK FROM : ${clickFrom} \n`);
2120
const itemType = clickFromElementDataSet?.itemType;
2221
const optionsMenuItem = clickFromElementDataSet?.optionsMenuItem;
2322
const pathName = clickFromElementDataSet?.pathName;
2423

25-
console.log(
26-
`\n Environments: ${itemType} : ${optionsMenuItem} : ${JSON.stringify(clickFromElementDataSet)} \n`,
27-
);
28-
2924
setSelectedPathName(pathName);
3025
setSelectedCollectionId(collections[0].id);
3126
setSelectedMenuItem(optionsMenuItem);

src/components/organisms/SideBar.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Content from 'components/molecules/sidebar/content';
66

77
const SideBar = () => {
88
const collections = useCollectionStore((state) => state.collections);
9-
console.log(JSON.stringify(collections));
109
return (
1110
<div className='flex-auto'>
1211
<SideBarHeader />

src/service/collection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const createEnvironmentFile = (name, collectionId) => {
8787
const collection = useCollectionStore.getState().collections.find((c) => c.id === collectionId);
8888

8989
if (collection) {
90-
const existingEnv = collection.enviroments.find((e) => e.name === name);
90+
const existingEnv = collection.environments.find((e) => e.name === `${name}.env`);
9191
if (existingEnv) {
9292
return Promise.reject(new Error('An environment with the same name already exists'));
9393
} else {
@@ -134,7 +134,7 @@ export const deleteEnvironmentFile = (name, collectionId) => {
134134
const collection = useCollectionStore.getState().collections.find((c) => c.id === collectionId);
135135

136136
if (collection) {
137-
const existingEnv = collection.enviroments.find((e) => e.name === name);
137+
const existingEnv = collection.environments.find((e) => e.name === name);
138138
if (existingEnv) {
139139
return new Promise((resolve, reject) => {
140140
ipcRenderer.invoke('renderer:delete-environment', collection.pathname, name).then(resolve).catch(reject);

0 commit comments

Comments
 (0)