From ae10b72b52c8dd88cebb36dc93537f5861496621 Mon Sep 17 00:00:00 2001 From: James Stott <158563996+jamesstottmoj@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:04:01 +0000 Subject: [PATCH] Feature/vscode tool add (#1256) * Changed code to allow for new tool, vscode, to be displayed on the tools page * modified unit tests to cover vscode tooling * added missing references to vscode * updated references of vscode to visual-studio-code --- controlpanel/api/models/tool.py | 4 +++- controlpanel/frontend/forms.py | 2 ++ .../frontend/jinja2/release-create.html | 4 ++-- .../frontend/jinja2/release-detail.html | 6 +++--- tests/frontend/test_forms.py | 19 +++++++++++++++++++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/controlpanel/api/models/tool.py b/controlpanel/api/models/tool.py index aea233002..32243f1e1 100644 --- a/controlpanel/api/models/tool.py +++ b/controlpanel/api/models/tool.py @@ -22,7 +22,9 @@ class Tool(TimeStampedModel): # Defines how a matching chart name is put into a named tool bucket. # E.g. jupyter-* charts all end up in the jupyter-lab bucket. # chart name match: tool bucket - TOOL_BOX_CHART_LOOKUP = {"jupyter": "jupyter-lab", "rstudio": "rstudio"} + TOOL_BOX_CHART_LOOKUP = {"jupyter": "jupyter-lab", + "rstudio": "rstudio", + "visual-studio-code": "visual-studio-code"} description = models.TextField(blank=True) chart_name = models.CharField(max_length=100, blank=False) diff --git a/controlpanel/frontend/forms.py b/controlpanel/frontend/forms.py index be8a27dd4..017ea538d 100644 --- a/controlpanel/frontend/forms.py +++ b/controlpanel/frontend/forms.py @@ -470,6 +470,7 @@ def clean_chart_name(self): "airflow-sqlite", "jupyter-", "rstudio", + "visual-studio-code" ] value = self.cleaned_data["chart_name"] is_valid = False @@ -492,6 +493,7 @@ def clean_tool_domain(self): "airflow-sqlite", "jupyter-lab", "rstudio", + "visual-studio-code" ] value = self.cleaned_data.get("tool_domain") if value and value not in valid_names: diff --git a/controlpanel/frontend/jinja2/release-create.html b/controlpanel/frontend/jinja2/release-create.html index 33d4cbc72..42f10e8f0 100644 --- a/controlpanel/frontend/jinja2/release-create.html +++ b/controlpanel/frontend/jinja2/release-create.html @@ -45,7 +45,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-* or rstudio' + "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-*, rstudio or visual-studio-code' }, "name": "chart_name", "attributes": { @@ -95,7 +95,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab or rstudio.' + "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab, rstudio or visual-studio-code.' }, "name": "tool_domain", "attributes": { diff --git a/controlpanel/frontend/jinja2/release-detail.html b/controlpanel/frontend/jinja2/release-detail.html index 9cd9a58b0..c9b497ceb 100644 --- a/controlpanel/frontend/jinja2/release-detail.html +++ b/controlpanel/frontend/jinja2/release-detail.html @@ -48,7 +48,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-* or rstudio' + "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-*, rstudio or visual-studio-code' }, "name": "chart_name", "attributes": { @@ -98,7 +98,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab or rstudio.' + "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab, rstudio or visual-studio-code.' }, "name": "tool_domain", "attributes": { @@ -153,7 +153,7 @@

{{ page_title }}

{{ csrf_input }} diff --git a/tests/frontend/test_forms.py b/tests/frontend/test_forms.py index 91a9baff0..bc3cfcec8 100644 --- a/tests/frontend/test_forms.py +++ b/tests/frontend/test_forms.py @@ -55,6 +55,15 @@ def test_tool_release_form_check_release_name(): } f = forms.ToolReleaseForm(data) assert f.is_valid() + data = { + "name": "Test Release", + "chart_name": "visual-studio-code", + "version": "1.2.3", + "values": {"foo": "bar"}, + "is_restricted": False, + } + f = forms.ToolReleaseForm(data) + assert f.is_valid() data = { "name": "Test Release", "chart_name": "invalid-chartname", @@ -91,6 +100,16 @@ def test_tool_release_form_check_tool_domain(): } f = forms.ToolReleaseForm(data) assert f.is_valid() + data = { + "name": "Test Release", + "chart_name": "visual-studio-code", + "version": "1.2.3", + "values": {"foo": "bar"}, + "is_restricted": False, + "tool_domain": "visual-studio-code", + } + f = forms.ToolReleaseForm(data) + assert f.is_valid() data = { "name": "Test Release", "chart_name": "jupyter-lab-all-spark",