Files
threshold-ui/addons/rose/index.js
T
d469f305de Replace Rose::CodeEditor with Hds::CodeEditor (#2679)
* chore: 🤖 replace Rose::CodeEditor with Hds::CodeEditor

- Remove CodeEditor 5 dependency

* chore: 🤖 Replace CodeMirror5 dep

remove CodeMirror5 and replace existing editors with HDS::CodeEditor

* chore: 🤖 deleting old codeeditor styles

* feat: 🎸 changing code editor

changing code editor

✅ Closes: 0

* removed unused export

* pr cleanup

* updating tests for new code editor

* responding to PR feedback

* added whitespace

* fixing linting violations

* chore: 🤖 self-review PR

self-review PR in the course of switching to new HDS code editor

* fix: 🐛 fix linting bug

* fix: 🐛 unneeded dependency

remove jslint dependency as this is handled in the new code editor from
HDS

* fix: 🐛 Fixing import bug

Fix import bug caused by importing scss modules that no longer exist

* Fix and refactor code editor acceptance test

* Fix and refactor code editor acceptance test

* chore: 🤖 remove codemirror dependency

* refactor: 💡 fix merge conflict issues

* test: 💍 update e2e test selectors

* test: 💍 fix target spec click event

* refactor: 💡 clean up test selectors for code editor

* refactor: 💡 clean up storage bucket test selectors

* chore: 🤖 remove code mirror modifiers

---------

Co-authored-by: calcaide <ccorvo@hashicorp.com>
Co-authored-by: cameronperera <cameron.perera@hashicorp.com>
2026-05-14 15:21:27 -04:00

107 lines
3.1 KiB
JavaScript

/**
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
'use strict';
const path = require('path');
module.exports = {
name: require('./package').name,
included(app) {
this._super.included.apply(this, arguments);
this.includeHDSStyles(app);
this.includeFlightIcons(app);
this.includePublic(app);
this.setupSVGO(app);
},
/**
* Due to a limitation in how ember treats nested addons (see https://github.com/ember-cli/ember-cli/issues/4475)
* this is needed to reach down into @hashicorp/design-system-components' contentFor hook to run the logic
* that injects the sprite into the DOM
*/
contentFor(type, config) {
return this.findOwnAddonByName(
'@hashicorp/design-system-components',
).contentFor(type, config);
},
/**
* Finds the HDS styles folder and includes it into the running
* application's `sassOptions.includePaths`.
*/
includeHDSStyles(app) {
const tokensPath = path.resolve(
__dirname,
'node_modules/@hashicorp/design-system-tokens/dist/products/css',
);
const hdsPath = path.resolve(
__dirname,
'node_modules/@hashicorp/design-system-components/dist/styles',
);
// Setup default sassOptions on the running application
app.options.sassOptions = app.options.sassOptions || {};
app.options.sassOptions.includePaths =
app.options.sassOptions.includePaths || [];
// Include the addon styles
app.options.sassOptions.includePaths.push(tokensPath, hdsPath);
},
/**
* Finds the structure-icons folder and includes it into the
* ember-inline-svg addon.
*/
includeFlightIcons(app) {
const iconPackagePath = path.resolve(
__dirname,
'node_modules/@hashicorp/flight-icons',
);
const iconsPath = path.resolve(iconPackagePath, '..');
app.options.svg ||= {};
app.options.svg.paths ||= [];
app.options.svg.paths.push(iconsPath);
this.addons.forEach((addon) => {
if (addon.name === 'ember-inline-svg') addon.included(app);
});
},
/**
* Finds the public folder and includes it into the ember-inline-svg addon.
*/
includePublic(app) {
const publicPath = path.resolve('public');
const dummyPublicPath = path.resolve('tests/dummy/public');
app.options.svg = app.options.svg || {};
app.options.svg.paths = app.options.svg.paths || [];
app.options.svg.paths.push(publicPath);
if (this.isDevelopingAddon()) app.options.svg.paths.push(dummyPublicPath);
this.addons.forEach((addon) => {
if (addon.name === 'ember-inline-svg') addon.included(app);
});
},
/**
* Adjust SVG optimizer defaults (used by ember-inline-svg).
* Note: Currently, there is a svgo pre-release that disables removeViewBox
* by default. So, this extra setup can be discarded once ember-inline-svg
* is updated to svgo v4.
*/
setupSVGO(app) {
app.options.svg = app.options.svg || {};
app.options.svg.optimize = app.options.svg.optimize || {};
app.options.svg.optimize.plugins = app.options.svg.optimize.plugins || [];
app.options.svg.optimize.plugins.push({ removeViewBox: false });
},
};