refactoring: update severals components

This commit is contained in:
Simon Vieille
2025-04-04 20:13:15 +02:00
parent 4f261c434d
commit d8a622ce0f
37 changed files with 1857 additions and 1782 deletions
+15
View File
@@ -0,0 +1,15 @@
import { loadState } from '@nextcloud/initial-state'
const getActiveAppId = () => {
const apps = loadState('core', 'apps', {})
for (let id in apps) {
if (apps[id].active) {
return id
}
}
return null
}
export { getActiveAppId }
+15 -1
View File
@@ -1,4 +1,16 @@
module.exports = (tagName, attributes) => {
const waitContainer = async (selector) => {
new Promise((resolve) => {
setTimeout(() => {
const container = document.querySelector(selector)
if (container) {
resolve(selector, container)
}
}, 50)
})
}
const createElement = (tagName, attributes) => {
const element = document.createElement(tagName)
if (typeof attributes === 'object') {
@@ -15,3 +27,5 @@ module.exports = (tagName, attributes) => {
return element
}
export { waitContainer, createElement }
+26
View File
@@ -0,0 +1,26 @@
const containsAppsMatchingSearch = (values, search) => {
if (search.value.trim() === '') {
return true
}
for (let key in values) {
if (isAppMatchingSearch(values[key].name)) {
return true
}
}
return false
}
const isAppMatchingSearch = (item, search) => {
if (search.value.trim() === '') {
return true
}
return item.name.toLowerCase().includes(search.value.trim().toLowerCase())
}
export {
containsAppsMatchingSearch,
isAppMatchingSearch,
}