-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add changelog inside the application (#1172)
- Loading branch information
Showing
36 changed files
with
591 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Parsedown; | ||
use App\Helpers\DateHelper; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Changelog extends Model | ||
{ | ||
/** | ||
* The attributes that aren't mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $guarded = ['id']; | ||
|
||
/** | ||
* Get the user records associated with the tag. | ||
*/ | ||
public function users() | ||
{ | ||
return $this->belongsToMany('App\User')->withPivot('read', 'upvote')->withTimestamps(); | ||
} | ||
|
||
/** | ||
* Return the markdown parsed description. | ||
* | ||
* @return string | ||
*/ | ||
public function getDescriptionAttribute($value) | ||
{ | ||
return (new Parsedown())->text($value); | ||
} | ||
|
||
/** | ||
* Return the created_at date in a friendly format. | ||
* | ||
* @return string | ||
*/ | ||
public function getCreatedAtAttribute($value) | ||
{ | ||
return DateHelper::getShortDate($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Auth; | ||
use App\Changelog; | ||
use Illuminate\Http\Request; | ||
|
||
class ChangelogController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @param Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index(Request $request) | ||
{ | ||
$changelogs = auth()->user()->changelogs()->orderBy('created_at', 'desc')->get(); | ||
|
||
auth()->user()->markChangelogAsRead(); | ||
|
||
return view('changelog.index')->withChangelogs($changelogs); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Account; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
|
||
/** | ||
* This job adds a changelog entry for all users in a given account. | ||
*/ | ||
class AddChangelogEntry implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
protected $account; | ||
protected $changelogId; | ||
|
||
/** | ||
* Create a new job instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Account $account, int $changelogId) | ||
{ | ||
$this->account = $account; | ||
$this->changelogId = $changelogId; | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
$this->account->addUnreadChangelogEntry($this->changelogId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
database/migrations/2018_04_13_205231_create_changes_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateChangesTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('changelogs', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->mediumText('description'); | ||
$table->timestamps(); | ||
}); | ||
|
||
Schema::create('changelog_user', function (Blueprint $table) { | ||
$table->integer('changelog_id'); | ||
$table->integer('user_id'); | ||
$table->boolean('read')->default(0); | ||
$table->boolean('upvote')->default(0); | ||
$table->timestamps(); | ||
}); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
database/migrations/2018_04_13_230536_update_changelog.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class UpdateChangelog extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
$description = ' | ||
**Introducing a new product changes section** | ||
There is a new header now in Monica. It shows a bell that slowly pulsate, with a red dot, if there is a new feature or an important change in the application. You will not have to find out by yourself what has changed in the product. | ||
'; | ||
|
||
$id = DB::table('changelogs')->insertGetId([ | ||
'description' => $description, | ||
'created_at' => '2018-04-15', | ||
]); | ||
|
||
$instance = \App\Instance::first(); | ||
$instance->addUnreadChangelogEntry($id); | ||
|
||
$description = ' | ||
**New relationships** | ||
You now have much more control on how you link contacts together. | ||
Before you could only have parent/child relationships and significant other relationships. Now you can have much more types of relationships, like uncle/nephew, lover, coworker, and so on. We hope you will like what we have done. | ||
'; | ||
|
||
$id = DB::table('changelogs')->insertGetId([ | ||
'description' => $description, | ||
'created_at' => \Carbon\Carbon::now(), | ||
]); | ||
|
||
$instance->addUnreadChangelogEntry($id); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"/js/app.js": "/js/app.js?id=ddb011814d41693d9c81", | ||
"/css/app.css": "/css/app.css?id=a760618775a6eaf349c1", | ||
"/js/app.js": "/js/app.js?id=0b47a1c14e2467588242", | ||
"/css/app.css": "/css/app.css?id=50497e2c042457a7cc7b", | ||
"/css/stripe.css": "/css/stripe.css?id=64c68c04c4e475fcc7c6", | ||
"/js/vendor.js": "/js/vendor.js?id=490bf428af4c7224b600", | ||
"/js/vendor.js": "/js/vendor.js?id=09ba43dec0e7c5c38705", | ||
"/js/stripe.js": "/js/stripe.js?id=e2284957ba723a52a4b7", | ||
"/js/manifest.js": "/js/manifest.js?id=7999d63793f040b855fb" | ||
"/js/manifest.js": "/js/manifest.js?id=0225916a5d4fbc86a881" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.changelog { | ||
img { | ||
max-width: 100%; | ||
border: 1px solid #e5e5e5; | ||
padding: 3px; | ||
} | ||
} |
Oops, something went wrong.