-
-
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
Add visibility to component groups #2027
Conversation
Right now, for the introduced test to work, you need to copy |
@@ -138,7 +138,7 @@ protected function setupConfig() | |||
$settings = array_merge($this->app->config->get('setting'), $loaded); | |||
|
|||
$this->app->config->set('setting', $settings); | |||
} catch (Exception $e) { | |||
} catch (\Exception $e) { |
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.
Please import this instead.
Hey @jbrooksuk and @GrahamCampbell. Any news on this? Thanks. |
If you could rebase without any merge commits, that would be great please. |
Done. LE: Hmm, I don't think I can though 😢 |
Switch to the |
If there are conflicts, you're best off squashing first otherwise there could be more than one commit to resolve conflicts with. |
This doesn't work unless I get the latest changes from I created a pull request for that and merged it into my fork 2.4 branch. Now I guess I should rebase |
@jbrooksuk and @GrahamCampbell, it should be good now. |
It would be cool to extend this to metrics too I think. |
Thanks @yoyosan! We'll take a look at this shortly. |
* | ||
* @var int | ||
*/ | ||
public $visible; |
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?
@yoyosan why are we concerned about which users own a component group? |
@ConnorVG all done. |
@@ -29,14 +30,28 @@ | |||
*/ | |||
class ComponentGroupController extends AbstractApiController | |||
{ | |||
protected $guard; |
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.
Docblock this please.
Bar those last comments, I think this is pretty damn solid 😄 Thoughts 💢@GrahamCampbell💢? |
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.
Are there any plans to add support to Components themselves? I'd imagine it'd make more sense (now that I think about it) if Components had visibility flags and when a ComponentGroup was queried it could check that (if none are available for the current visibility, it'd just not be accounted for, ie: has
).
@@ -40,14 +40,22 @@ | |||
public $collapsed; | |||
|
|||
/** | |||
* To whom should the component group be visible? |
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.
This comment sort of makes it sound like you can make components visible to specific users which is confusing as that is not the case.
@@ -49,14 +49,22 @@ | |||
public $collapsed; | |||
|
|||
/** | |||
* To whom should the component group be visible? |
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.
Same here.
'collapsed' => $command->collapsed, | ||
'name' => $command->name, | ||
'order' => $command->order, | ||
'collapsed' => $command->collapsed, |
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.
One too many spaces before arrow.
'collapsed' => $command->collapsed, | ||
'name' => $command->name, | ||
'order' => $command->order, | ||
'collapsed' => $command->collapsed, |
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.
One too many spaces before arrow.
protected $guard; | ||
|
||
/** | ||
* Creates a new Components composer instance. |
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.
Please strtolower
the word Components
'order' => 0, | ||
'collapsed' => 0, | ||
'order' => 0, | ||
'collapsed' => 0, |
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.
Too many spaces again.
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.
It's my curse 😿
'collapsed' => 'int', | ||
'name' => 'string', | ||
'order' => 'int', | ||
'collapsed' => 'int', |
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.
Too many spaces again.
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.
🙀
'collapsed' => 'int', | ||
'name' => 'required|string', | ||
'order' => 'int', | ||
'collapsed' => 'int', |
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.
Too many spaces again.
* | ||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function componentGroups() |
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.
Is this needed?
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.
Not really. 😊
But I think it makes sense to have the relation defined.
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.
But a user can't 'own' a ComponentGroup?
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.
Oh, you're right. It's related to the initial implementation.
I'll remove it.
'group' => new ComponentGroup(), | ||
'name' => 'Foo', | ||
'order' => 1, | ||
'collapsed' => 2, |
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.
Too many spaces again.
Yes, I think it makes sense, but not in this PR. I can create another ticket for it. |
Ping @ConnorVG! |
Ping @GrahamCampbell and @jbrooksuk for feedback regarding this PR. |
Hi @yoyosan can you rebase onto 2.4 please and then I'll merge 👍 |
Add functional test that asserts a guest can only see public items.
The missing `boostrap/cachet/testing.php` file is now generated the first time tests are ran.
Add constants for possible values for the visible column/field of the ComponentGroup model. Code review changes.
…1892. Add migration for the created_by column, in component_groups table. Add methods to the ComponentGroup and User models to be able to work with the created_by column. Hidden component groups are no longer displayed on the index page for loggedin users. Add functional test for the dashboard page. Save owner on create/edit component group. Update the API tests for Component group visibility feature.
Some code review fixes too.
… fixes and correct typo.
Hi @jbrooksuk! All done 🚀 |
Awesome, thanks! 👏🏻 |
Hello.
The work on #1897 and #1892 is pretty much done so it's safe to say this PR is ready for code review.
The two tickets require that a component group have visibility for the public vs logged in users. Here's what I've done:
component_groups
table(check the last two migrations):visible
, which specifies whether the component group can be visible to different kinds of users:created_by
, which contains the user id of the component group creatorAbstractTestCase
class that take care of:Also, I'd like to make have some discussions with you,on Slack/other IM if possible, regarding the following:
tests/functional
, integration tests intotests/integration
, unit testsinto tests/unit
?beUser
methods from theAbstractApiTestCase
and replace its usage with the newly added method,signIn
, in theAbstractTestCase
class?StatusPageControllerTest
andDashboardControllerTest
are a bit similar. I would move these methods in a trait which contains ComponentGroup creation methods?!Thanks for reviewing this PR.