Merge pull request #194 from dod-ccpo/show-workspace-name-in-header

Show currently active workspace name in label
This commit is contained in:
patricksmithdds 2018-08-21 16:42:36 -04:00 committed by GitHub
commit 0abaf8bd77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 61 additions and 62 deletions

View File

@ -64,11 +64,6 @@ def make_app(config):
def make_flask_callbacks(app): def make_flask_callbacks(app):
@app.before_request @app.before_request
def _set_globals(): def _set_globals():
g.navigationContext = (
"workspace"
if re.match("\/workspaces\/[A-Za-z0-9]*", request.path)
else "global"
)
g.dev = os.getenv("FLASK_ENV", "dev") == "dev" g.dev = os.getenv("FLASK_ENV", "dev") == "dev"
g.matchesPath = lambda href: re.match("^" + href, request.path) g.matchesPath = lambda href: re.match("^" + href, request.path)
g.modal = request.args.get("modal", None) g.modal = request.args.get("modal", None)

View File

@ -1,14 +1,33 @@
class Workspaces(object):
MOCK_WORKSPACES = [
{
"name": "Unclassified IaaS and PaaS for Defense Digital Service (DDS)",
"id": "5966187a-eff9-44c3-aa15-4de7a65ac7ff",
"task_order": {"number": 123456},
"user_count": 23,
}
]
@classmethod
def get(cls, workspace_id):
return cls.MOCK_WORKSPACES[0]
@classmethod
def get_many(cls):
return cls.MOCK_WORKSPACES
class Projects(object): class Projects(object):
def __init__(self):
@classmethod
def create(cls, creator_id, body):
pass pass
def create(self, creator_id, body): @classmethod
def get(cls, project_id):
pass pass
def get(self, project_id): @classmethod
pass def get_many(cls, workspace_id):
def get_many(self, workspace_id):
return [ return [
{ {
"id": "187c9bea-9541-45d7-801f-cf8e7a642e93", "id": "187c9bea-9541-45d7-801f-cf8e7a642e93",
@ -41,21 +60,23 @@ class Projects(object):
}, },
] ]
def update(self, request_id, request_delta): @classmethod
def update(cls, request_id, request_delta):
pass pass
class Members(object): class Members(object):
def __init__(self):
@classmethod
def create(cls, creator_id, body):
pass pass
def create(self, creator_id, body): @classmethod
def get(cls, request_id):
pass pass
def get(self, request_id): @classmethod
pass def get_many(cls, workspace_id):
def get_many(self, workspace_id):
return [ return [
{ {
"first_name": "Danny", "first_name": "Danny",
@ -86,5 +107,6 @@ class Members(object):
}, },
] ]
def update(self, request_id, request_delta): @classmethod
def update(cls, request_id, request_delta):
pass pass

View File

@ -1,45 +1,35 @@
from flask import Blueprint, render_template from flask import Blueprint, render_template, request as http_request
from atst.domain.workspaces import Projects, Members from atst.domain.workspaces import Members, Projects, Workspaces
bp = Blueprint("workspaces", __name__) bp = Blueprint("workspaces", __name__)
mock_workspaces = [ @bp.context_processor
{ def workspace():
"name": "Unclassified IaaS and PaaS for Defense Digital Service (DDS)", workspace = None
"id": "5966187a-eff9-44c3-aa15-4de7a65ac7ff", if "workspace_id" in http_request.view_args:
"task_order": {"number": 123456}, workspace = Workspaces.get(http_request.view_args["workspace_id"])
"user_count": 23, return { "workspace": workspace }
}
]
@bp.route("/workspaces") @bp.route("/workspaces")
def workspaces(): def workspaces():
return render_template("workspaces.html", page=5, workspaces=mock_workspaces) return render_template("workspaces.html", page=5, workspaces=Workspaces.get_many())
@bp.route("/workspaces/<workspace_id>/projects") @bp.route("/workspaces/<workspace_id>/projects")
def workspace_projects(workspace_id): def workspace_projects(workspace_id):
projects_repo = Projects() projects = Projects.get_many(workspace_id)
projects = projects_repo.get_many(workspace_id) return render_template("workspace_projects.html", projects=projects)
return render_template(
"workspace_projects.html", workspace_id=workspace_id, projects=projects
)
@bp.route("/workspaces/<workspace_id>/members") @bp.route("/workspaces/<workspace_id>/members")
def workspace_members(workspace_id): def workspace_members(workspace_id):
members_repo = Members() members = Members.get_many(workspace_id)
members = members_repo.get_many(workspace_id) return render_template("workspace_members.html", members=members)
return render_template(
"workspace_members.html", workspace_id=workspace_id, members=members
)
@bp.route("/workspaces/<workspace_id>/reports") @bp.route("/workspaces/<workspace_id>/reports")
def workspace_reports(workspace_id): def workspace_reports(workspace_id):
return render_template( return render_template("workspace_reports.html")
"workspace_reports.html", workspace_id=workspace_id
)

