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

feat(launchpad): Directory Upload in Global Mode #18165

Merged
merged 8 commits into from
Sep 22, 2021

Conversation

marktnoonan
Copy link
Contributor

@marktnoonan marktnoonan commented Sep 20, 2021

How has the user experience changed?

No visible change. But directory upload is now possible by

  • Dragging a directory into the drop zone
  • Clicking the drop zone
  • Interacting with the "browse manually" button

file-upload

How to test

Upload a project folder by dragging it to the drop zone or manually adding it. A hidden <div> element with the test id upload-name should be populated with the name of your project.

Additional Information

When dragging, this allows users to drag any file in, not specifically directories. If the manual upload feature is used, this does currently only allow directories. Not sure if that issue for drag is something we want to dig into in this PR. It may be better handled when we add the general handling of uploaded files and go to whatever error state is needed when the upload was not a cypress project.

PR Tasks

  • Have tests been added/updated?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 20, 2021

Thanks for taking the time to open a PR!

@CLAassistant
Copy link

CLAassistant commented Sep 20, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@JessicaSachs JessicaSachs left a comment

Choose a reason for hiding this comment

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

This looks good to me, but I have to check it out and run it manually still.

@ImCesar ImCesar self-requested a review September 20, 2021 21:02
@ImCesar
Copy link
Contributor

ImCesar commented Sep 20, 2021

Currently we add a project with the directories path. Technically I don't think it's the biggest deal if we can only select a file because we can chop off the file and send the directory path to the addProject mutation. From a DX perspective it may be a bit confusing on what file the developer is supposed to drag into this field. Does it really matter if we chop off the file from the path? Is it better to go with the cypress.json file for consistency?

Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

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

Some comments

packages/launchpad/src/global/GlobalEmpty.vue Outdated Show resolved Hide resolved
packages/launchpad/src/global/GlobalEmpty.vue Outdated Show resolved Hide resolved
watch(files, (newVal) => {
const uploadLength = newVal.length;
const latestUpload = newVal[uploadLength - 1]
selectProject(latestUpload)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a null check here (maybe, maybe not?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the selectProject function is up and running, here we should probably validate that the directory that was dragged in is actually a Cypress project, and go to an error state if it's not.

Though if we don't have that flow in another ticket yet, maybe now's the time to pin down that interaction?

packages/launchpad/src/global/GlobalEmpty.vue Outdated Show resolved Hide resolved

onMounted(() => {
// TODO: remove this when vue3-file-selector supports setting this attribute
document.querySelector('input[type=file]')?.setAttribute('webkitdirectory', 'webkitdirectory')
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to avoid potentially accidentally selecting another file input, we could scope the query to this component with a template ref:

<template>
  <div ref="root">
    <!-- ... -->
  </div>
</template>

<script setup>
const root = ref<HTMLDivElement>()

onMounted(() => {
  root.value?.querySelector('input')
})
</script>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this seems good, done

marktnoonan and others added 2 commits September 21, 2021 08:55
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
@marktnoonan marktnoonan changed the title feat(launchpad): File Upload in Global Mode feat(launchpad): Directory Upload in Global Mode Sep 21, 2021
@marktnoonan
Copy link
Contributor Author

@ImCesar In this situation people will be able to drag in a directory, I edited the PR to use that wording as it was unclear before. The main issue is that currently, using the drag feature, they could also upload any other regular file. During manual upload, they can only pick directories, so it's going to force them to pick the project folder.

But I could totally see somebody dragging a cypress.json file in as a 'project'. We might need to explain somewhere that a "project" means "directory containing a cypress.json", or whatever our exact rules are. Or just, if we get a path that's not a directory, check the parent like you suggest.

That validation can happen here and get some feedback to the user about why their upload didn't work, though it may go well with the ticket that implements the addProject functionality, since I guess there you are already doing things that would reveal if the path was not a real project.

@lmiller1990 lmiller1990 self-requested a review September 22, 2021 01:19
@lmiller1990
Copy link
Contributor

Weird, not sure why circle is not running here. Code looks good though.

@lmiller1990 lmiller1990 merged commit 3b88289 into unified-desktop-gui Sep 22, 2021
@lmiller1990 lmiller1990 deleted the UNIFY-270-global-mode-file-drop branch September 22, 2021 01:19
tgriesser added a commit that referenced this pull request Sep 28, 2021
* unified-desktop-gui: (48 commits)
  refactor: remove nexus-decorators, add data context (#18211)
  fix mountFragment tests
  fix(unified-desktop-gui branch): initial installation on windows (#18247)
  fix(unify): fixing icons and supporting router within the shared cypress commands package (#18237)
  feat(launchpad): improve layout and design (#18238)
  feat(launchpad): add design tokens from Figma (#18223)
  fix(unify): appveyor windows issue + better icon types (#18226)
  fixing broken ct tests
  fix types
  remove old code
  chore: bump deps (#18213)
  feat(app): icon library supporting Cy's custom icons (#18195)
  feat(app): adding navigation, pages, router, and layout (#18194)
  chore: Update Chrome (stable) to 94.0.4606.54 (#18196)
  fix(launchpad): fix bugs introduced by urql/graphcache (#18193)
  chore: bump yarn.lock (#18204)
  feat: add gulp makePackage, begin to scaffold data-context (#18186)
  feat(launchpad): Directory Upload in Global Mode (#18165)
  chore(tests): fix flake in net stubbing/xhr/proxy logging tests (#18163)
  chore: remove nxs.gen.ts - should be created by codegen (#18184)
  ...
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.

5 participants