-
Notifications
You must be signed in to change notification settings - Fork 25
feat: Enhance browse UI by adding extra columns #368
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
140484b
feat: Add basic breadcrumb.
9213bb5
feat: Add breadcrumb to browse panel.
35b4bf9
fix: Update breadcrumb separator.
e912ecd
fix: Remove unused icon.
75b8fe4
fix: Apply latest UX, and improve the implementation.
bfd9dff
Merge branch 'ew' into ew-breadcrumb
e40fb94
fix: Move breadcrumb under shared and fix.
c40e388
Merge branch 'ew' into ew-breadcrumb
02935db
fix: Fix code style.
4bab866
fix: Sticky browse panel header.
e9eab59
feat: Add browse columns.
dd2ffa6
fix: Make the borwse panel use the full height.
db05c2e
Merges ew and resolve conflicts.
1bcfcd3
fix: Add action to copy the preview & publish url.
bcad37c
fix: Handle open document and sheet.
e9041a2
fix: Fix code style.
10936d4
fix: Document styling local override.
79b94b1
fix: Add utility method to parse the path.
910e1e0
fix: Open sheet with the default nx verison.
37aa513
fix: Remove additional columns.
be1f786
fix: Simplify style overrides.
883e44c
fix: Fix column spacing.
5fc20f3
fix: Fix header font weight.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,22 @@ | ||
| import { LitElement, html, nothing } from 'da-lit'; | ||
| import { loadStyle, hashChange } from '../../utils/utils.js'; | ||
| import { listFolder } from './browse-api.js'; | ||
| import { contextToPathContext } from './utils.js'; | ||
| import { | ||
| contextToPathContext, | ||
| entryTypeFromExtension, | ||
| isFolder, | ||
| RESOURCE_TYPE, | ||
| } from './utils.js'; | ||
| import '../shared/breadcrumb/breadcrumb.js'; | ||
| import './list/list.js'; | ||
|
|
||
| const styles = await loadStyle(import.meta.url); | ||
|
|
||
| const documentLayoutStyles = await loadStyle( | ||
| new URL('overrides.css', import.meta.url).href, | ||
| ); | ||
| document.adoptedStyleSheets = [...document.adoptedStyleSheets, documentLayoutStyles]; | ||
|
|
||
| class NxBrowse extends LitElement { | ||
| static properties = { | ||
| _items: { state: true }, | ||
|
|
@@ -25,7 +35,6 @@ class NxBrowse extends LitElement { | |
| connectedCallback() { | ||
| super.connectedCallback(); | ||
| this.shadowRoot.adoptedStyleSheets = [styles]; | ||
| document.body.style.overflow = 'hidden'; | ||
| this._unsubscribeHash = hashChange.subscribe((hashState) => { | ||
| if (!this._explicitContext) { | ||
| this._context = hashState; | ||
|
|
@@ -39,7 +48,6 @@ class NxBrowse extends LitElement { | |
|
|
||
| disconnectedCallback() { | ||
| this._unsubscribeHash?.(); | ||
| document.body.style.overflow = ''; | ||
| super.disconnectedCallback(); | ||
| } | ||
|
|
||
|
|
@@ -56,23 +64,40 @@ class NxBrowse extends LitElement { | |
| return; | ||
| } | ||
|
|
||
| const result = await listFolder(ctx.fullpath); | ||
| const { fullpath } = ctx; | ||
|
|
||
| const result = await listFolder(fullpath); | ||
|
|
||
| if ('error' in result) { | ||
| this._items = undefined; | ||
| this._listError = result.error; | ||
| } else { | ||
| this._listError = undefined; | ||
| this._items = result.items; | ||
| this._items = result; | ||
| } | ||
| this.requestUpdate(); | ||
| } | ||
|
|
||
| _onBrowseOpenFolder(event) { | ||
| const { pathKey } = event.detail; | ||
| if (!pathKey) { | ||
| _onBrowseActivate(event) { | ||
| const { pathKey, item } = event.detail || {}; | ||
| if (entryTypeFromExtension(item.ext) === RESOURCE_TYPE.document) { | ||
| const url = new URL(window.location.href); | ||
| url.pathname = '/canvas'; | ||
| url.hash = `#/${item.path.slice(1, -(item.ext.length + 1))}`; | ||
| window.location.assign(url.href); | ||
| return; | ||
| } | ||
| window.location.hash = `#/${pathKey}`; | ||
| if (entryTypeFromExtension(item.ext) === RESOURCE_TYPE.sheet) { | ||
| const url = new URL(window.location.href); | ||
| url.pathname = '/sheet'; | ||
| url.search = ''; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sheet is opened in the sheet editor using the default da-nx version. |
||
| url.hash = `#/${item.path.slice(1, -(item.ext.length + 1))}`; | ||
| window.open(url.href, '_blank', 'noopener,noreferrer'); | ||
| return; | ||
| } | ||
| if (item && isFolder(item)) { | ||
| window.location.hash = `#/${pathKey}`; | ||
| } | ||
| } | ||
|
|
||
| render() { | ||
|
|
@@ -121,7 +146,7 @@ class NxBrowse extends LitElement { | |
| <nx-browse-list | ||
| .items=${this._items} | ||
| .currentPathKey=${currentPathKey} | ||
| @nx-browse-open-folder=${this._onBrowseOpenFolder} | ||
| @nx-browse-activate=${this._onBrowseActivate} | ||
| ></nx-browse-list> | ||
| `; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| const TIME_FORMAT_OPTIONS = { hour: 'numeric', minute: '2-digit' }; | ||
|
|
||
| function parseTimestamp(timestampRaw) { | ||
| if (timestampRaw == null || timestampRaw === '') return null; | ||
| const parsedDate = new Date(timestampRaw); | ||
| return Number.isNaN(parsedDate.getTime()) ? null : parsedDate; | ||
| } | ||
|
|
||
| function formatAbsolute(dateInstant, referenceNow = new Date()) { | ||
| const timeSegment = dateInstant.toLocaleTimeString(undefined, TIME_FORMAT_OPTIONS); | ||
| if (dateInstant.getFullYear() === referenceNow.getFullYear()) { | ||
| const dateSegment = dateInstant.toLocaleDateString(undefined, { | ||
| month: 'short', | ||
| day: 'numeric', | ||
| }); | ||
| return `${dateSegment}, ${timeSegment}`; | ||
| } | ||
| const dateSegment = dateInstant.toLocaleDateString(undefined, { | ||
| year: 'numeric', | ||
| month: 'short', | ||
| day: 'numeric', | ||
| }); | ||
| return `${dateSegment}, ${timeSegment}`; | ||
| } | ||
|
|
||
| function formatRelative(dateInstant, referenceNow = new Date()) { | ||
| const elapsedMilliseconds = referenceNow - dateInstant; | ||
| const relativeTimeFormatter = new Intl.RelativeTimeFormat(undefined, { numeric: 'auto' }); | ||
| const eventCalendarDay = dateInstant.toDateString(); | ||
| const referenceCalendarDay = referenceNow.toDateString(); | ||
|
|
||
| let displayLabel; | ||
| if (eventCalendarDay === referenceCalendarDay) { | ||
| const elapsedSeconds = Math.floor(elapsedMilliseconds / 1000); | ||
| if (elapsedSeconds < 60) displayLabel = relativeTimeFormatter.format(0, 'second'); | ||
| else { | ||
| const elapsedMinutes = Math.floor(elapsedSeconds / 60); | ||
| if (elapsedMinutes < 60) displayLabel = relativeTimeFormatter.format(-elapsedMinutes, 'minute'); | ||
| else { | ||
| const elapsedHours = Math.floor(elapsedMinutes / 60); | ||
| displayLabel = relativeTimeFormatter.format(-elapsedHours, 'hour'); | ||
| } | ||
| } | ||
| } else { | ||
| const referenceYesterday = new Date(referenceNow); | ||
| referenceYesterday.setDate(referenceYesterday.getDate() - 1); | ||
| if (eventCalendarDay === referenceYesterday.toDateString()) { | ||
| const relativeDayPhrase = relativeTimeFormatter.format(-1, 'day'); | ||
| const timeSegment = dateInstant.toLocaleTimeString(undefined, TIME_FORMAT_OPTIONS); | ||
| displayLabel = `${relativeDayPhrase}, ${timeSegment}`; | ||
| } else { | ||
| displayLabel = formatAbsolute(dateInstant, referenceNow); | ||
| } | ||
| } | ||
|
|
||
| return displayLabel; | ||
| } | ||
|
|
||
| export function formatColumnLastModified(lastModified) { | ||
| const lastModifiedDate = parseTimestamp(lastModified); | ||
| if (!lastModifiedDate) return { label: null }; | ||
| return { | ||
| label: formatRelative(lastModifiedDate), | ||
| title: `Last modified on ${formatAbsolute(lastModifiedDate)}`, | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.