Skip to content
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

Implements Tethys Reactpy App Scaffold #1081

Merged
merged 45 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
67b2098
Reactpy configured at the baseline-level
shawncrawley May 13, 2024
b16676e
Merge branch 'main' into tethys-reactpy
ckrew May 14, 2024
a585699
Added RESelectInput react component to create a reach dropdown just l…
ckrew May 16, 2024
debe2a4
Integrates reactpy and implements app scaffold
shawncrawley Aug 17, 2024
0c9ecc4
Merge branch 'main' into tethys-reactpy
shawncrawley Aug 17, 2024
f6cc1a9
Handle reactpy-django at app install level
shawncrawley Aug 19, 2024
9324df4
Bugfixes from fresh test
shawncrawley Aug 19, 2024
521eef0
Initial wave of tests and resulting refactors/fixes
shawncrawley Aug 23, 2024
55e31f9
Adds tests and test-based fixes
shawncrawley Aug 29, 2024
645e4de
Merge branch 'main' into tethys-reactpy
shawncrawley Aug 29, 2024
80eea3d
Fix broken tests on Windows, flake8 cleanup
shawncrawley Aug 29, 2024
408b7ab
Applies black formatting
shawncrawley Aug 29, 2024
fdfb0a5
Try fixing async test
shawncrawley Aug 29, 2024
dc93f59
Fix flake8 warning
shawncrawley Aug 29, 2024
5628657
Tweak test for macos
shawncrawley Aug 29, 2024
33e0632
Another tweak for tests on macos
shawncrawley Aug 29, 2024
4640634
Fix broken test from last commit
shawncrawley Aug 29, 2024
af5cb81
black reformatting
shawncrawley Aug 29, 2024
3e59a05
Unpin daphne version
shawncrawley Sep 5, 2024
3c67bcc
Merge branch 'main' into tethys-reactpy
shawncrawley Sep 6, 2024
8d48e47
Bugfix: Default arg must be passed to scaffold_command
shawncrawley Sep 11, 2024
79e44ad
applies suggested changes
shawncrawley Oct 3, 2024
64732c5
Merge branch 'main' into tethys-reactpy
shawncrawley Oct 3, 2024
b5493d2
Revert spot where os.path had been converted to pathlib.Path
shawncrawley Oct 3, 2024
4c9697b
Remove erroneous argument
shawncrawley Oct 3, 2024
ae1d688
Fix bug with pathlib update to static_finders
shawncrawley Oct 7, 2024
46b4f83
Update tests/unit_tests/test_tethys_apps/test_template_loaders.py
shawncrawley Oct 11, 2024
1bdcdcf
Update tethys_cli/cli_helpers.py
shawncrawley Oct 11, 2024
f7af003
Merge branch 'main' into tethys-reactpy
shawncrawley Oct 11, 2024
b6178b8
Merge branch 'main' into tethys-reactpy
swainn Oct 16, 2024
9122f42
Additional tweaks per feedback
shawncrawley Oct 17, 2024
305a910
black and flake8
shawncrawley Oct 17, 2024
0718fd5
remove file that was unintentionally committed
shawncrawley Oct 17, 2024
d898438
Fixes pyproject.toml_tmpl for reacpty scaffold
shawncrawley Oct 19, 2024
f0e00e9
Update tethys_apps/base/url_map.py
shawncrawley Oct 22, 2024
01bdf94
Implements latest feedback from @swainn
shawncrawley Oct 22, 2024
8a810af
Additional tweaks per feedback/tests
shawncrawley Oct 23, 2024
8ab53d4
Fix broken test
shawncrawley Oct 23, 2024
f4bc8b6
Removes reactpy[-django] from dependencies
shawncrawley Nov 25, 2024
f5af044
Replace Path.walk with os.walk
shawncrawley Nov 25, 2024
183cd7f
Merge branch 'main' into tethys-reactpy
shawncrawley Nov 25, 2024
58bd925
Replaces odd Namespace usage with UrlMap
shawncrawley Nov 25, 2024
3ba6119
Merge branch 'tethys-reactpy' of https://github.com/tethysplatform/te…
shawncrawley Nov 25, 2024
7b8a45c
Applies black formatting
shawncrawley Nov 25, 2024
b3bb243
Separates channels and daphne
shawncrawley Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implements latest feedback from @swainn
- pyproject.toml added to all scaffolds
- reactpy_base.html refactored to extend app_base.html
- minor cleanups and refactors
  • Loading branch information
shawncrawley committed Oct 22, 2024
commit 01bdf94e85b193d2907a29c7cb1a070c24058de4
11 changes: 5 additions & 6 deletions tests/unit_tests/test_tethys_apps/test_base/test_app_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from django.db.utils import ProgrammingError
from django.test import RequestFactory, override_settings
from django.core.exceptions import ValidationError, ObjectDoesNotExist
from argparse import Namespace

