Skip to content

Commit ec26c1d

Browse files
authored
Move to Knockout 3.5.1 and fix admin JS errors (#8168)
* Move to Knockout 3.5.1 and fix admin JS errors * Fix binding issue in stats pivot table Address https://github.com/NuGet/Engineering/issues/3311
1 parent 2973e54 commit ec26c1d

11 files changed

Lines changed: 168 additions & 155 deletions

File tree

src/NuGetGallery/App_Start/AppActivator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private static void BundlingPostStart()
132132
.Include("~/Scripts/gallery/jquery-3.4.1.js")
133133
.Include("~/Scripts/gallery/jquery.validate-1.16.0.js")
134134
.Include("~/Scripts/gallery/jquery.validate.unobtrusive-3.2.6.js")
135-
.Include("~/Scripts/gallery/knockout-3.4.2.js")
135+
.Include("~/Scripts/gallery/knockout-3.5.1.js")
136136
.Include("~/Scripts/gallery/bootstrap.js")
137137
.Include("~/Scripts/gallery/moment-2.18.1.js")
138138
.Include("~/Scripts/gallery/common.js")

src/NuGetGallery/Areas/Admin/Views/ApiKeys/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
});
173173
};
174174
175-
ko.applyBindings(new viewModel(), $('#stage').get(0));
175+
ko.applyBindings(new viewModel(), $('.main-container').get(0));
176176
});
177177
</script>
178178
}

src/NuGetGallery/Areas/Admin/Views/Delete/Index.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
$self.searchResults(data);
8181
}
8282
})
83-
.error(function(jqXhr, textStatus, errorThrown) {
83+
.fail(function(jqXhr, textStatus, errorThrown) {
8484
alert("Error: " + errorThrown);
8585
})
8686
.always(function () {
@@ -123,7 +123,7 @@
123123
});
124124
};
125125
126-
ko.applyBindings(new viewModel(), $('#stage').get(0));
126+
ko.applyBindings(new viewModel(), $('.main-container').get(0));
127127
});
128128
</script>
129129
@Scripts.Render("~/Scripts/gallery/page-delete-package.min.js")

src/NuGetGallery/Areas/Admin/Views/DeleteAccount/Index.cshtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
this.search = function () {
3636
$self.doneSearching = ko.observable(false);
3737
$.ajax({
38-
url: '@Url.Action("Search", "DeleteAccount", new {area = "Admin"})?query=' + encodeURIComponent($self.searchQuery()),
38+
url: '@Url.Action("Search", "DeleteAccount", new {area = "Admin"})?query=' + encodeURIComponent($self.searchQuery().trim()),
3939
cache: false,
4040
dataType: 'json',
4141
success: function(data) {
@@ -45,7 +45,7 @@
4545
$self.searchResults(data);
4646
}
4747
})
48-
.error(function(jqXhr, textStatus, errorThrown) {
48+
.fail(function(jqXhr, textStatus, errorThrown) {
4949
alert("Error: " + errorThrown);
5050
})
5151
.always(function () {
@@ -58,7 +58,7 @@
5858
this.searchResults = ko.observableArray([]);
5959
};
6060
61-
ko.applyBindings(new viewModel(), $('#stage').get(0));
61+
ko.applyBindings(new viewModel(), $('.main-container').get(0));
6262
});
6363
</script>
6464
}

src/NuGetGallery/Areas/Admin/Views/ReservedNamespace/Index.cshtml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
@ViewHelpers.AlertInfo(@<text><span class="message" data-bind="text: message"></span></text>)
1111
</div>
1212
<h2>Reserve Namespace</h2>
13-
<form>
13+
<form data-bind="submit: prefixSearch">
1414
<div class="form-horizontal">
1515
<input type="text" placeholder="Search for a prefix" autocomplete="on" autofocus data-bind="value: prefixSearchQuery" />
16-
<input type="button" value="Search Prefix" title="Search Prefix" data-bind="click: prefixSearch" />
16+
<input type="submit" value="Search Prefix" title="Search Prefix" />
1717
</div>
1818
</form><br />
1919

@@ -117,7 +117,7 @@
117117
}
118118
}
119119
})
120-
.error(function(jqXhr, textStatus, errorThrown) {
120+
.fail(function(jqXhr, textStatus, errorThrown) {
121121
alert("Error: " + errorThrown);
122122
});
123123
};
@@ -148,7 +148,7 @@
148148
}
149149
}
150150
})
151-
.error(function (jqXhr, textStatus, errorThrown) {
151+
.fail(function (jqXhr, textStatus, errorThrown) {
152152
alert("Error: " + errorThrown);
153153
});
154154
};
@@ -178,7 +178,7 @@
178178
}
179179
}
180180
})
181-
.error(function (jqXhr, textStatus, errorThrown) {
181+
.fail(function (jqXhr, textStatus, errorThrown) {
182182
alert("Error: " + errorThrown);
183183
});
184184
};
@@ -210,7 +210,7 @@
210210
}
211211
}
212212
})
213-
.error(function (jqXhr, textStatus, errorThrown) {
213+
.fail(function (jqXhr, textStatus, errorThrown) {
214214
alert("Error: " + errorThrown);
215215
});
216216
};
@@ -228,7 +228,7 @@
228228
};
229229
};
230230
231-
ko.applyBindings(new viewModel(), $('#stage').get(0));
231+
ko.applyBindings(new viewModel(), $('.main-container').get(0));
232232
});
233233
</script>
234234
}

