Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [sc-213347] [SharePoint plugin] display of metadata columns is not activated #67

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [Version 1.1.5](https://github.com/dataiku/dss-plugin-sharepoint-online/releases/tag/v1.1.5) - Feature release - 2024-11-13

- Add option to retrieve metadata columns, provided they are visible in the selected view

## [Version 1.1.4](https://github.com/dataiku/dss-plugin-sharepoint-online/releases/tag/v1.1.4) - Feature release - 2024-07-16

- Fix writing when using presets with no root folder defined
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "sharepoint-online",
"version": "1.1.4",
"version": "1.1.5",
"meta": {
"label": "SharePoint Online",
"description": "Read and write data from/to your SharePoint Online account",
Expand Down
12 changes: 10 additions & 2 deletions python-connectors/sharepoint-online_lists/connector.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
},
{
"name": "advanced_parameters",
"label": "Show advanced parameters",
"description": "",
"label": " ",
"description": "Show advanced parameters",
"type": "BOOLEAN",
"defaultValue": false
},
Expand All @@ -125,6 +125,14 @@
"defaultValue": "",
"visibilityCondition": "model.advanced_parameters == true"
},
{
"name": "are_metadata_columns_visible",
"label": " ",
"description": "Render all metadata columns",
"type": "BOOLEAN",
"defaultValue": false,
"visibilityCondition": "model.advanced_parameters == true"
},
{
"name": "write_mode",
"label": "Write mode",
Expand Down
2 changes: 1 addition & 1 deletion python-lib/dss_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DSSConstants(object):
"sharepoint_oauth": "The access token is missing"
}
PATH = 'path'
PLUGIN_VERSION = "1.1.4"
PLUGIN_VERSION = "1.1.5-beta.1"
SECRET_PARAMETERS_KEYS = ["Authorization", "sharepoint_username", "sharepoint_password", "client_secret", "client_certificate", "passphrase"]
SITE_APP_DETAILS = {
"sharepoint_tenant": "The tenant name is missing",
Expand Down
8 changes: 7 additions & 1 deletion python-lib/sharepoint_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, config):
self.session = RobustSession(status_codes_to_retry=[429, 503], attempt_session_reset_on_403=attempt_session_reset_on_403)
self.number_dumped_logs = 0
self.username_for_namespace_diag = None
self.are_metadata_columns_visible = config.get("advanced_parameters", False) and config.get("are_metadata_columns_visible", False)

self.dss_column_name = {}
self.column_ids = {}
Expand Down Expand Up @@ -948,7 +949,10 @@ def get_read_schema(self, display_metadata=False, metadata_to_retrieve=[]):
self.is_column_displayable(column, display_metadata, metadata_to_retrieve)
))
if self.is_column_displayable(column, display_metadata, metadata_to_retrieve):
sharepoint_type = get_dss_type(column[SharePointConstants.TYPE_AS_STRING])
sharepoint_type = get_dss_type(
column[SharePointConstants.TYPE_AS_STRING],
with_computed=self.are_metadata_columns_visible
)
self.column_sharepoint_type[column[SharePointConstants.STATIC_NAME]] = column[SharePointConstants.TYPE_AS_STRING]
if sharepoint_type is not None:
dss_columns.append({
Expand All @@ -968,6 +972,8 @@ def get_read_schema(self, display_metadata=False, metadata_to_retrieve=[]):
}

def is_column_displayable(self, column, display_metadata=False, metadata_to_retrieve=[]):
if self.are_metadata_columns_visible:
return True
if display_metadata and (column['StaticName'] in metadata_to_retrieve):
return True
return (not column[SharePointConstants.HIDDEN_COLUMN])
Expand Down
13 changes: 13 additions & 0 deletions python-lib/sharepoint_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ class SharePointConstants(object):
"User": "array",
"Thumbnail": "object"
}
TYPES_WITH_COMPUTED = {
"Text": "string",
"Number": "string",
"DateTime": "date",
"Boolean": "string",
"URL": "object",
"Location": "object",
"Computed": "string",
"Attachments": None,
"Calculated": "string",
"User": "array",
"Thumbnail": "object"
}
TYPE_AS_STRING = 'TypeAsString'
TYPE_COLUMN = 'type'
VALUE = 'value'
Expand Down
7 changes: 5 additions & 2 deletions python-lib/sharepoint_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ def extract_results(response):
return response[SharePointConstants.RESULTS_CONTAINER_V2][SharePointConstants.RESULTS]


def get_dss_type(sharepoint_type):
return SharePointConstants.TYPES.get(sharepoint_type, DSSConstants.FALLBACK_TYPE)
def get_dss_type(sharepoint_type, with_computed=False):
if with_computed:
return SharePointConstants.TYPES_WITH_COMPUTED.get(sharepoint_type, DSSConstants.FALLBACK_TYPE)
else:
return SharePointConstants.TYPES.get(sharepoint_type, DSSConstants.FALLBACK_TYPE)


def get_sharepoint_type(dss_type):
Expand Down