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

fix: improve default contribution action icon #5236

Merged
merged 1 commit into from Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions packages/renderer/src/lib/actions/ContributionActions.spec.ts
Expand Up @@ -43,6 +43,41 @@ test('Expect one ListItemButtonIcon', async () => {
expect(item).toBeInTheDocument();
});

test('Expect one ListItemButtonIcon without detail', async () => {
render(ContributionActions, {
args: [],
contributions: [
{
command: 'dummy.command',
title: 'dummy-title',
},
],
onError: () => {},
dropdownMenu: false,
});
const item = screen.getByLabelText('dummy-title');
expect(item).toBeInTheDocument();
expect(item).toHaveClass('m-0.5');
});

test('Expect one ListItemButtonIcon with detail', async () => {
render(ContributionActions, {
args: [],
contributions: [
{
command: 'dummy.command',
title: 'dummy-title',
},
],
onError: () => {},
dropdownMenu: false,
detailed: true,
});
const item = screen.getByLabelText('dummy-title');
expect(item).toBeInTheDocument();
expect(item).not.toHaveClass('m-0.5');
});

test('Expect executeCommand to be called', async () => {
render(ContributionActions, {
args: [],
Expand Down
@@ -1,6 +1,6 @@
<script lang="ts">
import type { Menu } from '../../../../main/src/plugin/menu-registry';
import { faEllipsisVertical } from '@fortawesome/free-solid-svg-icons';
import { faPlug } from '@fortawesome/free-solid-svg-icons';
import ListItemButtonIcon from '../ui/ListItemButtonIcon.svelte';
import { removeNonSerializableProperties } from '/@/lib/actions/ActionUtils';
import type { ContextUI } from '/@/lib/context/context';
Expand All @@ -16,6 +16,7 @@ export let contextPrefix: string | undefined = undefined;

export let dropdownMenu = false;
export let contributions: Menu[] = [];
export let detailed = false;

let filteredContributions: Menu[] = [];
$: {
Expand Down Expand Up @@ -75,6 +76,7 @@ async function executeContribution(menu: Menu): Promise<void> {
title="{menu.title}"
onClick="{() => executeContribution(menu)}"
menu="{dropdownMenu}"
icon="{faEllipsisVertical}"
icon="{faPlug}"
detailed="{detailed}"
disabledWhen="{menu.disabled}" />
{/each}
1 change: 1 addition & 0 deletions packages/renderer/src/lib/compose/ComposeActions.svelte
Expand Up @@ -138,5 +138,6 @@ if (dropdownMenu) {
contextPrefix="composeItem"
dropdownMenu="{dropdownMenu}"
contributions="{contributions}"
detailed="{detailed}"
onError="{errorCallback}" />
</svelte:component>
Expand Up @@ -187,5 +187,6 @@ if (dropdownMenu) {
contextPrefix="containerItem"
dropdownMenu="{dropdownMenu}"
contributions="{contributions}"
detailed="{detailed}"
onError="{errorCallback}" />
</svelte:component>
1 change: 1 addition & 0 deletions packages/renderer/src/lib/image/ImageActions.svelte
Expand Up @@ -132,6 +132,7 @@ function onError(error: string): void {
dropdownMenu="{dropdownMenu}"
contributions="{contributions}"
contextPrefix="imageItem"
detailed="{detailed}"
onError="{onError}" />

{#if errorMessage}
Expand Down
1 change: 1 addition & 0 deletions packages/renderer/src/lib/pod/PodActions.svelte
Expand Up @@ -202,5 +202,6 @@ if (dropdownMenu) {
contextPrefix="podItem"
dropdownMenu="{dropdownMenu}"
contributions="{contributions}"
detailed="{detailed}"
onError="{errorCallback}" />
</svelte:component>