mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
jsxc: Allow disabling the app
Closes: #1872. Previously, JSXC can't be disabled and it's shortcut appears on the homepage forever. Use the EnableState component which stores a flag in the sqlite database to maintain the status of app being enabled. Tests: - Enable/disable button appears. Enabling/disabling the app updates the status currently. - Enabling the app shows icon on the homepage and disabling removes it. - Enabling shows the menu item in the apps page as enabled. Disabling shows the menu item in the apps page as disabled. - It is possible the uninstall the app. When app is uninstall it is removed from homepage and shows as disabled in the apps page. - When app is disabled or uninstalled, trying to visit the /plinth/apps/jsxc/jsxc/ throws a 404 error. - Run functional tests. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> [jvalleroy: Enable JSXC for Ejabberd test] Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
67860385d0
commit
0881dae665
@ -54,6 +54,7 @@ class TestEjabberdApp(functional.BaseAppTests):
|
||||
def test_backup_restore(self, session_browser):
|
||||
"""Test backup and restore of app data."""
|
||||
functional.app_enable(session_browser, 'ejabberd')
|
||||
functional.app_enable(session_browser, 'jsxc')
|
||||
_jsxc_add_contact(session_browser)
|
||||
functional.backup_create(session_browser, 'ejabberd', 'test_ejabberd')
|
||||
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
FreedomBox app to configure XMPP web client/jsxc.
|
||||
"""
|
||||
"""FreedomBox app to configure XMPP web client/jsxc."""
|
||||
|
||||
import logging
|
||||
|
||||
@ -32,8 +30,6 @@ class JSXCApp(app_module.App):
|
||||
|
||||
_version = 1
|
||||
|
||||
can_be_disabled = False
|
||||
|
||||
def __init__(self):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
@ -50,6 +46,9 @@ class JSXCApp(app_module.App):
|
||||
parent_url_name='apps')
|
||||
self.add(menu_item)
|
||||
|
||||
enable_state = app_module.EnableState('enable-state-jsxc')
|
||||
self.add(enable_state)
|
||||
|
||||
shortcut = frontpage.Shortcut('shortcut-jsxc', name=info.name,
|
||||
short_description=info.short_description,
|
||||
icon=info.icon_filename,
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Functional, browser based tests for jsxc app.
|
||||
"""
|
||||
"""Functional, browser based tests for jsxc app."""
|
||||
|
||||
import pytest
|
||||
|
||||
@ -10,21 +8,5 @@ from plinth.tests import functional
|
||||
pytestmark = [pytest.mark.apps, pytest.mark.jsxc]
|
||||
|
||||
|
||||
@pytest.fixture(scope='module', autouse=True)
|
||||
def fixture_background(session_browser):
|
||||
"""Login."""
|
||||
functional.login(session_browser)
|
||||
|
||||
|
||||
def test_install(session_browser):
|
||||
"""Test installing the app."""
|
||||
functional.install(session_browser, 'jsxc')
|
||||
assert functional.is_available(session_browser, 'jsxc')
|
||||
|
||||
|
||||
@pytest.mark.backups
|
||||
def test_backup(session_browser):
|
||||
"""Test backing up and restoring."""
|
||||
functional.backup_create(session_browser, 'jsxc', 'test_jsxc')
|
||||
functional.backup_restore(session_browser, 'jsxc', 'test_jsxc')
|
||||
assert functional.is_available(session_browser, 'jsxc')
|
||||
class TestJSXCApp(functional.BaseAppTests):
|
||||
app_name = 'jsxc'
|
||||
|
||||
@ -1,17 +1,26 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Views for the JSXC module
|
||||
"""
|
||||
"""Views for the JSXC module."""
|
||||
|
||||
from django.http import Http404
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
import plinth.app as app_module
|
||||
from plinth.modules import config
|
||||
|
||||
|
||||
class JsxcView(TemplateView):
|
||||
"""A simple page to embed Javascript XMPP Client library."""
|
||||
|
||||
template_name = 'jsxc_launch.html'
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
"""Don't serve the view when app is disabled."""
|
||||
app = app_module.App.get('jsxc')
|
||||
if not app.is_enabled():
|
||||
raise Http404
|
||||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
"""Add domain information to view context."""
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
|
||||
@ -157,7 +157,7 @@ def is_available(browser, site_name):
|
||||
browser.visit(url_to_visit)
|
||||
time.sleep(3)
|
||||
browser.reload()
|
||||
if '404' in browser.title:
|
||||
if '404' in browser.title or 'Page not found' in browser.title:
|
||||
return False
|
||||
|
||||
# The site might have a default path after the sitename,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user