feat: Add folder view to view folder media (#2077)

- Closes: #2068

Note: Renames existing `folder` view to `folders` [experimental
functionality]
This commit is contained in:
Dermot Duffy
2025-05-31 17:13:39 -07:00
committed by GitHub
parent 1901475065
commit 956a2e523c
30 changed files with 246 additions and 132 deletions
@@ -105,7 +105,17 @@ describe('ActionsManager', () => {
{
tap_action: {
action: 'navigate',
// Folder also uses the media gallery.
// Folders also uses the media viewer.
navigation_path: '4',
},
},
],
[
'folders' as const,
{
tap_action: {
action: 'navigate',
// Folders also uses the media gallery.
navigation_path: '3',
},
},
@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from 'vitest';
import { FolderAction } from '../../../../src/card-controller/actions/actions/folder';
import { FoldersViewAction } from '../../../../src/card-controller/actions/actions/folders-view';
import { FolderQuery } from '../../../../src/card-controller/folders/types';
import { FolderViewQuery } from '../../../../src/view/query';
import { createCardAPI, createFolder } from '../../../test-utils';
@@ -7,7 +7,7 @@ import { createCardAPI, createFolder } from '../../../test-utils';
describe('should handle folder action', async () => {
it('should handle folder action successfully', async () => {
const api = createCardAPI();
const action = new FolderAction(
const action = new FoldersViewAction(
{},
{
action: 'fire-dom-event',
@@ -20,7 +20,7 @@ describe('should handle folder action', async () => {
const query: FolderQuery = {
folder,
path: ['path'],
path: [{ ha: { id: 'path' } }],
};
vi.mocked(api.getFoldersManager().generateDefaultFolderQuery).mockReturnValue(query);
@@ -44,7 +44,7 @@ describe('should handle folder action', async () => {
it('should do nothing with non-existent folder', async () => {
const api = createCardAPI();
const action = new FolderAction(
const action = new FoldersViewAction(
{},
{
action: 'fire-dom-event',
@@ -64,7 +64,7 @@ describe('should handle folder action', async () => {
it('should do nothing with non-existent default query', async () => {
const api = createCardAPI();
const action = new FolderAction(
const action = new FoldersViewAction(
{},
{
action: 'fire-dom-event',
@@ -7,7 +7,7 @@ import { DefaultAction } from '../../../src/card-controller/actions/actions/defa
import { DisplayModeSelectAction } from '../../../src/card-controller/actions/actions/display-mode-select';
import { DownloadAction } from '../../../src/card-controller/actions/actions/download';
import { ExpandAction } from '../../../src/card-controller/actions/actions/expand';
import { FolderAction } from '../../../src/card-controller/actions/actions/folder';
import { FoldersViewAction } from '../../../src/card-controller/actions/actions/folders-view';
import { FullscreenAction } from '../../../src/card-controller/actions/actions/fullscreen';
import { InternalCallbackAction } from '../../../src/card-controller/actions/actions/internal-callback';
import { LogAction } from '../../../src/card-controller/actions/actions/log';
@@ -185,7 +185,8 @@ describe('ActionFactory', () => {
},
InternalCallbackAction,
],
[{ advanced_camera_card_action: 'folder' as const }, FolderAction],
[{ advanced_camera_card_action: 'folder' as const }, FoldersViewAction],
[{ advanced_camera_card_action: 'folders' as const }, FoldersViewAction],
])(
'advanced_camera_card_action: $advanced_camera_card_action',
(action: Partial<ActionConfig>, classObject: object) => {