Skip to content
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
merged 15 commits into from
Oct 2, 2016
Merged

Add visibility to component groups #2027

merged 15 commits into from
Oct 2, 2016

Conversation

yoyosan
Copy link
Contributor

@yoyosan yoyosan commented Aug 3, 2016

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:

  • added two new columns to the component_groups table(check the last two migrations):
    • visible, which specifies whether the component group can be visible to different kinds of users:
      • 0, viewable by public/guests
      • 1, only visible to logged in users,
      • 2, hidden to logged in users but visible to its creator. Default value
    • created_by, which contains the user id of the component group creator
  • updated all related Command and CommandHandler classes and their tests
  • added functional tests for the StatusPageController and the DashboardController classes
  • added a couple of new methods to the AbstractTestCase class that take care of:
    • setting up the project configuration before running the functional tests in order to avoid the setup installation page
    • a sign in helper method that can be used to easily sign in users as needed for future tests

Also, I'd like to make have some discussions with you,on Slack/other IM if possible, regarding the following:

  • Should I move functional tests into their own directory e.g. tests/functional, integration tests into tests/integration, unit tests into tests/unit?
  • Is it ok with you if I remove the beUser methods from the AbstractApiTestCase and replace its usage with the newly added method, signIn, in the AbstractTestCase class?
  • The StatusPageControllerTest and DashboardControllerTest are a bit similar. I would move these methods in a trait which contains ComponentGroup creation methods?!

Thanks for reviewing this PR.

@yoyosan
Copy link
Contributor Author

yoyosan commented Aug 3, 2016

Right now, for the introduced test to work, you need to copy boostrap/cachet/production.php to boostrap/cachet/testing.php. I'm going to look for a better way though .

@jbrooksuk jbrooksuk added this to the V2.4.0 milestone Aug 4, 2016
@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please import this instead.

@yoyosan yoyosan changed the title [WIP] Add visibility to component groups Add visibility to component groups Aug 7, 2016
@yoyosan
Copy link
Contributor Author

yoyosan commented Aug 8, 2016

Hey @jbrooksuk and @GrahamCampbell.

Any news on this?

Thanks.

@GrahamCampbell
Copy link
Contributor

If you could rebase without any merge commits, that would be great please.

@yoyosan
Copy link
Contributor Author

yoyosan commented Aug 8, 2016

Done.
I need to resolve the conflicts with 2.4.

LE: Hmm, I don't think I can though 😢

@jbrooksuk
Copy link
Member

I need to resolve the conflicts with 2.4.

Switch to the 2.4 branch and run git fetch origin && git reset --hard origin/2.4.

@GrahamCampbell
Copy link
Contributor

If there are conflicts, you're best off squashing first otherwise there could be more than one commit to resolve conflicts with.

@yoyosan
Copy link
Contributor Author

yoyosan commented Aug 9, 2016

Switch to the 2.4 branch and run git fetch origin && git reset --hard origin/2.4.

This doesn't work unless I get the latest changes from CachetHQ/Cachet:2.4 into my 2.4 branch, on yoyosan/Cachet.

I created a pull request for that and merged it into my fork 2.4 branch. Now I guess I should rebase add-visibility-to-component-groups with my fork's 2.4 branch?

@yoyosan
Copy link
Contributor Author

yoyosan commented Aug 9, 2016

@jbrooksuk and @GrahamCampbell, it should be good now.

@GrahamCampbell
Copy link
Contributor

It would be cool to extend this to metrics too I think.

@jbrooksuk
Copy link
Member

@jbrooksuk and @GrahamCampbell, it should be good now.

Thanks @yoyosan! We'll take a look at this shortly.

*
* @var int
*/
public $visible;
Copy link
Member

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.

Copy link
Contributor Author

@yoyosan yoyosan Aug 10, 2016

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.

Copy link
Contributor Author

@yoyosan yoyosan Aug 11, 2016

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?

@jbrooksuk
Copy link
Member

@yoyosan why are we concerned about which users own a component group?

@yoyosan
Copy link
Contributor Author

yoyosan commented Sep 13, 2016

@ConnorVG all done.

@@ -29,14 +30,28 @@
*/
class ComponentGroupController extends AbstractApiController
{
protected $guard;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docblock this please.

@ConnorVG
Copy link
Contributor

Bar those last comments, I think this is pretty damn solid 😄

Thoughts 💢@GrahamCampbell💢?

Copy link
Contributor

@ConnorVG ConnorVG left a 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?
Copy link
Contributor

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?
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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.
Copy link
Contributor

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 :trollface:

'order' => 0,
'collapsed' => 0,
'order' => 0,
'collapsed' => 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many spaces again.

Copy link
Contributor Author

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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many spaces again.

Copy link
Contributor Author

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',
Copy link
Contributor

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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor Author

@yoyosan yoyosan Sep 17, 2016

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.

Copy link
Contributor

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?

Copy link
Contributor Author

@yoyosan yoyosan Sep 19, 2016

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many spaces again.

@yoyosan
Copy link
Contributor Author

yoyosan commented Sep 17, 2016

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).

Yes, I think it makes sense, but not in this PR. I can create another ticket for it.

@yoyosan
Copy link
Contributor Author

yoyosan commented Sep 17, 2016

Ping @ConnorVG!

@yoyosan
Copy link
Contributor Author

yoyosan commented Sep 19, 2016

Ping @GrahamCampbell and @jbrooksuk for feedback regarding this PR.

@jbrooksuk
Copy link
Member

Hi @yoyosan can you rebase onto 2.4 please and then I'll merge 👍

Yoyosan and others added 15 commits October 2, 2016 15:16
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.
@yoyosan
Copy link
Contributor Author

yoyosan commented Oct 2, 2016

Hi @jbrooksuk! All done 🚀

@jbrooksuk jbrooksuk merged commit ad0954e into cachethq:2.4 Oct 2, 2016
@jbrooksuk
Copy link
Member

Awesome, thanks! 👏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants