Skip to content

Commit

Permalink
Fix ApiKeys page issues from bug bash (#5341)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenriksson committed Jan 25, 2018
1 parent d682501 commit 455fbcc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/Bootstrap/dist/css/bootstrap-theme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/Bootstrap/less/theme/page-api-keys.less
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@

.api-key-details {
padding: @section-padding;
border-bottom: @section-border;

.ms-Icon {
position: relative;
Expand All @@ -89,4 +88,9 @@
}
}
}

.api-key-details:not(:first-child)
{
border-top: @section-border;
}
}
23 changes: 19 additions & 4 deletions src/NuGetGallery/Scripts/gallery/page-api-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,18 @@
this.Scopes(data.Scopes || []);
this.Packages(data.Packages || []);
this.GlobPattern(data.GlobPattern || "");
this._SetPackageSelection(this.Packages())
this._SetPackageSelection(this.Packages());

if (this.Owner()) {
var existingOwner = ko.utils.arrayFirst(
this.PackageOwners,
function (owner) {
return owner.Owner.toUpperCase() == data.Owner.toUpperCase()
});
this.PackageOwner(existingOwner);
} else {
this.PackageOwner(this.PackageOwners[0]);
}
};
this.Key = ko.observable();
this.Type = ko.observable();
Expand All @@ -105,7 +116,6 @@
this.Scopes = ko.observableArray();
this.Packages = ko.observableArray();
this.GlobPattern = ko.observable();
this._UpdateData(data);

// Properties used for the form
this.PendingDescription = ko.observable();
Expand Down Expand Up @@ -270,11 +280,17 @@
});
self.PendingPackages(self.packageViewModels);
self.ApplyPendingGlobPattern(self.PendingGlobPattern());

// reset form validation error
self.ScopesError(null);
self.SubjectsError(null);
});

// Update data only after PackageOwner subscription is fully enabled.
this._UpdateData(data);

// Default owner to self to initialize the pending data.
this.PendingGlobPattern(this.GlobPattern());
this.PackageOwner(this.PackageOwners[0]);

// Apply validation to the scopes and subjects
this.PendingScopes.subscribe(function (newValue) {
Expand Down Expand Up @@ -336,7 +352,6 @@

// Reset the field values.
self.PendingDescription(self.Description());
self.PackageOwner($("#" + self.PackageOwnerId() + " option:first-child").val());
self.ExpiresIn($("#" + self.ExpiresInId() + " option:last-child").val());
self.PushEnabled(false);
self.PushScope(initialData.PackagePushScope);
Expand Down
13 changes: 6 additions & 7 deletions src/NuGetGallery/Views/Users/ApiKeys.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@
"create",
"Create",
@<text>
<div class="panel panel-default upsert-api-key">
<div class="panel-body"
data-bind="template: { name: 'upsert-api-key', data: NewApiKey }">
</div>
<div class="upsert-api-key">
<div class="panel-body" data-bind="template: { name: 'upsert-api-key', data: NewApiKey }"></div>
</div>
</text>,
expanded: false,
Expand Down Expand Up @@ -105,9 +103,9 @@
<!-- ko if: AnyJustRegenerated -->
@ViewHelpers.AlertWarning(
@<text>
Your API key has been regenerated. Make sure to copy your new API key now using the
<b>Copy</b>
button below. You will not be able to do so again.
Your API key has been regenerated. Make sure to copy your new API key now using the
<b>Copy</b>
button below. You will not be able to do so again.
</text>,
isAlertRole: true)
<!-- /ko -->
Expand Down Expand Up @@ -217,6 +215,7 @@
</ul>
</div>
</div>

<div class="upsert-api-key">
<div class="panel panel-default panel-collapse collapse"
data-bind="attr: { id: EditContainerId() },
Expand Down

0 comments on commit 455fbcc

Please sign in to comment.