diff --git a/.vscode/settings.json b/.vscode/settings.json index 912798a491..4ab79b01a2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,7 +19,7 @@ "stylelint.packageManager": "yarn", "stylelint.snippet": ["css", "less", "postcss", "scss"], "stylelint.validate": ["css", "less", "postcss", "scss"], - "cSpell.words": ["mailenabledsecurity"], + "cSpell.words": ["mailenabledsecurity", "noreferrer"], "liveServer.settings.root": "storybook-static", "liveServer.settings.port": 6006 } diff --git a/.yarn/cache/@esbuild-linux-x64-npm-0.18.20-de8e99b449-10.zip b/.yarn/cache/@esbuild-linux-x64-npm-0.18.20-de8e99b449-10.zip deleted file mode 100644 index 67ac3efedd..0000000000 Binary files a/.yarn/cache/@esbuild-linux-x64-npm-0.18.20-de8e99b449-10.zip and /dev/null differ diff --git a/.yarn/cache/@esbuild-linux-x64-npm-0.19.12-59062fdb38-10.zip b/.yarn/cache/@esbuild-linux-x64-npm-0.19.12-59062fdb38-10.zip deleted file mode 100644 index 2f5ee528ff..0000000000 Binary files a/.yarn/cache/@esbuild-linux-x64-npm-0.19.12-59062fdb38-10.zip and /dev/null differ diff --git a/.yarn/cache/@esbuild-linux-x64-npm-0.21.5-88079726c4-10.zip b/.yarn/cache/@esbuild-linux-x64-npm-0.21.5-88079726c4-10.zip deleted file mode 100644 index 2a3a835a4e..0000000000 Binary files a/.yarn/cache/@esbuild-linux-x64-npm-0.21.5-88079726c4-10.zip and /dev/null differ diff --git a/.yarn/cache/@esbuild-win32-x64-npm-0.18.20-37a9ab2bda-10.zip b/.yarn/cache/@esbuild-win32-x64-npm-0.18.20-37a9ab2bda-10.zip new file mode 100644 index 0000000000..df11d939b0 Binary files /dev/null and b/.yarn/cache/@esbuild-win32-x64-npm-0.18.20-37a9ab2bda-10.zip differ diff --git a/.yarn/cache/@esbuild-win32-x64-npm-0.19.12-1bf4cb5f20-10.zip b/.yarn/cache/@esbuild-win32-x64-npm-0.19.12-1bf4cb5f20-10.zip new file mode 100644 index 0000000000..2216b6838a Binary files /dev/null and b/.yarn/cache/@esbuild-win32-x64-npm-0.19.12-1bf4cb5f20-10.zip differ diff --git a/.yarn/cache/@esbuild-win32-x64-npm-0.21.5-eddc2b5ad6-10.zip b/.yarn/cache/@esbuild-win32-x64-npm-0.21.5-eddc2b5ad6-10.zip new file mode 100644 index 0000000000..2c0cb74a7d Binary files /dev/null and b/.yarn/cache/@esbuild-win32-x64-npm-0.21.5-eddc2b5ad6-10.zip differ diff --git a/.yarn/cache/@nx-nx-linux-x64-gnu-npm-18.0.5-d5092c5ec5-10.zip b/.yarn/cache/@nx-nx-linux-x64-gnu-npm-18.0.5-d5092c5ec5-10.zip deleted file mode 100644 index 06702318c7..0000000000 Binary files a/.yarn/cache/@nx-nx-linux-x64-gnu-npm-18.0.5-d5092c5ec5-10.zip and /dev/null differ diff --git a/.yarn/cache/@nx-nx-win32-x64-msvc-npm-18.0.5-0017aa2a0f-10.zip b/.yarn/cache/@nx-nx-win32-x64-msvc-npm-18.0.5-0017aa2a0f-10.zip new file mode 100644 index 0000000000..eb89b87b39 Binary files /dev/null and b/.yarn/cache/@nx-nx-win32-x64-msvc-npm-18.0.5-0017aa2a0f-10.zip differ diff --git a/.yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.22.4-f57b34433d-10.zip b/.yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.22.4-f57b34433d-10.zip deleted file mode 100644 index 99bf72f8a8..0000000000 Binary files a/.yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.22.4-f57b34433d-10.zip and /dev/null differ diff --git a/.yarn/cache/@rollup-rollup-win32-x64-msvc-npm-4.22.4-f32030f087-10.zip b/.yarn/cache/@rollup-rollup-win32-x64-msvc-npm-4.22.4-f32030f087-10.zip new file mode 100644 index 0000000000..2894f42c8a Binary files /dev/null and b/.yarn/cache/@rollup-rollup-win32-x64-msvc-npm-4.22.4-f32030f087-10.zip differ diff --git a/.yarn/cache/@swc-core-linux-x64-gnu-npm-1.3.105-928407db1c-10.zip b/.yarn/cache/@swc-core-win32-x64-msvc-npm-1.3.105-ada1444d72-10.zip similarity index 62% rename from .yarn/cache/@swc-core-linux-x64-gnu-npm-1.3.105-928407db1c-10.zip rename to .yarn/cache/@swc-core-win32-x64-msvc-npm-1.3.105-ada1444d72-10.zip index 77df4f9e09..d3d89d3c8f 100644 Binary files a/.yarn/cache/@swc-core-linux-x64-gnu-npm-1.3.105-928407db1c-10.zip and b/.yarn/cache/@swc-core-win32-x64-msvc-npm-1.3.105-ada1444d72-10.zip differ diff --git a/packages/mgt-components/src/components/mgt-file-list/mgt-file-list.scss b/packages/mgt-components/src/components/mgt-file-list/mgt-file-list.scss index b899ef471d..058fd7c3b9 100644 --- a/packages/mgt-components/src/components/mgt-file-list/mgt-file-list.scss +++ b/packages/mgt-components/src/components/mgt-file-list/mgt-file-list.scss @@ -26,6 +26,10 @@ $show-more-button-border-bottom-left-radius: var( ); $progress-ring-size: var(--progress-ring-size, 24px); +@mixin nested-file-list($margin: 0) { + margin-inline-start: calc(#{$margin} * 2); +} + :host { font-size: $font-size; @@ -58,6 +62,25 @@ $progress-ring-size: var(--progress-ring-size, 24px); flex-direction: column; list-style: none; + .file-list-children { + &-show { + display: block; + @include nested-file-list(16px); + + ul { + list-style: none; + + li { + padding: 8px 0; + } + } + } + + &-hide { + display: none; + } + } + .file-item { cursor: pointer; border-radius: var(--file-border-radius); @@ -77,6 +100,10 @@ $progress-ring-size: var(--progress-ring-size, 24px); --file-border-radius: 2px; --file-background-color: var(--file-item-background-color, var(--neutral-layer-1)); } + + .file-list-children { + background-color: beige; + } } } diff --git a/packages/mgt-components/src/components/mgt-file-list/mgt-file-list.ts b/packages/mgt-components/src/components/mgt-file-list/mgt-file-list.ts index ba11d4aa33..5ac5c60742 100644 --- a/packages/mgt-components/src/components/mgt-file-list/mgt-file-list.ts +++ b/packages/mgt-components/src/components/mgt-file-list/mgt-file-list.ts @@ -11,7 +11,8 @@ import { ProviderState, mgtHtml, MgtTemplatedTaskComponent, - registerComponent + registerComponent, + customElementHelper } from '@microsoft/mgt-element'; import { DriveItem, SharedInsight } from '@microsoft/microsoft-graph-types'; import { html, TemplateResult } from 'lit'; @@ -516,6 +517,7 @@ export class MgtFileList extends MgtTemplatedTaskComponent implements CardSectio class="file-list" >
  • f.id, f => html`
  • this.handleItemSelect(f, e)}> @@ -587,7 +590,7 @@ export class MgtFileList extends MgtTemplatedTaskComponent implements CardSectio : null; return html` -
    this.handleFileClick(file, e)} tabindex="0"> +
    this.handleSharedInsightClick(file, e)} tabindex="0">
    ${file.resourceVisualization.title} { - const fileList = this.renderRoot.querySelector('.file-list'); + const target = event.target as HTMLElement; + let fileList: HTMLElement; + if (!target.classList) { + fileList = this.renderRoot.querySelector('.file-list-children'); + } else { + fileList = this.renderRoot.querySelector('.file-list'); + } let focusedItem: HTMLElement; if (!fileList?.children.length) { @@ -822,6 +831,18 @@ export class MgtFileList extends MgtTemplatedTaskComponent implements CardSectio this.files = files; } } + for (const file of this.files) { + if (file?.folder?.childCount > 0) { + // expand the file with children + const driveId = file?.parentReference?.driveId; + const itemId = file?.id; + const iterator = await getDriveFilesByIdIterator(graph, driveId, itemId, 5); + if (iterator) { + const children = [...iterator.value]; + file.children = children; + } + } + } } /** @@ -894,15 +915,52 @@ export class MgtFileList extends MgtTemplatedTaskComponent implements CardSectio this.requestUpdate(); } - private readonly handleFileClick = (file: DriveItem | SharedInsight, e?: MouseEvent) => { - if (e && isSharedInsight(file) && file.resourceReference?.webUrl && !this.disableOpenOnClick) { + private readonly handleSharedInsightClick = (file: SharedInsight, e?: MouseEvent) => { + if (file.resourceReference?.webUrl && !this.disableOpenOnClick) { e.preventDefault(); window.open(file.resourceReference.webUrl, '_blank', 'noreferrer'); - } else if (!isSharedInsight(file) && file?.webUrl && !this.disableOpenOnClick) { + } + }; + + private readonly handleFileClick = (file: DriveItem) => { + const hasChildFolders = file?.folder?.childCount > 0 && file?.children; + // the item has child folders, on click should get the child folders and render them + if (hasChildFolders) { + this.showChildren(file.id); + return; + } + + if (file?.webUrl && !this.disableOpenOnClick) { window.open(file.webUrl, '_blank', 'noreferrer'); } }; + private readonly showChildren = (fileId: string) => { + const itemDOM = this.renderRoot.querySelector(`#file-list-item-${fileId}`); + this.renderChildren(fileId, itemDOM); + }; + + private readonly renderChildren = (itemId: string, itemDOM: Element) => { + const fileListName = customElementHelper.isDisambiguated + ? `${customElementHelper.prefix}-file-list` + : 'mgt-file-list'; + const childrenContainer = this.renderRoot.querySelector(`#file-list-children-${itemId}`); + if (!childrenContainer) { + const fl = document.createElement(fileListName); + fl.setAttribute('item-id', itemId); + fl.setAttribute('id', `file-list-children-${itemId}`); + fl.setAttribute('class', 'file-list-children-show'); + itemDOM.after(fl); + } else { + // toggle to show/hide the children container + if (childrenContainer.classList.contains('file-list-children-hide')) { + childrenContainer.setAttribute('class', 'file-list-children-show'); + } else { + childrenContainer.setAttribute('class', 'file-list-children-hide'); + } + } + }; + /** * Get file extension string from file name * diff --git a/packages/mgt-element/src/utils/version.ts b/packages/mgt-element/src/utils/version.ts index a44b7a71fa..9600038d9c 100644 --- a/packages/mgt-element/src/utils/version.ts +++ b/packages/mgt-element/src/utils/version.ts @@ -8,4 +8,4 @@ // THIS FILE IS AUTO GENERATED // ANY CHANGES WILL BE LOST DURING BUILD -export const PACKAGE_VERSION = '4.2.4'; +export const PACKAGE_VERSION = '4.3.0'; diff --git a/stories/components/fileList/fileList.html.stories.js b/stories/components/fileList/fileList.html.stories.js index d73a19d1ff..5e0e250160 100644 --- a/stories/components/fileList/fileList.html.stories.js +++ b/stories/components/fileList/fileList.html.stories.js @@ -102,60 +102,38 @@ export const openFolderBreadcrumbs = () => html` - + `;