src/NuGetGallery/Areas/Admin/Views/SecurityPolicy/Index.cshtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
$self.message("Security policies updated!");
9595
}
9696
})
97-
.error(function(jqXhr, textStatus, errorThrown) {
97+
.fail(function(jqXhr, textStatus, errorThrown) {
9898
alert("Error: " + errorThrown);
9999
});
100100
},
@@ -124,7 +124,7 @@
124124
$self.searchNotFoundResults(data.UsersNotFound);
125125
}
126126
})
127-
.error(function(jqXhr, textStatus, errorThrown) {
127+
.fail(function(jqXhr, textStatus, errorThrown) {
128128
alert("Error: " + errorThrown);
129129
});
130130
};
@@ -180,7 +180,7 @@
180180
}
181181
};
182182
183-
ko.applyBindings(new viewModel(), $('#stage').get(0));
183+
ko.applyBindings(new viewModel(), $('.main-container').get(0));
184184
});
185185
</script>
186186
}

src/NuGetGallery/Areas/Admin/Views/SupportRequest/Admins.cshtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
data: window.nuget.addAjaxAntiForgeryToken(model),
109109
success: success
110110
})
111-
.error(error);
111+
.fail(error);
112112
};
113113
}
114114
function EditAdminViewModel() {
@@ -132,7 +132,7 @@
132132
data: window.nuget.addAjaxAntiForgeryToken(model),
133133
success: success
134134
})
135-
.error(error);
135+
.fail(error);
136136
};
137137
}
138138
@@ -194,7 +194,7 @@
194194
$self.refresh();
195195
}
196196
})
197-
.error(function (jqXhr, textStatus, errorThrown) {
197+
.fail(function (jqXhr, textStatus, errorThrown) {
198198
alert("Error: " + errorThrown);
199199
});
200200
}
@@ -213,7 +213,7 @@
213213
$self.styleButtons();
214214
}
215215
})
216-
.error(function (jqXhr, textStatus, errorThrown) {
216+
.fail(function (jqXhr, textStatus, errorThrown) {
217217
alert("Error: " + errorThrown);
218218
});
219219
};

src/NuGetGallery/NuGetGallery.csproj

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,7 @@
16581658
<Content Include="Areas\Admin\Views\Revalidation\Index.cshtml" />
16591659
<Content Include="App_Data\Files\Content\Symbols-Configuration.json" />
16601660
<Content Include="Scripts\gallery\instrumentation.js" />
1661+
<Content Include="Scripts\gallery\knockout-3.5.1.js" />
16611662
<Content Include="Views\Shared\SiteMenu.cshtml">
16621663
<SubType>Code</SubType>
16631664
</Content>
@@ -1808,7 +1809,6 @@
18081809
<Content Include="Scripts\gallery\jquery-ui-1.10.3.js" />
18091810
<Content Include="Scripts\gallery\jquery.validate-1.16.0.js" />
18101811
<Content Include="Scripts\gallery\jquery.validate.unobtrusive-3.2.6.js" />
1811-
<Content Include="Scripts\gallery\knockout-3.4.2.js" />
18121812
<Content Include="Scripts\gallery\knockout-projections.js" />
18131813
<Content Include="Scripts\gallery\md5.js" />
18141814
<Content Include="Scripts\gallery\moment-2.18.1.js" />
@@ -2110,12 +2110,6 @@
21102110
<PackageReference Include="EntityFramework">
21112111
<Version>6.4.0-preview3-19553-01</Version>
21122112
</PackageReference>
2113-
<PackageReference Include="Knockout.Mapping">
2114-
<Version>2.4.0</Version>
2115-
</PackageReference>
2116-
<PackageReference Include="knockoutjs">
2117-
<Version>2.2.1</Version>
2118-
</PackageReference>
21192113
<PackageReference Include="Lucene.Net">
21202114
<Version>3.0.3</Version>
21212115
</PackageReference>

0 commit comments

Comments
 (0)