Skip to content

Commit

Permalink
Added ID for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Dec 2, 2024
1 parent 278e65e commit 9fb5548
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/iobroker.vis-2/src-vis/src/Toolbar/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ interface MultiSelectProps {
setSelectedWidgets: (widgets: string[]) => void;
themeType: ThemeType;
theme: VisTheme;
id?: string;
}

interface MultiSelectState {
Expand All @@ -105,10 +106,10 @@ class MultiSelect extends Component<MultiSelectProps, MultiSelectState> {
const props = this.props;
const value = props.value || [];

let text;
let subText = null;
let text: string | React.JSX.Element;
let subText: string | null = null;
let color: string;
let icon;
let icon: React.JSX.Element | undefined;
if (value.length === 1) {
const item = props.options.find(foundItem => foundItem.value === value[0]);
if (item) {
Expand All @@ -128,6 +129,9 @@ class MultiSelect extends Component<MultiSelectProps, MultiSelectState> {
} else {
text = value.join(', ');
}
if (props.id) {
text = <span id={props.id}>{text}</span>;
}

let backColor;
if (color) {
Expand Down
2 changes: 2 additions & 0 deletions packages/iobroker.vis-2/src-vis/src/Toolbar/ToolbarItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export interface MultiselectToolbarItem extends BaseToolbarItem {
width: number;
value?: string[];
onAction: (value: string[]) => void;
id?: string;
}

export interface CheckboxToolbarItem extends BaseToolbarItem {
Expand Down Expand Up @@ -218,6 +219,7 @@ class ToolbarItems extends React.Component<ToolbarItemsProps, ToolbarItemsState>
theme={this.props.theme}
key={key}
// style={{ margin: '0px 10px' }}
id={item.id}
label={
this.props.toolbarHeight !== 'veryNarrow'
? item.doNotTranslateName
Expand Down
1 change: 1 addition & 0 deletions packages/iobroker.vis-2/src-vis/src/Toolbar/Widgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const Widgets: React.FC<WidgetsProps> = props => {
type: 'multiselect',
name: I18n.t('Active widget(s) from %s', shownWidgets.length),
doNotTranslateName: true,
id: 'tests-vis-selected-widget',
items: shownWidgets.map((widgetId: AnyWidgetId) => {
const tpl = widgets[widgetId].tpl;
const widgetType = widgetTypes.find(w => w.name === tpl);
Expand Down

0 comments on commit 9fb5548

Please sign in to comment.