Compare commits

..

3 Commits

Author SHA1 Message Date
538216b5fe Fix logic to purge points less than 1000. 2024-12-02 15:33:31 -08:00
a537b3bf6e Ensure plot points are unique (fix usage of lodash sorted unique tool) 2024-12-02 11:48:11 -08:00
ea9947cab5 Use the disabled attribute on a valid element - the button. (#7914)
* Use the disabled attribute on a valid tag - the button.

* Add e2e test to check for add criteria button being enabled

* Improve test

* Check for add criteria button to have attribute disabled

* Remove focused test
2024-11-05 20:53:28 +00:00
6 changed files with 51 additions and 6 deletions

View File

@ -15,5 +15,5 @@ export default merge(common, {
__OPENMCT_ROOT_RELATIVE__: '""'
})
],
devtool: 'eval-source-map'
devtool: 'source-map'
});

View File

@ -287,6 +287,41 @@ test.describe('Basic Condition Set Use', () => {
description: 'https://github.com/nasa/openmct/issues/7484'
});
});
test('ConditionSet has add criteria button enabled/disabled when composition is and is not available', async ({
page
}) => {
const exampleTelemetry = await createExampleTelemetryObject(page);
await page.getByLabel('Show selected item in tree').click();
await page.goto(conditionSet.url);
// Change the object to edit mode
await page.getByLabel('Edit Object').click();
// Create a condition
await page.locator('#addCondition').click();
await page.locator('#conditionCollection').getByRole('textbox').nth(0).fill('First Condition');
// Validate that the add criteria button is disabled
await expect(page.getByLabel('Add Criteria - Disabled')).toHaveAttribute('disabled');
// Add Telemetry to ConditionSet
const sineWaveGeneratorTreeItem = page
.getByRole('tree', {
name: 'Main Tree'
})
.getByRole('treeitem', {
name: exampleTelemetry.name
});
const conditionCollection = page.locator('#conditionCollection');
await sineWaveGeneratorTreeItem.dragTo(conditionCollection);
// Validate that the add criteria button is enabled and adds a new criterion
await expect(page.getByLabel('Add Criteria - Enabled')).not.toHaveAttribute('disabled');
await page.getByLabel('Add Criteria - Enabled').click();
const numOfUnnamedCriteria = await page.getByLabel('Criterion Telemetry Selection').count();
expect(numOfUnnamedCriteria).toEqual(2);
});
});
test.describe('Condition Set Composition', () => {

View File

@ -160,8 +160,10 @@
</div>
</template>
<div class="c-cdef__separator c-row-separator"></div>
<div class="c-cdef__controls" :disabled="!telemetry.length">
<div class="c-cdef__controls">
<button
:disabled="!telemetry.length"
:aria-label="`Add Criteria - ${!telemetry.length ? 'Disabled' : 'Enabled'}`"
class="c-cdef__add-criteria-button c-button c-button--labeled icon-plus"
@click="addCriteria"
>

View File

@ -1113,6 +1113,7 @@ export default {
}
this.listenTo(window, 'mouseup', this.onMouseUp, this);
// TODO: Why do we need this mousemove listener when we have a mousemove listener on the canvas above?
this.listenTo(window, 'mousemove', this.trackMousePosition, this);
// track frozen state on mouseDown to be read on mouseUp
@ -1133,6 +1134,7 @@ export default {
onMouseUp(event) {
this.stopListening(window, 'mouseup', this.onMouseUp, this);
// TODO: Why do we need this when we have a mousemove listener on the canvas above?
this.stopListening(window, 'mousemove', this.trackMousePosition, this);
if (this.isMouseClick() && event.shiftKey) {

View File

@ -230,7 +230,9 @@ export default class PlotSeries extends Model {
const newPoints = _(data)
.concat(points)
.sortBy(this.getXVal)
.uniq(true, (point) => [this.getXVal(point), this.getYVal(point)].join())
.sortedUniqBy((point) => {
return [this.getXVal(point), this.getYVal(point)].join();
})
.value();
this.reset(newPoints);
} catch (error) {
@ -429,7 +431,7 @@ export default class PlotSeries extends Model {
let data = this.getSeriesData();
let insertIndex = data.length;
const currentYVal = this.getYVal(newData);
const lastYVal = this.getYVal(data[insertIndex - 1]);
const lastYVal = insertIndex > 0 ? this.getYVal(data[insertIndex - 1]) : undefined;
if (this.isValueInvalid(currentYVal) && this.isValueInvalid(lastYVal)) {
console.warn(`[Plot] Invalid Y Values detected: ${currentYVal} ${lastYVal}`);
@ -505,8 +507,12 @@ export default class PlotSeries extends Model {
const pointsToRemove = startIndex + (data.length - endIndex + 1);
if (pointsToRemove > 0) {
if (pointsToRemove < 1000) {
// Remove all points up to the start index
data.slice(0, startIndex).forEach(this.remove, this);
data.slice(endIndex, data.length).forEach(this.remove, this);
// Re-calculate the endIndex since the data array has changed,
// then remove items from endIndex to the end of the array
const newEndIndex = endIndex - startIndex + 1;
data.slice(newEndIndex, data.length).forEach(this.remove, this);
this.updateSeriesData(data);
this.resetStats();
} else {

View File

@ -142,7 +142,7 @@ export default class TelemetryTableConfiguration extends EventEmitter {
getAllHeaders() {
let flattenedColumns = _.flatten(Object.values(this.columns));
/* eslint-disable you-dont-need-lodash-underscore/uniq */
let headers = _.uniq(flattenedColumns, false, (column) => column.getKey()).reduce(
let headers = _.uniqBy(flattenedColumns, (column) => column.getKey()).reduce(
fromColumnsToHeadersMap,
{}
);