View File

@ -1,7 +1,3 @@
{# TODO: set this context elsewhere #}
{# set context='workspace' #}
{% set context=g.navigationContext %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>

View File

@ -1,7 +1,3 @@
{# TODO: set this context elsewhere #}
{# set context='workspace' #}
{% set context=g.navigationContext %}
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>

View File

@ -1,6 +1,6 @@
{% from "components/sidenav_item.html" import SidenavItem %} {% from "components/sidenav_item.html" import SidenavItem %}
<div class="global-navigation sidenav global-navigation__context--{{context}}"> <div class="global-navigation sidenav">
<ul> <ul>
{% if g.dev %} {% if g.dev %}
{{ SidenavItem("Styleguide", {{ SidenavItem("Styleguide",

View File

@ -6,9 +6,9 @@
{{ Icon('shield', classes='topbar__link-icon') }} {{ Icon('shield', classes='topbar__link-icon') }}
</a> </a>
<div class="topbar__context topbar__context--{{context}}"> <div class="topbar__context {% if workspace %}topbar__context--workspace{% endif %}">
<a href="/" class="topbar__link"> <a href="/" class="topbar__link">
<span class="topbar__link-label">{{ "Workspace 123456" if context == 'workspace' else "JEDI" }}</span> <span class="topbar__link-label">{{ ("Workspace " + workspace.name) if workspace else "JEDI" }}</span>
{{ Icon('caret_down', classes='topbar__link-icon icon--tiny') }} {{ Icon('caret_down', classes='topbar__link-icon icon--tiny') }}
</a> </a>

View File

@ -4,8 +4,8 @@
<ul> <ul>
{{ SidenavItem( {{ SidenavItem(
"Projects", "Projects",
href=url_for("workspaces.workspace_projects", workspace_id=123456), href=url_for("workspaces.workspace_projects", workspace_id=workspace.id),
active=g.matchesPath('\/workspaces\/[A-Za-z0-9]*\/projects'), active=request.url_rule.rule.startswith('/workspaces/<workspace_id>/projects'),
subnav=[ subnav=[
{ {
"label": "Add New Project", "label": "Add New Project",
@ -18,8 +18,8 @@
{{ SidenavItem( {{ SidenavItem(
"Members", "Members",
href=url_for("workspaces.workspace_members", workspace_id=123456), href=url_for("workspaces.workspace_members", workspace_id=workspace.id),
active=g.matchesPath('\/workspaces\/[A-Za-z0-9]*\/members'), active=request.url_rule.rule.startswith('/workspaces/<workspace_id>/members'),
subnav=[ subnav=[
{ {
"label": "Add New Member", "label": "Add New Member",
@ -32,8 +32,8 @@
{{ SidenavItem( {{ SidenavItem(
"Funding & Reports", "Funding & Reports",
href='/workspaces/123456/reports', href=url_for("workspaces.workspace_reports", workspace_id=workspace.id),
active=g.matchesPath('\/workspaces\/[A-Za-z0-9]*\/reports') active=request.url_rule.rule.startswith('/workspaces/<workspace_id>/reports')
) }} ) }}
</ul> </ul>
</nav> </nav>

View File

@ -8,7 +8,7 @@
<div class='block-list project-list-item'> <div class='block-list project-list-item'>
<header class='block-list__header'> <header class='block-list__header'>
<h2 class='block-list__title'>{{ project['name'] }} ({{ project['environments']|length }} environments)</h2> <h2 class='block-list__title'>{{ project['name'] }} ({{ project['environments']|length }} environments)</h2>
<a class='icon-link' href='/workspaces/123456/projects/789/edit'> <a class='icon-link' href=''>
{{ Icon('edit') }} {{ Icon('edit') }}
<span>edit</span> <span>edit</span>
</a> </a>

View File

@ -4,7 +4,7 @@
{% block workspace_content %} {% block workspace_content %}
{{ Alert("Funding Information & Reports for Workspace " + workspace_id, {{ Alert("Funding Information & Reports for Workspace " + workspace.name,
message="<p>On this screen you'll find detailed reporting information on this workspace. This message needs to be written better and be dismissable.</p>", message="<p>On this screen you'll find detailed reporting information on this workspace. This message needs to be written better and be dismissable.</p>",
actions=[ actions=[
{"label": "Learn More", "href": "/", "icon": "info"}, {"label": "Learn More", "href": "/", "icon": "info"},