Skip to content

Commit

Permalink
Merge branch 'main' into urlencode-entity-url
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchdawson1982 authored Dec 16, 2024
2 parents ebeb7d5 + b35eaa5 commit 121f73d
Show file tree
Hide file tree
Showing 14 changed files with 423 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scan-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ jobs:
- name: Upload SARIF
if: always()
id: upload_sarif
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v2.2.7
uses: github/codeql-action/upload-sarif@8a93837afdf1873301a68d777844b43e98cd4313 # v2.2.7
with:
sarif_file: trivy-results.sarif
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ Current swicthes and default settings:

- `search-sort-radio-buttons` off - switches on/off radio selection buttons for sort order of search results.
- `display-result-tags` off - switches on/off the display of tags in search and results pages
- `show_is_nullable_in_table_details_column` off - switches on/off the `Is Nullable` column in the table details page
10 changes: 7 additions & 3 deletions home/service/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
from urllib.parse import urlsplit

from data_platform_catalogue.entities import (
EntityRef, RelationshipType, DatabaseEntityMapping,
DashboardEntityMapping, PublicationCollectionEntityMapper, PublicationDatasetEntityMapping
DashboardEntityMapping,
DatabaseEntityMapping,
EntityRef,
PublicationCollectionEntityMapping,
PublicationDatasetEntityMapping,
RelationshipType,
)
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.core.validators import URLValidator
Expand Down Expand Up @@ -222,7 +226,7 @@ def __init__(self, urn: str):
def _get_context(self):
context = {
"entity": self.publication_collection_metadata,
"entity_type": PublicationCollectionEntityMapper.find_moj_data_type.value,
"entity_type": PublicationCollectionEntityMapping.find_moj_data_type.value,
"platform_name": friendly_platform_name(
self.publication_collection_metadata.platform.display_name
),
Expand Down
6 changes: 3 additions & 3 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ChartEntityMapping,
DashboardEntityMapping,
DatabaseEntityMapping,
PublicationCollectionEntityMapper,
PublicationCollectionEntityMapping,
PublicationDatasetEntityMapping,
TableEntityMapping,
)
Expand Down Expand Up @@ -42,8 +42,8 @@
DatabaseEntityMapping.url_formatted: DatabaseDetailsService,
ChartEntityMapping.url_formatted: ChartDetailsService,
DashboardEntityMapping.url_formatted: DashboardDetailsService,
PublicationCollectionEntityMapper.url_formatted: PublicationCollectionDetailsService,
PublicationDatasetEntityMapping.url_formatted: PublicationDatasetDetailsService
PublicationCollectionEntityMapping.url_formatted: PublicationCollectionDetailsService,
PublicationDatasetEntityMapping.url_formatted: PublicationDatasetDetailsService,
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import json
import logging
from collections import namedtuple
from typing import Any, Sequence, Tuple

from datahub.configuration.common import GraphError # pylint: disable=E0611
from datahub.ingestion.graph.client import DataHubGraph # pylint: disable=E0611

