Skip to content

TagSpaces is an offline, open source, document manager with tagging support

remove action prefix from SearchAutocomplete

sytolkbaec19d645ba
diff --git a/src/renderer/components/SearchAutocomplete.tsx b/src/renderer/components/SearchAutocomplete.tsx
index 5e518c217..127e264e5 100644
--- a/src/renderer/components/SearchAutocomplete.tsx
+++ b/src/renderer/components/SearchAutocomplete.tsx
@@ -63,7 +63,7 @@ import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
-import { CommonLocation } from '-/utils/CommonLocation';
+import { removePrefix } from '-/services/utils-io';
interface Props {
style?: any;
@@ -95,16 +95,11 @@ function SearchAutocomplete(props: Props) {
searchQuery,
setSearchQuery,
} = useDirectoryContentContext();
- const {
- // watchForChanges,
- isIndexing,
- searchAllLocations,
- searchLocationIndex,
- } = useLocationIndexContext();
+ const { isIndexing, searchAllLocations, searchLocationIndex } =
+ useLocationIndexContext();
const dispatch: AppDispatch = useDispatch();
const maxSearchResults = useSelector(getMaxSearchResults);
const showUnixHiddenEntries = useSelector(getShowUnixHiddenEntries);
- //const locations: CommonLocation[] = useSelector(getLocations);
const searches: Array<TS.SearchQuery> = useSelector(getSearches);
const openLinkDispatch = (link, options) => openLink(link, options);
@@ -1322,27 +1317,29 @@ function SearchAutocomplete(props: Props) {
{option}
</Box>
) : (
- <Button
- onClick={() => {
- changeOptions(action.action, false);
- }}
- data-tid={dataTidFormat('menu' + option)}
- size="small"
- style={{
- backgroundColor: 'transparent',
- textTransform: 'lowercase',
- padding: 0,
- margin: 0,
- }}
- endIcon={
- <ArrowDropDownIcon
- style={{ marginLeft: -10 }}
- fontSize="small"
- />
- }
- >
- {option}
- </Button>
+ <Tooltip title={option}>
+ <Button
+ onClick={() => {
+ changeOptions(action.action, false);
+ }}
+ data-tid={dataTidFormat('menu' + option)}
+ size="small"
+ style={{
+ backgroundColor: 'transparent',
+ textTransform: 'lowercase',
+ padding: 0,
+ margin: 0,
+ }}
+ endIcon={
+ <ArrowDropDownIcon
+ style={{ marginLeft: -10 }}
+ fontSize="small"
+ />
+ }
+ >
+ {removePrefix(option, action.action)}
+ </Button>
+ </Tooltip>
)}
{!isAction(action.action, SearchQueryComposition.SCOPE) &&
diff --git a/src/renderer/services/utils-io.ts b/src/renderer/services/utils-io.ts
index 0eff1282d..67f2427f7 100644
--- a/src/renderer/services/utils-io.ts
+++ b/src/renderer/services/utils-io.ts
@@ -1055,3 +1055,10 @@ export function selectDirectoryDialog(): Promise<any> {
}
return Promise.reject(new Error('selectDirectoryDialog: not implemented'));
}
+
+export function removePrefix(str, prefix) {
+ if (str.startsWith(prefix)) {
+ return str.slice(prefix.length);
+ }
+ return str.trim();
+}