mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-31 06:15:49 +00:00
support DeleteRecord in New DNS Change form (#791)
This commit is contained in:
@@ -100,13 +100,14 @@
|
||||
<td>
|
||||
<select class="form-control changeType" ng-model="change.changeType">
|
||||
<option value="Add">Add</option>
|
||||
<option value="DeleteRecord">DeleteRecord</option>
|
||||
<option value="DeleteRecordSet">DeleteRecordSet</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" ng-model="change.type">
|
||||
<option value="A+PTR" selected>A+PTR</option>
|
||||
<option>AAAA+PTR</option>
|
||||
<option ng-if="change.changeType!=='DeleteRecordSet'" value="A+PTR" selected>A+PTR</option>
|
||||
<option ng-if="change.changeType!=='DeleteRecordSet'">AAAA+PTR</option>
|
||||
<option>A</option>
|
||||
<option>AAAA</option>
|
||||
<option>CNAME</option>
|
||||
@@ -129,7 +130,7 @@
|
||||
<span ng-show="createBatchChangeForm.ttl_{{$index}}.$error.number || createBatchChangeForm.ttl_{{$index}}.$error.min || createBatchChangeForm.ttl_{{$index}}.$error.max" class="batch-change-error-help">TTL must be between 30 and 2147483647.</span>
|
||||
</p>
|
||||
</td>
|
||||
<td ng-if="change.changeType=='DeleteRecordSet'">
|
||||
<td ng-if="change.changeType != 'Add'">
|
||||
<input class="form-control" disabled/>
|
||||
</td>
|
||||
<!--TTL based on change type-->
|
||||
@@ -151,42 +152,42 @@
|
||||
<span ng-show="createBatchChangeForm.record_address_{{$index}}.$error.ipv6" class="batch-change-error-help">must be a valid IPv6 Address!</span>
|
||||
</p>
|
||||
</td>
|
||||
<td ng-if="change.type=='A' && change.changeType=='Add'">
|
||||
<input name="record_address_{{$index}}" type="text" ng-model="change.record.address" ng-required="change.changeType=='Add'" class="form-control" placeholder="e.g. 1.1.1.1" ng-disabled="change.changeType=='DeleteRecordSet'" ipv4>
|
||||
<td ng-if="change.type=='A' && change.changeType != 'DeleteRecordSet'">
|
||||
<input name="record_address_{{$index}}" type="text" ng-model="change.record.address" ng-required="change.changeType != 'DeleteRecordSet'" class="form-control" placeholder="e.g. 1.1.1.1" ng-disabled="change.changeType=='DeleteRecordSet'" ipv4>
|
||||
<p ng-show="createBatchChangeForm.$submitted">
|
||||
<span ng-show="createBatchChangeForm.record_address_{{$index}}.$error.required" class="batch-change-error-help">Record data is required!</span>
|
||||
<span ng-show="createBatchChangeForm.record_address_{{$index}}.$error.ipv4" class="batch-change-error-help">must be a valid IPv4 Address!</span>
|
||||
</p>
|
||||
</td>
|
||||
<td ng-if="change.type=='AAAA' && change.changeType=='Add'">
|
||||
<input name="record_address_{{$index}}" type="text" ng-model="change.record.address" ng-required="change.changeType=='Add'" class="form-control" placeholder="e.g. fd69:27cc:fe91::60" ng-disabled="change.changeType=='DeleteRecordSet'" ipv6>
|
||||
<td ng-if="change.type=='AAAA' && change.changeType != 'DeleteRecordSet'">
|
||||
<input name="record_address_{{$index}}" type="text" ng-model="change.record.address" ng-required="change.changeType != 'DeleteRecordSet'" class="form-control" placeholder="e.g. fd69:27cc:fe91::60" ng-disabled="change.changeType=='DeleteRecordSet'" ipv6>
|
||||
<p ng-show="createBatchChangeForm.$submitted">
|
||||
<span ng-show="createBatchChangeForm.record_address_{{$index}}.$error.required" class="batch-change-error-help">Record data is required!</span>
|
||||
<span ng-show="createBatchChangeForm.record_address_{{$index}}.$error.ipv6" class="batch-change-error-help">must be a valid IPv6 Address!</span>
|
||||
</p>
|
||||
</td>
|
||||
<td ng-if="change.type=='CNAME' && change.changeType=='Add'">
|
||||
<input name="record_cname_{{$index}}" type="text" ng-model="change.record.cname" ng-required="change.changeType=='Add'" class="form-control" placeholder="e.g. test.example.com." ng-disabled="change.changeType=='DeleteRecordSet'" fqdn>
|
||||
<td ng-if="change.type=='CNAME' && change.changeType != 'DeleteRecordSet'">
|
||||
<input name="record_cname_{{$index}}" type="text" ng-model="change.record.cname" ng-required="change.changeType != 'DeleteRecordSet'" class="form-control" placeholder="e.g. test.example.com." ng-disabled="change.changeType=='DeleteRecordSet'" fqdn>
|
||||
<p ng-show="createBatchChangeForm.$submitted">
|
||||
<span ng-show="createBatchChangeForm.record_cname_{{$index}}.$error.required" class="batch-change-error-help">Record data is required!</span>
|
||||
<span ng-show="createBatchChangeForm.record_cname_{{$index}}.$error.fqdn" class="batch-change-error-help">CNAME data must be absolute!</span>
|
||||
</p>
|
||||
</td>
|
||||
<td ng-if="change.type=='PTR' && change.changeType=='Add'">
|
||||
<input name="record_ptr_{{$index}}" type="text" ng-model="change.record.ptrdname" ng-required="change.changeType=='Add'" class="form-control" placeholder="e.g. test.com." ng-disabled="change.changeType=='DeleteRecordSet'">
|
||||
<td ng-if="change.type=='PTR' && change.changeType != 'DeleteRecordSet'">
|
||||
<input name="record_ptr_{{$index}}" type="text" ng-model="change.record.ptrdname" ng-required="change.changeType != 'DeleteRecordSet'" class="form-control" placeholder="e.g. test.com." ng-disabled="change.changeType=='DeleteRecordSet'">
|
||||
<p ng-show="createBatchChangeForm.$submitted">
|
||||
<span ng-show="createBatchChangeForm.record_ptr_{{$index}}.$error.required" class="batch-change-error-help">Record data is required!</span>
|
||||
</p>
|
||||
</td>
|
||||
<td ng-if="change.type=='TXT' && change.changeType=='Add'">
|
||||
<textarea name="record_txt_{{$index}}" type="text" ng-model="change.record.text" ng-required="change.changeType=='Add'" class="form-control" placeholder="e.g. attr=val" ng-disabled="change.changeType=='DeleteRecordSet'"></textarea>
|
||||
<td ng-if="change.type=='TXT' && change.changeType != 'DeleteRecordSet'">
|
||||
<textarea name="record_txt_{{$index}}" type="text" ng-model="change.record.text" ng-required="change.changeType != 'DeleteRecordSet'" class="form-control" placeholder="e.g. attr=val" ng-disabled="change.changeType=='DeleteRecordSet'"></textarea>
|
||||
<p ng-show="createBatchChangeForm.$submitted">
|
||||
<span ng-show="createBatchChangeForm.record_txt_{{$index}}.$error.required" class="batch-change-error-help">Record data is required!</span>
|
||||
</p>
|
||||
</td>
|
||||
<td ng-if="change.type=='MX' && change.changeType=='Add'">
|
||||
<td ng-if="change.type=='MX' && change.changeType != 'DeleteRecordSet'">
|
||||
<label class="batch-label">Preference</label>
|
||||
<input name="record_mx_preference_{{$index}}" type="number" ng-model="change.record.preference" ng-required="change.changeType=='Add'" class="form-control" placeholder="e.g. 1" ng-min="0" ng-max="65535" ng-disabled="change.changeType=='DeleteRecordSet'">
|
||||
<input name="record_mx_preference_{{$index}}" type="number" ng-model="change.record.preference" ng-required="change.changeType != 'DeleteRecordSet'" class="form-control" placeholder="e.g. 1" ng-min="0" ng-max="65535" ng-disabled="change.changeType=='DeleteRecordSet'">
|
||||
<p ng-show="createBatchChangeForm.$submitted">
|
||||
<span ng-show="createBatchChangeForm.record_mx_preference_{{$index}}.$error.required" class="batch-change-error-help">Preference is required!</span>
|
||||
<span ng-show="createBatchChangeForm.record_mx_preference_{{$index}}.$error.min" class="batch-change-error-help">Must be between 0 and 65535!</span>
|
||||
@@ -197,7 +198,7 @@
|
||||
<br />
|
||||
|
||||
<label class="batch-label">Exchange</label>
|
||||
<input name="record_mx_exchange_{{$index}}" type="text" ng-model="change.record.exchange" ng-required="change.changeType=='Add'" class="form-control" placeholder="e.g. test.example.com." ng-disabled="change.changeType=='DeleteRecordSet'" fqdn>
|
||||
<input name="record_mx_exchange_{{$index}}" type="text" ng-model="change.record.exchange" ng-required="change.changeType != 'DeleteRecordSet'" class="form-control" placeholder="e.g. test.example.com." ng-disabled="change.changeType=='DeleteRecordSet'" fqdn>
|
||||
<p ng-show="createBatchChangeForm.$submitted">
|
||||
<span ng-show="createBatchChangeForm.record_mx_exchange_{{$index}}.$error.required" class="batch-change-error-help">Exchange data is required!</span>
|
||||
<span ng-show="createBatchChangeForm.record_mx_exchange_{{$index}}.$error.fqdn" class="batch-change-error-help">Exchange data must be absolute!</span>
|
||||
|
@@ -176,8 +176,10 @@
|
||||
if (headers[j] == "changeType") {
|
||||
if (rowContent[j].match(/add/i)) {
|
||||
change[headers[j]] = "Add"
|
||||
} else if (rowContent[j].match(/delete/i)) {
|
||||
} else if (rowContent[j].match(/deleterecordset/i)) {
|
||||
change[headers[j]] = "DeleteRecordSet"
|
||||
} else if (rowContent[j].match(/deleterecord/i)) {
|
||||
change[headers[j]] = "DeleteRecord"
|
||||
}
|
||||
} else if (headers[j] == "type") {
|
||||
change[headers[j]] = rowContent[j].trim().toUpperCase()
|
||||
|
@@ -225,8 +225,8 @@ describe('BatchChange', function(){
|
||||
}, 1000);
|
||||
})
|
||||
|
||||
it('handles "delete" change type', function(done) {
|
||||
var fileBlob = new Blob(["Change Type,Record Type,Input Name,TTL,Record Data\nDelete,A+PTR,test.example.,200,1.1.1.1"], { type: 'text/csv' });
|
||||
it('handles "deleterecordset" change type', function(done) {
|
||||
var fileBlob = new Blob(["Change Type,Record Type,Input Name,TTL,Record Data\nDeleterecordset,A+PTR,test.example.,200,1.1.1.1"], { type: 'text/csv' });
|
||||
var batchChange = this.scope.newBatch;
|
||||
this.scope.uploadCSV(fileBlob);
|
||||
|
||||
@@ -237,8 +237,20 @@ describe('BatchChange', function(){
|
||||
}, 1000);
|
||||
})
|
||||
|
||||
it('handles "deleterecord" change type', function(done) {
|
||||
var fileBlob = new Blob(["Change Type,Record Type,Input Name,TTL,Record Data\nDeleterecord,A+PTR,test.example.,200,1.1.1.1"], { type: 'text/csv' });
|
||||
var batchChange = this.scope.newBatch;
|
||||
this.scope.uploadCSV(fileBlob);
|
||||
|
||||
setTimeout(function() {
|
||||
expect(batchChange.changes.length).toEqual(1)
|
||||
expect(batchChange).toEqual({comments: "", changes: [{changeType: "DeleteRecord", type: "A+PTR", inputName: "test.example.", ttl: 200, record: {address: "1.1.1.1"}}], scheduledTime: tomorrow});
|
||||
done();
|
||||
}, 1000);
|
||||
})
|
||||
|
||||
it('handles whitespace', function(done) {
|
||||
var fileBlob = new Blob(["Change Type,Record Type,Input Name,TTL,Record Data\nDelete, A+PTR ,test.example. ,200,1.1.1.1"], { type: 'text/csv' });
|
||||
var fileBlob = new Blob(["Change Type,Record Type,Input Name,TTL,Record Data\nDeleterecordset, A+PTR ,test.example. ,200,1.1.1.1"], { type: 'text/csv' });
|
||||
var batchChange = this.scope.newBatch;
|
||||
this.scope.uploadCSV(fileBlob);
|
||||
|
||||
@@ -263,7 +275,7 @@ describe('BatchChange', function(){
|
||||
})
|
||||
|
||||
it('does not include empty lines', function(done) {
|
||||
var fileBlob = new Blob(["Change Type,Record Type,Input Name,TTL,Record Data\n,,,,,\nDelete,A+PTR,test.example.,200,1.1.1.1"], { type: 'text/csv' });
|
||||
var fileBlob = new Blob(["Change Type,Record Type,Input Name,TTL,Record Data\n,,,,,\nDeleteRecordSet,A+PTR,test.example.,200,1.1.1.1"], { type: 'text/csv' });
|
||||
var batchChange = this.scope.newBatch;
|
||||
this.scope.uploadCSV(fileBlob);
|
||||
|
||||
|
Reference in New Issue
Block a user