Skip to content

refactor: convert the member attribute forms to TypeScript (CM-1592) - #5315

Open
gaspergrom wants to merge 2 commits into
mainfrom
refactor/issue-292-member-form-attributes-ts
Open

gaspergrom wants to merge 2 commits into
mainfrom
refactor/issue-292-member-form-attributes-ts

Conversation

@gaspergrom

Copy link
Copy Markdown
Contributor

Converts member-form-attributes.vue and member-form-global-attributes.vue to <script setup lang="ts">. F-03 (#5295) already removed their fields layer.

  • Both components get a defineOptions name, which only affects devtools and warnings.
  • member-form-attributes.vue imports autocomplete-many-input explicitly instead of using the global registration, so vue-tsc checks its bindings.
  • AttributeField derives id and canDelete from FilterCustomAttribute. ContributorAttribute gains an optional enrichment field, which the enrichment worker already writes.
  • Type-forced, same runtime: modelValue is required on the attributes form (the old () => {} default returned undefined, and the drawer always binds v-model); record keeps its undefined default; Number() wraps the booleans in the sort.
  • Seen and left as they are (behaviour-identical ticket): a failed save still shows a success toast, and creating an option on a multiSelect attribute sends null; with production data (options: null) the new option is dropped.
  • Lint, cycle check, vue-tsc (0 errors), the production build and the Storybook build pass on this branch rebased on current main.
  • Clicked through on main and the branch with a mocked API: person profile → Edit attributes (edit text, number, boolean and date values, Update; hide and show an attribute; multiSelect open and create), then Manage global attributes. Not verified with a real backend.

Closes linuxfoundation/lfx-cdp-insights-ops#292

member-form-attributes.vue and member-form-global-attributes.vue move to
`<script setup lang="ts">` with typed props, emits and refs, and leave
the vue/block-lang legacy list.

Both get a defineOptions name, which only shows in devtools and
warnings. The attributes form imports autocomplete-many-input instead of
using the global registration, so vue-tsc checks its bindings.

Changes the types force, with the same runtime behaviour:
- modelValue on the attributes form is required. Its old default factory
  returned undefined and the manage-attributes drawer always passes it.
  record keeps an undefined default, which the !record branch reads.
- The attribute sort wraps show and canDelete in Number(), the coercion
  `-` already applied to the booleans.
- ContributorAttribute gains enrichment?, the source key the members
  enrichment worker writes and the sort reads.
- The type label reads from the AttributeType enum through a
  Partial<Record<string, AttributeType>> alias, because multiSelect and
  special have no label and render blank, as on main.
- Non-null assertions on ids and new labels: only existing attributes
  can be edited or deleted, and Update stays disabled while a label is
  empty.

Refs linuxfoundation/lfx-cdp-insights-ops#292

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 10, 2026 14:32
@cursor

cursor Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Type-only and component API typing on member attribute UI; no auth, data migration, or new business rules.

Overview
Migrates member-form-attributes.vue and member-form-global-attributes.vue from untyped <script setup> to <script setup lang="ts">, with defineOptions names, typed defineProps / defineEmits, and stricter locals (e.g. AttributeField, FilterCustomAttribute, Contributor).

The profile attributes form now types modelValue as required, imports AppAutocompleteManyInput explicitly for vue-tsc, and uses attributeTypeLabels plus Number() when sorting by booleans. ContributorAttribute gains an optional enrichment field so enrichment-based ordering is typed. ESLint vue/block-lang exemptions are removed for both forms because they are no longer legacy JS blocks.

Runtime behavior is intended to stay the same; this is mostly compile-time safety and lint cleanup.

Reviewed by Cursor Bugbot for commit 79d64a6. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the member attribute forms’ TypeScript migration.

No open issues 🎉

What changed in this PR

Continues the member-form modernization after #5295 by converting both attribute forms to TypeScript while preserving existing runtime behavior.

Changes:

  • Adds typed props, emits, form models, and handlers to both components.
  • Imports the autocomplete component explicitly for binding checks and adds the optional enrichment contributor attribute.
  • Removes both migrated forms from the ESLint legacy-file list.
File Description
frontend/​src/​modules/​member/​components/​form/​member-form-global-attributes.vue Converts to TypeScript with typed attribute models and handlers.
frontend/​src/​modules/​member/​components/​form/​member-form-attributes.vue Types component bindings and handlers; explicitly imports autocomplete.
frontend/​src/​modules/​contributor/​types/​Contributor.ts Adds optional enrichment to ContributorAttribute.
frontend/​.eslint/​legacy-files.json Removes the two converted forms from legacy exemptions.

Review effort: Balanced

joanagmaia
joanagmaia previously approved these changes Nov 11, 2026
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>

# Conflicts:
#	frontend/.eslint/legacy-files.json
Copilot AI balanced review requested due to automatic review settings November 14, 2026 00:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the TypeScript conversion of the member attribute forms.

No open issues 🎉

Review effort: Balanced

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants