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 component for configuring features #579

Merged
merged 6 commits into from
Sep 25, 2018
Merged

Add component for configuring features #579

merged 6 commits into from
Sep 25, 2018

Conversation

lukebjerring
Copy link
Contributor

@lukebjerring lukebjerring commented Sep 21, 2018

Description

As discussed in #440, we should be putting new features behind flags by default.

This PR adds an wpt-flags component which uses window.localStorage to store feature state.
Also configurable with wpt-flags-editor component, which uses checkboxes.

Review Information

Visit /flags (might need a query parameter if your browser's stored a redirect from /flags -> /results/flags.

@wpt-pr-bot
Copy link

Staging instance deployed by Travis CI!
Running at https://flags-dot-wptdashboard-staging.appspot.com

Copy link
Member

@Hexcles Hexcles left a comment

Choose a reason for hiding this comment

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

Visit /flags (might need a query parameter if your browser's stored a redirect from /flags -> /results/flags.

I don't think that'd ever happen. We use temporary redirect, not permanent.

How do we access the flags? Is there an easy way to make this component a globally accessible singleton?

@@ -0,0 +1,15 @@
// Copyright 2017 The WPT Dashboard Project. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: 2018

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just edit the PR in cases like this :)

@lukebjerring
Copy link
Contributor Author

I was seeing that behaviour (redirecting) locally.

We'd simply need a <wpt-flags></wpt-flags> component somewhere, e.g.
https://github.com/web-platform-tests/wpt.fyi/pull/580/files#diff-ff3585b170ed88df8ef0c2fa8bcc61ecR476

@Hexcles
Copy link
Member

Hexcles commented Sep 24, 2018

Yeah that generally looks fine. The only minor concern I have is about race conditions. It'd be good to clearly separate "editor" and read-only "reader".

@lukebjerring
Copy link
Contributor Author

Done; I've separated the readonly into a mixin, and the writable into an actual component (since the readonly behaviour is intended as just checking the flags). PTAL.

Copy link
Member

@Hexcles Hexcles left a comment

Choose a reason for hiding this comment

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

LGTM. Using localStorage is a good idea! We don't want cookies :)

<script>
const WPT_FYI_FEATURES = ['queryBuilder'];

const _wptFlags = (superClass, opt_writable) => class extends superClass {
Copy link
Member

Choose a reason for hiding this comment

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

The name opt_writable is a bit unclear to me. What is opt? Optional?

Also, what about using readOnly directly as the argument to avoid the extra negation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

ready() {
super.ready();
for (const feature of WPT_FYI_FEATURES) {
this._createMethodObserver(`valueChanged(${feature}, '${feature}')`);
Copy link
Member

Choose a reason for hiding this comment

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

The leading underscore made me a bit worried at first, but looks like it's documented: https://www.polymer-project.org/2.0/docs/devguide/observers

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 had the same reaction.

@lukebjerring lukebjerring merged commit 701f452 into master Sep 25, 2018
@lukebjerring lukebjerring deleted the flags branch September 25, 2018 13:41
@lukebjerring
Copy link
Contributor Author

We'll use this to hide the component I'm building for #535

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