from data_platform_catalogue.client.exceptions import CatalogueError
from data_platform_catalogue.client.graphql_helpers import (
get_graphql_query,
Expand All @@ -19,17 +15,17 @@
)
from data_platform_catalogue.client.search.filters import map_filters
from data_platform_catalogue.entities import (
ChartEntityMapping,
DashboardEntityMapping,
DatabaseEntityMapping,
DatahubEntityType,
DatahubSubtype,
EntityRef,
FindMoJdataEntityMapper,
TableEntityMapping,
ChartEntityMapping,
DatabaseEntityMapping,
DashboardEntityMapping,
PublicationDatasetEntityMapping,
PublicationCollectionEntityMapper,
GlossaryTermEntityMapping,
EntityRef
PublicationCollectionEntityMapping,
PublicationDatasetEntityMapping,
TableEntityMapping,
)
from data_platform_catalogue.search_types import (
DomainOption,
Expand All @@ -40,6 +36,8 @@
SearchResult,
SortOption,
)
from datahub.configuration.common import GraphError # pylint: disable=E0611
from datahub.ingestion.graph.client import DataHubGraph # pylint: disable=E0611

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -89,7 +87,7 @@ def __init__(self, graph: DataHubGraph):
DatahubSubtype.PUBLICATION_COLLECTION.value,
): (
self._parse_container,
PublicationCollectionEntityMapper,
PublicationCollectionEntityMapping,
),
(
DatahubEntityType.DATASET.value,
Expand Down Expand Up @@ -311,7 +309,9 @@ def _parse_dataset(
"total_parents": entity.get("relationships", {}).get("total", 0),
"domain_name": domain.display_name,
"domain_id": domain.urn,
"entity_types": self._parse_types_and_sub_types(entity, result_type.find_moj_data_type.value),
"entity_types": self._parse_types_and_sub_types(
entity, result_type.find_moj_data_type.value
),
}
logger.debug(f"{metadata=}")

Expand Down Expand Up @@ -451,7 +451,9 @@ def _parse_container(
"owner_email": owner.email,
"domain_name": domain.display_name,
"domain_id": domain.urn,
"entity_types": self._parse_types_and_sub_types(entity, subtype.find_moj_data_type.value),
"entity_types": self._parse_types_and_sub_types(
entity, subtype.find_moj_data_type.value
),
}

metadata.update(custom_properties)
Expand Down
30 changes: 13 additions & 17 deletions lib/datahub-client/data_platform_catalogue/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,51 +59,45 @@ class FindMoJdataEntityMapper:
DatahubSubtype.MODEL.value,
DatahubSubtype.TABLE.value,
DatahubSubtype.SEED.value,
DatahubSubtype.SOURCE.value
DatahubSubtype.SOURCE.value,
],
"table"
"table",
)

ChartEntityMapping = FindMoJdataEntityMapper(
FindMoJdataEntityType.CHART,
DatahubEntityType.CHART,
[],
"chart"
FindMoJdataEntityType.CHART, DatahubEntityType.CHART, [], "chart"
)

GlossaryTermEntityMapping = FindMoJdataEntityMapper(
FindMoJdataEntityType.GLOSSARY_TERM,
DatahubEntityType.GLOSSARY_TERM,
[],
"glossary_term"
"glossary_term",
)

DatabaseEntityMapping = FindMoJdataEntityMapper(
FindMoJdataEntityType.DATABASE,
DatahubEntityType.CONTAINER,
[DatahubSubtype.DATABASE.value],
"database"
"database",
)

DashboardEntityMapping = FindMoJdataEntityMapper(
FindMoJdataEntityType.DASHBOARD,
DatahubEntityType.DASHBOARD,
[],
"dashboard"
FindMoJdataEntityType.DASHBOARD, DatahubEntityType.DASHBOARD, [], "dashboard"
)

PublicationDatasetEntityMapping = FindMoJdataEntityMapper(
FindMoJdataEntityType.PUBLICATION_DATASET,
DatahubEntityType.DATASET,
[DatahubSubtype.PUBLICATION_DATASET.value],
"publication_dataset"
"publication_dataset",
)

PublicationCollectionEntityMapper = FindMoJdataEntityMapper(
PublicationCollectionEntityMapping = FindMoJdataEntityMapper(
FindMoJdataEntityType.PUBLICATION_COLLECTION,
DatahubEntityType.CONTAINER,
[DatahubSubtype.PUBLICATION_COLLECTION.value],
"publication_collection"
"publication_collection",
)

Mappers = [
Expand All @@ -113,7 +107,7 @@ class FindMoJdataEntityMapper:
DatabaseEntityMapping,
DashboardEntityMapping,
PublicationDatasetEntityMapping,
PublicationCollectionEntityMapper
PublicationCollectionEntityMapping,
]


Expand Down Expand Up @@ -595,10 +589,11 @@ class Database(Entity):
description="Unique identifier for the entity. Relates to Datahub's urn",
examples=["urn:li:container:my_database"],
)
# tables: list = Field(description="list of tables in the database")


class PublicationCollection(Entity):
"""For source system publication collections"""

