core: use tabs for user settings
This commit is contained in:
parent
6495d6c50a
commit
1c25f4f09b
|
@ -31,6 +31,6 @@ values =
|
||||||
|
|
||||||
[bumpversion:file:authentik/__init__.py]
|
[bumpversion:file:authentik/__init__.py]
|
||||||
|
|
||||||
[bumpversion:file:proxy/pkg/version.go]
|
[bumpversion:file:outpost/pkg/version.go]
|
||||||
|
|
||||||
[bumpversion:file:web/src/constants.ts]
|
[bumpversion:file:web/src/constants.ts]
|
||||||
|
|
|
@ -32,7 +32,7 @@ REQUEST_MOCK_VALID = Mock(
|
||||||
return_value=MockResponse(
|
return_value=MockResponse(
|
||||||
200,
|
200,
|
||||||
"""{
|
"""{
|
||||||
"tag_name": "version/1.2.3"
|
"tag_name": "version/99999999.9999999"
|
||||||
}""",
|
}""",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -47,10 +47,10 @@ class TestAdminTasks(TestCase):
|
||||||
def test_version_valid_response(self):
|
def test_version_valid_response(self):
|
||||||
"""Test Update checker with valid response"""
|
"""Test Update checker with valid response"""
|
||||||
update_latest_version.delay().get()
|
update_latest_version.delay().get()
|
||||||
self.assertEqual(cache.get(VERSION_CACHE_KEY), "1.2.3")
|
self.assertEqual(cache.get(VERSION_CACHE_KEY), "99999999.9999999")
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
Event.objects.filter(
|
Event.objects.filter(
|
||||||
action=EventAction.UPDATE_AVAILABLE, context__new_version="1.2.3"
|
action=EventAction.UPDATE_AVAILABLE, context__new_version="99999999.9999999"
|
||||||
).exists()
|
).exists()
|
||||||
)
|
)
|
||||||
# test that a consecutive check doesn't create a duplicate event
|
# test that a consecutive check doesn't create a duplicate event
|
||||||
|
@ -58,7 +58,7 @@ class TestAdminTasks(TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len(
|
len(
|
||||||
Event.objects.filter(
|
Event.objects.filter(
|
||||||
action=EventAction.UPDATE_AVAILABLE, context__new_version="1.2.3"
|
action=EventAction.UPDATE_AVAILABLE, context__new_version="99999999.9999999"
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
1,
|
1,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load authentik_user_settings %}
|
{% load authentik_user_settings %}
|
||||||
|
{% load authentik_utils %}
|
||||||
|
|
||||||
<div class="pf-c-page">
|
<div class="pf-c-page">
|
||||||
<main role="main" class="pf-c-page__main" tabindex="-1">
|
<main role="main" class="pf-c-page__main" tabindex="-1">
|
||||||
|
@ -12,7 +13,8 @@
|
||||||
<p>{% trans "Configure settings relevant to your user profile." %}</p>
|
<p>{% trans "Configure settings relevant to your user profile." %}</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="pf-c-page__main-section">
|
<ak-tabs>
|
||||||
|
<section slot="page-1" data-tab-title="{% trans 'User details' %}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
||||||
<div class="pf-u-display-flex pf-u-justify-content-center">
|
<div class="pf-u-display-flex pf-u-justify-content-center">
|
||||||
<div class="pf-u-w-75">
|
<div class="pf-u-w-75">
|
||||||
<ak-site-shell url="{% url 'authentik_core:user-details' %}">
|
<ak-site-shell url="{% url 'authentik_core:user-details' %}">
|
||||||
|
@ -21,21 +23,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="pf-c-page__main-section">
|
<section slot="page-2" data-tab-title="{% trans 'Tokens' %}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
||||||
<div class="pf-u-display-flex pf-u-justify-content-center">
|
|
||||||
<div class="pf-u-w-75">
|
|
||||||
<ak-site-shell url="{% url 'authentik_core:user-tokens' %}">
|
<ak-site-shell url="{% url 'authentik_core:user-tokens' %}">
|
||||||
<div slot="body"></div>
|
<div slot="body"></div>
|
||||||
</ak-site-shell>
|
</ak-site-shell>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
{% user_stages as user_stages_loc %}
|
{% user_stages as user_stages_loc %}
|
||||||
{% for stage in user_stages_loc %}
|
{% for stage, stage_link in user_stages_loc.items %}
|
||||||
<section class="pf-c-page__main-section">
|
<section slot="page-{{ stage.pk }}" data-tab-title="{{ stage|verbose_name }}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
||||||
<div class="pf-u-display-flex pf-u-justify-content-center">
|
<div class="pf-u-display-flex pf-u-justify-content-center">
|
||||||
<div class="pf-u-w-75">
|
<div class="pf-u-w-75">
|
||||||
<ak-site-shell url="{{ stage }}">
|
<ak-site-shell url="{{ stage_link }}">
|
||||||
<div slot="body"></div>
|
<div slot="body"></div>
|
||||||
</ak-site-shell>
|
</ak-site-shell>
|
||||||
</div>
|
</div>
|
||||||
|
@ -43,16 +41,17 @@
|
||||||
</section>
|
</section>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% user_sources as user_sources_loc %}
|
{% user_sources as user_sources_loc %}
|
||||||
{% for source in user_sources_loc %}
|
{% for source, source_link in user_sources_loc.item %}
|
||||||
<section class="pf-c-page__main-section">
|
<section slot="page-{{ source.pk }}" data-tab-title="{{ source|verbose_name }}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
||||||
<div class="pf-u-display-flex pf-u-justify-content-center">
|
<div class="pf-u-display-flex pf-u-justify-content-center">
|
||||||
<div class="pf-u-w-75">
|
<div class="pf-u-w-75">
|
||||||
<ak-site-shell url="{{ source }}">
|
<ak-site-shell url="{{ source_link }}">
|
||||||
<div slot="body"></div>
|
<div slot="body"></div>
|
||||||
</ak-site-shell>
|
</ak-site-shell>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</ak-tabs>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,26 +13,26 @@ register = template.Library()
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def user_stages(context: RequestContext) -> list[str]:
|
def user_stages(context: RequestContext) -> dict[Stage, str]:
|
||||||
"""Return list of all stages which apply to user"""
|
"""Return list of all stages which apply to user"""
|
||||||
_all_stages: Iterable[Stage] = Stage.objects.all().select_subclasses()
|
_all_stages: Iterable[Stage] = Stage.objects.all().select_subclasses()
|
||||||
matching_stages: list[str] = []
|
matching_stages: dict[Stage, str] = {}
|
||||||
for stage in _all_stages:
|
for stage in _all_stages:
|
||||||
user_settings = stage.ui_user_settings
|
user_settings = stage.ui_user_settings
|
||||||
if not user_settings:
|
if not user_settings:
|
||||||
continue
|
continue
|
||||||
matching_stages.append(user_settings)
|
matching_stages[stage] = user_settings
|
||||||
return matching_stages
|
return matching_stages
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
def user_sources(context: RequestContext) -> list[str]:
|
def user_sources(context: RequestContext) -> dict[Source, str]:
|
||||||
"""Return a list of all sources which are enabled for the user"""
|
"""Return a list of all sources which are enabled for the user"""
|
||||||
user = context.get("request").user
|
user = context.get("request").user
|
||||||
_all_sources: Iterable[Source] = Source.objects.filter(
|
_all_sources: Iterable[Source] = Source.objects.filter(
|
||||||
enabled=True
|
enabled=True
|
||||||
).select_subclasses()
|
).select_subclasses()
|
||||||
matching_sources: list[str] = []
|
matching_sources: dict[Source, str] = {}
|
||||||
for source in _all_sources:
|
for source in _all_sources:
|
||||||
user_settings = source.ui_user_settings
|
user_settings = source.ui_user_settings
|
||||||
if not user_settings:
|
if not user_settings:
|
||||||
|
@ -40,5 +40,5 @@ def user_sources(context: RequestContext) -> list[str]:
|
||||||
policy_engine = PolicyEngine(source, user, context.get("request"))
|
policy_engine = PolicyEngine(source, user, context.get("request"))
|
||||||
policy_engine.build()
|
policy_engine.build()
|
||||||
if policy_engine.passing:
|
if policy_engine.passing:
|
||||||
matching_sources.append(user_settings)
|
matching_sources[source] = user_settings
|
||||||
return matching_sources
|
return matching_sources
|
||||||
|
|
Reference in a new issue