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

Reorganize static file structure and display revision data to user #16

Merged
merged 4 commits into from
Jul 5, 2017

Conversation

purelogiq
Copy link
Contributor

@purelogiq purelogiq commented Jun 2, 2017

Update: I've split the patch into smaller commits that have self contained commits.

See the "Document changes" patch with a lot of readme information.

To test this patch, you will have to start the lando-api docker image then in this projects docker-compose file edit the LANDO_API_URL to point to the docker-ip address:port of lando api.

It will help greatly to look at the structure of this PR in your file editor for it to make more sense.

============================================================
[wip] I will update the screenshot as I push more changes.

lando-revision-ss

@purelogiq purelogiq force-pushed the plq/display-revision branch from a22b53b to c8444c7 Compare June 5, 2017 21:22
@purelogiq
Copy link
Contributor Author

New WIP SS. Nothing special, but, all the data is being pulled in including parent revisions.
lando-revision-ss-2

@darkwing
Copy link
Contributor

Looks good so far. What is THIS_WONT_BE_NEEDED_LATER_API_KEY and why wont it be needed.

Back over to you

@purelogiq
Copy link
Contributor Author

The last commit adds support for layouts and fixes some issues with how I was using Semantic UI. I will fully explain in the PR section when finished!

Also THIS_WONT_BE_NEEDED_LATER_API_KEY was a temporary fix for mozilla-conduit/lando-api#6 :D

@purelogiq purelogiq force-pushed the plq/display-revision branch from f270b1a to 10aab82 Compare June 22, 2017 08:46
@purelogiq
Copy link
Contributor Author

lando-revision-more

@purelogiq
Copy link
Contributor Author

Still haven't actually styled the revision page, just did all behind the scenes work to include sass and materialize. I've written a small novel in READMEs so please do check them out :D (there are 4 or so in total in this PR).

BTW the final PR will be more organized in terms of commits and so on. Getting there!

@purelogiq
Copy link
Contributor Author

6-27

