Skip to content

A self-hosted media server and file management system

fix: code smells

aminnausin35744ceb5222
diff --git a/resources/css/cedar-base.css b/resources/css/cedar-base.css
index c4d98bd5..1189cc9a 100644
--- a/resources/css/cedar-base.css
+++ b/resources/css/cedar-base.css
@@ -59,12 +59,14 @@
}
.scrollbar-thin {
- /* --width-scrollbar: thin; */
+ --width-scrollbar: thin;
scrollbar-width: var(--width-scrollbar);
}
}
-/* @layer base {
+/*
+Default Cedar-UI Scrollbar code interferes with what I have here
+@layer base {
::-webkit-scrollbar {
width: var(--scrollbar-width);
}
diff --git a/resources/js/App.vue b/resources/js/App.vue
index 70e4a21e..7bcc84f6 100755
--- a/resources/js/App.vue
+++ b/resources/js/App.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { ToastPostion } from '@aminnausin/cedar-ui';
-import { onMounted, onUnmounted, ref, watch } from 'vue';
+import { onMounted, onUnmounted, ref } from 'vue';
import { DrawerController } from './components/cedar-ui/drawer';
import { ToastController } from '@/components/cedar-ui/toast';
import { useFullscreen } from '@/composables/useFullscreen';
diff --git a/resources/js/components/cedar-ui/hover-card/HoverCard.vue b/resources/js/components/cedar-ui/hover-card/HoverCard.vue
index c00bfabc..de469320 100644
--- a/resources/js/components/cedar-ui/hover-card/HoverCard.vue
+++ b/resources/js/components/cedar-ui/hover-card/HoverCard.vue
@@ -78,7 +78,7 @@ watch(
<template>
<div @mouseover="hoverCardEnter" @mouseleave="hoverCardLeave">
<slot name="trigger">
- <a href="#_" class="hover:underline"></a>
+ <a href="#_" class="hover:underline">Trigger</a>
</slot>
<Teleport to="body" v-if="init">
<Transition enter-from-class="opacity-0" enter-to-class="opacity-100" leave-from-class="opacity-100" leave-to-class="opacity-0">
diff --git a/resources/js/components/cedar-ui/multi-select/InputMultiChip.vue b/resources/js/components/cedar-ui/multi-select/InputMultiChip.vue
index 7f7038e5..7fcf47b3 100644
--- a/resources/js/components/cedar-ui/multi-select/InputMultiChip.vue
+++ b/resources/js/components/cedar-ui/multi-select/InputMultiChip.vue
@@ -25,12 +25,15 @@ const select = useMultiSelect(props, { selectableItemsList, selectButton });
const newValue = ref('');
const lastActiveItemId = ref(-1);
+const search = computed(() => newValue.value.trim().toLocaleLowerCase());
+
+const selectedNames = computed(() => new Set((select.selectedItems ?? []).map((item: MultiSelectItem) => item.name)));
+
const filteredItemsList = computed(() => {
- return (
- select.selectableItems.filter((selectable: MultiSelectItem) => {
- return !select.selectedItems?.find((selected: MultiSelectItem) => selectable.name === selected.name) && selectable.name?.includes(newValue.value.toLocaleLowerCase());
- }) ?? []
- );
+ return select.selectableItems.filter((selectable: MultiSelectItem) => {
+ const name = selectable.name?.toLocaleLowerCase() ?? '';
+ return !selectedNames.value.has(selectable.name) && name.includes(search.value);
+ });
});
const handleItemClick = (item: any, setFocus = true, triggerSelect = true) => {
@@ -76,26 +79,25 @@ const handleCreate = (e: Event) => {
e.preventDefault();
e.stopPropagation();
- const parsedValue = newValue.value?.toLocaleLowerCase().trim();
- if (!parsedValue) return;
+ if (!search.value) return;
- if (select.selectableItemActive && (select.selectableItemActive as unknown as MultiSelectItem).name === parsedValue) {
- handleItemClick(select.selectableItemActive);
+ if (selectedNames.value.has(search.value)) {
+ toast.info('This tag was already added');
return;
}
- if (select.selectedItems.some((item: MultiSelectItem) => item.name === parsedValue)) {
- toast.info('This tag was already added');
+ if (select.selectableItemActive && (select.selectableItemActive as unknown as MultiSelectItem).name === search.value) {
+ handleItemClick(select.selectableItemActive);
return;
}
- const selectableFound = select.selectableItems.find((item: MultiSelectItem) => item.name === parsedValue);
+ const selectableFound = select.selectableItems.find((item: MultiSelectItem) => item.name === search.value);
if (selectableFound) {
handleItemClick(selectableFound);
return;
}
- emit('createAction', parsedValue);
+ emit('createAction', search.value);
newValue.value = '';
select.toggleSelect(false);
@@ -128,7 +130,7 @@ onMounted(() => {
// haha this is inefficient
select.selectedItems = [];
props.options.forEach((element) => {
- if (props.defaultItems.find((item) => item.name === element.name)) {
+ if (props.defaultItems.some((item) => item.name === element.name)) {
handleItemClick(element, false);
}
});
diff --git a/sonar-project.properties b/sonar-project.properties
index 6b4390bd..09b5ed60 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -1,4 +1,4 @@
-sonar.exclusions=resources/js/components/pulse/**,resources/js/components/icons/**,resources/js/components/pulseCards/**
+sonar.exclusions=resources/js/components/pulse/**,resources/js/components/icons/**,resources/js/components/pulseCards/**,resources/js/components-archive/**
sonar.issue.ignore.multicriteria=e1
sonar.issue.ignore.multicriteria.e1.ruleKey=typescript:S2686