from tethys_apps.exceptions import (
TethysAppSettingDoesNotExist,
Expand Down Expand Up @@ -1558,11 +1557,11 @@ def test_navigation_links_auto_excluded_page(self):
app.root_url = "test-app"

app._registered_url_maps = [
Namespace(name="exclude_page", title="Exclude Page", index=-1),
Namespace(name="last_page", title="Last Page", index=3),
Namespace(name="third_page", title="Third Page", index=2),
Namespace(name="second_page", title="Second Page", index=1),
Namespace(name="home", title="Home", index=0),
mock.MagicMock(name="exclude_page", title="Exclude Page", index=-1),
mock.MagicMock(name="last_page", title="Last Page", index=3),
mock.MagicMock(name="third_page", title="Third Page", index=2),
mock.MagicMock(name="second_page", title="Second Page", index=1),
mock.MagicMock(name="home", title="Home", index=0),
]

links = app.navigation_links
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/test_tethys_components/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def test_delayed_execute(self):
def test_func(arg1):
pass

utils.delayed_execute(10, test_func, ["Hello"])
mock_import().Timer.assert_called_once_with(10, test_func, ["Hello"])
utils.delayed_execute(test_func, 10, ["Hello"])
mock_import().Timer.assert_called_once_with(test_func, 10, ["Hello"])
mock_import().Timer().start.assert_called_once()
mock.patch.stopall()

Expand Down
6 changes: 4 additions & 2 deletions tethys_apps/templates/tethys_apps/app_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@
{% endcomment %}

{% block styles %}
{{ tethys.bootstrap.link_tag|safe }}
{{ tethys.bootstrap_icons.link_tag|safe }}
{% block bootstrap_styles %}
{{ tethys.bootstrap.link_tag|safe }}
{{ tethys.bootstrap_icons.link_tag|safe }}
{% endblock %}
{% block app_base_styles %}
<link href="{% static 'tethys_apps/css/app_base.min.css' %}" rel="stylesheet" />
{% endblock %}
Expand Down
149 changes: 32 additions & 117 deletions tethys_apps/templates/tethys_apps/reactpy_base.html
Original file line number Diff line number Diff line change
@@ -1,119 +1,34 @@
{% extends "tethys_apps/app_base.html" %}
{% load static tethys reactpy %}
<!DOCTYPE html>
<!--[if IE 7]> <html lang="en" class="ie ie7 h-100"> <![endif]-->
<!--[if IE 8]> <html lang="en" class="ie ie8 h-100"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 h-100"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" class="h-100"> <!--<![endif]-->
<head>
{% if has_analytical %}
{% include "analytical_head_top.html" %}
{% endif %}

<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="Django" />

<title>{{ title }} | {{ tethys_app.name }}</title>
<link rel="shortcut icon" href="{% if site_globals.favicon and 'http' in site_globals.favicon %}{{ site_globals.favicon }}{% elif site_globals.favicon %}{% static site_globals.favicon %}{% else %}{% static 'tethys_portal/images/default_favicon.png' %}{% endif %}" />
{% if tethys_app.enable_feedback %}
<link href="{% static 'tethys_apps/css/feedback.css' %}" rel="stylesheet" />
{% endif %}
<link href="{% static 'tethys_portal/css/termsandconditions.min.css' %}" rel="stylesheet" />
{% for css in custom_css %}
<link href="{{ css }}" rel="stylesheet" />
{% endfor %}
<style>
:root {
--app-primary-color: {{ tethys_app.color }};
--app-secondary-color: {{ tethys_app.color|lighten:20 }};
}

#app-header .tethys-app-header {
background: var(--app-primary-color, '#7ec1f7');
}

#app-header .tethys-app-header .icon-wrapper img {
background: var(--app-primary-color, '#7ec1f7');
}

#app-header .btn-user-profile {
background-color: rgba(255, 255, 255, 0.08);
border: none;
color: {{ site_globals.primary_text_color }};
}

#app-header .btn-user-profile:hover {
background-color: rgba(255, 255, 255, 0.30);
}

#app-navigation .nav li a {
color: var(--app-primary-color, '#7ec1f7');
}

#app-navigation .nav li.active a {
color: var(--app-primary-color, '#7ec1f7');
}

#app-navigation .nav li a.active {
background: var(--app-primary-color, '#7ec1f7');
color: white;
}

#app-content-wrapper #app-content #app-actions {
background: var(--app-secondary-color);
}
.styled-header-button:hover, .styled-header-button:focus {
background-color: rgba(0, 0, 0, 0.1)!important;
color: white;
border: none;
box-shadow: none;
}
</style>
<script type="module">
import React from "https://esm.sh/react@{{ reactjs_version }}"
import ReactDOM from "https://esm.sh/react-dom@{{ reactjs_version }}"
globalThis['React'] = React
globalThis['ReactDOM'] = ReactDOM
</script>

