•  
      request #41486 Use data- instead of camelCase in getDatasetItemOrThrow
    Infos
    #41486
    Nicolas Terray (nterray)
    2025-02-20 17:33
    2025-01-27 11:22
    43162
    Details
    Use data- instead of camelCase in getDatasetItemOrThrow

    getDatasetItemOrThrow accepts both data attribute name (e.g data-user-id) and its camelCase version (e.g userId). Using data attribute name is easier because we can directly search its usage in mustache files instead of having to do the conversion when using camelCase. We should favor usage of data attribute names everywhere and remove support of camelCase.

    Current usages (as of Jan 27th, 2025):

    Targets
        Occurrences of 'getDatasetItemOrThrow' in Directory /home/nicolas/dev/tuleap
    Found occurrences in Directory /home/nicolas/dev/tuleap  (122 usages found)
        Unclassified  (122 usages found)
            tuleap  (122 usages found)
                plugins/artidoc/scripts/artidoc/src  (9 usages found)
                    index.ts  (9 usages found)
                        74 const item_id = Number.parseInt(getDatasetItemOrThrow(vue_mount_point, "itemId"), 10);
                        81 getDatasetItemOrThrow(vue_mount_point, "canUserEditDocument"),
                        83 const selected_tracker = JSON.parse(getDatasetItemOrThrow(vue_mount_point, "selectedTracker"));
                        88 JSON.parse(getDatasetItemOrThrow(vue_mount_point, "allowedTrackers")),
                        110 app.provide(TITLE, getDatasetItemOrThrow(vue_mount_point, "title"));
                        113 Number.parseInt(getDatasetItemOrThrow(vue_mount_point, "uploadMaxSize"), 10),
                        118 initPdfTemplatesStore(JSON.parse(getDatasetItemOrThrow(vue_mount_point, "pdfTemplates"))),
                        120 app.provide(IS_USER_ANONYMOUS, Number(getDatasetItemOrThrow(document.body, "userId")) === 0);
                plugins/document/scripts/document  (36 usages found)
                    index.ts  (36 usages found)
                        59 const project_id = getDatasetItemOrThrow(vue_mount_point, "projectId");
                        60 const root_id = Number.parseInt(getDatasetItemOrThrow(vue_mount_point, "rootId"), 10);
                        61 const project_name = getDatasetItemOrThrow(vue_mount_point, "projectName");
                        62 const project_public_name = getDatasetItemOrThrow(vue_mount_point, "projectPublicName");
                        63 const project_url = getDatasetItemOrThrow(vue_mount_point, "projectUrl");
                        64 const user_is_admin = Boolean(getDatasetItemOrThrow(vue_mount_point, "userIsAdmin"));
                        66 getDatasetItemOrThrow(vue_mount_point, "userCanCreateWiki"),
                        68 const user_timezone = getDatasetItemOrThrow(document.body, "userTimezone");
                        69 const date_time_format = getDatasetItemOrThrow(document.body, "dateTimeFormat");
                        70 const user_id = Number.parseInt(getDatasetItemOrThrow(document.body, "userId"), 10);
                        72 getDatasetItemOrThrow(vue_mount_point, "maxFilesDragndrop"),
                        76 getDatasetItemOrThrow(vue_mount_point, "maxSizeUpload"),
                        80 getDatasetItemOrThrow(vue_mount_point, "warningThreshold"),
                        84 getDatasetItemOrThrow(vue_mount_point, "maxArchiveSize"),
                        88 getDatasetItemOrThrow(vue_mount_point, "embeddedAreAllowed"),
                        91 getDatasetItemOrThrow(vue_mount_point, "userCanDeleteItem"),
                        94 getDatasetItemOrThrow(vue_mount_point, "isItemStatusPropertyUsed"),
                        97 getDatasetItemOrThrow(vue_mount_point, "forbidWritersToUpdate"),
                        100 getDatasetItemOrThrow(vue_mount_point, "forbidWritersToDelete"),
                        103 getDatasetItemOrThrow(vue_mount_point, "isObsolescenceDatePropertyUsed"),
                        106 getDatasetItemOrThrow(vue_mount_point, "isChangelogDisplayedAfterDnd"),
                        108 const csrf_token_name = getDatasetItemOrThrow(vue_mount_point, "csrfTokenName");
                        109 const csrf_token = getDatasetItemOrThrow(vue_mount_point, "csrfToken");
                        110 const relative_dates_display = getDatasetItemOrThrow(vue_mount_point, "relativeDatesDisplay");
                        111 const privacy = JSON.parse(getDatasetItemOrThrow(vue_mount_point, "privacy"));
                        112 const project_flags = JSON.parse(getDatasetItemOrThrow(vue_mount_point, "projectFlags"));
                        113 const project_icon = getDatasetItemOrThrow(vue_mount_point, "projectIcon");
                        114 const filename_pattern = getDatasetItemOrThrow(vue_mount_point, "filenamePattern");
                        116 getDatasetItemOrThrow(vue_mount_point, "isFilenamePatternEnforced"),
                        119 getDatasetItemOrThrow(vue_mount_point, "canUserSwitchToOldUi"),
                        122 getDatasetItemOrThrow(vue_mount_point, "shouldDisplaySourceColumn"),
                        130 const criteria = JSON.parse(getDatasetItemOrThrow(vue_mount_point, "criteria")).map(
                        133 const columns = JSON.parse(getDatasetItemOrThrow(vue_mount_point, "columns"));
                        135 getDatasetItemOrThrow(vue_mount_point, "createNewItemAlternatives"),
                        137 const other_item_types = JSON.parse(getDatasetItemOrThrow(vue_mount_point, "otherItemTypes"));
                plugins/git/scripts/repositories-list/src  (14 usages found)
                    index.ts  (14 usages found)
                        42 const locale = getDatasetItemOrThrow(document.body, "userLocale");
                        58 getDatasetItemOrThrow(vue_mount_point, "repositoriesAdministrationUrl"),
                        59 getDatasetItemOrThrow(vue_mount_point, "repositoryListUrl"),
                        60 getDatasetItemOrThrow(vue_mount_point, "repositoriesForkUrl"),
                        61 getDatasetItemOrThrow(vue_mount_point, "projectPublicName"),
                        62 getDatasetItemOrThrow(vue_mount_point, "projectUrl"),
                        63 JSON.parse(getDatasetItemOrThrow(vue_mount_point, "privacy")),
                        64 JSON.parse(getDatasetItemOrThrow(vue_mount_point, "projectFlags")),
                        68 const repositories_owners = getDatasetItemOrThrow(vue_mount_point, "repositoriesOwners");
                        71 Number.parseInt(getDatasetItemOrThrow(document.body, "userId"), 10),
                        72 Number.parseInt(getDatasetItemOrThrow(vue_mount_point, "projectId"), 10),
                        81 JSON.parse(getDatasetItemOrThrow(vue_mount_point, "externalPlugins")),
                        101 getDatasetItemOrThrow(vue_mount_point, "externalServicesNameUsed"),
                plugins/gitlab/scripts/group-link-wizard/src  (4 usages found)
                    gitlab-group-link.ts  (4 usages found)
                        24 import { getDatasetItemOrThrow } from "@tuleap/dom";
                        36 getDatasetItemOrThrow(mount_point, "currentProjectUnixName"),
                        50 id: Number.parseInt(getDatasetItemOrThrow(mount_point, "currentProjectId"), 10),
                        51 public_name: getDatasetItemOrThrow(mount_point, "currentProjectName"),
                plugins/gitlab/scripts/linked-group/src  (5 usages found)
                    main.ts  (5 usages found)
                        34 const locale = getDatasetItemOrThrow(document.body, "userLocale");
                        42 const group_id = Number.parseInt(getDatasetItemOrThrow(buttons_section, "groupId"), 10);
                        43 const gitlab_server_uri = getDatasetItemOrThrow(buttons_section, "gitlabUri");
                        45 getDatasetItemOrThrow(buttons_section, "gitlabGroupId"),
                plugins/graphontrackersv5/scripts/graph-loader/src  (5 usages found)
                    loadGraphs.ts  (5 usages found)
                        44 const graph_id = getDatasetItemOrThrow(graph_node, "data-graph-id");
                        45 const renderer_id = getDatasetItemOrThrow(graph_node, "data-renderer-id");
                        46 const report_id = getDatasetItemOrThrow(graph_node, "data-report-id");
                        47 const in_dashboard = getDatasetItemOrThrow(graph_node, "data-in-dashboard");
                plugins/pdftemplate/scripts/admin/src  (2 usages found)
                    initiate-print-preview.ts  (2 usages found)
                        76 JSON.parse(getDatasetItemOrThrow(button, "variables")),
                plugins/program_management/scripts/planned-iterations/src  (8 usages found)
                    index.ts  (8 usages found)
                        34 const user_locale = getDatasetItemOrThrow(document.body, "data-user-locale");
                        44 program: JSON.parse(getDatasetItemOrThrow(vue_mount_point, "data-program")),
                        46 getDatasetItemOrThrow(vue_mount_point, "data-program-privacy"),
                        49 getDatasetItemOrThrow(vue_mount_point, "data-program-flags"),
                        53 getDatasetItemOrThrow(vue_mount_point, "data-program-increment"),
                        56 getDatasetItemOrThrow(vue_mount_point, "data-iterations-labels"),
                        60 getDatasetItemOrThrow(vue_mount_point, "data-iteration-tracker-id"),
                plugins/program_management/scripts/program_management/src  (12 usages found)
                    index.ts  (12 usages found)
                        35 const locale = getDatasetItemOrThrow(document.body, "userLocale");
                        41 const project_name = getDatasetItemOrThrow(vue_mount_point, "projectName");
                        42 const project_short_name = getDatasetItemOrThrow(vue_mount_point, "projectShortName");
                        43 const project_privacy = JSON.parse(getDatasetItemOrThrow(vue_mount_point, "projectPrivacy"));
                        44 const project_flags = JSON.parse(getDatasetItemOrThrow(vue_mount_point, "projectFlags"));
                        45 const program_id = parseInt(getDatasetItemOrThrow(vue_mount_point, "programId"), 10);
                        47 getDatasetItemOrThrow(vue_mount_point, "programIncrementTrackerId"),
                        50 const program_increment_label = getDatasetItemOrThrow(vue_mount_point, "programIncrementLabel");
                        51 const program_increment_sub_label = getDatasetItemOrThrow(
                        55 const iteration_label = getDatasetItemOrThrow(vue_mount_point, "iterationLabel");
                        63 const project_icon = getDatasetItemOrThrow(vue_mount_point, "projectIcon");
                plugins/pullrequest/scripts/pullrequest-homepage/src  (5 usages found)
                    pullrequest-homepage.ts  (5 usages found)
                        43 const repository_id = Number.parseInt(getDatasetItemOrThrow(mount_point, "repositoryId"), 10);
                        44 const project_id = Number.parseInt(getDatasetItemOrThrow(mount_point, "projectId"), 10);
                        45 const user_id = Number.parseInt(getDatasetItemOrThrow(document.body, "userId"), 10);
                        57 getDatasetItemOrThrow(mount_point, "relativeDateDisplay"),
                plugins/pullrequest/scripts/pullrequest-overview/src  (7 usages found)
                    pullrequest-overview.ts  (7 usages found)
                        42 const project_id = getDatasetItemOrThrow(mount_point, "projectId");
                        43 const current_repository_id = getDatasetItemOrThrow(mount_point, "repositoryId");
                        52 Number.parseInt(getDatasetItemOrThrow(document.body, "userId"), 10),
                        56 .provide(CURRENT_USER_AVATAR_URL, getDatasetItemOrThrow(mount_point, "userAvatarUrl"))
                        59 getDatasetItemOrThrow(mount_point, "relativeDateDisplay"),
                        63 Boolean(getDatasetItemOrThrow(mount_point, "areMergeCommitsAllowedInRepository")),
                plugins/timetracking/scripts/timetracking-management-widget/src  (3 usages found)
                    index.ts  (3 usages found)
                        43 .provide(USER_LOCALE_KEY, getDatasetItemOrThrow(document.body, "userLocale"))
                        45 .provide(WIDGET_ID, Number.parseInt(getDatasetItemOrThrow(mount_point, "widgetId"), 10))
                plugins/tracker/scripts/artifact/src/edition/comments  (4 usages found)
                    DOMAdapter.ts  (4 usages found)
                        77 const format = getDatasetItemOrThrow(element, "data-user-preferred-format");
                        106 const changeset_id = getDatasetItemOrThrow(follow_up_content, "data-changeset-id");
                        107 const project_id = getDatasetItemOrThrow(follow_up_content, "data-project-id");
                plugins/tracker/scripts/move-artifact-action/src  (6 usages found)
                    modal.ts  (6 usages found)
                        38 Number.parseInt(getDatasetItemOrThrow(vue_mount_point, "trackerId"), 10),
                        40 .provide(TRACKER_NAME, getDatasetItemOrThrow(vue_mount_point, "trackerName"))
                        41 .provide(TRACKER_COLOR, getDatasetItemOrThrow(vue_mount_point, "trackerColor"))
                        44 Number.parseInt(getDatasetItemOrThrow(vue_mount_point, "artifactId"), 10),
                        48 Number.parseInt(getDatasetItemOrThrow(vue_mount_point, "projectId"), 10),
                src/scripts/account/src  (2 usages found)
                    keys-tokens.ts  (2 usages found)
                        37 const locale = getDatasetItemOrThrow(document.body, "userLocale");

     

    Empty
    Empty
    Empty
    • [ ] enhancement
    • [x] internal improvement
    Empty
    Stage
    Martin GOYOT (goyotm)
    Closed
    2025-02-19
    Attachments
    Empty
    References

    Follow-ups

    User avatar
    Martin GOYOT (goyotm)2025-02-12 15:55

    a patch is under review at gerrit #33486


    • Status changed from New to Under implementation
    • Assigned to changed from None to Martin GOYOT (goyotm)
    User avatar
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes