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

Preliminary frontend work #13

Merged
merged 2 commits into from
Mar 9, 2017
Merged

Preliminary frontend work #13

merged 2 commits into from
Mar 9, 2017

Conversation

PVince81
Copy link
Contributor

Preliminary work for the frontend.

This extends the Makefile significantly and adds the following:

  • composer deps (currently only phpunit)
  • nodejs deps (karma + bower + handlebars)
  • bower deps
  • karma test runner
  • handlebars compilation

@PVince81 PVince81 added this to the 10.0 milestone Dec 14, 2016
@PVince81 PVince81 self-assigned this Dec 14, 2016
@PVince81 PVince81 force-pushed the frontend branch 2 times, most recently from 87a4cad to 2046e8c Compare December 19, 2016 10:12
@PVince81
Copy link
Contributor Author

PVince81 commented Dec 19, 2016

@PVince81
Copy link
Contributor Author

PVince81 commented Dec 19, 2016

@PVince81
Copy link
Contributor Author

PVince81 commented Feb 3, 2017

Rebased.

Will require adjustments to be able to work with the updated endpoint structure.

@PVince81
Copy link
Contributor Author

PVince81 commented Feb 8, 2017

This "uri" approach is a nightmare.

Backbone (and potentially other frameworks) assume that if the id is known, then the object already exists. I have used the "uri" as id so it always uses the "update" internal method instead of "create" and tries to PROPPATCH instead of MKCOL.

I think we'll still need to use the actual internal id field as the backbone id, and the uri is only used for the path. I'll try that approach then.

@PVince81
Copy link
Contributor Author

PVince81 commented Feb 8, 2017

@PVince81
Copy link
Contributor Author

PVince81 commented Feb 8, 2017

  • BUG: the Webdav endpoint must return the internal ID as header after MKCOL, for Backbone to be able to set an internal id

@PVince81 PVince81 force-pushed the frontend branch 5 times, most recently from f12b48d to 61b0149 Compare February 17, 2017 10:14
@PVince81
Copy link
Contributor Author

So I finally have a solution, but it required me to write custom model and collections specifically for Webdav. This would make it reusable in the future. See owncloud/core#27119.

The frontend now works, you can now:

  • create/rename/delete groups
  • leave a group
  • rename a group
  • add/delete members
  • switch role for a member

@PVince81 PVince81 force-pushed the frontend branch 2 times, most recently from 9899c96 to 059007d Compare March 7, 2017 11:39
@PVince81
Copy link
Contributor Author

PVince81 commented Mar 7, 2017

Latest state:
Custom Groups

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 7, 2017

This is now ready for review.

Note that this core PR is still required to test this: owncloud/core#27119 (make sure to run make in core again to get the updated lib)

Everything is squashed into two commits:
The first commit is about improving the base stuff with a better Makefile (try make help). I hope to make this reusable for other apps.
The second commit adds all the JS code + JS unit tests to make the UI work as seen in #13 (comment)

Please review @felixheidecke @jvillafanez @DeepDiver1975 @VicDeo @IljaN

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 7, 2017

... and if you're wondering why I used window.prompt and window.confirm:
this here is the crude version of the UI. It is functional, but doesn't provide the best UX yet.
UX will be improved in subsequent PRs.

At least we could say this is a POC that could be used for demoing the functionality.

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 8, 2017

ah of course, unit tests cannot pass until owncloud/core#27119 from core is merged

css/app.css Outdated
/* FIXME: integrate with core styles */
#customgroups .sidebar .close {
position: absolute;
top: 0;
Copy link
Member

Choose a reason for hiding this comment

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

indentation

customGroupsTitle: t('customgroups', 'Custom Groups')
}));

this.$groupsContainer = this.$('.groups-container').removeClass('icon-loading');
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if this.$('.groups-container') is a good idea. This is confusing for me.

If it's for marking the variable as a jquery object, I'd rather use a name to reflect that, for example "this.jqueryGroupsContainer"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this.$('.groups-container') is a Backbone View shortcut for this.$el.find('.groups-container')

As for this.$groupsContainer the $ sign is a convention that already tells that this attribute is a jQuery object, just like this.$el.

Hope that makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

👍

js/App.js Outdated

