Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73d68ad

Browse files
committed
[IM] - Add Notes for Infrastructure - fixes inex#699
1 parent 56036b9 commit 73d68ad

7 files changed

Lines changed: 87 additions & 5 deletions

File tree

app/Http/Controllers/InfrastructureController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ public function feInit(): void
101101
'title' => 'Country',
102102
'type' => self::$FE_COL_TYPES[ 'COUNTRY' ]
103103
],
104+
'notes' => [
105+
'title' => 'Notes',
106+
'type' => self::$FE_COL_TYPES[ 'PARSDOWN' ]
107+
],
104108
'created_at' => [
105109
'title' => 'Created',
106110
'type' => self::$FE_COL_TYPES[ 'DATETIME' ]
@@ -159,6 +163,7 @@ protected function editPrepareForm( int $id ): array
159163
'shortname' => request()->old( 'shortname', $this->object->shortname ),
160164
'isPrimary' => request()->old( 'isPrimary', $this->object->isPrimary ),
161165
'country' => request()->old( 'country', in_array( $this->object->country, array_values( Countries::getListForSelect( 'iso_3166_2' ) ), false ) ? $this->object->country : null ),
166+
'notes' => request()->old( 'notes', $this->object->notes ),
162167
]);
163168

164169
return [

app/Models/Infrastructure.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
* @method static Builder|Infrastructure whereShortname($value)
6464
* @method static Builder|Infrastructure whereUpdatedAt($value)
6565
* @mixin Eloquent
66+
* @property string|null $notes
67+
* @method static Builder|Infrastructure whereNotes($value)
6668
*/
6769
class Infrastructure extends Model
6870
{
@@ -87,7 +89,8 @@ class Infrastructure extends Model
8789
'isPrimary',
8890
'peeringdb_ix_id',
8991
'ixf_ix_id',
90-
'country'
92+
'country',
93+
'notes',
9194
];
9295

9396
/**

data/travis-ci/travis_ci_test_db.sql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ CREATE TABLE `infrastructure` (
925925
`peeringdb_ix_id` bigint(20) DEFAULT NULL,
926926
`ixf_ix_id` bigint(20) DEFAULT NULL,
927927
`country` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
928+
`notes` longtext COLLATE utf8_unicode_ci,
928929
`created_at` timestamp NULL DEFAULT NULL,
929930
`updated_at` timestamp NULL DEFAULT NULL,
930931
PRIMARY KEY (`id`),
@@ -938,7 +939,7 @@ CREATE TABLE `infrastructure` (
938939

939940
LOCK TABLES `infrastructure` WRITE;
940941
/*!40000 ALTER TABLE `infrastructure` DISABLE KEYS */;
941-
INSERT INTO `infrastructure` VALUES (1,'Infrastructure #1','#1',1,48,20,NULL,NULL,NULL),(2,'Infrastructure #2','#2',0,387,645,NULL,NULL,NULL);
942+
INSERT INTO `infrastructure` VALUES (1,'Infrastructure #1','#1',1,48,20,NULL,NULL,NULL,NULL),(2,'Infrastructure #2','#2',0,387,645,NULL,NULL,NULL,NULL);
942943
/*!40000 ALTER TABLE `infrastructure` ENABLE KEYS */;
943944
UNLOCK TABLES;
944945

@@ -1276,7 +1277,7 @@ CREATE TABLE `migrations` (
12761277
`migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
12771278
`batch` int(11) NOT NULL,
12781279
PRIMARY KEY (`id`)
1279-
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1280+
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
12801281
/*!40101 SET character_set_client = @saved_cs_client */;
12811282

12821283
--
@@ -1285,7 +1286,7 @@ CREATE TABLE `migrations` (
12851286

12861287
LOCK TABLES `migrations` WRITE;
12871288
/*!40000 ALTER TABLE `migrations` DISABLE KEYS */;
1288-
INSERT INTO `migrations` VALUES (1,'2014_10_12_100000_create_password_resets_table',1),(2,'2018_08_08_100000_create_telescope_entries_table',1),(3,'2019_03_25_211956_create_failed_jobs_table',1),(4,'2020_02_06_204556_create_docstore_directories',2),(5,'2020_02_06_204608_create_docstore_files',2),(6,'2020_02_06_204911_create_docstore_logs',2),(7,'2020_03_09_110945_create_docstore_customer_directories',3),(8,'2020_03_09_111505_create_docstore_customer_files',3),(9,'2020_07_21_094354_create_route_server_filters',4),(12,'2020_09_03_153723_add_timestamps',5),(13,'2020_09_18_095136_delete_ixp_table',6),(14,'2020_11_16_102415_database_fixes',7),(15,'2021_03_12_150418_create_log_table',8),(16,'2021_04_14_125742_user_pref',9),(17,'2021_04_14_101948_update_timestamps',10);
1289+
INSERT INTO `migrations` VALUES (1,'2014_10_12_100000_create_password_resets_table',1),(2,'2018_08_08_100000_create_telescope_entries_table',1),(3,'2019_03_25_211956_create_failed_jobs_table',1),(4,'2020_02_06_204556_create_docstore_directories',2),(5,'2020_02_06_204608_create_docstore_files',2),(6,'2020_02_06_204911_create_docstore_logs',2),(7,'2020_03_09_110945_create_docstore_customer_directories',3),(8,'2020_03_09_111505_create_docstore_customer_files',3),(9,'2020_07_21_094354_create_route_server_filters',4),(12,'2020_09_03_153723_add_timestamps',5),(13,'2020_09_18_095136_delete_ixp_table',6),(14,'2020_11_16_102415_database_fixes',7),(15,'2021_03_12_150418_create_log_table',8),(16,'2021_04_14_125742_user_pref',9),(17,'2021_04_14_101948_update_timestamps',10),(18,'2021_05_18_085721_add_note_infrastructure',11);
12891290
/*!40000 ALTER TABLE `migrations` ENABLE KEYS */;
12901291
UNLOCK TABLES;
12911292

@@ -2759,4 +2760,4 @@ UNLOCK TABLES;
27592760
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
27602761
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
27612762

2762-
-- Dump completed on 2021-05-13 13:46:29
2763+
-- Dump completed on 2021-05-18 12:59:57
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class AddNoteInfrastructure extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('infrastructure', function (Blueprint $table) {
17+
$table->longText( 'notes' )->after( 'country' )->nullable();
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('infrastructure', function (Blueprint $table) {
29+
$table->dropColumn('notes');
30+
});
31+
32+
}
33+
}

resources/views/infrastructure/edit-form.foil.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,39 @@
5959
. "cached for two hours. Use 'artisan cache:clear' to reset it.");
6060
?>
6161

62+
<div class="form-group row">
63+
<div class="col-sm-8">
64+
<div class="card">
65+
<div class="card-header">
66+
<ul class="nav nav-tabs card-header-tabs">
67+
<li role="presentation" class="nav-item">
68+
<a class="tab-link-body-note nav-link active" href="#body1">Public Notes</a>
69+
</li>
70+
<li role="presentation" class="nav-item">
71+
<a class="tab-link-preview-note nav-link " href="#preview1">Preview</a>
72+
</li>
73+
</ul>
74+
</div>
75+
<div class="tab-content card-body">
76+
<div role="tabpanel" class="tab-pane show active" id="body1">
77+
<?= Former::textarea( 'notes' )
78+
->id( 'notes' )
79+
->class( 'notes' )
80+
->label( '' )
81+
->rows( 10 )
82+
->blockHelp( "These notes are visible (but not editable) to the member. You can use markdown here." )
83+
?>
84+
</div>
85+
<div role="tabpanel" class="tab-pane" id="preview1">
86+
<div class="bg-light p-4 well-preview">
87+
Loading...
88+
</div>
89+
</div>
90+
</div>
91+
</div>
92+
</div>
93+
</div>
94+
6295
<?= Former::actions(
6396
Former::primary_submit( $t->data['params']['isAdd'] ? 'Create' : 'Save Changes' )->id( 'btn-submit' )->disabled( true )->class( "mb-2 mb-sm-0" ),
6497
Former::secondary_link( 'Cancel' )->href( route($t->feParams->route_prefix . '@list') )->class( "mb-2 mb-sm-0" ),

resources/views/infrastructure/js/edit.foil.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
});
2020

2121
$(document).ready(function() {
22+
$( "#notes" ).parent().removeClass().addClass( "col-sm-12" )
23+
2224
$.ajax( "<?= url('api/v4/ix-f/ixp') ?>" )
2325
.done( function( data ) {
2426
let selectedixp, selectNow;

tests/Browser/InfrastructureControllerTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public function testAdd(): void
9595
->check('isPrimary')
9696
->select( 'ixf_ix_id', 1 )
9797
->select( 'peeringdb_ix_id',1 )
98+
->type( 'notes', 'I am a note')
9899
->press('Create' )
99100
->assertPathIs('/infrastructure/create' )
100101
->assertSee( "The name has already been taken" )
@@ -115,6 +116,7 @@ public function testAdd(): void
115116
$this->assertEquals( 'Infrastructure PHPUnit', $infra->name );
116117
$this->assertEquals( 'phpunit', $infra->shortname );
117118
$this->assertEquals( 'IE', $infra->country );
119+
$this->assertEquals( 'I am a note', $infra->notes );
118120
$this->assertEquals( true, $infra->isPrimary );
119121
$this->assertEquals( '1', $infra->ixf_ix_id );
120122
$this->assertEquals( '1', $infra->peeringdb_ix_id );
@@ -126,6 +128,7 @@ public function testAdd(): void
126128
$browser->assertInputValue('name', 'Infrastructure PHPUnit')
127129
->assertInputValue('shortname', 'phpunit' )
128130
->assertSelected('country', 'IE' )
131+
->assertInputValue('notes', 'I am a note' )
129132
->assertChecked( 'isPrimary' )
130133
->waitForText( "LINX LON1" )
131134
->pause(5000)
@@ -150,6 +153,7 @@ public function testAdd(): void
150153
$this->assertInstanceOf( Infrastructure::class, $infra );
151154
$this->assertEquals( 'Infrastructure PHPUnit', $infra->name );
152155
$this->assertEquals( 'phpunit', $infra->shortname );
156+
$this->assertEquals( 'I am a note', $infra->notes );
153157
$this->assertEquals( 'FR', $infra->country );
154158
$this->assertEquals( false, $infra->isPrimary );
155159
$this->assertEquals( '2', $infra->ixf_ix_id );
@@ -165,6 +169,7 @@ public function testAdd(): void
165169

166170
$browser->assertInputValue('name', 'Infrastructure PHPUnit')
167171
->assertInputValue('shortname', 'phpunit')
172+
->assertInputValue('notes', 'I am a note')
168173
->assertNotChecked( 'isPrimary' )
169174
->assertSelected('ixf_ix_id', '2')
170175
->assertSelected('country', 'FR')

0 commit comments

Comments
 (0)