urn: str | None = Field(
description="Unique identifier for the entity. Relates to Datahub's urn",
examples=["urn:li:container:criminal_justice_stats"],
Expand All @@ -611,6 +606,7 @@ class PublicationCollection(Entity):

class PublicationDataset(Entity):
"""For source system publication collections"""

urn: str | None = Field(
description="Unique identifier for the entity. Relates to Datahub's urn",
examples=["urn:li:dataset:(urn:li:dataPlatform:gov.uk,statistics2011,DEV)"],
Expand Down
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {
"@babel/preset-env": "^7.26.0",
"@ministryofjustice/frontend": "^3.1.0",
"@ministryofjustice/frontend": "^3.2.1",
"babel-jest": "^29.7.0",
"govuk-frontend": "^5.7.1",
"jest-environment-jsdom": "^29.7.0",
Expand Down
16 changes: 8 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ markdown = "^3.7"
python-dotenv = "^1.0.1"
markdown-headdown = "^0.1.3"
nltk = "^3.9.1"
sentry-sdk = { extras = ["django"], version = "^2.19.1" }
sentry-sdk = { extras = ["django"], version = "^2.19.2" }
ministryofjustice-data-platform-catalogue = { path = "lib/datahub-client", develop = true }
django-azure-auth = "2.1.0"
django-waffle = "^4.2.0"
psycopg = "^3.2.3"
psycopg-binary = "^3.2.3"
django-debug-toolbar = "^4.4.6"
redis = {extras = ["hiredis"], version = "^5.2.0"}
redis = {extras = ["hiredis"], version = "^5.2.1"}
notifications-python-client = "^10.0.0"

[tool.poetry.group.dev.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion scripts/app-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ fi
python manage.py migrate
python manage.py waffle_switch search-sort-radio-buttons off --create # create switch with default setting
python manage.py waffle_switch display-result-tags off --create # create display tags switch with default off

python manage.py waffle_switch show_is_nullable_in_table_details_column off --create # create isnullable column switch with default off

gunicorn --bind 0.0.0.0:8000 core.wsgi:application --workers 2 --threads 4
41 changes: 41 additions & 0 deletions scss/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,44 @@ The masthead is an extended header with search included.
### Similar components elsewhere

- [GOV.UK Design system documentation](https://github.com/alphagov/govuk-design-system/blob/b3223714d8f2e9564b7e9d2ca703a3f902bf1ce8/src/stylesheets/components/_masthead.scss)

## Table component
This enhances the [GOV.UK table component](https://design-system.service.gov.uk/components/table/), making tables on result details pages responsive when loaded in small resolutions.

### Expected behaviours

- At high zooms table contents are wrapped and transposed or rotated so all information is still visible. With headings becoming part of the table rows.

### Usage
```html
<table class="govuk-table app-table-responsive">
<caption class="govuk-table__caption govuk-table__caption--m">Table schema</caption>
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header">Column name</th>
<th scope="col" class="govuk-table__header">"Description</th>
<th scope="col" class="govuk-table__header">Type</th>
</tr>
</thead>
<tbody class="govuk-table__body app-table-responsive__body">
{% for column in entity.column_details %}
<tr class="govuk-table__row app-table-responsive__row">
<td class="govuk-table__cell"><span class="app-table-responsive__heading">Column name:</span>{{column.display_name}}</td>
<td class="govuk-table__cell column-description"><span class="app-table-responsive__heading">Description:</span>
{% if column.description %}
<div>
{{column.description|default:''|markdown:3}}
</div>
{% else %}
<p class="govuk-visually-hidden">A description for {{column.display_name}} does not exist</p>
{% endif %}
</td>
<td class="govuk-table__cell"><span class="app-table-responsive__heading">Type:</span>{{column.type|title}}</td>
</tr>
{% endfor %}
</tbody>
</table>
```

### Similar components elsewhere
- [NHS UK frontend](https://github.com/nhsuk/nhsuk-frontend/blob/e8928ebe19d39fe6137a5ca046217f9ac043b29b/packages/components/tables/_tables.scss#L80)
Loading

0 comments on commit 121f73d

Please sign in to comment.