Skip to content

fix disable behavior - #285

Open
leoscholl wants to merge 1 commit into
masterfrom
leo-disable-features
Open

fix disable behavior#285
leoscholl wants to merge 1 commit into
masterfrom
leo-disable-features

Conversation

@leoscholl

Copy link
Copy Markdown
Collaborator

Previously if you disable a feature, it removes it from the database and unlinks task entries that use that feature.
Now it merely hides the feature from showing up anywhere until it is re-enabled.

@leoscholl

Copy link
Copy Markdown
Collaborator Author

Not sure what will happen when testing a new feature. We might also need a mechanism to add a temporary feature that can be later deleted.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes “Disable” behavior for features from hard-deleting DB rows (which also unlinked historical task entries) to a soft-disable model using the existing Feature.visible flag, so disabled features are hidden until re-enabled.

Changes:

  • Update feature toggling to flip Feature.visible instead of deleting rows.
  • Update the setup/features UI to show active vs hidden (re-enableable) features.
  • Reuse an existing feature row on “add new feature” when the name already exists (instead of creating duplicates).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
db/tracker/views.py Only list visible=True features as “active” and pass hidden custom features to the template.
db/tracker/templates/setup_features.html Render active features with “Disable” and add a hidden-features section with “Enable”.
db/tracker/templates/setup_base.html Update client-side row creation to use “Disable” and include the expected button id.
db/tracker/ajax.py Implement soft-disable/enable behavior and reuse existing feature rows on add.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 186 to 196
if (resp["status"] == "success") {
// clear fields
$("#new_feature_name").val('');
$("#new_feature_path").val('');

// add new row to table
tr = $(document.createElement("tr"));
tr.html("<td>" + resp["data"].id + "</td>" + "<td>" + resp["data"].name + "</td>" + "<td>" +
"<input type=\"submit\" value=\"Remove\" onclick=\"toggle_feature(\'" + resp["data"].name + "\')\">" + "</td>");
"<input type=\"submit\" id=\"feature_" + resp["data"].name + "\" value=\"Disable\" onclick=\"toggle_feature(\'" + resp["data"].name + "\')\">" + "</td>");
$('#new-feature-row').after(tr);
}
Comment on lines 24 to +26
<td>
{% if not feature.name in built_in_feature_names %}
<input type="submit" id="feature_{{feature.name}}" value="Remove" onclick="toggle_feature('{{feature.name}}')">
{% else %}
<input type="submit" id="feature_{{feature.name}}" value="Disable" onclick="toggle_feature('{{feature.name}}')">
{% endif %}
<input type="submit" id="feature_{{feature.name}}" value="Disable" onclick="toggle_feature('{{feature.name}}')">
</tr>
Comment thread db/tracker/ajax.py
Comment on lines 576 to +590
# check if the feature is already installed
existing_features = Feature.objects.filter(name=name)
existing_features = Feature.objects.filter(name=name).order_by('id')

if len(existing_features) > 0:
# disable the feature
Feature.objects.filter(name=name).delete()
msg = "Disabled feature: %s" % str(name)
return _respond(dict(msg=msg, status="success"))
if existing_features.filter(visible=True).exists():
# Soft-disable the feature so historical task links remain intact.
existing_features.filter(visible=True).update(visible=False)
msg = "Disabled feature: %s" % str(name)
return _respond(dict(msg=msg, status="success"))

# Re-enable an existing hidden feature instead of creating a new row.
existing_features.update(visible=True)
feat = existing_features[0]
msg = "Enabled feature: %s" % str(feat.name)
return _respond(dict(msg=msg, status="success", id=feat.id))

@ajm2605 ajm2605 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty cool I don't know how to program html so I have no Idea if it works but happy to test it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants