-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add visibility to component groups #2027
Merged
jbrooksuk
merged 15 commits into
cachethq:2.4
from
yoyosan:add-visibility-to-component-groups
Oct 2, 2016
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
21e0ac7
Implement visibility for the components groups. Part of #1897.
11b75e1
Fix tests not running due to hitting the Setup page.
11a3a70
Add a functional test that asserts logged in users can see all items.
8588806
Add API tests for component group visibility feature.
24c61ed
Implement the visibility hidden option for a component group. Fixes #…
1e502d8
Replace auth() usage with app(Guard::class).
658c760
Apply StyleCI fixes.
1b69813
Drop the hidden visibility feature and fix all tests.
1cfb26b
Rename public to visible since it's a reserved keyword. Apply StyleCI…
1cf11f1
Code review changes.
bc3cfea
Tidy up component and component groups gathering.
8e3e401
Code review changes and StyleCI fixes.
7de032b
Code review changes.
09b4570
Remove extra whitespace
259672f
Remove useless method.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
use CachetHQ\Cachet\Bus\Commands\ComponentGroup\UpdateComponentGroupCommand; | ||
use CachetHQ\Cachet\Models\ComponentGroup; | ||
use GrahamCampbell\Binput\Facades\Binput; | ||
use Illuminate\Contracts\Auth\Guard; | ||
use Illuminate\Database\QueryException; | ||
use Illuminate\Support\Facades\Request; | ||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | ||
|
@@ -29,6 +30,23 @@ | |
*/ | ||
class ComponentGroupController extends AbstractApiController | ||
{ | ||
/** | ||
* The user session object. | ||
* | ||
* @var \Illuminate\Contracts\Auth\Guard | ||
*/ | ||
protected $guard; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docblock this please. |
||
|
||
/** | ||
* Creates a new component group controller instance. | ||
* | ||
* @param \Illuminate\Contracts\Auth\Guard $guard | ||
*/ | ||
public function __construct(Guard $guard) | ||
{ | ||
$this->guard = $guard; | ||
} | ||
|
||
/** | ||
* Get all groups. | ||
* | ||
|
@@ -37,6 +55,9 @@ class ComponentGroupController extends AbstractApiController | |
public function getGroups() | ||
{ | ||
$groups = ComponentGroup::query(); | ||
if (!$this->guard->check()) { | ||
$groups = ComponentGroup::visible(); | ||
} | ||
|
||
$groups->search(Binput::except(['sort', 'order', 'per_page'])); | ||
|
||
|
@@ -74,7 +95,8 @@ public function postGroups() | |
$group = dispatch(new AddComponentGroupCommand( | ||
Binput::get('name'), | ||
Binput::get('order', 0), | ||
Binput::get('collapsed', 0) | ||
Binput::get('collapsed', 0), | ||
Binput::get('visible', ComponentGroup::VISIBLE_AUTHENTICATED) | ||
)); | ||
} catch (QueryException $e) { | ||
throw new BadRequestHttpException(); | ||
|
@@ -97,7 +119,8 @@ public function putGroup(ComponentGroup $group) | |
$group, | ||
Binput::get('name'), | ||
Binput::get('order'), | ||
Binput::get('collapsed') | ||
Binput::get('collapsed'), | ||
Binput::get('visible') | ||
)); | ||
} catch (QueryException $e) { | ||
throw new BadRequestHttpException(); | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is better named as
visibility
or something. To me,visible
implies a boolean.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, makes sense. I'll do the modification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we no longer have a third option, I think it should stay as it is now. This way it's identical to the
Incident
model. Don't you agree?