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

[AT] - added remove site modal, controller, and tests #64

Merged
merged 14 commits into from
Jan 16, 2018
Merged

[AT] - added remove site modal, controller, and tests #64

merged 14 commits into from
Jan 16, 2018

Conversation

andrew-c-tran
Copy link
Contributor

@andrew-c-tran andrew-c-tran commented Dec 20, 2017

The Problem/Issue/Bug:

DDEV UI did not have the ability to remove a site

How this PR Solves The Problem:

remove site functionality with prompts and tests added

Manual Testing Instructions:

  • make build darwin
  • launch installer or standalone binary
  • click the ellipsis on the bottom right of any site card
  • click remove
  • toggle one of the options, ensure that changing radio buttons shows the button (making it impossible to remove without selecting an option first) and that the text on the remove button updates on radio button change.
  • click the red remove button
  • ensure loading spinner updates progress
  • ensure modal closes upon success and that DDEV UI cards update accordingly
    *note: if you remove all your sites and the UI no longer has any sites (i.e. ddev list returns "no ddev apps running" message, the UI will error out. This has been corrected in Issue 14 add from cms #62 )

Automated Testing Overview:

DDEV Remove functionality tests written, testing calling ddev cli with and without --remove-data flag, and exiting with a 0 and non-0 code.

Related Issue Link(s):

#19 #17

@andrew-c-tran
Copy link
Contributor Author

remove site rebased, tests updated, and ready for functionality review @rickmanelius , pending that approval also ready for technical review.

@rickmanelius rickmanelius self-assigned this Jan 3, 2018
@rfay
Copy link
Member

rfay commented Jan 4, 2018

@andrew-c-tran I'd say despite much work the communication about what we're removing still needs a little work. I like the "Not removing your files" thing. That's good.

  • But we're not removing anything from the dashboard, we're removing it from ddev. Removing from the ddev-ui dashboard would imply ignoring it. So let's improve that description.
  • Please use the word "Remove" on each option: "Remove site from (dashboard-or-whatever)", at least it's my opinion it would read better with the word remove there.
  • Please use the word "Project" which I think we've standardized on right?
  • Actually, I note that "site" has survived several places. We definitely need to use just "project" I think.
  • I don't think "hard drive" is probably the right word these days is it? (Certainly not as one word) Maybe "will not be removed from your workstation", or "from your system" or "from your computer".

ddev_ui

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Unless I've done something wrong, this doesn't work yet. I get the error "Could not remove site... path.replace is not a function" I'm on d4b59f6 and ran it with npm install and then npm start.

ddev_ui

After I click "OK" on the path.replace complaint, it goes off into spinning "Working" land, with no result and no way to fix. And the "Remove site from dashboard" button remains active.

Please make sure this has error checking and can't do that.

ddev_ui

Copy link
Contributor

@rickmanelius rickmanelius left a comment

Choose a reason for hiding this comment

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

Stubbing out preparation. Working on review now...

Testing

Performed by Rick Manelius as of 2018-01-04

Hardware

I’m using a laptop with the following high level specifications:

  • MacBook Pro: Retina 15-inch Mid 2015
  • 2.2 Ghz Intel Core i7
  • 16 GB 1600 MHz DDR3 RAM
  • 250 GB Hard Drive
  • macOS Sierra 10.13.2

Software Setup

  • Xcode
  • Go 1.9
  • Docker 17.12.0-ce-rc4
  • Git 2.13.6

Repositories Used

Preparation

  • Run make clean && make darwin
  • Verified I have macOS and DMG generated
  • Run electron . and app displayed
  • Installed WordPress 4.9.1 and Drupal 7.56 sites operational with an active database.

Results

Fails

  • Deleting Data drud/ddev-ui/issues/19
    • ...with an active Drupal 7.5.6 site showing up as a card in ddev-ui.
    • I click on the card's dropdown menu represented by the third button with ...
    • I see "Remove Site" as the 2nd of 3 items.
    • I click "Remove Site" and see the following attachment (ddev-ui-pull-64-attachment-1-2018-01-04.png)
      • Change Request: We're standardizing on "Project" over "Site" as per Standardize usage to "project", away from "app" or "site", at least in interacting with user ddev#526. We need to change "Remove Site" to "Remove Project".
      • The UI's reliance on active Docker container labels to power ddev list makes it somewhat challenging to properly label what's happening. From the perspective of the end-user, removing the containers essentially removes it from the DDEV-UI dashboard, so the "Site from Dashboard" language seems accurate even though someone that bounces back and forth between the the CLI and UI would need to think a bit because they wouldn't necessarily make the connection between active containers as the prerequisite to populate the ddev-ui. To that end, would it be more appropriate to say "Project Containers" and "Project's Containers and Databases" as the two options.
      • I like the warning and think the "removal option" could be rewritten to "Please select an option:"
      • I like the button updating to confirm the selection.
      • It's important to highlight that this modal does not highlight WHICH project is being removed. I was busy writing up this review and left the modal active. I then forgot which site I was about to remove because it doesn't specify which project is about to be removed. I think we need to prepend in the modal's title. It could be something like "Remove $XYZ Project" where $XYZ is the project.
    • I select "Site from Dashboard" and click the "Remove Site from Dashboard" button.
      • I receive an electron error "Could Not Remove Site (TypeError: path.replace is not a function)" that I have to close.
      • I then see the site removal starting with a spinner and the message "Removing..." appearing above the card with a knock out.
      • I still see the "Remove Site from Dashboard" button persisting.
      • I went to the command line and ran ddev list. I see the site there and in the running state.
      • The ddev-ui app is stuck in the modal with the spinner
    • This is not working at this time. I'll stop my review and return later.

Needs Testing

ddev-ui-pull-64-attachment-1-2018-01-04

@rickmanelius
Copy link
Contributor

Idea. I'm not sure if this would work, but it might be helpful as part of these open PRs before testing for a quick screencast video by @andrew-c-tran to provide more of a tour of the functionality as working or as built. That 1-3 minute overview might help considerably given the time to test is considerable and it might help provide a faster turn on feedback.

@andrew-c-tran
Copy link
Contributor Author

andrew-c-tran commented Jan 4, 2018

updated with better error state, as well as implemented verbiage and button changes. expanding test coverage now. can be reviewed for functionality during.

@rickmanelius
Copy link
Contributor

@andrew-c-tran I'm having an issue where this is deleting the database regardless of which option is selected in the modal. I've traced this down to https://github.com/andrew-c-tran/ddev-ui/blob/16571c6dea008a0c08def83b9d0943caa12c7e28/js/remove-site.js#L19. Can you confirm that both values are passing through correctly?

@andrew-c-tran
Copy link
Contributor Author

much more complete tests implemented, manual and automated testing confirm correct error states, handling, and removal flags being passed.

@rickmanelius
Copy link
Contributor

Before my next round of manual testing, I'm going to take a stab at what an automated test might look like in terms of steps. I haven't reviewed the diff on this pull request prior to this, so this might already be in place or similar.

Given that both the remove site and the remove database functionality require an active site running AND given that we already have the ability to generate a fresh site from a CMS distro, we can leverage what should be a pre-existing automated test routine of getting said site up and running before running through the tear down test.

  • Prereq: DDEV-UI core tests
    1. Ensure ddev-ui.app can be opened.
    2. Ensure ddev CLI is installed at the correct version (v0.10.0 at the time of this writing).
  • Prereq: Add Drupal 7 Site from CMS
    1. "Add Project" card exists with + button
    2. Clicking the plus button brings up a security prompt
    3. Clicking "OK" and entering a valid SUDO password brings up a modal
    4. The modal includes a "Add from fresh start" option.
    5. Clicking this option brings up a new modal with 3 form field elements (or form element equivalents)
    • CMS type (options)
    • Project Name (text)
    • Installation directory (text)
    1. Drupal7 Info:
    • CMS: Drupal 7
    • PROJECT: TestAddD7
    • FOLDER: ~/
    1. Clicking "Create Project" creates an alert and closes the modal
    2. After 10 seconds the card with a project name TestAddD7 appears
  • Delete Containers
    1. Assert a card exists for TestAddD7 project with a "running" status.
    2. Click the dropdown menu and click "Remove Project"
    3. Assert that modal appears with an option form field with the following as options
    • Remove Project
    • Remove Project AND Project Database
    1. Select "Remove Project" and assert modal submit button says "Remove Project from Dashboard"
    2. Clicking Removing Project triggers a spinner and changes the color of the submit button.
    3. A success message appears
    4. On the dashboard, the site is no longer present.
    5. Running ls ~/.ddev/TestAddD7/mysql shows a populated folder

Going to manual testing now... but happy to review this to sanity check whether this is too detailed of a test run or not detailed enough given where regressions could be introduced.

@rickmanelius
Copy link
Contributor

rickmanelius commented Jan 5, 2018

Actually, I missed a step in my own test instructions. By default the site(s) won't have a populated database because we do not assume that. We can pass a drush site install command through drush exec that would provide that.

UPDATE: Here would be a way to achieve the install via drush leveraging some of the work already done in the ddev codebase.

https://github.com/drud/ddev/blob/master/testing/ddev-perf-test.sh#L80
ddev exec drush si standard -y --db-url=mysql://db:db@db/db

@rickmanelius
Copy link
Contributor

I'll create a more thorough review when I get to the office, but I was able to confirm the two different options now work in terms of whether or not the db is removed or not.

@rickmanelius rickmanelius self-requested a review January 5, 2018 13:43
Copy link
Contributor

@rickmanelius rickmanelius left a comment

Choose a reason for hiding this comment

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

This is approved from an end-user functionality perspective with one comment and two conditions.

  • Comment: This PR purports to address issues Delete config #17 and Delete data #19. Unfortunately, the intention of Delete config #17 is to remove the configuration files (specifically ~/.ddev/config.yml and ~/.ddev/docker-compose.yml). This of course pre-supposses that we have removed the project containers so they are not left unattached. I'll update this in Delete config #17.
  • Condition: We still need to address all the sudo, security, /etc/host considerations which has been a pain in the arse. There are multiple tickets to draw from and we'll do this in v0.3.
  • Condition: We'll address the s/Site/Project/ changes in replace instances of "site"/"app" with "project" #73 when we're in v0.3 and clarifying our wireframes/design.

From my perspective, we just need a code/test review before merging.

@andrew-c-tran andrew-c-tran mentioned this pull request Jan 5, 2018
@rickmanelius rickmanelius assigned cweagans and unassigned rickmanelius Jan 5, 2018
@rickmanelius
Copy link
Contributor

Going to add @cweagans to assist on the code/test review and then we can get this merged. Thanks!

rfay
rfay previously requested changes Jan 8, 2018
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Site/Project terminology is still not consistent in the removal dialog, also still Add/Create "site". Sorry about being ***l about this, just thought that ddev-ui had pioneered the (excellent) "project" terminology.

ddev_ui

(Edited to remove site card size issue which didn't seem to exist after a make clean)

Most of the functionality seems to be there now. I haven't looked at the code yet.

…ed code references for remove module to use project vs site. added name of project being removed to modal
@andrew-c-tran
Copy link
Contributor Author

  • Updated code references and tests to use project vs site verbiage
  • Added name of project being targeted for removal to removal modal.
  • added a quick (ddev rm) and (ddev rm --remove-data) text to the modal to further clarify what each option is doing under the hood as per slack conversation with @rfay

On that last point, I was thinking of adding a "for more information on what these options do, please refer to the ddev remove documentation" and link to the docs. However, https://ddev.readthedocs.io/en/latest/users/cli-usage/#removing-a-site is out of date now, correct?

@rfay
Copy link
Member

rfay commented Jan 10, 2018

I just ran through this and the functionality of the remote-project seems fine now. I like the verbiage on the dialog box, thanks. I'll look at the code now.

@rfay rfay dismissed their stale review January 10, 2018 23:55

I've used this in its current state and it seems to be working fine and has the verbiage we want. Now I'll take a look at the code.

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

I didn't look carefully at the tests, but I'm pretty good with this, just some attention to the few items mentioned here.

js/ddev-shell.js Outdated
const remove = (path, callback, errorCallback) => {
ddevShell('remove', null, path, callback, errorCallback, true);
const remove = (path, db) => {
var args = db ? ['-j', '--remove-data'] : ['-j'];
Copy link
Member

Choose a reason for hiding this comment

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

So the header isn't right at all here is it? db seems to be a bool that if set, does a remove? If so, could we rename db to "remove_data" or something? And aren't there only the 2 params?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, i did miss the header on that update. i've updated it, and changed the ambiguous "db" variable to "shouldRemoveData" to be more descriptive


return ddevShell.remove(removePath, removeData)
.then(function(){
removeCompleted('Project Successfully Removed.');
Copy link
Member

Choose a reason for hiding this comment

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

No big deal, but all caps on a sentence isn't all that normal. "Project successfully removed." would be OK. We probably need a style guide on this kind of thing, but all caps (except for NY Times headlines) isn't all that useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, we do need to get consistent across the application. I'll leave this as is, and have opened issue #74 to get all messaging across the app consistent as there are many, many dialogs and prompts that we'll need to address, as well as a review of current verbiage being used.

Copy link
Member

Choose a reason for hiding this comment

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

That works.

removeCompleted('Could Not Remove Project ('+err+')');
});
} catch(e) {
removeCompleted('Invalid Input Passed To Remove');
Copy link
Member

Choose a reason for hiding this comment

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

You can just provide the exception as a string here like above right, and maybe quote the invalid input? Because if we ever have a customer hit this we'll sure want it.

Copy link
Contributor Author

@andrew-c-tran andrew-c-tran Jan 11, 2018

Choose a reason for hiding this comment

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

Sure, the formdata is an object, so the best way to display that would be to convert it to a json string and include that along with the actual error text.

js/site-cards.js Outdated
@@ -55,6 +55,7 @@ function createCard(site) {
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item restartbtn" href="#">Restart</a>
<a class="dropdown-item removebtn" href="#" data-project-name="`+site.name+`" data-project-path="` + site.approot + `">Remove Project</a>
Copy link
Member

Choose a reason for hiding this comment

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

You don't actually need the data-project-path to use ddev remove, and it really would generally be better IMO to use ddev remove <project> instead of going to the directory and issuing the command. It just seems simpler to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, originally in the prototypes when I was first writing the ddev-shell wrapper, I was indeed just calling remove with a site name. However, I began to notice that the basic functionality commands were not consistent. Some made sense, i.e. why we cannot start a site by name as we have no idea where it is, but why for instance can we stop a running site by name, but not restart a running site by name? So we were left with the fact that we can stop, remove, or describe a site by name, but must be in the directory to config, start, or restart one. In an attempt at consistency, I made it so every action takes a path. That way, every action you want to perform needs to know just the path, vs having to decide when to pass in name and when to use path.

It's pretty convenient from a development side to not have to think about that, to just know that every command will work if you give it a path, but if you feel strongly about it we can segment out which calls need a name and pass that, vs which ones need a path and pass that instead.

Copy link
Member

Choose a reason for hiding this comment

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

Now I remember that whole thing. And I certainly agree with you that we could wish for consistency from ddev. Your push can help us with that though. Glad we've discovered that ddev can be improved to help ddev-ui work easier with easier code.

js/site-cards.js Outdated
@@ -55,6 +55,7 @@ function createCard(site) {
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item restartbtn" href="#">Restart</a>
<a class="dropdown-item removebtn" href="#" data-project-name="`+site.name+`" data-project-path="` + site.approot + `">Remove Project</a>
<a class="dropdown-item" onclick='electron.shell.showItemInFolder("` + site.approot + `")' href="#">Browse Local Files</a>
Copy link
Member

@rfay rfay Jan 11, 2018

Choose a reason for hiding this comment

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

I thought the onclick stuff was old fashioned and not something people did any more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you'd be surprised, it seemed to fall out of favor for a while, but is now a pretty standard way of triggering click events in React-land. In this case though, it is inconsistent with the rest of the action bindings, and i'll move it out of there.

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

OK, good to go. Thanks for your long "pull" on this one. 👍

@andrew-c-tran
Copy link
Contributor Author

@rickmanelius can we get a final look at this before i merge it in?

@rickmanelius
Copy link
Contributor

@andrew-c-tran I missed this notification until right now. Updating assignment and I'll get this by COB today.

@rickmanelius rickmanelius requested review from rickmanelius and removed request for cweagans January 16, 2018 19:27
Copy link
Contributor

@rickmanelius rickmanelius left a comment

Choose a reason for hiding this comment

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

I will save another pass at the more detailed, step by step documented review for the v0.2 release, but I did a complete spin on WordPress and Drupal 7.56 for both remove options and I can confirm they work as expected. Thanks for the text/label updates.

@andrew-c-tran andrew-c-tran merged commit aad843d into ddev:master Jan 16, 2018
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.

4 participants