Skip to content

Commit 5ead073

Browse files
Copilotdavidfstr
andcommitted
Fix editable fields on NIA page when project is readonly
Co-authored-by: davidfstr <764688+davidfstr@users.noreply.github.com> Agent-Logs-Url: https://github.com/davidfstr/Crystal-Web-Archiver/sessions/da6ecc28-932b-4524-a6d3-b8aae4d2a83d
1 parent 815ca0f commit 5ead073

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

RELEASE_NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ Release Notes ⋮
4949
* Documentation improvements
5050
* Project format documented at: <doc/crystalproj_project_format.md>
5151

52+
* Read-only project fixes
53+
* Fix editable fields on the "Not in Archive" page to be correctly
54+
disabled when the project is opened in read-only mode.
55+
The name, URL pattern, source, group name, and download-immediately
56+
checkbox were all previously editable even in read-only mode.
57+
5258
* Headless mode fixes
5359
* UI progress dialogs will now never show in headless mode.
5460
* wxPython is now never even loaded in headless mode.

src/crystal/server/special_pages.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,29 +716,29 @@ def not_in_archive_html(
716716
<div id="cr-create-root-url-form" class="cr-create-root-url-form">
717717
<div class="cr-form-row">
718718
<label class="cr-form-row__label">Name:</label>
719-
<input type="text" id="cr-root-url-name" class="cr-form-row__input" placeholder="e.g. Home">
719+
<input type="text" id="cr-root-url-name" class="cr-form-row__input" placeholder="e.g. Home" {'disabled ' if readonly else ''}>
720720
</div>
721721
</div>
722722
723723
<div id="cr-create-group-form" class="cr-create-group-form" style="display: none;">
724724
<div class="cr-form-row">
725725
<label class="cr-form-row__label">URL Pattern:</label>
726726
<div class="cr-form-input-container">
727-
<input type="text" id="cr-group-url-pattern" class="cr-form-row__input" placeholder="https://example.com/post/*" value="{html_escape(create_group_form_data['predicted_url_pattern'])}">
727+
<input type="text" id="cr-group-url-pattern" class="cr-form-row__input" placeholder="https://example.com/post/*" value="{html_escape(create_group_form_data['predicted_url_pattern'])}" {'disabled ' if readonly else ''}>
728728
<div class="cr-form-row__help-text"># = numbers, @ = letters, * = anything but /, ** = anything</div>
729729
</div>
730730
</div>
731731
732732
<div class="cr-form-row">
733733
<label class="cr-form-row__label">Source:</label>
734-
<select id="cr-group-source" class="cr-form-row__input">
734+
<select id="cr-group-source" class="cr-form-row__input" {'disabled ' if readonly else ''}>
735735
<!-- Source options will be populated by JavaScript -->
736736
</select>
737737
</div>
738738
739739
<div class="cr-form-row">
740740
<label class="cr-form-row__label">Name:</label>
741-
<input type="text" id="cr-group-name" class="cr-form-row__input" placeholder="e.g. Post" value="{html_escape(create_group_form_data['predicted_name'])}">
741+
<input type="text" id="cr-group-name" class="cr-form-row__input" placeholder="e.g. Post" value="{html_escape(create_group_form_data['predicted_name'])}" {'disabled ' if readonly else ''}>
742742
</div>
743743
744744
<div class="cr-form__section">
@@ -752,7 +752,7 @@ def not_in_archive_html(
752752
<div class="cr-form__section">
753753
<div class="cr-form__section-header">New Group Options</div>
754754
<label class="cr-checkbox">
755-
<input type="checkbox" id="cr-download-group-immediately-checkbox" checked onchange="onDownloadImmediatelyCheckboxChange()">
755+
<input type="checkbox" id="cr-download-group-immediately-checkbox" {'disabled ' if readonly else ''}checked onchange="onDownloadImmediatelyCheckboxChange()">
756756
<span>Download Group Immediately</span>
757757
</label>
758758
</div>

src/crystal/tests/test_server.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,41 @@ async def test_given_readonly_project_then_all_action_type_radio_buttons_disable
719719
'Download Only radio button should be disabled in readonly mode'
720720

721721

722+
async def test_given_readonly_project_then_all_form_input_fields_disabled() -> None:
723+
async with _not_in_archive_page_visible(readonly=True) as server_page:
724+
content = server_page.content
725+
726+
# Root URL name field should be disabled
727+
assert 'id="cr-root-url-name"' in content, \
728+
'Root URL name field should be present even in readonly mode'
729+
assert 'id="cr-root-url-name" class="cr-form-row__input" placeholder="e.g. Home" disabled' in content, \
730+
'Root URL name field should be disabled in readonly mode'
731+
732+
# Group URL pattern field should be disabled
733+
assert 'id="cr-group-url-pattern"' in content, \
734+
'Group URL pattern field should be present even in readonly mode'
735+
assert re.search(r'id="cr-group-url-pattern"[^>]+ disabled', content) is not None, \
736+
'Group URL pattern field should be disabled in readonly mode'
737+
738+
# Group source select should be disabled
739+
assert 'id="cr-group-source"' in content, \
740+
'Group source select should be present even in readonly mode'
741+
assert 'id="cr-group-source" class="cr-form-row__input" disabled' in content, \
742+
'Group source select should be disabled in readonly mode'
743+
744+
# Group name field should be disabled
745+
assert 'id="cr-group-name"' in content, \
746+
'Group name field should be present even in readonly mode'
747+
assert 'id="cr-group-name" class="cr-form-row__input" placeholder="e.g. Post" value="" disabled' in content, \
748+
'Group name field should be disabled in readonly mode'
749+
750+
# Download group immediately checkbox should be disabled
751+
assert 'id="cr-download-group-immediately-checkbox"' in content, \
752+
'Download group immediately checkbox should be present even in readonly mode'
753+
assert 'id="cr-download-group-immediately-checkbox" disabled' in content, \
754+
'Download group immediately checkbox should be disabled in readonly mode'
755+
756+
722757
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
723758
# Test: "Not in Archive" Page: Create Root URL + Download Progress Bar
724759

0 commit comments

Comments
 (0)