vault/ui/scripts/codemods/dropdown-transform.js
Vault Automation 0845606fe3
UI: Adopt HDS tooltip (#9967) (#10326)
* replace instances of ToolTip component with HDS tooltip

* Replace InfoTooltip component instances with HDS tooltip

* update tests

* remove remaining custom tooltip code

* remove rich tooltip with copy

* update test and update toolbar link with styling to remove extra link

* Apply suggestions from code review



* update test and remove setRunOptions now that tooltip violations are addressed

* Revert "Apply suggestions from code review"

This reverts commit 90f01c653be68f23b6dbd75f252d227e38dbe53f.

* Remove unused disabled tooltip code

* add comment and TODO explaining conditional modifier pattern

---------

Co-authored-by: lane-wetmore <lane.wetmore@hashicorp.com>
Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
2025-10-22 18:24:50 +00:00

45 lines
1.6 KiB
JavaScript

#!/usr/bin/env node
/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
/* eslint-env node */
/**
* Codemod to transform BasicDropdown and content components
* As of version 2 of ember-basic-dropdown the yielded component names are now capitalized
* In addition, splattributes are used and class must be passed as an attribute rather than argument
*/
module.exports = () => {
return {
ElementNode(node) {
// ensure we have the right parent node by first looking for BasicDropdown nodes
if (['BasicDropdown'].includes(node.tag)) {
node.children.forEach((child) => {
// capitalize trigger and content and transform attributes
if (child.type === 'ElementNode' && child.tag.match(/\.(content|trigger)/gi)) {
const { tag } = child;
const char = tag.charAt(tag.indexOf('.') + 1);
child.tag = tag.replace(char, char.toUpperCase());
// remove @ symbol from class and change @tagName to @htmlTag
// Content component does not use splattributes -- apply class with @defaultClass arg
child.attributes.forEach((attr) => {
if (attr.name.includes('class')) {
if (child.tag.includes('Content')) {
attr.name = '@defaultClass';
} else if (attr.name === '@class') {
attr.name = 'class';
}
} else if (attr.name.includes('tagName')) {
attr.name = '@htmlTag';
}
});
}
});
}
},
};
};