@purelogiq purelogiq force-pushed the plq/display-revision branch from c2e902a to d71264a Compare June 27, 2017 18:12
@purelogiq purelogiq changed the title [WIP] Display revision data to user Reorganize static file structure and display revision data to user Jun 27, 2017
@@ -0,0 +1,3 @@
.Footer {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep selectors as lowercase, especially if we're using - to separate selector words instead of camelcase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you see the static/src/css/README.md ? They start with uppercase letters because of the SUIT CSS pattern discussed there (meant to allow us to have components for all our stuff, sorta like we did in React).

@@ -0,0 +1,2 @@
// Setup one global namespace to hold all our classes.
var Lando = Lando || {};
Copy link
Contributor

Choose a reason for hiding this comment

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

You can run into a runtime error with this; instead put window in:

window.Lando = window.Lando || {};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed

@@ -0,0 +1,13 @@
// In dev, you must make a change in lando.scss for changes here to be detected.
// This file isn't autowatched by the Flask asset pipeline.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do something about this? Initiate a watcher of some kind?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can :)

@@ -73,8 +69,10 @@ def create_app(

# Register routes via Flask Blueprints
from landoui.pages import pages
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: why are we pulling these in here instead of at the top.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really not that I think of it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes actually! It is because these depend on the global oidc variable we set at the top.

@@ -0,0 +1,33 @@
/* Simple class to manage events and state on the /revision/{id} page */
Lando.RevisionPage = class {
Copy link
Contributor

Choose a reason for hiding this comment

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

In looking at how this is used, we should really use the jQuery plugin pattern. You can find an example I created for MDN here:

https://github.com/mozilla/kuma/blob/master/kuma/static/js/moz-jquery-plugins.js#L287

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean we should create 1 plugin for the entire 1 "RevisionPage" or a plugin for the collapsible that I made?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it I'll update this to use the pattern for the whole page e.g.$page.landoRevisionPage().
Also doing so will probably remove the need for the global Lando variable I made (maybe it wouldn't hurt to keep it)

@darkwing
Copy link
Contributor

This isn't building properly:

Requirement already satisfied: setuptools>=11.3 in /usr/local/lib/python3.5/site-packages (from cryptography==1.8.1->-r /requirements.txt (line 55))
In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
    six from https://pypi.python.org/packages/c8/0a/b6723e1bc4c516cb687841499455a8505b44607ab535be01091c0f24f079/six-1.10.0-py2.py3-none-any.whl#md5=3ab558cf5d4f7a72611d59a81a315dc8 (from oic==0.9.1.0->-r /requirements.txt (line 27))
    packaging from https://pypi.python.org/packages/87/1b/c39b7c65b5612812b83d6cab7ef2885eac9f6beb0b7b8a7071a186aea3b1/packaging-16.8-py2.py3-none-any.whl#md5=c7326351bf015fa53c74b0075923ab02 (from cryptography==1.8.1->-r /requirements.txt (line 55))
ERROR: Service 'lando-ui' failed to build: The command '/bin/sh -c pip install -r /requirements.txt' returned a non-zero code: 1
...

@purelogiq purelogiq force-pushed the plq/display-revision branch 3 times, most recently from b48e03b to ad186ca Compare June 29, 2017 23:12
@purelogiq purelogiq force-pushed the plq/display-revision branch 3 times, most recently from ff7be65 to 7828cc1 Compare June 30, 2017 20:52
}

bindEvents(){
$('button').click(clickHandler);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use .on('click', clickHandler)

### Example Class for the widget above

```javascript
Lando.Widget = class {
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, is any of this documentation current?

@@ -0,0 +1,2 @@
// Setup one global namespace to hold all our classes.
window.Lando = window.Lando || {};
Copy link
Contributor

Choose a reason for hiding this comment

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

No longer needed.

function RevisionPageCollapsible(){
let $revision = $(this).closest('.RevisionPage-parentRevision').first();

$(this).click(function(){
Copy link
Contributor

Choose a reason for hiding this comment

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

.on('click', fn)

$page.find('.RevisionPage-collapseLink').landoRevisionPageCollapsible();
}

return this.each(RevisionPage);
Copy link
Contributor

Choose a reason for hiding this comment

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

RevisionPage is so small we can probably just inline it. Also, only classes should be capitalized.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be $(this).each()?

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.each I believe


@revisions.route('/revisions/<revision_id>')
def get_revision(revision_id):
revision_api_url = os.getenv('LANDO_API_URL') + '/revisions/' + revision_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we do:

{API_URL}/revisions/{REVISION_ID}'.format(...)?

@purelogiq purelogiq force-pushed the plq/display-revision branch from 7828cc1 to 46585fe Compare June 30, 2017 21:28
const iconClassSelectors = '.fa-chevron-circle-right, .fa-chevron-circle-down';
const iconClassToggle = 'fa-chevron-circle-right, fa-chevron-circle-down';

return this.each(function(){
Copy link
Contributor

Choose a reason for hiding this comment

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

$(this).each?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pretty sure it is this.each, since this already refers to the jquery selector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(and it works so far)

@purelogiq purelogiq requested a review from zalun July 5, 2017 14:12
Copy link
Contributor

@zalun zalun left a comment

Choose a reason for hiding this comment

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

Ready to go after nits

display: none;
margin-top: .5rem;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: empty lines, also later at the endo of the file

color: $blue;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: empty lines

@revisions.route('/revisions/<revision_id>')
def get_revision(revision_id):
revision_api_url = '{}/revisions/{}'\
.format(os.getenv('LANDO_API_URL'), revision_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: wouldn't it be better to write it like this?

'{}/revisions/{}'.format(
    os.getenv('LANDO_API_URL'), revision_id
)

@purelogiq purelogiq force-pushed the plq/display-revision branch from 46585fe to 280b317 Compare July 5, 2017 15:26
@purelogiq purelogiq force-pushed the plq/display-revision branch from 280b317 to deb69b8 Compare July 5, 2017 15:27
@purelogiq
Copy link
Contributor Author

Fixed, gonna merge it :)

@purelogiq purelogiq merged commit 8a5d3c3 into master Jul 5, 2017
@purelogiq purelogiq deleted the plq/display-revision branch September 26, 2017 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants