Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - CLI Tutor Mode #1572

Merged
merged 29 commits into from Aug 26, 2020
Merged

Conversation

jay-dee7
Copy link
Contributor

@jay-dee7 jay-dee7 commented Aug 1, 2020

Adds the CLI Tutor Mode, which can help with learning the IPFS Command Line Interface from the Webui/Desktop. This feature was requested in #1421

Done

  • Option to enable/disable CLI Tutor Mode from the settings page
  • If enabled, a copy-icon 📋 is shown next to the buttons/menus where those actions can be performed via IPFS' CLI
  • This icon is visible at:
    • Files Page -> inside + Import menu (Add File, Folder, Copy from IFPS)
    • Files Page -> File Menu (three dots next to a file) -> (Delete, Rename, Pin/Unpin, Download)
    • Peers Page -> next to + Add Connection
    • Settings Page -> next to Reset button in config edit box
    • Setting Page -> next to Submit button in API edit box

Pending Work:

  • I recently discovered a state management issue with the modals, I couldn't find the root cause so far, it started happening after the refactor today (1st Aug 2020)
  • After rebasing from master today, there's a small UI glitch (text in the modal actions is left aligned, I'll work it out before making this PR reviewable)
  • I have added a bunch of TODO's in the code, which can potentially help with the code cleanup
  • Files component kind of looks like a mess right now, a lot of state is being shared across mulitple components (maybe we can refactor it to make it look neat)

Here's a visual for how it looks in action: [Jessica note: these are a bit outdated now since commits for visual tweaks on 12 Aug]

Settings Page | Option to enable CLI Tutor Mode

enable-ipfs-cli-tutor-mode

Files Page | CLI Tutor Mode Enabled

cli-tutor-mode-files-page

Settings Page | CLI Tutor Mode - Open Modal

cli-tutor-mode-open-modal

Signed-off-by: Jasdeep Singh jasdeepsingh.uppal@gmail.com

@jay-dee7
Copy link
Contributor Author

jay-dee7 commented Aug 1, 2020

@jessicaschilling here's the draft for cli tutor mode, the place which would need more attention is files component, since it has a lot of shared state, please check this out and suggest any refactors/changes for places where i might have broken any acceptable coding patterns. I'll update this PR tomorrow with little of code cleanup and modal actions alignment fix

@jessicaschilling
Copy link
Contributor

Thanks, @jay-dee7! I'd like @rafaelramalho19 to look through this in more detail ... but just a heads up that he's on holiday for the next week. Don't want you to think that we are ignoring you. 😊

@jay-dee7
Copy link
Contributor Author

jay-dee7 commented Aug 1, 2020

That's okay @jessicaschilling. In-fact apologies for the delay. This should've been up way before than it did. In the meantime I'll keep on iterating over this, just to see if anything can be improved upon 😄

Copy link
Contributor

@jessicaschilling jessicaschilling left a comment

Choose a reason for hiding this comment

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

