Skip to content

Commit

Permalink
fix(files): CustomElementRender $el replacement bug
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Sep 17, 2023
1 parent bf6bda5 commit 22c57f6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
9 changes: 3 additions & 6 deletions apps/files/src/components/CustomElementRender.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,11 @@ export default {
},
methods: {
async updateRootElement() {
const span = document.createElement('span') as HTMLSpanElement
this.$el.replaceWith(span)
this.$el = span
const element = await this.render(this.source, this.currentView)
if (element) {
this.$el.replaceWith(element)
this.$el = element
this.$el.replaceChildren(element)
} else {
this.$el.replaceChildren()
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
data-cy-files-list-row
:data-cy-files-list-row-fileid="fileid"
:data-cy-files-list-row-name="source.basename"
class="list__row"
class="files-list__row"
@contextmenu="onRightClick">
<!-- Failed indicator -->
<span v-if="source.attributes.failed" class="files-list__row--failed" />
Expand Down
5 changes: 4 additions & 1 deletion apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,12 @@ export default Vue.extend({
}
}
.files-list__row{
.files-list__row {
&:hover, &:focus, &:active, &--active {
background-color: var(--color-background-dark);
> * {
--color-border: var(--color-border-dark);
}
// Hover state of the row should also change the favorite markers background
.favorite-marker-icon svg path {
stroke: var(--color-background-dark);
Expand Down
20 changes: 19 additions & 1 deletion apps/systemtags/src/actions/inlineSystemTagsAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,26 @@ describe('Inline system tags action conditions tests', () => {
expect(action.displayName([file], view)).toBe('')
expect(action.iconSvgInline([], view)).toBe('')
expect(action.default).toBeUndefined()
expect(action.enabled).toBeUndefined()
expect(action.enabled).toBeDefined()
expect(action.order).toBe(0)
expect(action.enabled!([file], view)).toBe(false)
})

test('Enabled with valid system tags', () => {
const file = new File({
id: 1,
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
owner: 'admin',
mime: 'text/plain',
permissions: Permission.ALL,
attributes: {
'system-tags': {
'system-tag': 'Confidential',
},
},
})

expect(action.enabled!([file], view)).toBe(true)
})
})

Expand Down
18 changes: 18 additions & 0 deletions apps/systemtags/src/actions/inlineSystemTagsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ export const action = new FileAction({
id: 'system-tags',
displayName: () => '',
iconSvgInline: () => '',

enabled(nodes: Node[]) {
// Only show the action on single nodes
if (nodes.length !== 1) {
return false

Check warning on line 57 in apps/systemtags/src/actions/inlineSystemTagsAction.ts

View check run for this annotation

Codecov / codecov/patch

apps/systemtags/src/actions/inlineSystemTagsAction.ts#L57

Added line #L57 was not covered by tests
}

const node = nodes[0]
const tags = getNodeSystemTags(node)

// Only show the action if the node has system tags
if (tags.length === 0) {
return false
}

return true
},

exec: async () => null,

async renderInline(node: Node) {
Expand Down

0 comments on commit 22c57f6

Please sign in to comment.