Skip to content

Commit

Permalink
Address code review
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Dec 16, 2022
1 parent a509251 commit 584cf7b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('OcRecipient', () => {
hasAvatar: false
})

console.log(wrapper.html())
const icon = wrapper.find('[data-testid="recipient-icon"]')

expect(icon.exists()).toBeTruthy()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { shallowMount } from '@vue/test-utils'

import { AVAILABLE_SIZES } from '../../helpers/constants'
import { OcResourceIcon } from '..'

Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/components/AppBar/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import { mapGetters, mapState, mapMutations } from 'vuex'
import { Resource } from 'web-client'
import { SpaceResource } from 'web-client/src/helpers'
import { ViewModeConstants } from '../../composables'
import { ViewModeConstants } from '../../composables/viewMode/constants'
import { BreadcrumbItem } from '../../helpers/breadcrumbs'
import MixinFileActions from '../../mixins/fileActions'
import { isLocationTrashActive } from '../../router'
Expand Down
6 changes: 3 additions & 3 deletions packages/web-app-files/src/components/AppBar/ViewOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<oc-button
v-for="viewMode in viewModes"
:key="viewMode.name"
v-oc-tooltip="viewMode.label"
v-oc-tooltip="$gettext(viewMode.label)"
:appearance="viewModeCurrent === viewMode.name ? 'filled' : 'outline'"
:label="viewMode.label"
:label="$gettext(viewMode.label)"
@click="setViewMode(viewMode)"
>
<oc-icon :name="viewMode.icon.name" :fill-type="viewMode.icon.fillType" size="small" />
Expand Down Expand Up @@ -85,7 +85,7 @@ export default defineComponent({
})
const viewModeQuery = useRouteQueryPersisted({
name: ViewModeConstants.queryName,
defaultValue: ViewModeConstants.default.name
defaultValue: ViewModeConstants.defaultModeName
})
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const useResourcesViewDefaults = <T, TT, TU extends any[]>(
fields
})

const currentViewModeQuery = useRouteQuery('view-mode', ViewModeConstants.default.name)
const currentViewModeQuery = useRouteQuery('view-mode', ViewModeConstants.defaultModeName)
const currentViewMode = computed((): string => queryItemAsString(currentViewModeQuery.value))
const viewMode = useViewMode(currentViewMode)

Expand Down
6 changes: 5 additions & 1 deletion packages/web-app-files/src/composables/viewMode/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { $gettext } from 'web-app-files/src/router/utils'
import { ViewMode } from 'web-pkg/src/ui/types'

function $gettext(msg: string): string {
return msg
}

export abstract class ViewModeConstants {
static readonly defaultModeName: string = 'resource-table'
static readonly default: ViewMode = {
name: 'resource-table',
label: $gettext('Switch to default table view'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { computed, ComputedRef, unref } from 'vue'
import { queryItemAsString, useRouteQueryPersisted } from 'web-pkg/src/composables'
import { queryItemAsString } from 'web-pkg/src/composables/appDefaults'
import { useRouteQueryPersisted } from 'web-pkg/src/composables/router'
import { ViewModeConstants } from './constants'

export function useViewMode<T>(options: ComputedRef<string>): ComputedRef<string> {
Expand All @@ -9,7 +10,7 @@ export function useViewMode<T>(options: ComputedRef<string>): ComputedRef<string

const viewModeQuery = useRouteQueryPersisted({
name: ViewModeConstants.queryName,
defaultValue: ViewModeConstants.default.name
defaultValue: ViewModeConstants.defaultModeName
})
return computed(() => queryItemAsString(unref(viewModeQuery)))
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
defaultComponentMocks
} from 'web-test-helpers'
import { ViewModeConstants } from 'web-app-files/src/composables'
import { ViewMode } from 'web-pkg/src/ui/types'

jest.mock('web-pkg/src/composables/router')
const selectors = {
Expand Down Expand Up @@ -52,8 +53,8 @@ describe('ViewOptions component', () => {

function getWrapper(
{ perPage = '100' } = {},
props: { [key: string]: any } = {
viewModes: []
props?: {
viewModes: ViewMode[]
}
) {
jest.mocked(useRouteQueryPersisted).mockImplementation(() => ref(perPage))
Expand Down

0 comments on commit 584cf7b

Please sign in to comment.