A few quick thoughts before @rafaelramalho19 reviews; two review comments inline for text changes, too:

  • Can you please center text in the "Close" and "Copy" buttons in the modal?
  • For the example shown (IPFS config file) - if the user just pastes ipfs config replace settings.json into their terminal, this won't actually work, because there's no context of settings.json. Or is this what you mean by the download icon - is that supposed to download the changes made in the window to a file settings.json? If it's the latter, we'll need to make that more clear (and there will still be issues, because just "settings.json" won't necessarily be the right directory level).
  • Overall, can you please make the size of the clipboard icon a little smaller, based on a vertical height to visually match the vertical height of the trash can icon in the three-dots context menu? (Understood that this might be numerically smaller than the trash can vertically due to inconsistencies in icon aspect ratios.)

I'll have a deeper look when you're done with your cleanup, too. 😊 Thanks!

src/components/cli-tutor-mode/CliTutorMode.js Outdated Show resolved Hide resolved
src/components/cli-tutor-mode/CliTutorMode.js Outdated Show resolved Hide resolved
@jay-dee7
Copy link
Contributor Author

jay-dee7 commented Aug 4, 2020

sure @jessicaschilling i'll make these changes ASAP. There are more things that I didn't notice initially. ContextMenu in files pages needs some work, after rebasing, the copy icon and the text aren't aligned symmetrically and some of the commands aren't correct (as in rename command in files page). I'll need some sort of verification if the commands that i did add are the correct ones.

@jay-dee7
Copy link
Contributor Author

jay-dee7 commented Aug 9, 2020

@jessicaschilling I rebased from master just a while ago, one of the incoming changes were in ApiAddressForm component and since it was written using hooks (I believe), I was not able to overwrite props easily (I'm not sure what exactly broke the prop sharing, i believe its hooks but i have no idea.). So just for the ApiAddressForm component, I've managed the state for cli-tutor-modal locally to the component, instead of using the regular redux actions. Rest of the stuff stays almost same. I think this PR is ready for review 🤞

@jessicaschilling
Copy link
Contributor

Thanks, @jay-dee7!
@rafaelramalho19 - are you able to take a look at this PR once you are back in and settled? Thank you!

@jay-dee7 jay-dee7 marked this pull request as ready for review August 9, 2020 15:35
@jay-dee7 jay-dee7 changed the title [WIP] Feature - CLI Tutor Mode Feature - CLI Tutor Mode Aug 10, 2020
src/bundles/cli-tutor-mode.js Outdated Show resolved Hide resolved
src/bundles/cli-tutor-mode.js Outdated Show resolved Hide resolved
<CopyIcon
onClick={setCliTutorModal}
className='dib fill-current-color ph2 glow o-80 pointer'
style={{ height: '28px', transform: 'scale(1.5)', verticalAlign: 'bottom', color: 'dodgerblue' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

This scale can lead to some issues in Safari. Can you try and make it without the scale?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for this, i have now added two options, one using just the bigger pixel size (height is increased) and another one using msTransform and webkitTransform. I can quickly stick to one solution but as far as i can tell, they both work as expected. webkitTransform worked okay for me on safari too

Copy link
Contributor

Choose a reason for hiding this comment

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

It works, the problem is that it renders a pixelated icon in safari (old issue unfortunately), so I would just stick with increasing the height

src/components/cli-tutor-mode/CliTutorMode.js Outdated Show resolved Hide resolved
src/components/cli-tutor-mode/CliTutorMode.js Outdated Show resolved Hide resolved
src/files/FilesPage.js Outdated Show resolved Hide resolved
</button>
<button {...props} className={`bg-animate hover-bg-near-white pa2 pointer flex items-center ${className}`}>
<CopyIcon {...props} onClick={onCliTutorMode} className='dib fill-current-color ph2 glow o-80 pointer'
style={{ height: '28px', transform: 'scale(1.3)', color: 'dodgerblue' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to avoid the transform (same as commented before)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a css class for this with webkitTransform but it would also work if we simple increased the height by 1.3X. Lemme know which way we'd like to move forward with :)

src/settings/SettingsPage.js Outdated Show resolved Hide resolved
src/settings/SettingsPage.js Outdated Show resolved Hide resolved
src/settings/SettingsPage.js Outdated Show resolved Hide resolved
jay-dee7 and others added 5 commits August 11, 2020 00:12
Signed-off-by: Jasdeep Singh <jasdeepsingh.uppal@gmail.com>
Co-authored-by: Jessica Schilling <jessica@protocol.ai>
Co-authored-by: Jessica Schilling <jessica@protocol.ai>
Signed-off-by: Jasdeep Singh <jasdeepsingh.uppal@gmail.com>
Signed-off-by: Jasdeep Singh <jasdeepsingh.uppal@gmail.com>
@jay-dee7 jay-dee7 force-pushed the jay-dee7/cli-tutor-mode branch 2 times, most recently from 8890925 to 6ff45e4 Compare August 11, 2020 21:19
@rafaelramalho19
Copy link
Contributor

After you remove the transforms, LGTM 😄

Signed-off-by: Jasdeep Singh <jasdeepsingh.uppal@gmail.com>
@jay-dee7
Copy link
Contributor Author

thanks for the amazing review @rafaelramalho19, i've change the css class to use just height and no transforms :)

@jessicaschilling
Copy link
Contributor

@jay-dee7 @lidel I'd vote for closing the dialog onclick of the "Copy" button. @jay-dee7, can you please change that?

@jay-dee7
Copy link
Contributor Author

Sure @jessicaschilling I'll make the change ASAP :)

@jessicaschilling
Copy link
Contributor

@jay-dee7 And thanks for spotting the misaligned checkbox! Fixed it. 😊

@jessicaschilling jessicaschilling added this to the v2.11 milestone Aug 14, 2020
Signed-off-by: Jasdeep Singh <jasdeepsingh.uppal@gmail.com>
Signed-off-by: Jasdeep Singh <jasdeepsingh.uppal@gmail.com>
@jay-dee7
Copy link
Contributor Author

@jessicaschilling @lidel i've added both the requested points.
Now by clicking the copy button in the modal, we copy the contents (command) and then close the modal.

Also, I've added a fix for rename command. I realized that we need to preserve the file path while renaming and we should wrap the full path path with quotes (""), because it'll throw errors if the full path contains spaces (for example a file named cat image.png would throw error in cli but if we wrap it with quotes as "cat image.png") it won't. Please let me know if we're good to go with this :)

@jessicaschilling
Copy link
Contributor

@lidel - I'm happy but will wait for your OK, please feel free to merge 😊

@jay-dee7 jay-dee7 requested a review from lidel August 20, 2020 09:37
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

@jay-dee7 nearly there! small asks inline 🙏

src/bundles/files/consts.js Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
src/files/modals/Modals.js Show resolved Hide resolved
jay-dee7 and others added 4 commits August 21, 2020 00:44
…dList

Signed-off-by: Jasdeep Singh <jasdeepsingh.uppal@gmail.com>
Without this below will fail:
ipfs files rm -r /test/white space/flowers.jpeg
This removed CLI tutor from "API Adddress" selector because it does not
make sense:

"API ADDRESS" section does not change the config of IPFS node, but
defines the API which WebUI will use when connecting to the node.
@lidel lidel mentioned this pull request Aug 21, 2020
4 tasks
text between < and > won't be translated because Transifex blackboxes
HTML tags, it is better to remove it
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

I made small tweaks in 9821bc8, 7d71641 and 8cc6d85 and run all tests locally (because CI missed them: #1595).

Everything looks ok, but i'm afk till Tuesday so leaving this open in case someone has time to tackle i18n issue described below.
If not, ok to merge and tackle the problem in separate PR.


Note on i18n: Duplicated of translation keys (cliModal and actions) are not the best, but fallbackNS does not work correctly in i18next for some reason, and I understand why it has to be like this for now. I spent some time today trying to find a fix but it proved to be huge time sink and a rabbit hole of i18next internals: we may need to leave duplicated keys as they are and revisit in separate PR.

Transifex will automatically fill all places when at least one of them is translated, so in practice it should not be a problem, and it will be easy to deduplicate keys in the future, if the issue is resolved upstream.

@jessicaschilling
Copy link
Contributor

jessicaschilling commented Aug 21, 2020

@lidel — Unless I'm missing something, I believe 881bcbf and 84b6cf4 take care of this ... per i18next docs we can explicitly reference a different namespace than the default one we declare for a given file.

I added the i18n keys for cliModal and the actions buttons to app.json since it looks like at one point that was actually intended as a highest-level or common translation file.

If this approach makes sense to you, there's an opportunity to remove other duplicate keys throughout the project — especially in the tour and actions categories — and point them at app.json, but that's off-topic enough to merit being done as a separate effort.

The way import via Webui works is:
1. `ipfs add` produces CID
2. we create a reference to that CID in MFS

We do this to produce the same CID as regular ipfs add from CLI would
do, mainly to avoid issue described in:
ipfs#676
Right now CLI tutor defaults to MFS root at /,
this makes it easier to include current path in the future.
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Thank you @jessicaschilling, I think the old i18next issue is gone, all looks good.


I've made a small fix in 5641184 to ensure CLI tutor lists import actions as the button in GUI
(ipfs add && ipfs files cp, context: #676)


nit: CLI tutor for Import commands ignores the fact we may be in a subdirectory.

Ideally /<dest-name> in import commands would be replaced with "${path}/<dest-name>" where path is the current dir in MFS. I started doing that in 3a337de but had no bandwidth to wire it up.

I think it's ok to merge with static destination, but if anyone has time to ensure path is set for these actions that would be even better for user experience.

@jessicaschilling
Copy link
Contributor

@lidel -- Thanks for calling the subdirectory detail out. I'm inclined to merge this as-is and address that in a separate issue (#1601), since I suspect we may want to make some tweaks to tutor mode overall after this gets into the hands of users for a bit.

I've also opened #1600 for consolidating repeat-use i18n keys, which I can probably take care of in the next week or two.

Thanks all (especially @jay-dee7!) for all of the work!

@jessicaschilling jessicaschilling merged commit b08b14e into ipfs:master Aug 26, 2020
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.

None yet

4 participants