{% if has_session_security %}
{% include 'session_security/all.html' %}
<link href="{% static 'tethys_portal/css/session_security_override.min.css' %}" rel="stylesheet" />
{% endif %}

{% if has_analytical %}
{% include "analytical_head_bottom.html" %}
{% endif %}
</head>

<body class="h-100">
{% if has_analytical %}
{% include "analytical_body_top.html" %}
{% endif %}

{% component "tethys_apps.base.page_handler.page_component_wrapper" app=app user=request.user layout=layout_func component=component_func extras=extras %}

{% if has_terms %}
{% include "terms.html" %}
{% endif %}

<div id="page-attributes" data-username="{{ user.username }}" style="display: none;"></div>

{% csrf_token %}

{{ tethys.doc_cookies.script_tag|safe }}

{% if tethys_app.enable_feedback %}
<script src="{% static 'tethys_apps/js/feedback.js' %}" type="text/javascript"></script>
{% endif %}

{% for js in custom_js %}
<script src="{{ js }}" type="text/javascript"></script>
{% endfor %}

{% if has_analytical %}
{% include "analytical_body_bottom.html" %}
{% endif %}
</body>
</html>
{% block title %}{{ title }} | {{ tethys_app.name }}{% endblock %}

{% block bootstrap_styles %}{% endblock %}
{% block app_base_styles %}{% endblock %}

{% block app_styles %}
{% for css in custom_css %}
<link href="{{ css }}" rel="stylesheet" />
{% endfor %}
{{ block.super }}
{% endblock %}

{% block global_scripts %}
{{ tethys.jquery.script_tag|safe }}
<script type="module">
import React from "https://esm.sh/react@{{ reactjs_version }}"
import ReactDOM from "https://esm.sh/react-dom@{{ reactjs_version }}"
globalThis['React'] = React
globalThis['ReactDOM'] = ReactDOM
</script>
{% endblock %}

{% block app_content_wrapper_override %}
{% component "tethys_apps.base.page_handler.page_component_wrapper" app=app user=request.user layout=layout_func component=component_func extras=extras %}
{% endblock %}

{% block app_base_js %}
{% for js in custom_js %}
<script src="{{ js }}" type="text/javascript"></script>
{% endfor %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[project]
name = "{{project_dir}}"
description = "{{description|default('')}}"
{% if license_name %}license = {text = "{{license_name|default('')}}"}{% endif %}
keywords = [{{', '.join(tags.split(','))}}]
{% if author and author_email %}authors = [
{name = "{{author|default('')}}", email = "{{author_email|default('')}}"},
]{% endif %}
classifiers = [
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",{% if license_name %}
"License :: OSI Approved :: {{license_name}}",{% endif %}
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
]
dynamic = ["version"]

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
include = ["tethysapp*"]

[tool.setuptools.package-data]
"*" = [
"*.js",
"*.png",
"*.gif",
"*.jpg",
"*.html",
"*.css",
"*.gltf",
"*.json",
"*.svg",
]
33 changes: 0 additions & 33 deletions tethys_cli/scaffold_templates/app_templates/default/setup.py_tmpl

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[project]
name = "{{project_dir}}"
description = "{{description|default('')}}"
readme = "README.md"
{% if license_name %}license = {text = "{{license_name|default('')}}"}{% endif %}
keywords = [{{', '.join(tags.split(','))}}]
{% if author and author_email %}authors = [
{name = "{{author|default('')}}", email = "{{author_email|default('')}}"},
]{% endif %}
classifiers = [
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",{% if license_name %}
"License :: OSI Approved :: {{license_name}}",{% endif %}
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
]
dynamic = ["version"]

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
include = ["tethysapp*"]

[tool.setuptools.package-data]
"*" = [
"*.js",
"*.png",
"*.gif",
"*.jpg",
"*.html",
"*.css",
"*.gltf",
"*.json",
"*.svg",
]
31 changes: 0 additions & 31 deletions tethys_cli/scaffold_templates/app_templates/react/setup.py_tmpl

This file was deleted.

shawncrawley marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,22 @@ classifiers = [
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
]
dynamic = ["version"]

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
include = ["tethysapp*"]

[tool.setuptools.package-data]
"*" = [
"*.js",
"*.png",
"*.gif",
"*.jpg",
"*.html",
"*.css",
"*.gltf",
"*.json",
"*.svg",
]
4 changes: 2 additions & 2 deletions tethys_components/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def use_workspace(user=None):
return workspace


def delayed_execute(seconds, callable, args=None):
def delayed_execute(callable, delay_seconds, args=None):
from threading import Timer

t = Timer(seconds, callable, args or [])
t = Timer(delay_seconds, callable, args or [])
t.start()


Expand Down
Loading
Loading