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: add all possible types to exchange to sharing dialog type prop #1513

Merged
merged 3 commits into from
Jun 20, 2024

Conversation

flaminic
Copy link
Contributor

@flaminic flaminic commented Jun 4, 2024

Description

Expand types of sharing dialog type prop to include all possible types. Needed for https://dhis2.atlassian.net/browse/DHIS2-17276

@flaminic flaminic requested a review from a team as a code owner June 4, 2024 08:11
@dhis2-bot
Copy link
Contributor

dhis2-bot commented Jun 4, 2024

🚀 Deployed on https://pr-1513--dhis2-ui.netlify.app

@dhis2-bot dhis2-bot temporarily deployed to netlify June 4, 2024 08:15 Inactive
Copy link

cypress bot commented Jun 4, 2024

Passing run #3418 ↗︎

0 584 0 0 Flakiness 0

Details:

fix: restrict dialog types to only sharable and restrict type of sharing type
Project: ui Commit: ee8a056f46
Status: Passed Duration: 09:57 💡
Started: Jun 4, 2024 1:13 PM Ended: Jun 4, 2024 1:23 PM

Review all test suite changes for PR #1513 ↗︎

@flaminic flaminic changed the title fix: add aggregate data exchange to sharing dialog type prop's type fix: add alll possible types to exchange to sharing dialog type prop Jun 4, 2024
@flaminic flaminic changed the title fix: add alll possible types to exchange to sharing dialog type prop fix: add all possible types to exchange to sharing dialog type prop Jun 4, 2024
@dhis2-bot dhis2-bot temporarily deployed to netlify June 4, 2024 09:17 Inactive
@@ -19,7 +19,254 @@ export const SHARE_TARGET_GROUP = 'SHARE_TARGET_GROUP'
* Sharing dialog types
*/

export const VISUALIZATION = 'visualization'
export const ACCESS = 'access'
Copy link
Member

@Birkbjo Birkbjo Jun 4, 2024

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']

Copy link
Member

@Birkbjo Birkbjo Jun 4, 2024

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)

Copy link
Contributor Author

@flaminic flaminic Jun 4, 2024

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 :)

Copy link
Member

@Birkbjo Birkbjo left a 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].

@dhis2-bot dhis2-bot temporarily deployed to netlify June 4, 2024 13:10 Inactive
@flaminic flaminic requested a review from Birkbjo June 4, 2024 14:10
@flaminic flaminic force-pushed the add-type-to-sharing-dialog branch from ee8a056 to 1748809 Compare June 6, 2024 07:39
@dhis2-bot dhis2-bot temporarily deployed to netlify June 6, 2024 07:43 Inactive
@flaminic flaminic merged commit 1a3ba5e into master Jun 20, 2024
16 checks passed
@flaminic flaminic deleted the add-type-to-sharing-dialog branch June 20, 2024 06:59
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 9.8.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

3 participants