-
Notifications
You must be signed in to change notification settings - Fork 14
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: add all possible types to exchange to sharing dialog type prop #1513
Conversation
🚀 Deployed on https://pr-1513--dhis2-ui.netlify.app |
Passing run #3418 ↗︎Details:
Review all test suite changes for PR #1513 ↗︎ |
@@ -19,7 +19,254 @@ export const SHARE_TARGET_GROUP = 'SHARE_TARGET_GROUP' | |||
* Sharing dialog types | |||
*/ | |||
|
|||
export const VISUALIZATION = 'visualization' | |||
export const ACCESS = 'access' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these are not shareable
, is this all schemas?
When I do schemas.filter(s => s.shareable).map(s => s.name).sort()
, I get the following list:
['aggregateDataExchange', 'apiToken', 'attribute', 'category', 'categoryCombo', 'categoryOption', 'categoryOptionGroup', 'categoryOptionGroupSet', 'constant', 'dashboard', 'dataApprovalLevel', 'dataApprovalWorkflow', 'dataElement', 'dataElementGroup', 'dataElementGroupSet', 'dataSet', 'document', 'eventChart', 'eventFilter', 'eventReport', 'eventVisualization', 'expressionDimensionItem', 'externalMapLayer', 'identifiableObject', 'identifiableObject', 'identifiableObject', 'indicator', 'indicatorGroup', 'indicatorGroupSet', 'interpretation', 'legendSet', 'map', 'optionGroup', 'optionGroupSet', 'optionSet', 'organisationUnitGroup', 'organisationUnitGroupSet', 'predictorGroup', 'program', 'programIndicator', 'programIndicatorGroup', 'programStage', 'programStageWorkingList', 'relationshipType', 'report', 'sqlView', 'trackedEntityAttribute', 'trackedEntityFilter', 'trackedEntityType', 'userGroup', 'userRole', 'validationRule', 'validationRuleGroup', 'visualization']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to group these in an object, then do Object.values(DIALOG_TYPES)
in propTypes?. I realize this changes the "structure" of the constants, so would need to check if this breaks something.
I also realized eg. tabbed-content.js
may need an update to refer to the new array instead of each constant separately.
Here's my generated object. (I copy pasted the schemas object from the request from https://debug.dhis2.org/dev/dhis-web-maintenance/index.html#/list/all , then put that in console and filtered with code above and transformed to an object).
It looked something like this:
const dialogTypesObj = schemas.filter(s => s.shareable).map(s => s.name).sort().reduce((acc, curr) => { acc[camelCaseToConstantCase(curr)] = curr; return acc}, {})
const DIALOG_TYPES = {
"AGGREGATE_DATA_EXCHANGE": "aggregateDataExchange",
"API_TOKEN": "apiToken",
"ATTRIBUTE": "attribute",
"CATEGORY": "category",
"CATEGORY_COMBO": "categoryCombo",
"CATEGORY_OPTION": "categoryOption",
"CATEGORY_OPTION_GROUP": "categoryOptionGroup",
"CATEGORY_OPTION_GROUP_SET": "categoryOptionGroupSet",
"CONSTANT": "constant",
"DASHBOARD": "dashboard",
"DATA_APPROVAL_LEVEL": "dataApprovalLevel",
"DATA_APPROVAL_WORKFLOW": "dataApprovalWorkflow",
"DATA_ELEMENT": "dataElement",
"DATA_ELEMENT_GROUP": "dataElementGroup",
"DATA_ELEMENT_GROUP_SET": "dataElementGroupSet",
"DATA_SET": "dataSet",
"DOCUMENT": "document",
"EVENT_CHART": "eventChart",
"EVENT_FILTER": "eventFilter",
"EVENT_REPORT": "eventReport",
"EVENT_VISUALIZATION": "eventVisualization",
"EXPRESSION_DIMENSION_ITEM": "expressionDimensionItem",
"EXTERNAL_MAP_LAYER": "externalMapLayer",
"IDENTIFIABLE_OBJECT": "identifiableObject",
"INDICATOR": "indicator",
"INDICATOR_GROUP": "indicatorGroup",
"INDICATOR_GROUP_SET": "indicatorGroupSet",
"INTERPRETATION": "interpretation",
"LEGEND_SET": "legendSet",
"MAP": "map",
"OPTION_GROUP": "optionGroup",
"OPTION_GROUP_SET": "optionGroupSet",
"OPTION_SET": "optionSet",
"ORGANISATION_UNIT_GROUP": "organisationUnitGroup",
"ORGANISATION_UNIT_GROUP_SET": "organisationUnitGroupSet",
"PREDICTOR_GROUP": "predictorGroup",
"PROGRAM": "program",
"PROGRAM_INDICATOR": "programIndicator",
"PROGRAM_INDICATOR_GROUP": "programIndicatorGroup",
"PROGRAM_STAGE": "programStage",
"PROGRAM_STAGE_WORKING_LIST": "programStageWorkingList",
"RELATIONSHIP_TYPE": "relationshipType",
"REPORT": "report",
"SQL_VIEW": "sqlView",
"TRACKED_ENTITY_ATTRIBUTE": "trackedEntityAttribute",
"TRACKED_ENTITY_FILTER": "trackedEntityFilter",
"TRACKED_ENTITY_TYPE": "trackedEntityType",
"USER_GROUP": "userGroup",
"USER_ROLE": "userRole",
"VALIDATION_RULE": "validationRule",
"VALIDATION_RULE_GROUP": "validationRuleGroup",
"VISUALIZATION": "visualization"
}
// could also export in constants
const DIALOG_TYPES_LIST = Object.values(DIALOG_TYPES)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks @Birkbjo , definately just printed all the available schemas from the backend :)
Re the object vs list of constants, yes I think that works as well, so happy to copy and paste from what you have in here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for adding this. I've had to override this recently in the maintenance app myself.
It would be great to add these to the types as well. But since we don't use typescript in runtime code I think we would have to duplicate this in types instead of reusing the runtime constants (eg. we could've done const DIALOG_TYPES = [.....] as const
and do type SharingTypes = DIALOG_TYPES[number]
.
ee8a056
to
1748809
Compare
Description
Expand types of sharing dialog type prop to include all possible types. Needed for https://dhis2.atlassian.net/browse/DHIS2-17276