Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to icon type string instead of node #43111

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ test('Returns title', async () => {

test('Returns an icon', async () => {
const action = new ExpandPanelAction();
expect(action.getIcon({ embeddable })).toBeDefined();
expect(action.getIconType({ embeddable })).toBeDefined();
});
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ export class ExpandPanelAction extends Action {
);
}

public getIcon({ embeddable }: ActionContext) {
public getIconType({ embeddable }: ActionContext) {
if (!embeddable.parent || !isDashboard(embeddable.parent)) {
throw new IncompatibleActionError();
}
// TODO: use 'minimize' when an eui-icon of such is available.
return <EuiIcon type={isExpanded(embeddable) ? 'expand' : 'expand'} />;
return isExpanded(embeddable) ? 'expand' : 'expand';
}

public async isCompatible({ embeddable }: ActionContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ export abstract class Action<
constructor(public readonly id: string) {}

/**
* Optional icon that can be displayed along with the title.
* Optional EUI icon type that can be displayed along with the title.
*/
public getIcon(
context: ActionContext<TEmbeddable, TTriggerContext>
): EuiContextMenuItemIcon | undefined {
public getIconType(context: ActionContext<TEmbeddable, TTriggerContext>): string | undefined {
return undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
* under the License.
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiIcon } from '@elastic/eui';
import { Action, ActionContext } from './action';
import { GetEmbeddableFactory, ViewMode } from '../types';
import { EmbeddableFactoryNotFoundError } from '../errors';
Expand All @@ -46,8 +44,8 @@ export class EditPanelAction extends Action {
});
}

getIcon() {
return <EuiIcon type="pencil" />;
getIconType() {
return 'pencil';
}

public async isCompatible({ embeddable }: ActionContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function convertPanelActionToContextMenuItem({
}): EuiContextMenuPanelItemDescriptor {
const menuPanelItem: EuiContextMenuPanelItemDescriptor = {
name: action.getDisplayName(actionContext),
icon: action.getIcon(actionContext),
icon: action.getIconType(actionContext),
panel: _.get(action, 'childContextMenuPanel.id'),
'data-test-subj': `embeddablePanelAction-${action.id}`,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@ test('Returns title', async () => {
});

test('Returns an icon', async () => {
expect(action.getIcon()).toBeDefined();
expect(action.getIconType()).toBeDefined();
});
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class AddPanelAction extends Action {
});
}

public getIcon() {
return <EuiIcon type="plusInCircleFilled" />;
public getIconType() {
return 'plusInCircleFilled';
}

public async isCompatible({ embeddable }: ActionContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* under the License.
*/

import { EuiIcon } from '@elastic/eui';
import React from 'react';
import { i18n } from '@kbn/i18n';
import { Action, ActionContext } from '../../../../actions';
import { ViewMode } from '../../../../types';
Expand All @@ -41,8 +39,8 @@ export class CustomizePanelTitleAction extends Action {
});
}

public getIcon() {
return <EuiIcon type="pencil" />;
public getIconType() {
return 'pencil';
}

public async isCompatible({ embeddable }: ActionContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,5 @@ test('Returns title', async () => {
test('Returns an icon', async () => {
const inspector = inspectorPluginMock.createStartContract();
const inspectAction = new InspectPanelAction(inspector);
expect(inspectAction.getIcon()).toMatchInlineSnapshot(`
<EuiIcon
type="inspect"
/>
`);
expect(inspectAction.getIconType()).toBe('inspect');
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* under the License.
*/

import { EuiIcon } from '@elastic/eui';
import React from 'react';
import { i18n } from '@kbn/i18n';
import { Action, ActionContext } from '../../../actions';
import { Start as InspectorStartContract } from '../../../../../../../../../../plugins/inspector/public';
Expand All @@ -39,8 +37,8 @@ export class InspectPanelAction extends Action {
});
}

public getIcon() {
return <EuiIcon type="inspect" />;
public getIconType() {
return 'inspect';
}

public async isCompatible({ embeddable }: ActionContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ test('Returns title', async () => {
expect(action.getDisplayName()).toBeDefined();
});

test('Returns an icon', async () => {
test('Returns an icon type', async () => {
const action = new RemovePanelAction();
expect(action.getIcon()).toBeDefined();
expect(action.getIconType()).toBeDefined();
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiIcon } from '@elastic/eui';
import { ContainerInput, IContainer } from '../../../containers';
import { ViewMode } from '../../../types';
import { Action, ActionContext } from '../../../actions';
Expand Down Expand Up @@ -50,8 +48,8 @@ export class RemovePanelAction extends Action {
});
}

public getIcon() {
return <EuiIcon type="trash" />;
public getIconType() {
return 'trash';
}

public async isCompatible({ embeddable }: ActionContext) {
Expand Down