Skip to content

Have a way to yank a crate from the UI #1659

@carols10cents

Description

@carols10cents

What needs to be done: This looks like a lot, but I tried to provide a lot of detail and examples to work from. The actual code changes shouldn't be very big.

  • If the current user is an owner of the current crate, add a link or button in the sidebar with each version that says "yank" if the version is not yanked and "unyank" if the version is yanked. (Or is there a better place to put this control? I'm open to different UIs)

  • The link/button should send a DELETE request to /api/v1/crates/[crate name]/[version num]/yank for yanking and a PUT request to /api/v1/crates/[crate name]/[version num]/unyank for unyanking.

    • A similar link/button is the "Remove" button for removing an owner
      <button class='remove-owner small yellow-button' {{action 'removeOwner' user}}>Remove</button>
    • Which calls the ember removeOwner controller function:
      async removeOwner(user) {
      this.set('removed', false);
      try {
      await this.crate.removeOwner(user.get('login'));
      this.set('removed', `User ${user.get('login')} removed as crate owner`);
      this.get('crate.owner_user').removeObject(user);
      } catch (error) {
      if (error.errors) {
      this.set('removed', `Error removing owner: ${error.errors[0].detail}`);
      } else {
      this.set('removed', 'Error removing owner');
      }
      }
      },
    • Which calls the ember crate model removeOwner function:
      removeOwner(username) {
      return this.store.adapterFor('crate').removeOwner(this.id, username);
      },
    • Which calls the ember crate adapter removeOwner function:
      removeOwner(id, username) {
      return this.ajax(this.urlForOwnerAction(id), 'DELETE', {
      data: {
      owners: [username],
      },
      });
      },
    • I'm not actually sure how idiomatic Ember this example is; if this example isn't good, feel free to do whatever the normal Ember way of doing this would be.
    • There should be an indication to the user that the request is being sent and then that the request has completed either successfully or with an error. You should be able to yank and unyank the same version repeatedly without reloading the full page.
  • The ember tests should assert that the UI behaves as expected. This commit has an example of adding an ember test for the "remove owner" functionality: f524472

  • There should be a test in the Rust code that yank and unyank can be performed by MockCookieUsers as well as MockTokenUsers.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions