{"html_url": "https://github.com/simonw/datasette/issues/1831#issuecomment-1278198700", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1831", "id": 1278198700, "node_id": "IC_kwDOBm6k_c5ML8Os", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-13T21:29:09Z", "updated_at": "2022-10-13T21:29:09Z", "author_association": "OWNER", "body": "I'm going to commit the code now, but then I need to add some extra tests to ensure the breadcrumb permission display logic works correctly.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1397084281, "label": "If user can see table but NOT database/instance nav links should not display"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1831#issuecomment-1278198145", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1831", "id": 1278198145, "node_id": "IC_kwDOBm6k_c5ML8GB", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-13T21:28:30Z", "updated_at": "2022-10-13T21:28:30Z", "author_association": "OWNER", "body": "This has turned into a full refactor of how breadcrumbs work.\r\n\r\nI'm using my first ever Jinja macro for this - I import that at the top of `base.html` so that it will be available everywhere else:\r\n\r\n```html+jinja\r\n{% import \"_crumbs.html\" as crumbs with context %}\r\n```\r\nThe `with context` bit is needed so the macro can see the new `crumb_items()` function that I'm adding to the global template rendering scope.\r\n\r\nHere's the full content of `_crumbs.html`:\r\n\r\n```html+jinja\r\n{% macro nav(request, database=None, table=None) -%}\r\n{% set items=crumb_items(request=request, database=database, table=table) %}\r\n{% if items %}\r\n

\r\n {% for item in items %}\r\n {{ item.label }}\r\n {% if not loop.last %}\r\n /\r\n {% endif %}\r\n {% endfor %}\r\n

\r\n{% endif %}\r\n{%- endmacro %}\r\n```\r\nThis means custom template authors can use their own `_crumbs.html` template to do something different with the breadcrumbs.\r\n\r\nIn the actual templates I display breadcrumbs like this:\r\n\r\n```html+jinja\r\n{% block crumbs %}\r\n{{ crumbs.nav(request=request, database=database) }}\r\n{% endblock %}\r\n```\r\nPass `database=` to get `home / database_name` - pass `table=` as well to get `home / database_name / table_name` - if you just send `request=` you just get `home`.\r\n\r\nI've also made the default base template show the `home` breadcrumbs - other pages such as `table.html` and `row.html` can then over-ride `{% block crumbs %}` to get different breadcrumbs.\r\n\r\n\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1397084281, "label": "If user can see table but NOT database/instance nav links should not display"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1831#issuecomment-1278175798", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1831", "id": 1278175798, "node_id": "IC_kwDOBm6k_c5ML2o2", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-13T21:02:52Z", "updated_at": "2022-10-13T21:02:52Z", "author_association": "OWNER", "body": "This patch to `default_permissions.py` made debugging easier: https://gist.github.com/simonw/daddf022e75a98ea6246ac1e12dc8759", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1397084281, "label": "If user can see table but NOT database/instance nav links should not display"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1831#issuecomment-1276882359", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1831", "id": 1276882359, "node_id": "IC_kwDOBm6k_c5MG623", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-13T00:36:09Z", "updated_at": "2022-10-13T00:36:19Z", "author_association": "OWNER", "body": "It's important that, however this works, it supports custom templates changing how the breadcrumbs are displayed. Probably needs a `_crumbs.html` template.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1397084281, "label": "If user can see table but NOT database/instance nav links should not display"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1831#issuecomment-1276856836", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1831", "id": 1276856836, "node_id": "IC_kwDOBm6k_c5MG0oE", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-12T23:57:28Z", "updated_at": "2022-10-12T23:57:28Z", "author_association": "OWNER", "body": "As part of this I think I want `request` to always be available in the template context, which will remove the need for https://datasette.io/plugins/datasette-template-request", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1397084281, "label": "If user can see table but NOT database/instance nav links should not display"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1831#issuecomment-1276706181", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1831", "id": 1276706181, "node_id": "IC_kwDOBm6k_c5MGP2F", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-12T20:34:00Z", "updated_at": "2022-10-12T23:43:39Z", "author_association": "OWNER", "body": "Maybe new template functions: `table_crumbs(table, database)` and `database_crumbs(database)` and `instance_crumbs()` - which know how to both check the permissions and display the `