Skip to content

Commit

Permalink
Change search location filter names (#9629)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Aug 30, 2023
1 parent 4be3df6 commit d4d3a5a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,13 @@ export const useFileActionsMove = ({ store }: { store?: Store<any> } = {}) => {
!isLocationPublicActive(router, 'files-public-link') &&
!isLocationCommonActive(router, 'files-common-favorites')
) {
console.log('A')
return false
}
if (resources.length === 0) {
console.log('B')
return false
}

if (!store.getters['Files/currentFolder']) {
console.log('C')
return false
}

Expand Down
6 changes: 3 additions & 3 deletions packages/web-app-search/src/portals/SearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default defineComponent({
const isMobileWidth = inject<Ref<boolean>>('isMobileWidth')
const scopeQueryValue = useRouteQuery('scope')
const shareId = useRouteQuery('shareId')
const locationFilterId = ref(SearchLocationFilterConstants.currentFolder)
const locationFilterId = ref(SearchLocationFilterConstants.inHere)
const optionsDropRef = ref(null)
const activePreviewIndex = ref(null)
const term = ref('')
Expand Down Expand Up @@ -184,7 +184,7 @@ export default defineComponent({
let searchTerm = unref(term)
if (
unref(currentFolderAvailable) &&
unref(locationFilterId) === SearchLocationFilterConstants.currentFolder
unref(locationFilterId) === SearchLocationFilterConstants.inHere
) {
const currentFolder = store.getters['Files/currentFolder']
let scope
Expand Down Expand Up @@ -224,7 +224,7 @@ export default defineComponent({
const useScope =
unref(term) &&
unref(currentFolderAvailable) &&
unref(locationFilterId) === SearchLocationFilterConstants.currentFolder
unref(locationFilterId) === SearchLocationFilterConstants.inHere
router.push(
createLocationCommon('files-common-search', {
query: {
Expand Down
16 changes: 8 additions & 8 deletions packages/web-pkg/src/components/SearchBarFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ export default defineComponent({
const currentSelectionTitle = computed(() => $gettext(currentSelection.value?.title))
const locationOptions = computed<LocationOption[]>(() => [
{
id: SearchLocationFilterConstants.currentFolder,
title: $gettext('Current Folder'),
id: SearchLocationFilterConstants.inHere,
title: $gettext('In here'),
enabled: props.currentFolderAvailable
},
{
id: SearchLocationFilterConstants.allFiles,
title: $gettext('All Files'),
id: SearchLocationFilterConstants.everywhere,
title: $gettext('Everywhere'),
enabled: true
}
])
Expand All @@ -84,19 +84,19 @@ export default defineComponent({
const useScope = unref(useSopeQueryValue).toString() === 'true'
if (useScope) {
currentSelection.value = unref(locationOptions).find(
({ id }) => id === SearchLocationFilterConstants.currentFolder
({ id }) => id === SearchLocationFilterConstants.inHere
)
return
}
currentSelection.value = unref(locationOptions).find(
({ id }) => id === SearchLocationFilterConstants.allFiles
({ id }) => id === SearchLocationFilterConstants.everywhere
)
return
}
if (!props.currentFolderAvailable) {
currentSelection.value = unref(locationOptions).find(
({ id }) => id === SearchLocationFilterConstants.allFiles
({ id }) => id === SearchLocationFilterConstants.everywhere
)
return
}
Expand All @@ -109,7 +109,7 @@ export default defineComponent({
}
currentSelection.value = unref(locationOptions).find(
({ id }) => id === SearchLocationFilterConstants.currentFolder
({ id }) => id === SearchLocationFilterConstants.everywhere
)
},
{ immediate: true }
Expand Down
6 changes: 3 additions & 3 deletions packages/web-pkg/src/composables/search/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export abstract class SearchLocationFilterConstants {
static readonly defaultModeName: string = 'current-folder'
static readonly allFiles: string = 'all-files'
static readonly currentFolder: string = 'current-folder'
static readonly defaultModeName: string = 'everywhere'
static readonly everywhere: string = 'everywhere'
static readonly inHere: string = 'in-here'
}
16 changes: 8 additions & 8 deletions packages/web-pkg/tests/unit/components/SearchBarFilter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ const selectors = {
}

describe('SearchBarFilter', () => {
it('shows "All Files" as current option if no current folder available', () => {
const { wrapper } = getWrapper()
it('shows "Everywhere" as default option', () => {
const { wrapper } = getWrapper({ currentFolderAvailable: true })
const filterLabel = wrapper.findComponent<any>(selectors.filterChipStub).props('filterLabel')
expect(filterLabel).toBe('All Files')
expect(filterLabel).toBe('Everywhere')
})
it('shows "Current Folder" as current option if current folder available', () => {
const { wrapper } = getWrapper({ currentFolderAvailable: true })
it('shows "Everywhere" as current option if no In here available', () => {
const { wrapper } = getWrapper()
const filterLabel = wrapper.findComponent<any>(selectors.filterChipStub).props('filterLabel')
expect(filterLabel).toBe('Current Folder')
expect(filterLabel).toBe('Everywhere')
})
it('shows "Current Folder" as current option if given via scipe', () => {
it('shows "In here" as current option if given via scope', () => {
const { wrapper } = getWrapper({ useScope: 'true' })
const filterLabel = wrapper.findComponent<any>(selectors.filterChipStub).props('filterLabel')
expect(filterLabel).toBe('Current Folder')
expect(filterLabel).toBe('In here')
})
})

Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/cucumber/features/smoke/fullTextSearch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Feature: Search
| fileWithTag.txt | tag 1 |
| withTag.txt | tag 1 |

When "Brian" searches "" using the global search and the "all files" filter and presses enter
When "Brian" searches "" using the global search and the "everywhere" filter and presses enter
Then "Brian" should see the message "Search for files" on the webUI

When "Brian" selects tag "alice tag" from the search result filter chip
Expand All @@ -66,7 +66,7 @@ Feature: Search
| fileWithTag.txt |
| withTag.txt |

When "Brian" searches "file" using the global search and the "all files" filter and presses enter
When "Brian" searches "file" using the global search and the "everywhere" filter and presses enter
Then following resources should be displayed in the files list for user "Brian"
| resource |
| fileWithTag.txt |
Expand All @@ -81,7 +81,7 @@ Feature: Search
| spaceFolder/spaceTextfile.txt |

When "Brian" enables the option to search in file content
And "Brian" searches "Cheers" using the global search and the "all files" filter and presses enter
And "Brian" searches "Cheers" using the global search and the "everywhere" filter and presses enter
Then following resources should be displayed in the files list for user "Brian"
| resource |
| textfile.txt |
Expand Down
16 changes: 8 additions & 8 deletions tests/e2e/cucumber/features/smoke/search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Feature: Search
| .hidden-file.txt |

# search for objects of personal space
When "Alice" searches "foldeR" using the global search and the "all files" filter
When "Alice" searches "foldeR" using the global search and the "everywhere" filter
Then following resources should be displayed in the search list for user "Alice"
| resource |
| folder |
Expand All @@ -52,7 +52,7 @@ Feature: Search
| .hidden-file.txt |

# search for hidden file
When "Alice" searches "hidden" using the global search and the "all files" filter
When "Alice" searches "hidden" using the global search and the "everywhere" filter
Then following resources should be displayed in the search list for user "Alice"
| resource |
| .hidden-file.txt |
Expand All @@ -64,7 +64,7 @@ Feature: Search
| new-lorem-big.txt |

# subfolder search
And "Alice" searches "child" using the global search and the "all files" filter
And "Alice" searches "child" using the global search and the "everywhere" filter
Then following resources should be displayed in the search list for user "Alice"
| resource |
| child-one |
Expand All @@ -78,7 +78,7 @@ Feature: Search
| new-lorem-big.txt |

# received shares search
And "Alice" searches "NEW" using the global search and the "all files" filter
And "Alice" searches "NEW" using the global search and the "everywhere" filter
Then following resources should be displayed in the search list for user "Alice"
| resource |
| new_share_from_brian |
Expand All @@ -95,7 +95,7 @@ Feature: Search
| resource | as |
| folder | renamedFolder |
| FolDer | renamedFolDer |
And "Alice" searches "rena" using the global search and the "all files" filter
And "Alice" searches "rena" using the global search and the "everywhere" filter
Then following resources should be displayed in the search list for user "Alice"
| resource |
| renamedFolder |
Expand Down Expand Up @@ -123,7 +123,7 @@ Feature: Search
And "Carol" creates the following resources
| resource | type |
| folder | folder |
And "Carol" searches "NEW" using the global search and the "all files" filter
And "Carol" searches "NEW" using the global search and the "everywhere" filter
Then following resources should be displayed in the search list for user "Carol"
| resource |
| new_share_from_brian |
Expand All @@ -149,14 +149,14 @@ Feature: Search
| mainFolder/subFolder/exampleInsideTheSubFolder.txt | I'm in the sub folder |
And "Alice" opens the "files" app
When "Alice" opens folder "mainFolder"
And "Alice" searches "example" using the global search and the "all files" filter
And "Alice" searches "example" using the global search and the "everywhere" filter
Then following resources should be displayed in the search list for user "Alice"
| resource |
| exampleInsideThePersonalSpace.txt |
| exampleInsideTheMainFolder.txt |
| exampleInsideTheSubFolder.txt |

When "Alice" searches "example" using the global search and the "current folder" filter
When "Alice" searches "example" using the global search and the "in here" filter
Then following resources should be displayed in the search list for user "Alice"
| resource |
| exampleInsideTheMainFolder.txt |
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/cucumber/features/smoke/searchProjectSpace.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ Feature: Search in the project space
And "Alice" navigates to the personal space page

# search for project space objects
When "Alice" searches "-'s" using the global search and the "all files" filter
When "Alice" searches "-'s" using the global search and the "everywhere" filter
Then following resources should be displayed in the search list for user "Alice"
| resource |
| new-'single'quotes.txt |
But following resources should not be displayed in the search list for user "Alice"
| resource |
| folder(WithSymbols:!;_+-&) |
When "Alice" searches "!;_+-&)" using the global search and the "all files" filter
When "Alice" searches "!;_+-&)" using the global search and the "everywhere" filter
Then following resources should be displayed in the search list for user "Alice"
| resource |
| folder(WithSymbols:!;_+-&) |
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const globalSearchInput = '.oc-search-input'
const globalSearchBarFilter = '.oc-search-bar-filter'
const globalSearchDirFilterDropdown =
'//div[@id="files-global-search"]//button[contains(@id, "oc-filter")]'
const globalSearchBarFilterAllFiles = '//*[@data-test-id="all-files"]'
const globalSearchBarFilterCurrentFolder = '//*[@data-test-id="current-folder"]'
const globalSearchBarFilterAllFiles = '//*[@data-test-id="everywhere"]'
const globalSearchBarFilterCurrentFolder = '//*[@data-test-id="in-here"]'
const searchList =
'//div[@id="files-global-search-options"]//li[contains(@class,"preview")]//span[@class="oc-resource-name"]'
const globalSearchOptions = '#files-global-search-options'
Expand Down Expand Up @@ -1075,7 +1075,7 @@ export const getTagsForResourceVisibilityInDetailsPanel = async (

return true
}
export type searchFilter = 'all files' | 'current folder'
export type searchFilter = 'everywhere' | 'in here'

export interface searchResourceGlobalSearchArgs {
keyword: string
Expand All @@ -1097,7 +1097,7 @@ export const searchResourceGlobalSearch = async (
await page.locator(globalSearchDirFilterDropdown).click()
await page
.locator(
filter === 'all files' ? globalSearchBarFilterAllFiles : globalSearchBarFilterCurrentFolder
filter === 'everywhere' ? globalSearchBarFilterAllFiles : globalSearchBarFilterCurrentFolder
)
.click()
}
Expand Down

0 comments on commit d4d3a5a

Please sign in to comment.