Skip to content

feat: add ability to create file#242

Merged
cguedes merged 19 commits into
mainfrom
209-add-ability-to-create-file
Jul 5, 2023
Merged

feat: add ability to create file#242
cguedes merged 19 commits into
mainfrom
209-add-ability-to-create-file

Conversation

@sehyod

@sehyod sehyod commented Jul 3, 2023

Copy link
Copy Markdown
Collaborator

This adds the shortcut Cmd+N to create a new file (and the corresponding item in the menu)

This also refactors the file tree component to use an atom. This enables several things:

  • refreshing the file tree from anywhere
  • saving the file tree state even when the explorer component is unmounted (to keep the collapsed/uncollapsed state of folders for example)
  • creating a file in any folder (the atom exists but the UI has not been implemented yet)
    This will also make the creation of delete and rename features easier

Closes #209

@codecov

codecov Bot commented Jul 3, 2023

Copy link
Copy Markdown

Codecov Report

Merging #242 (53339f0) into main (616974e) will increase coverage by 9.39%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #242      +/-   ##
==========================================
+ Coverage   75.27%   84.66%   +9.39%     
==========================================
  Files         103       12      -91     
  Lines        5370      652    -4718     
  Branches      451        0     -451     
==========================================
- Hits         4042      552    -3490     
+ Misses       1313      100    -1213     
+ Partials       15        0      -15     

see 90 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@sehyod sehyod marked this pull request as ready for review July 4, 2023 09:57
@sehyod sehyod requested a review from cguedes July 4, 2023 09:57

@cguedes cguedes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally great PR.
Added some note about the atoms complexity (collapsed) and other minor comments.

Comment thread src-tauri/src/core/menu.rs Outdated
Comment thread src/atoms/__tests__/test-fixtures.ts Outdated
Comment on lines +67 to +70
collapsedAtom: atom(
(get) => get(collapsedAtom),
(get, set) => set(collapsedAtom, !get(collapsedAtom)),
),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make this a primitive atom and split the toggle (that currently is implemented in the writable part) to a new atom action.

Or instead keep only the primitive atom and update usages to be explicit in the action:

const [collapsed, setCollapsed] = useAtom(fileExplorerEntry.collapsedAtom);
...
onClick={() => toggleCollapsed(!collapsed)}

Comment thread src/atoms/__tests__/fileEntryActions.test.ts Outdated
Comment thread src/atoms/__tests__/fileEntryActions.test.ts Outdated
Comment thread src/atoms/__tests__/fileExplorerActions.test.ts Outdated
}

async function isValidName(name: string, openEditorNames: string[]) {
return !openEditorNames.includes(name) && !(await exists(`${await getBaseDir()}/${name}`));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this dependency of tauri (and filesystem) here.

For the exists, I think that should be fine to trust that the store is in sync with the filesystem (then we can implement a fs watcher to make sure that the file explorer is in sync).

For the base dir, if needed, we should get is as parameter (or stored in a core atom, and updated on load)

Comment thread src/application/sidebar/ExplorerPanel.tsx Outdated
Comment thread src/components/FileEntryTree.tsx Outdated
Comment thread src/components/FileEntryTree.tsx Outdated
cguedes
cguedes previously approved these changes Jul 5, 2023
@cguedes cguedes merged commit 23015cd into main Jul 5, 2023
@cguedes cguedes deleted the 209-add-ability-to-create-file branch July 5, 2023 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to create a new file

2 participants