Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Azevedo <lhs_azevedo@hotmail.com>
  • Loading branch information
lhsazevedo authored and skjnldsv committed Sep 13, 2023
1 parent a2d7a70 commit f586521
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
44 changes: 22 additions & 22 deletions apps/systemtags/src/actions/inlineSystemTagsAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ describe('Inline system tags action render tests', () => {
permissions: Permission.ALL,
attributes: {
'system-tags': {
'system-tag': 'Confidential'
}
}
'system-tag': 'Confidential',
},
},
})

const result = await action.renderInline!(file, view)
expect(result).toBeInstanceOf(HTMLElement)
expect(result!.outerHTML).toBe(
'<ul class="files-list__system-tags" aria-label="This file has the tag Confidential">' +
'<li class="files-list__system-tag">Confidential</li>' +
'</ul>'
'<ul class="files-list__system-tags" aria-label="This file has the tag Confidential">'
+ '<li class="files-list__system-tag">Confidential</li>'
+ '</ul>',
)
})

Expand All @@ -96,19 +96,19 @@ describe('Inline system tags action render tests', () => {
'system-tags': {
'system-tag': [
'Important',
'Confidential'
]
}
}
'Confidential',
],
},
},
})

const result = await action.renderInline!(file, view)
expect(result).toBeInstanceOf(HTMLElement)
expect(result!.outerHTML).toBe(
'<ul class="files-list__system-tags" aria-label="This file has the tags Important and Confidential">' +
'<li class="files-list__system-tag">Important</li>' +
'<li class="files-list__system-tag files-list__system-tag--more" title="Confidential">+1</li>' +
'</ul>'
'<ul class="files-list__system-tags" aria-label="This file has the tags Important and Confidential">'
+ '<li class="files-list__system-tag">Important</li>'
+ '<li class="files-list__system-tag files-list__system-tag--more" title="Confidential">+1</li>'
+ '</ul>',
)
})

Expand All @@ -125,19 +125,19 @@ describe('Inline system tags action render tests', () => {
'Important',
'Confidential',
'Secret',
'Classified'
]
}
}
'Classified',
],
},
},
})

const result = await action.renderInline!(file, view)
expect(result).toBeInstanceOf(HTMLElement)
expect(result!.outerHTML).toBe(
'<ul class="files-list__system-tags" aria-label="This file has the tags Important, Confidential, Secret and Classified">' +
'<li class="files-list__system-tag">Important</li>' +
'<li class="files-list__system-tag files-list__system-tag--more" title="Confidential, Secret, Classified">+3</li>' +
'</ul>'
'<ul class="files-list__system-tags" aria-label="This file has the tags Important, Confidential, Secret and Classified">'
+ '<li class="files-list__system-tag">Important</li>'
+ '<li class="files-list__system-tag files-list__system-tag--more" title="Confidential, Secret, Classified">+3</li>'
+ '</ul>',
)
})
})
24 changes: 12 additions & 12 deletions apps/systemtags/src/actions/inlineSystemTagsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { FileAction, Node, registerDavProperty, registerFileAction } from "@nextcloud/files";
import { FileAction, Node, registerDavProperty, registerFileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'

import '../css/fileEntryInlineSystemTags.scss'

const getNodeSystemTags = function (node: Node): string[] {
const getNodeSystemTags = function(node: Node): string[] {
const tags = node.attributes?.['system-tags']?.['system-tag'] as string|string[]|undefined

if (tags === undefined) {
Expand All @@ -34,7 +34,7 @@ const getNodeSystemTags = function (node: Node): string[] {
return [tags].flat()
}

const renderTag = function (tag: string, isMore: boolean = false): HTMLElement {
const renderTag = function(tag: string, isMore = false): HTMLElement {
const tagElement = document.createElement('li')
tagElement.classList.add('files-list__system-tag')
tagElement.textContent = tag
Expand All @@ -43,7 +43,7 @@ const renderTag = function (tag: string, isMore: boolean = false): HTMLElement {
tagElement.classList.add('files-list__system-tag--more')
}

return tagElement;
return tagElement
}

export const action = new FileAction({
Expand All @@ -64,26 +64,26 @@ export const action = new FileAction({
systemTagsElement.classList.add('files-list__system-tags')

if (tags.length === 1) {
systemTagsElement.setAttribute('aria-label', t('files', 'This file has the tag {tag}', { tag: tags[0] }));
systemTagsElement.setAttribute('aria-label', t('files', 'This file has the tag {tag}', { tag: tags[0] }))
} else {
var firstTags = tags.slice(0, -1).join(', ');
var lastTag = tags[tags.length - 1];
systemTagsElement.setAttribute('aria-label', t('files', 'This file has the tags {firstTags} and {lastTag}', { firstTags, lastTag }));
const firstTags = tags.slice(0, -1).join(', ')
const lastTag = tags[tags.length - 1]
systemTagsElement.setAttribute('aria-label', t('files', 'This file has the tags {firstTags} and {lastTag}', { firstTags, lastTag }))
}

systemTagsElement.append(renderTag(tags[0]))

// More tags than the one we're showing
if (tags.length > 1) {
const moreTagElement = renderTag('+' + (tags.length - 1), true)
moreTagElement.setAttribute('title', tags.slice(1).join(', '));
systemTagsElement.append(moreTagElement);
moreTagElement.setAttribute('title', tags.slice(1).join(', '))
systemTagsElement.append(moreTagElement)
}

return systemTagsElement
},

order: 0
order: 0,
})

registerDavProperty('nc:system-tags')
Expand Down
2 changes: 1 addition & 1 deletion apps/systemtags/src/systemtags.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
import './app.js'
import './systemtagsfilelist.js'
import './css/systemtagsfilelist.scss'
import './actions/inlineSystemTagsAction'
import './actions/inlineSystemTagsAction.ts'

window.OCA.SystemTags = OCA.SystemTags

0 comments on commit f586521

Please sign in to comment.