-
Notifications
You must be signed in to change notification settings - Fork 781
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
Make data limits a permanent feature #698
Conversation
@@ -546,7 +546,7 @@ export class ServerView extends DirMixin(PolymerElement) { | |||
</div> | |||
</div> | |||
<div name="settings"> | |||
<outline-server-settings id="serverSettings" server-id="[[serverId]]" server-hostname="[[serverHostname]]" server-name="[[serverName]]" server-version="[[serverVersion]]" is-hostname-editable="[[isHostnameEditable]]" server-management-api-url="[[serverManagementApiUrl]]" server-port-for-new-access-keys="[[serverPortForNewAccessKeys]]" is-access-key-port-editable="[[isAccessKeyPortEditable]]" access-key-data-limit="{{accessKeyDataLimit}}" is-access-key-data-limit-enabled="{{isAccessKeyDataLimitEnabled}}" data-limits-availability-date="[[dataLimitsAvailabilityDate]]" supports-access-key-data-limit="[[supportsAccessKeyDataLimit]]" server-creation-date="[[serverCreationDate]]" server-monthly-cost="[[monthlyCost]]" server-monthly-transfer-limit="[[_formatBytesTransferred(monthlyOutboundTransferBytes)]]" is-server-managed="[[isServerManaged]]" server-location="[[serverLocation]]" metrics-enabled="[[metricsEnabled]]" localize="[[localize]]"> | |||
<outline-server-settings id="serverSettings" server-id="[[serverId]]" server-hostname="[[serverHostname]]" server-name="[[serverName]]" server-version="[[serverVersion]]" is-hostname-editable="[[isHostnameEditable]]" server-management-api-url="[[serverManagementApiUrl]]" server-port-for-new-access-keys="[[serverPortForNewAccessKeys]]" is-access-key-port-editable="[[isAccessKeyPortEditable]]" access-key-data-limit="{{accessKeyDataLimit}}" is-access-key-data-limit-enabled="{{isAccessKeyDataLimitEnabled}}" supports-access-key-data-limit="[[supportsAccessKeyDataLimit]]" server-creation-date="[[serverCreationDate]]" server-monthly-cost="[[monthlyCost]]" server-monthly-transfer-limit="[[_formatBytesTransferred(monthlyOutboundTransferBytes)]]" is-server-managed="[[isServerManaged]]" server-location="[[serverLocation]]" metrics-enabled="[[metricsEnabled]]" localize="[[localize]]"> |
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.
Nit: should we reformat this across across several lines? It's difficult for me to read on my laptop screen.
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.
We lost the formatting during the polymer upgrade. We should look into a way of automating formatting for these mixed (html + css + js) files.
apiServer.put( | ||
`${apiPrefix}/server/access-key-data-limit`, service.setAccessKeyDataLimit.bind(service)); | ||
apiServer.del( | ||
`${apiPrefix}/server/access-key-data-limit`, service.removeAccessKeyDataLimit.bind(service)); |
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 wonder if it's good to model features as a resource like we do with access keys (/server/features/
). That would be similar to /experimental/
url part we have.
Ideally, I think it would be nice to have something broken down by component like:
/server/access-key/keys/:id
/server/access-key/features/:id
/server/access-key/custom-methods
But that might not be possible to shoehorn to our current scheme.
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.
In a way we already do this: the access key data limit is a property of the server (resource). I like the idea of formalizing the hierarchy.
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.
Minor important change to the redirect code.
} | ||
|
||
// Returns a request handler that redirects a bound request path to `url` with HTTP status `code`. | ||
function redirect(url: string, code = 301): restify.RequestHandlerType { |
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 use 308 instead to preserve the HTTP method.
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.
Done.
} | ||
|
||
// Returns a request handler that redirects a bound request path to `url` with HTTP status `code`. | ||
function redirect(url: string, code = 301): restify.RequestHandlerType { |
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 you never pass a different code, maybe remove it?
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.
Done.
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.
Looks good. I have some minor readability tweaks.
@@ -649,6 +650,7 @@ export class ServerView extends DirMixin(PolymerElement) { | |||
this.isAccessKeyDataLimitEnabled = false; | |||
/** Whether the server supports data limits. */ | |||
this.supportsAccessKeyDataLimit = false; | |||
this.shouldShowFeatureMetricsDisclaimer = false; |
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.
You can be shorter: this.showFeatureMetricsDisclaimer
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.
Done.
@@ -262,6 +272,7 @@ Polymer({ | |||
accessKeyDataLimit: {type: Object, value: null}, // type: app.DisplayDataAmount | |||
supportsAccessKeyDataLimit: | |||
{type: Boolean, value: false}, // Whether the server supports data limits. | |||
shouldShowFeatureMetricsDisclaimer: {type: Boolean, value: false}, |
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.
You can be shorter: showFeatureMetricsDisclaimer
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.
Done.
src/server_manager/web_app/app.ts
Outdated
// - opt-in metrics are enabled | ||
// - user has not previously seen the data limits help bubble | ||
// - user has not previously seen this disclaimer | ||
function shouldShowFeatureMetricsDisclaimer(server: server.Server): 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.
Let's have a hasConsentForFeatureMetrics
or something along those lines. I think it's easier to reason about than having to understand the flows.
It should return dataLimits-feature-collection-consent
|| dataLimitsHelpBubble-dismissed
. Notice it's independent of the server.
Then you can have
view.showFeatureMetricsDisclaimer =
server.getMetricsEnabled() &&
!server.getAccessKeyDataLimit() &&
!this.hasConsentForFeatureMetrics()
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.
Done.
src/server_manager/web_app/app.ts
Outdated
@@ -1024,6 +1037,9 @@ export class App { | |||
this.appRoot.showNotification(this.appRoot.localize('saved')); | |||
serverView.accessKeyDataLimit = dataLimitToDisplayDataAmount(limit); | |||
this.refreshTransferStats(this.selectedServer, serverView); | |||
// Don't display the feature collection disclaimer anymore. | |||
serverView.shouldShowFeatureMetricsDisclaimer = false; | |||
window.localStorage.setItem('dataLimits-feature-collection-disclaimer', 'true'); |
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.
Let's rename -disclaimer
to -consent
. Consent is really what we want to track.
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.
Done.
src/server_manager/web_app/app.ts
Outdated
@@ -88,6 +85,13 @@ async function computeDefaultAccessKeyDataLimit( | |||
} | |||
} | |||
|
|||
// Returns whether the user has seen a disclaimer for the updated feature metrics data collection | |||
// policy. | |||
function hasFeatureMetricsConsent(): 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.
I'm sorry, I misunderstood on first read. So it's not really consent, because we can't collect the metric unless the metrics sharing is enabled. It's really about notification.
So maybe call it something like notifiedOfFeatureMetrics()
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.
Done.
src/server_manager/web_app/app.ts
Outdated
this.surveys.presentDataLimitsEnabledSurvey(); | ||
// Don't display the feature collection disclaimer anymore. | ||
serverView.showFeatureMetricsDisclaimer = false; | ||
window.localStorage.setItem('dataLimits-feature-collection-consent', 'true'); |
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.
Then this would be dataLimits-feature-collection-notification
or something similar.
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.
Done.
shadowbox
/server/access-key-data-limits
fromexperimental/access-key-data-limits
.Outline Manager