Skip to content

Conversation

violetadev
Copy link
Contributor

@violetadev violetadev commented Jul 28, 2024

✨ Pull Request

📓 Referenced Issue

Fixes: #1258

ℹ️ About the PR

This PR reintroduces import/export capabilities in order to users to back up their settings and import them back.

🖼️ Testing Scenarios / Screenshots

respons.mp4

@CLAassistant
Copy link

CLAassistant commented Jul 28, 2024

CLA assistant check
All committers have signed the CLA.

@violetadev violetadev marked this pull request as ready for review July 28, 2024 21:42
Copy link
Collaborator

@manojVivek manojVivek left a comment

Choose a reason for hiding this comment

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

You pulled it off so nicely!! 👏🏼
Just a couple of minor things, looks great otherwise!

window.electron.store.set('deviceManager.previewSuites', []);
state.suites = action.payload;
state.activeSuite = action.payload[0].id;
window.electron.store.set('deviceManager.previewSuites', action.payload);
Copy link
Collaborator

@manojVivek manojVivek Jul 29, 2024

Choose a reason for hiding this comment

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

This looks like it will override the existing suites as well, wouldn't that result in a loss of data if the user already had any custom suites?

I just noticed that there was a warning message indicating this, should we try to append it to the existing suites instead of replacing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, should we add also a button to reset the whole thing so they can go to the initial clean state as well?

@@ -739,6 +739,15 @@
"contributions": [
"code"
]
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can remove this, as it will be autopopulated by allContributors bot that updates the README as well.

const mockHandleUpload = jest.fn();
const mockResetUploadedFile = jest.fn();

describe('FileUploader', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Really appreciate the unit tests! 🫡

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to add more on the ManageSuitesTool but I am having issues with the electron store, I can't seem to mock it. Do you have any idea how to mock it properly?

This is the error:

FAIL  src/renderer/components/DeviceManager/PreviewSuites/ManageSuitesTool/ManageSuitesTool.test.tsx
  ● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'store')

      4 | import { sanitizeSuites } from './utils';
      5 |
    > 6 | const activeDeviceIds: string[] = window.electron.store.get(
        |                                                   ^
      7 |   'deviceManager.activeDevices'
      8 | );
      9 |

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we need to add a mock electron object to the window before the test runs?

Something like this:

electron-mock.ts

const store = {};
window.electron = {
  store: {
    get: (key: string) => {
        return store[key];
    },
    set: (key: string, val: any) => {
       store[key] = val;
    }
  }
};

And then import this file at the top of the test file?

(haven't thought this through, just a quick suggestion)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried, I think we need to add a setup file for jest in the root. I will investigate further in a different pr

@manojVivek
Copy link
Collaborator

Also on the UI layout, shall we try the following placement for the icons:
Screenshot 2024-07-29 at 9 22 29 AM

And remove the dividers so that it will indicate that both suites and devices will be exported/imported.

onClick={() => setOpen(true)}
>
<Icon
icon="mdi:folder-upload"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm leaning towards uil:import and uil:export for the icons?
As the current ones look more like a folder import/export to me. Wdyt?

@violetadev
Copy link
Contributor Author

Also on the UI layout, shall we try the following placement for the icons: Screenshot 2024-07-29 at 9 22 29 AM

And remove the dividers so that it will indicate that both suites and devices will be exported/imported.

yes, this was my first approach, but there are a few issues with this:

  1. The import / export refers to importing not only suites, but also custom devices created by the user, and that title refers to the suites.
  2. If I add it there, then I have to contaminate the PreviewSuites component with the setCustomDevices (which is unrelated) and then do prop drilling to the new component because we don't have a disptach action for it, so I need to pass it as prop.

I suggest instead we do something like this to improve the user experience (I did this over the screenshot and it's not very polished but so you get the idea):
Screenshot 2024-07-29 at 09 52 35

  1. Adjust font sizes and add accordion for each of the sections: suites, default devices and custom devices
  2. Move the title from the top to under the x space, so we can align any settings CTAs we have that are global to this screen

if you are ok with this I can implement it in this same PR or open a new one following up (which one do you prefer?)

violetadev added 2 commits July 29, 2024 22:04
@violetadev
Copy link
Contributor Author

Now instead of replacing, it merges whatever was there with the new.

replace.mp4

Also implements accordion and rearranges UI

newui.mp4

@manojVivek
Copy link
Collaborator

Also on the UI layout, shall we try the following placement for the icons: Screenshot 2024-07-29 at 9 22 29 AM
And remove the dividers so that it will indicate that both suites and devices will be exported/imported.

yes, this was my first approach, but there are a few issues with this:

  1. The import / export refers to importing not only suites, but also custom devices created by the user, and that title refers to the suites.
  2. If I add it there, then I have to contaminate the PreviewSuites component with the setCustomDevices (which is unrelated) and then do prop drilling to the new component because we don't have a disptach action for it, so I need to pass it as prop.

I suggest instead we do something like this to improve the user experience (I did this over the screenshot and it's not very polished but so you get the idea): Screenshot 2024-07-29 at 09 52 35

  1. Adjust font sizes and add accordion for each of the sections: suites, default devices and custom devices
  2. Move the title from the top to under the x space, so we can align any settings CTAs we have that are global to this screen

if you are ok with this I can implement it in this same PR or open a new one following up (which one do you prefer?)

Yes, I like the described approach. Let's go with that.

@violetadev violetadev requested a review from manojVivek July 30, 2024 10:53
@manojVivek
Copy link
Collaborator

Merging this in now. You pulled it off so great for your first commit to the repo! @violetadev 👏🏼

Thank you so much! Looking forward to more like this in the future.

@manojVivek manojVivek merged commit 3a00333 into responsively-org:main Jul 31, 2024
4 checks passed
@manojVivek
Copy link
Collaborator

@all-contributors Please add @violetadev for code.

Copy link
Contributor

@manojVivek

I've put up a pull request to add @violetadev! 🎉

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.

Export/import option missing again in 1.12.0
3 participants