_onSelectGroup: function(group) {
this.$membersContainer.empty();
var state = {
Copy link
Member

Choose a reason for hiding this comment

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

Is this variable used? The scope should be limited to this function and it isn't used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

forgot to kill it...

js/GroupsView.js Outdated
this,
'_onSubmitCreationForm',
'_onRenameGroup',
'_onDeleteGroup'
Copy link
Member

Choose a reason for hiding this comment

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

include the _onSelect function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually I'll remove them all because backbone auto-binds when specified in the "events" block

// TODO: lock row during save
model.save({
displayName: newName
});
Copy link
Member

Choose a reason for hiding this comment

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

I guess the function should return true if it's renamed properly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, this is a jquery event handler and the return value indicates whether bubbling is needed (or something like this).

Actually we don't need to return because we already call ev.preventDefault(); at the top.

I'll still add add return false;

Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -0,0 +1,27 @@
<form name="customGroupsCreationForm">
<div>
<input
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather "oneline" this if it fits. There is only one variable attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. now it has 134 columns 😉

</div>
<table class="grid">
<thead>
<th></th>
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of these empty headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This header is for the avatar column

Copy link
Member

Choose a reason for hiding this comment

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

maybe an HTML comment here to make sure these header are in use? Just looking exclusively at the file it seems they can be deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nah... will only do if I need to retouch this PR or next time I come around this place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

an experienced HTML dev would know that one does not simply remove an empty "th" or "td" because that would mess up the layout 😉

*/
public function index() {
// TODO: cache or add to info.xml ?
$modules = json_decode(file_get_contents(__DIR__ . '/../../js/modules.json'));
Copy link
Member

Choose a reason for hiding this comment

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

I guess this "modules.json" file is used in more places, otherwise it would be better to hardcode the modules here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The second usage is in the unit tests, that's why I wanted a separate file... I'm still longing for a proper portable way to load JS files for OC apps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let's discuss in #34

Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -91,7 +91,8 @@ public function initialize(\Sabre\DAV\Server $server) {
$this->server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
$ns = '{' . self::NS_OWNCLOUD . '}';
$this->server->resourceTypeMapping[MembershipNode::class] = $ns . 'customgroups-membership';
$this->server->resourceTypeMapping[GroupsCollection::class] = $ns . 'customgroups-group';
$this->server->resourceTypeMapping[GroupsCollection::class] = $ns . 'customgroups-groups';
Copy link
Member

Choose a reason for hiding this comment

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

"customgroups-groups" or "customgroups-group"? Is this intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is intended, but not specifically for the frontend work... just a "pass-by" fix.

"customgroups-groups" plural is for GroupsCollection as the collection is a list of groups, so "groups".
The next item GroupMemberShipCollection is actually a single group, so it has the type "customgroups-group" singular.

Still, thanks for spotting

Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -36,7 +36,6 @@ class MembershipNode implements \Sabre\DAV\INode, \Sabre\DAV\IProperties {

const PROPERTY_ROLE = '{http://owncloud.org/ns}role';
const PROPERTY_USER_ID = '{http://owncloud.org/ns}user-id';
const PROPERTY_GROUP_URI = '{http://owncloud.org/ns}group-uri';
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to remove this? Mainly to confirm this isn't accidental

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The property isn't used at all in this node.
It was a copy-paste from another node I believe so I removed it.

Copy link
Member

Choose a reason for hiding this comment

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

👍

@jvillafanez
Copy link
Member

I've also seen that the windows prompts aren't translatable... I think that we should make them translatable in order to merge this, so we can change that part at any time. Otherwise we might need to rush to change the implementation if this is merged.

@jvillafanez
Copy link
Member

I haven't reviewed the tests yet.... 😓

@SergioBertolinSG
Copy link
Contributor

When adding new users to custom group there is no autocomplete in the textfield. This will come after this PR or it is a bug here?

@SergioBertolinSG
Copy link
Contributor

When editing a member role, just a click on the pencil change member's role. Feels a bit unexpected, I think it should be a dropdown with the options admin or member.

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 8, 2017

windows prompts

You mean the native window.prompt ? We need to replace these anyway... I put these here to save some dev time. They definitely need a better replacement. (separately)

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 8, 2017

@SergioBertolinSG I've raised them separately:

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 8, 2017

Addressed all review comments and squashed the fixes into the last commit.

Note that I also renamed the unit tests from CustomGroupsCollection to GroupsCollection now.
Originally I had "CustomGroups" as prefix everywhere but it became boring so I renamed the JS files but forgot to rename the test files. This is done here now.

@jvillafanez another check ?

@PVince81 PVince81 mentioned this pull request Mar 8, 2017
2 tasks
@jvillafanez
Copy link
Member

You mean the native window.prompt ? We need to replace these anyway... I put these here to save some dev time. They definitely need a better replacement. (separately)

Yes. My point is that I don't know how much time we have to change them. If we make their text translatable, we could release the app. It's ugly, nobody likes it, but it's usable. We can improve the app later. (I'm refering to the windows prompts, not the app itself 😄 )
If we merge it as it is, we'll have to change it before releasing the app because those strings aren't translatable, and we shouldn't release the app under those conditions.

@PVince81
Copy link
Contributor Author

PVince81 commented Mar 9, 2017

We definitely shouldn't release the final app with the ugly window prompts.
Raised #36

@PVince81 PVince81 merged commit de7ba54 into master Mar 9, 2017
@PVince81 PVince81 deleted the frontend branch March 9, 2017 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants