-
Notifications
You must be signed in to change notification settings - Fork 210
frontend: Show feature flags in topbar and separate page #1144
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::{ | ||
db::Pool, | ||
impl_webpage, | ||
web::{page::WebPage, MetaData}, | ||
}; | ||
use iron::{IronResult, Request, Response}; | ||
use router::Router; | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)] | ||
struct FeaturesPage { | ||
metadata: MetaData, | ||
} | ||
|
||
impl_webpage! { | ||
FeaturesPage = "crate/features.html", | ||
} | ||
|
||
pub fn build_features_handler(req: &mut Request) -> IronResult<Response> { | ||
let router = extension!(req, Router); | ||
let name = cexpect!(req, router.find("name")); | ||
let version = cexpect!(req, router.find("version")); | ||
|
||
let mut conn = extension!(req, Pool).get()?; | ||
|
||
FeaturesPage { | ||
metadata: cexpect!(req, MetaData::from_crate(&mut conn, &name, &version)), | ||
} | ||
.into_response(req) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{%- extends "base.html" -%} | ||
{%- import "header/package_navigation.html" as navigation -%} | ||
|
||
{%- block title -%} | ||
{{ macros::doc_title(name=metadata.name, version=metadata.version) }} | ||
{%- endblock title -%} | ||
|
||
{%- block topbar -%} | ||
{%- set latest_version = "" -%} | ||
{%- set latest_path = "" -%} | ||
{%- set target = "" -%} | ||
{%- set inner_path = metadata.target_name ~ "/index.html" -%} | ||
{%- set is_latest_version = true -%} | ||
{%- set is_prerelease = false -%} | ||
{%- include "rustdoc/topbar.html" -%} | ||
{%- endblock topbar -%} | ||
|
||
{%- block header -%} | ||
{{ navigation::package_navigation(metadata=metadata, active_tab="features") }} | ||
{%- endblock header -%} | ||
|
||
{%- block body -%} | ||
<div class="container package-page-container"> | ||
<div class="pure-g"> | ||
<div class="pure-u-1 pure-u-sm-7-24 pure-u-md-5-24"> | ||
<div class="pure-menu package-menu"> | ||
<ul class="pure-menu-list"> | ||
<li class="pure-menu-heading">Feature flags</li> | ||
{%- if metadata.features -%} | ||
{%- for feature in metadata.features -%} | ||
<li class="pure-menu-item"> | ||
<a href="#{{ feature.name }}" class="pure-menu-link" style="text-align:center;"> | ||
{{ feature.name }} | ||
</a> | ||
</li> | ||
{%- endfor -%} | ||
{%- elif metadata.features is iterable -%} | ||
<li class="pure-menu-item"> | ||
<span style="font-size: 13px;">This release does not have any feature flags.</span> | ||
</li> | ||
{%- else -%} | ||
<li class="pure-menu-item"> | ||
<span style="font-size: 13px;">Feature flags data are not available for this release.</span> | ||
</li> | ||
{%- endif -%} | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
<div class="pure-u-1 pure-u-sm-17-24 pure-u-md-19-24 package-details" id="main"> | ||
<h1>{{ metadata.name }}</h1> | ||
{%- if metadata.features -%} | ||
<p>This version has <b>{{ metadata.features | length }}</b> feature flags, <b data-id="default-feature-len"> | ||
{%- if metadata.features[0].name == 'default' -%} | ||
{{ metadata.features[0].subfeatures | length }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This count is wrong when one of the default features activates more features. In Also I think the previous count should be decreased by 1 (if the crate has a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I was trying it locally and I can see both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the renamed dependency issue is unrelated to this UI I opened #1175 for it. |
||
{%- else -%} | ||
0 | ||
{%- endif -%} | ||
</b> of them enabled by <b>default</b>.</p> | ||
{%- for feature in metadata.features -%} | ||
<h3 id="{{ feature.name }}">{{ feature.name }}</h3> | ||
<ul class="pure-menu-list"> | ||
{%- if feature.subfeatures -%} | ||
{%- for subfeature in feature.subfeatures -%} | ||
<li class="pure-menu-item"> | ||
<span>{{ subfeature }}</span> | ||
</li> | ||
{%- endfor -%} | ||
{%- else -%} | ||
<p>This feature flag does not enable additional features.</p> | ||
{%- endif -%} | ||
</ul> | ||
{%- endfor -%} | ||
{%- elif metadata.features is iterable -%} | ||
<p data-id="empty-features">This release does not have any feature flags.</p> | ||
{%- else -%} | ||
<p data-id="null-features">Feature flags data are not available for this release.</p> | ||
{%- endif -%} | ||
</div> | ||
</div> | ||
</div> | ||
{%- endblock body -%} |
Uh oh!
There was an error while loading. Please reload this page.