text stringlengths 1 2.83M | id stringlengths 16 152 | metadata dict | __index_level_0__ int64 0 949 |
|---|---|---|---|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M12 3c4.284 0 8.22 1.497 11.31 3.996L12 21 .69 6.997C3.78 4.497 7.714 3 12 3zm0 7c-1.898 0-3.683.48-5.241 1.327l5.24 6.49 5.242-6.49C15.683 10.48 13.898 10 12 10zm0-5c-3.028 0-5.923.842-8.42 2.392l1.904 2.357C7.4 8.637 9.625 8 12 8s4.6.637 6.516 1.749L20.42 7.39C17.922 5.841 15.027 5 12 5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/signal-wifi-3-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/signal-wifi-3-line.svg",
"repo_id": "owncloud",
"token_count": 266
} | 759 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path fill-rule="nonzero" d="M15.69 12.918l1.769 1.768c-6.01 6.01-10.96 6.01-15.203 4.596L17.812 3.726l3.536 3.535-5.657 5.657zm-2.828 0l5.657-5.657-.707-.707L6.314 18.052c2.732.107 5.358-.907 8.267-3.416l-1.719-1.718z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/slice-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/slice-line.svg",
"repo_id": "owncloud",
"token_count": 214
} | 760 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M20 4v12h3l-4 5-4-5h3V4h2zm-8 14v2H3v-2h9zm2-7v2H3v-2h11zm0-7v2H3V4h11z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/sort-desc.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/sort-desc.svg",
"repo_id": "owncloud",
"token_count": 151
} | 761 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4 3h16a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm8 13a4 4 0 1 1 0-8 4 4 0 0 1 0 8zm0 2a6 6 0 1 0 0-12 6 6 0 0 0 0 12zM6 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm12 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 12a1 1 0 1 0 0-2 1 1 0 0 0 0 2zM6 19a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm6-5.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/speaker-3-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/speaker-3-fill.svg",
"repo_id": "owncloud",
"token_count": 287
} | 762 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M20.083 10.5l1.202.721a.5.5 0 0 1 0 .858L12 17.65l-9.285-5.571a.5.5 0 0 1 0-.858l1.202-.721L12 15.35l8.083-4.85zm0 4.7l1.202.721a.5.5 0 0 1 0 .858l-8.77 5.262a1 1 0 0 1-1.03 0l-8.77-5.262a.5.5 0 0 1 0-.858l1.202-.721L12 20.05l8.083-4.85zM12.514 1.309l8.771 5.262a.5.5 0 0 1 0 .858L12 13 2.715 7.429a.5.5 0 0 1 0-.858l8.77-5.262a1 1 0 0 1 1.03 0z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/stack-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/stack-fill.svg",
"repo_id": "owncloud",
"token_count": 313
} | 763 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M6 5h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/stop-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/stop-fill.svg",
"repo_id": "owncloud",
"token_count": 136
} | 764 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M17.2 20l1.8 1.5v.5H5v-.5L6.8 20H5a2 2 0 0 1-2-2V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4v11a2 2 0 0 1-2 2h-1.8zM11 12V5H7a2 2 0 0 0-2 2v5h6zm2 0h6V7a2 2 0 0 0-2-2h-4v7zm-5.5 6a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm9 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/subway-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/subway-fill.svg",
"repo_id": "owncloud",
"token_count": 266
} | 765 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M11 7v13H9V7H3V5h12v2h-4zm8.55-.42a.8.8 0 1 0-1.32-.36l-1.154.33A2.001 2.001 0 0 1 19 4a2 2 0 0 1 1.373 3.454L18.744 9H21v1h-4V9l2.55-2.42z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/superscript-2.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/superscript-2.svg",
"repo_id": "owncloud",
"token_count": 184
} | 766 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M21.678 7.98l-1.415 1.413-2.12-2.12-2.122 2.12 3.535 3.536-1.414 1.414-.707-.707L11.071 20H5.414l-2.121 2.121-1.414-1.414L4 18.586v-5.657l6.364-6.364-.707-.707 1.414-1.414 3.536 3.535 2.12-2.121-2.12-2.121 1.414-1.415 5.657 5.657zM9.657 14.342l-2.829-2.828-1.414 1.414 2.829 2.828 1.414-1.414zm2.828-2.828L9.657 8.686l-1.414 1.415 2.828 2.828 1.414-1.414z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/syringe-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/syringe-fill.svg",
"repo_id": "owncloud",
"token_count": 307
} | 767 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path fill-rule="nonzero" d="M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm0 2C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-3.11-8.83l-2.498-.779c-.54-.165-.543-.537.121-.804l9.733-3.76c.565-.23.885.061.702.79l-1.657 7.82c-.116.557-.451.69-.916.433l-2.551-1.888-1.189 1.148c-.122.118-.221.219-.409.244-.187.026-.341-.03-.454-.34l-.87-2.871-.012.008z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/telegram-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/telegram-line.svg",
"repo_id": "owncloud",
"token_count": 279
} | 768 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M15 18h1.5a2.5 2.5 0 1 0 0-5H3v-2h13.5a4.5 4.5 0 1 1 0 9H15v2l-4-3 4-3v2zM3 4h18v2H3V4zm6 14v2H3v-2h6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/text-wrap.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/text-wrap.svg",
"repo_id": "owncloud",
"token_count": 169
} | 769 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm3.536 5.05L10.586 12 12 13.414l4.95-4.95-1.414-1.414z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/timer-2-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/timer-2-fill.svg",
"repo_id": "owncloud",
"token_count": 158
} | 770 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M7 4V3a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v1h3c0 2.5-2.5 3.5-3 3.5V10h3c0 2.5-2.5 3.5-3 3.5V16h3c0 2.5-2.5 3.5-3 3.5V21a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1v-1.5c-.5 0-3-1-3-3.5h3v-2.5c-.5 0-3-1-3-3.5h3V7.5c-.5 0-3-1-3-3.5h3zm5 16a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0-6a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0-6a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/traffic-light-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/traffic-light-fill.svg",
"repo_id": "owncloud",
"token_count": 323
} | 771 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M17 8h3l3 4.056V18h-2.035a3.5 3.5 0 0 1-6.93 0h-5.07a3.5 3.5 0 0 1-6.93 0H1V6a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2zm0 2v3h4v-.285L18.992 10H17z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/truck-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/truck-fill.svg",
"repo_id": "owncloud",
"token_count": 185
} | 772 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M3 19h18v2H3v-2zM13 5.828V17h-2V5.828L4.929 11.9l-1.414-1.414L12 2l8.485 8.485-1.414 1.414L13 5.83z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/upload-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/upload-line.svg",
"repo_id": "owncloud",
"token_count": 157
} | 773 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M13 14.062V22H4a8 8 0 0 1 9-7.938zM12 13c-3.315 0-6-2.685-6-6s2.685-6 6-6 6 2.685 6 6-2.685 6-6 6zm5.793 6.914l3.535-3.535 1.415 1.414-4.95 4.95-3.536-3.536 1.415-1.414 2.12 2.121z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/user-follow-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/user-follow-fill.svg",
"repo_id": "owncloud",
"token_count": 205
} | 774 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M16 4c.552 0 1 .448 1 1v4.2l5.213-3.65c.226-.158.538-.103.697.124.058.084.09.184.09.286v12.08c0 .276-.224.5-.5.5-.103 0-.203-.032-.287-.09L17 14.8V19c0 .552-.448 1-1 1H2c-.552 0-1-.448-1-1V5c0-.552.448-1 1-1h14zm-1 2H3v12h12V6zm-5 2v4h3l-4 4-4-4h3V8h2zm11 .841l-4 2.8v.718l4 2.8V8.84z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/video-download-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/video-download-line.svg",
"repo_id": "owncloud",
"token_count": 273
} | 775 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4.873 3h14.254a1 1 0 0 1 .809.412l3.823 5.256a.5.5 0 0 1-.037.633L12.367 21.602a.5.5 0 0 1-.706.028c-.007-.006-3.8-4.115-11.383-12.329a.5.5 0 0 1-.037-.633l3.823-5.256A1 1 0 0 1 4.873 3zm.51 2l-2.8 3.85L12 19.05 21.417 8.85 18.617 5H5.383z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/vip-diamond-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/vip-diamond-line.svg",
"repo_id": "owncloud",
"token_count": 237
} | 776 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M19.39 3.161l1.413 1.414-2.475 2.475 2.475 2.475L18.328 12l2.475 2.476-2.475 2.475 2.475 2.475-1.414 1.414-3.889-3.89 2.475-2.474L15.5 12l2.475-2.475L15.5 7.05l3.89-3.889zM13 19.945a.5.5 0 0 1-.817.387L6.89 15.999 3 16a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1l2.584-.002-3.776-3.776 1.414-1.414L13 12.586v7.359zM7.584 9.998L4 10V14l3.603-.001L11 16.779v-3.365L7.584 9.998zm5.303-6.26a.5.5 0 0 1 .113.317v5.702l-2-2V7.22l-.296.241-1.421-1.42 2.9-2.373a.5.5 0 0 1 .704.07z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/volume-off-vibrate-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/volume-off-vibrate-line.svg",
"repo_id": "owncloud",
"token_count": 373
} | 777 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M.69 6.997A17.925 17.925 0 0 1 12 3c4.285 0 8.22 1.497 11.31 3.997l-1.256 1.556A15.933 15.933 0 0 0 12 5C8.191 5 4.694 6.33 1.946 8.553L.69 6.997zm3.141 3.89A12.946 12.946 0 0 1 12 8c3.094 0 5.936 1.081 8.169 2.886l-1.257 1.556A10.954 10.954 0 0 0 12 10c-2.618 0-5.023.915-6.912 2.442l-1.257-1.556zm3.142 3.89A7.967 7.967 0 0 1 12 13c1.904 0 3.653.665 5.027 1.776l-1.257 1.556A5.975 5.975 0 0 0 12 15c-1.428 0-2.74.499-3.77 1.332l-1.257-1.556zm3.142 3.89A2.987 2.987 0 0 1 12 18c.714 0 1.37.25 1.885.666L12 21l-1.885-2.334z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/wifi-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/wifi-line.svg",
"repo_id": "owncloud",
"token_count": 394
} | 778 |
<template>
<div class="oc-application-icon oc-flex-inline oc-flex-middle oc-flex-center" :style="iconStyle">
<oc-icon :name="icon" :color="iconColor" size="medium" />
</div>
</template>
<script lang="ts">
import {
generateHashedColorForString,
getHexFromCssVar,
hexToRgb,
rgbToHex,
setDesiredContrastRatio,
calculateShadeColor
} from '../../helpers'
import { computed, defineComponent, unref } from 'vue'
import OcIcon from '../OcIcon/OcIcon.vue'
export default defineComponent({
name: 'OcApplicationIcon',
components: { OcIcon },
status: 'ready',
release: '15.0.0',
props: {
icon: {
type: String,
required: true
},
colorPrimary: {
type: String,
required: false,
default: ''
},
colorSecondary: {
type: String,
required: false,
default: ''
}
},
setup(props) {
const iconColor = computed(() => {
return 'rgba(255,255,255,0.7)'
})
const getGradient = (primary: string, secondary: string): string => {
return `linear-gradient(90deg, ${primary} 0%, ${secondary} 100%)`
}
const primaryColor = computed(() => {
return getHexFromCssVar(props.colorPrimary)
})
const secondaryColor = computed(() => {
return getHexFromCssVar(props.colorSecondary)
})
const hasPrimaryColor = computed(() => {
return !!props.colorPrimary
})
const hasSecondaryColor = computed((): boolean => {
return !!props.colorSecondary
})
const generatedHashedPrimaryColor = computed((): string => {
let hashedColor = generateHashedColorForString(props.icon)
return rgbToHex(setDesiredContrastRatio(hexToRgb(hashedColor), hexToRgb('#ffffff'), 4))
})
const iconStyle = computed(() => {
const primaryHex = unref(hasPrimaryColor)
? unref(primaryColor)
: unref(generatedHashedPrimaryColor)
const secondaryHex = unref(hasSecondaryColor)
? unref(secondaryColor)
: calculateShadeColor(hexToRgb(primaryHex), 40)
const darkBorderHex = calculateShadeColor(hexToRgb(primaryHex), -25)
const lightBorderHex = calculateShadeColor(hexToRgb(primaryHex), 45)
return {
background: getGradient(primaryHex, secondaryHex),
boxShadow: `inset ${lightBorderHex} 0px 0px 1px 0px,${darkBorderHex} 0px 0px 1px 0px`
}
})
return {
iconColor,
iconStyle
}
}
})
</script>
<style lang="scss">
.oc-application-icon {
width: 28px;
height: 28px;
border-radius: 6px;
.oc-icon {
height: 18px !important;
max-height: 18px !important;
max-width: 18px !important;
width: 18px !important;
svg {
height: 18px !important;
max-height: 18px !important;
max-width: 18px !important;
width: 18px !important;
}
}
}
</style>
<docs>
```js
// No color: (color will be hash generated by icon name)
<oc-application-icon icon="account-box" />
// With primary color:
<oc-application-icon icon="account-box" colorPrimary="#37BC07" />
// With primary and secondary color:
<oc-application-icon icon="account-box" colorPrimary="#37BC07" colorSecondary="#37BC07" />
```
</docs>
| owncloud/web/packages/design-system/src/components/OcApplicationIcon/OcApplicationIcon.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcApplicationIcon/OcApplicationIcon.vue",
"repo_id": "owncloud",
"token_count": 1261
} | 779 |
import { defaultPlugins, shallowMount } from 'web-test-helpers'
import Breadcrumb from './OcBreadcrumb.vue'
const items = [
{ text: 'First folder', to: { path: 'folder' } },
{ text: 'Subfolder', onClick: () => alert('Breadcrumb clicked!') },
{ text: 'Deep', to: { path: 'folder' } },
{ text: 'Deeper ellipsize in responsive mode' }
]
describe('OcBreadcrumb', () => {
it('sets correct variation', () => {
const { wrapper } = getWrapper({ variation: 'lead' })
expect(wrapper.props().variation).toMatch('lead')
expect(wrapper.find('.oc-breadcrumb').classes()).toContain('oc-breadcrumb-lead')
expect(wrapper.html()).toMatchSnapshot()
})
it('displays all items', () => {
const { wrapper } = getWrapper()
expect(wrapper.findAll('.oc-breadcrumb-list-item:not(.oc-invisible-sr)').length).toBe(
items.length
)
expect(wrapper.html()).toMatchSnapshot()
})
it('displays context menu trigger if enabled via property', () => {
const { wrapper } = getWrapper({ showContextActions: true })
expect(wrapper.find('#oc-breadcrumb-contextmenu-trigger').exists()).toBe(true)
})
it('does not display context menu trigger if not enabled via property', () => {
const { wrapper } = getWrapper({ showContextActions: false })
expect(wrapper.find('#oc-breadcrumb-contextmenu-trigger').exists()).toBe(false)
})
describe('mobile navigation', () => {
it.each([
{ items: [], shows: false },
{ items: [items[0]], shows: false },
{ items: [items[0], items[1]], shows: true }
])('shows if more than 1 breadcrumb item is given', ({ items, shows }) => {
const { wrapper } = getWrapper({ items })
expect(wrapper.find('.oc-breadcrumb-mobile-navigation').exists()).toBe(shows)
})
})
describe('mobile current folder', () => {
it.each([
{ items: [], shows: false },
{ items: [items[0]], shows: false },
{ items: [items[0], items[1]], shows: true }
])('shows if more than 1 breadcrumb item is given', ({ items, shows }) => {
const { wrapper } = getWrapper({ items })
expect(wrapper.find('.oc-breadcrumb-mobile-current').exists()).toBe(shows)
})
})
})
const getWrapper = (props = {}) => {
return {
wrapper: shallowMount(Breadcrumb, {
props: {
items,
...props
},
global: { renderStubDefaultSlot: true, plugins: [...defaultPlugins()] }
})
}
}
| owncloud/web/packages/design-system/src/components/OcBreadcrumb/OcBreadcrumb.spec.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcBreadcrumb/OcBreadcrumb.spec.ts",
"repo_id": "owncloud",
"token_count": 905
} | 780 |
<template>
<div ref="emojiPickerRef"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, ref, unref, watch } from 'vue'
import { useGettext } from 'vue3-gettext'
import { Picker } from 'emoji-mart'
/**
* Emoji Picker
*/
export default defineComponent({
name: 'OcEmojiPicker',
status: 'ready',
release: '1.0.0',
props: {
theme: {
type: String,
default: 'light',
validator: (value: string) => {
return ['light', 'dark'].includes(value)
}
}
},
emits: ['emojiSelect', 'clickOutside'],
setup(props, { emit }) {
const { $gettext, current: currentLanguage } = useGettext()
const emojiPickerRef = ref<HTMLElement>()
watch(
[() => props.theme, currentLanguage],
async () => {
await nextTick()
const i18n = {
search: $gettext('Search'),
search_no_results_1: $gettext('Oh no!'),
search_no_results_2: $gettext('That emoji couldn’t be found'),
pick: $gettext('Pick an emoji…'),
add_custom: $gettext('Add custom emoji'),
categories: {
activity: $gettext('Activity'),
custom: $gettext('Custom'),
flags: $gettext('Flags'),
foods: $gettext('Food & Drink'),
frequent: $gettext('Frequently used'),
nature: $gettext('Animals & Nature'),
objects: $gettext('Objects'),
people: $gettext('Smileys & People'),
places: $gettext('Travel & Places'),
search: $gettext('Search Results'),
symbols: $gettext('Symbols')
},
skins: {
choose: $gettext('Choose default skin tone'),
'1': $gettext('Default'),
'2': $gettext('Light'),
'3': $gettext('Medium-Light'),
'4': $gettext('Medium'),
'5': $gettext('Medium-Dark'),
'6': $gettext('Dark')
}
}
const pickerOptions = {
onEmojiSelect: (emoji: any) => emit('emojiSelect', emoji.native),
onClickOutside: () => emit('clickOutside'),
i18n,
theme: props.theme
}
const picker = new Picker(pickerOptions)
unref(emojiPickerRef).innerHTML = ''
unref(emojiPickerRef).appendChild(picker as any)
},
{ immediate: true }
)
return {
emojiPickerRef
}
}
})
</script>
<docs>
```js
<template>
<h3>Light mode OcEmojiPicker</h3>
<oc-emoji-picker theme="light" @emoji-select="alert"/>
<h3>Dark mode OcEmojiPicker</h3>
<oc-emoji-picker theme="dark" @emoji-select="alert"/>
</template>
<script>
export default {
methods: {
alert(val) {
alert(val)
}
}
}
</script>
```
</docs>
| owncloud/web/packages/design-system/src/components/OcEmojiPicker/OcEmojiPicker.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcEmojiPicker/OcEmojiPicker.vue",
"repo_id": "owncloud",
"token_count": 1289
} | 781 |
<template>
<div :class="['oc-loader', { 'oc-loader-flat': flat }]" :aria-label="ariaLabel" />
</template>
<script lang="ts">
import { defineComponent } from 'vue'
/**
* Remote actions can take an undefined portion of time. The spinner gives feedback to the users about an actions being processed.
*/
export default defineComponent({
name: 'OcLoader',
status: 'ready',
release: '1.0.0',
props: {
/**
* Descriptive text to be read to screen-readers.
*/
ariaLabel: {
type: String,
default: 'Loading'
},
/**
* Removes border radius and shrinks the height. Defaults to false.
*/
flat: {
type: Boolean,
default: false
}
}
})
</script>
<style lang="scss">
.oc-loader {
-webkit-appearance: none;
-moz-appearance: none;
background-color: #f8f8f8;
border: 0;
border-radius: 500px;
display: block;
height: 15px;
margin-top: 20px;
margin-bottom: 20px;
overflow: hidden;
vertical-align: baseline;
width: 100%;
position: relative;
&-flat {
border-radius: 0 !important;
height: 5px !important;
}
&::after {
background: var(--oc-color-text-muted);
content: '';
height: 100%;
width: 0;
display: block;
position: absolute;
animation: {
duration: 1.4s;
iteration-count: infinite;
name: oc-loader;
}
}
}
@keyframes oc-loader {
0% {
left: 0;
width: 0;
}
50% {
left: 0;
width: 66%;
}
100% {
left: 100%;
width: 10%;
}
}
</style>
<docs>
```js
<h3 class="oc-heading-divider">
Default style
</h3>
<div>
<oc-loader />
</div>
<h3 class="oc-heading-divider">
Flat style
</h3>
<div>
<oc-loader :flat="true" />
</div>
```
</docs>
| owncloud/web/packages/design-system/src/components/OcLoader/OcLoader.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcLoader/OcLoader.vue",
"repo_id": "owncloud",
"token_count": 722
} | 782 |
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`OcProgress > sets correct classes 1`] = `
"<div class="oc-progress oc-progress-small oc-progress-warning" aria-valuemax="10" aria-valuenow="3" aria-busy="true" aria-valuemin="0" role="progressbar">
<div class="oc-progress-current" style="width: 30%;"></div>
</div>"
`;
| owncloud/web/packages/design-system/src/components/OcProgress/__snapshots__/OcProgress.spec.ts.snap/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcProgress/__snapshots__/OcProgress.spec.ts.snap",
"repo_id": "owncloud",
"token_count": 133
} | 783 |
import { defaultPlugins, mount } from 'web-test-helpers'
import Table from './OcTable.vue'
const ASC = 'ascending'
const DESC = 'descending'
const NONE = 'none'
const tableFieldId = {
name: 'id',
title: 'Id',
sortable: true,
sortDir: 'desc'
}
const tableFieldResource = {
name: 'resource',
title: 'Resource',
sortable: true,
sortDir: 'asc'
}
const tableFields: {
name: string
title: string
sortable?: boolean
sortDir?: string
}[] = [
{
name: 'selected',
title: 'Select'
},
tableFieldId,
tableFieldResource
]
const data = [
{
selected: false,
id: '111000234',
resource: 'id-1'
},
{
selected: true,
id: 1245,
resource: 'id-3'
},
{
selected: false,
id: '5324435',
resource: 'id-2'
}
]
describe('OcTable.sort', () => {
describe('aria-sort', () => {
const wrapper = mount(Table, {
props: {
fields: [...tableFields],
data
},
global: {
plugins: [...defaultPlugins()],
stubs: {
'oc-icon': true
}
}
})
const headers = wrapper.findAll('thead th')
it('has any [aria-sort] attribute on all sortable column headers', () => {
const sortableFields = tableFields.filter((f) => f.sortable).map((f) => f.name)
tableFields.forEach((field, index) => {
if (!sortableFields.includes(field.name)) {
return
}
expect(headers.at(index).attributes()['aria-sort']).toBeTruthy()
})
})
it('lacks an [aria-sort] attribute on non-sortable column headers', () => {
const sortableFields = tableFields.filter((f) => f.sortable).map((f) => f.name)
tableFields.forEach((field, index) => {
if (sortableFields.includes(field.name)) {
return
}
expect(headers.at(index).attributes()['aria-sort']).toBeFalsy()
})
})
it.each([
[
ASC,
{
sortBy: tableFieldId.name,
sortDir: 'asc',
ariaSort: ASC
}
],
[
DESC,
{
sortBy: tableFieldId.name,
sortDir: 'desc',
ariaSort: DESC
}
],
[
NONE,
{
sortBy: tableFieldResource.name,
sortDir: 'asc',
ariaSort: NONE
}
]
])(
'has the correct [aria-sort] = %s attribute according to the active sort direction of the ID column',
async (name, { sortBy, sortDir, ariaSort }) => {
await wrapper.setProps({
sortBy,
sortDir
})
expect(headers.at(1).attributes()['aria-sort']).toBe(ariaSort)
}
)
})
describe('emits sort events', () => {
it('toggles the sort direction when repeatedly clicking on the same column', async () => {
const wrapper = mount(Table, {
props: {
fields: tableFields,
sortBy: tableFieldId.name,
sortDir: tableFieldId.sortDir,
data
},
global: {
plugins: [...defaultPlugins()],
stubs: {
'oc-icon': true
}
}
})
const headers = wrapper.findAll('thead th')
const th1 = headers.at(1)
await th1.trigger('click')
expect(wrapper.emitted('sort')[0]).toMatchObject([
{
sortBy: tableFieldId.name,
sortDir: tableFieldId.sortDir === 'asc' ? 'desc' : 'asc'
}
])
})
it.each([
[
'clicking on a new column',
{
sortByOld: tableFieldId.name,
sortDirOld: tableFieldId.sortDir,
sortByNew: tableFieldResource.name,
sortDirNew: tableFieldResource.sortDir
}
],
[
'no direction was set before',
{
sortByOld: tableFieldId.name,
sortDirOld: undefined,
sortByNew: tableFieldResource.name,
sortDirNew: tableFieldResource.sortDir
}
]
])(
'sets the default sort direction from the field when %s',
async (name, { sortByOld, sortDirOld, sortByNew, sortDirNew }) => {
const wrapper = mount(Table, {
props: {
fields: tableFields,
data,
sortBy: sortByOld,
sortDir: sortDirOld
},
global: {
plugins: [...defaultPlugins()],
stubs: {
'oc-icon': true
}
}
})
const headers = wrapper.findAll('thead th')
const th2 = headers.at(2)
await th2.trigger('click')
expect(wrapper.emitted('sort')[0]).toMatchObject([
{
sortBy: sortByNew,
sortDir: sortDirNew
}
])
}
)
})
})
| owncloud/web/packages/design-system/src/components/OcTable/OcTable.sort.spec.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcTable/OcTable.sort.spec.ts",
"repo_id": "owncloud",
"token_count": 2319
} | 784 |
<template>
<div class="font-sizes">
<div
v-for="(prop, index) in tokens"
:key="index"
class="font"
:style="{ fontSize: prop.value }"
>
${{ prop.name }}, var(--{{ prop.name }})
<span>({{ prop.value }})</span>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import designTokens from '../../assets/tokens/ods.json'
/**
* This typographic scale makes it easier to achieve visual harmony in the
* interface. It’s purposefully designed to keep the number of separate font
* sizes to a minimum. To edit font-sizes, see
* [/src/tokens/font-size.yml](https://github.com/owncloud/web/blob/master/packages/design-system/src/tokens/font-size.yml).
*/
export default defineComponent({
name: 'DocsFontSize',
computed: {
tokens() {
return Object.values(designTokens).filter((token) => token.name.startsWith('oc-font-size-'))
}
}
})
</script>
<style lang="scss" scoped>
@import '../../../docs/docs.tokens';
/* STYLES
--------------------------------------------- */
.font-sizes {
margin-top: $space-l;
overflow: hidden;
width: 100%;
}
.font {
@include reset;
font-family: $font-heading;
font-weight: $weight-bold;
line-height: $line-height-xs;
color: $color-rich-black;
margin-bottom: $space-s;
font-style: normal;
span {
letter-spacing: -0.02em;
margin-left: 10px;
font-weight: $weight-normal;
color: $color-silver;
user-select: none;
font-style: normal;
}
}
</style>
<docs>
```
<DocsFontSize/>
```
</docs>
| owncloud/web/packages/design-system/src/components/_DocsFontSize/_DocsFontSize.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/_DocsFontSize/_DocsFontSize.vue",
"repo_id": "owncloud",
"token_count": 607
} | 785 |
import { ref, nextTick } from 'vue'
import { useIsVisible } from './index'
import { mount } from 'web-test-helpers'
const mockIntersectionObserver = () => {
const enable = () => {
const mock = {
observe: vi.fn(),
disconnect: vi.fn(),
unobserve: vi.fn()
}
window.IntersectionObserver = vi.fn().mockImplementation(() => mock)
return {
mock,
callback: (args, fastForward = 0) => {
;(window.IntersectionObserver as any).mock.calls[0][0](args)
vi.advanceTimersByTime(fastForward)
}
}
}
const disable = () => {
delete window.IntersectionObserver
}
return { enable, disable }
}
const createWrapper = (options = {}) =>
mount({
template: `
<div>
<div ref="target">{{ isVisible }}</div>
</div>`,
setup: () => {
const target = ref<HTMLElement>()
const { isVisible } = useIsVisible({ ...options, target })
return {
isVisible,
target
}
}
})
describe('useIsVisible', () => {
beforeEach(() => {
vi.useFakeTimers()
})
afterEach(() => {
vi.useRealTimers()
})
const { enable: enableIntersectionObserver, disable: disableIntersectionObserver } =
mockIntersectionObserver()
it('is visible by default if browser does not support IntersectionObserver', () => {
disableIntersectionObserver()
const wrapper = createWrapper()
expect((wrapper.vm.$refs.target as any).innerHTML).toBe('true')
})
it('observes the target', async () => {
const { mock: observerMock } = enableIntersectionObserver()
createWrapper()
await nextTick()
expect(observerMock.observe).toHaveBeenCalledTimes(1)
})
it('only shows once and then gets unobserved if the the composable is in the default show mode', async () => {
const { mock: observerMock, callback: observerCallback } = enableIntersectionObserver()
const wrapper = createWrapper()
await nextTick()
expect((wrapper.vm.$refs.target as any).innerHTML).toBe('false')
observerCallback([{ isIntersecting: true }])
await nextTick()
expect((wrapper.vm.$refs.target as any).innerHTML).toBe('true')
expect(observerMock.unobserve).toHaveBeenCalledTimes(1)
})
it('shows and hides multiple times if the the composable is in showHide mode', async () => {
const { mock: observerMock, callback: observerCallback } = enableIntersectionObserver()
const wrapper = createWrapper({ mode: 'showHide' })
await nextTick()
expect((wrapper.vm.$refs.target as any).innerHTML).toBe('false')
observerCallback([{ isIntersecting: true }])
await nextTick()
expect((wrapper.vm.$refs.target as any).innerHTML).toBe('true')
expect(observerMock.unobserve).toHaveBeenCalledTimes(0)
})
it('disconnects the observer before component gets unmounted', () => {
const { mock: observerMock } = enableIntersectionObserver()
const wrapper = createWrapper()
expect(observerMock.disconnect).toHaveBeenCalledTimes(0)
wrapper.unmount()
expect(observerMock.disconnect).toHaveBeenCalledTimes(1)
})
})
| owncloud/web/packages/design-system/src/composables/useIsVisible/index.spec.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/composables/useIsVisible/index.spec.ts",
"repo_id": "owncloud",
"token_count": 1123
} | 786 |
.oc-login {
@extend .oc-background-cover;
position: relative;
&-logo {
@extend .oc-background-cover;
left: 50%;
max-height: 200px;
max-width: 200px;
position: absolute;
text-indent: -9999px;
transform: translate(-50%, -150%);
}
&-authorize-button {
width: 100%;
}
&-card {
@extend .oc-card;
@extend .oc-text-center;
border-radius: 15px;
&-title {
@extend .oc-card-title;
}
&-body {
@extend .oc-card-body;
}
&-footer {
@extend .oc-card-footer;
@extend .oc-text-small;
}
}
}
| owncloud/web/packages/design-system/src/styles/theme/login.scss/0 | {
"file_path": "owncloud/web/packages/design-system/src/styles/theme/login.scss",
"repo_id": "owncloud",
"token_count": 285
} | 787 |
---
line-height:
medium:
value: '1.6'
small:
value: '1.3'
xsmall:
value: '1'
| owncloud/web/packages/design-system/src/tokens/docs/line-height.yaml/0 | {
"file_path": "owncloud/web/packages/design-system/src/tokens/docs/line-height.yaml",
"repo_id": "owncloud",
"token_count": 51
} | 788 |
export * from './src'
declare module 'vue' {
interface GlobalComponents {
OcAvatar: (typeof import('./src/components'))['OcAvatar']
OcAvatarCount: (typeof import('./src/components'))['OcAvatarCount']
OcAvatarFederated: (typeof import('./src/components'))['OcAvatarFederated']
OcAvatarGroup: (typeof import('./src/components'))['OcAvatarGroup']
OcAvatarGuest: (typeof import('./src/components'))['OcAvatarGuest']
OcAvatarItem: (typeof import('./src/components'))['OcAvatarItem']
OcAvatarLink: (typeof import('./src/components'))['OcAvatarLink']
OcAvatars: (typeof import('./src/components'))['OcAvatars']
OcBreadcrumb: (typeof import('./src/components'))['OcBreadcrumb']
OcButton: (typeof import('./src/components'))['OcButton']
OcCheckbox: (typeof import('./src/components'))['OcCheckbox']
OcContextualHelper: (typeof import('./src/components'))['OcContextualHelper']
OcDatepicker: (typeof import('./src/components'))['OcDatepicker']
OcDrop: (typeof import('./src/components'))['OcDrop']
OcDropzone: (typeof import('./src/components'))['OcDropzone']
OcFilterChip: (typeof import('./src/components'))['OcFilterChip']
OcGrid: (typeof import('./src/components'))['OcGrid']
OcHiddenAnnouncer: (typeof import('./src/components'))['OcHiddenAnnouncer']
OcIcon: (typeof import('./src/components'))['OcIcon']
OcImage: (typeof import('./src/components'))['OcImage']
OcInfoDrop: (typeof import('./src/components'))['OcInfoDrop']
OcList: (typeof import('./src/components'))['OcList']
OcLoader: (typeof import('./src/components'))['OcLoader']
OcLogo: (typeof import('./src/components'))['OcLogo']
OcModal: (typeof import('./src/components'))['OcModal']
OcNotificationMessage: (typeof import('./src/components'))['OcNotificationMessage']
OcNotifications: (typeof import('./src/components'))['OcNotifications']
OcPageSize: (typeof import('./src/components'))['OcPageSize']
OcPagination: (typeof import('./src/components'))['OcPagination']
OcProgress: (typeof import('./src/components'))['OcProgress']
OcProgressPie: (typeof import('./src/components'))['OcProgressPie']
OcRadio: (typeof import('./src/components'))['OcRadio']
OcRecipient: (typeof import('./src/components'))['OcRecipient']
OcSearchBar: (typeof import('./src/components'))['OcSearchBar']
OcSelect: (typeof import('./src/components'))['OcSelect']
OcSpinner: (typeof import('./src/components'))['OcSpinner']
OcStatusIndicators: (typeof import('./src/components'))['OcStatusIndicators']
OcSwitch: (typeof import('./src/components'))['OcSwitch']
OcTable: (typeof import('./src/components'))['OcTable']
OcTableSimple: (typeof import('./src/components'))['OcTableSimple']
OcTag: (typeof import('./src/components'))['OcTag']
OcTextInput: (typeof import('./src/components'))['OcTextInput']
OcTextarea: (typeof import('./src/components'))['OcTextarea']
OcTableBody: (typeof import('./src/components'))['OcTableBody']
OcTableCell: (typeof import('./src/components'))['OcTableCell']
OcTableCellData: (typeof import('./src/components'))['OcTableCellData']
OcTableCellHead: (typeof import('./src/components'))['OcTableCellHead']
OcTableFooter: (typeof import('./src/components'))['OcTableFooter']
OcTableHeader: (typeof import('./src/components'))['OcTableHeader']
OcTableRow: (typeof import('./src/components'))['OcTableRow']
}
}
| owncloud/web/packages/design-system/types.d.ts/0 | {
"file_path": "owncloud/web/packages/design-system/types.d.ts",
"repo_id": "owncloud",
"token_count": 1444
} | 789 |
<template>
<div>
<context-action-menu :menu-sections="menuSections" :action-options="actionOptions" />
</div>
</template>
<script lang="ts">
import { useActionsShowDetails } from '@ownclouders/web-pkg'
import { computed, defineComponent, PropType, unref } from 'vue'
import { ContextActionMenu } from '@ownclouders/web-pkg'
import { GroupActionOptions } from '@ownclouders/web-pkg'
import { useGroupActionsEdit, useGroupActionsDelete } from '../../composables/actions/groups'
export default defineComponent({
name: 'ContextActions',
components: { ContextActionMenu },
props: {
actionOptions: {
type: Object as PropType<GroupActionOptions>,
required: true
}
},
setup(props) {
const { actions: showDetailsActions } = useActionsShowDetails()
const { actions: deleteActions } = useGroupActionsDelete()
const { actions: editActions } = useGroupActionsEdit()
const menuItemsPrimaryActions = computed(() =>
[...unref(editActions), ...unref(deleteActions)].filter((item) =>
item.isVisible(props.actionOptions)
)
)
const menuItemsSidebar = computed(() =>
[...unref(showDetailsActions)].filter((item) => item.isVisible(props.actionOptions))
)
const menuSections = computed(() => {
const sections = []
if (unref(menuItemsPrimaryActions).length) {
sections.push({
name: 'primaryActions',
items: unref(menuItemsPrimaryActions)
})
}
if (unref(menuItemsSidebar).length) {
sections.push({
name: 'sidebar',
items: unref(menuItemsSidebar)
})
}
return sections
})
return {
menuSections
}
}
})
</script>
| owncloud/web/packages/web-app-admin-settings/src/components/Groups/ContextActions.vue/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/components/Groups/ContextActions.vue",
"repo_id": "owncloud",
"token_count": 659
} | 790 |
<template>
<div id="user-group-select-form">
<oc-select
:model-value="selectedOptions"
class="oc-mb-s"
:multiple="true"
:options="groupOptions"
option-label="displayName"
:label="$gettext('Groups')"
:fix-message-line="true"
v-bind="$attrs"
@update:model-value="onUpdate"
>
<template #selected-option="{ displayName, id }">
<span class="oc-flex oc-flex-center">
<avatar-image
class="oc-flex oc-align-self-center oc-mr-s"
:width="16.8"
:userid="id"
:user-name="displayName"
/>
<span>{{ displayName }}</span>
</span>
</template>
<template #option="{ displayName, id }">
<div class="oc-flex">
<span class="oc-flex oc-flex-center">
<avatar-image
class="oc-flex oc-align-self-center oc-mr-s"
:width="16.8"
:userid="id"
:user-name="displayName"
/>
<span>{{ displayName }}</span>
</span>
</div>
</template>
</oc-select>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, PropType, ref, unref, watch } from 'vue'
import { Group } from '@ownclouders/web-client/src/generated'
export default defineComponent({
name: 'GroupSelect',
props: {
selectedGroups: {
type: Array as PropType<Group[]>,
required: true
},
groupOptions: {
type: Array as PropType<Group[]>,
required: true
}
},
emits: ['selectedOptionChange'],
setup(props, { emit }) {
const selectedOptions = ref()
const onUpdate = (event) => {
selectedOptions.value = event
emit('selectedOptionChange', unref(selectedOptions))
}
const currentGroups = computed(() => props.selectedGroups)
watch(
currentGroups,
() => {
selectedOptions.value = props.selectedGroups
.map((g) => ({
...g,
readonly: g.groupTypes?.includes('ReadOnly')
}))
.sort((a: any, b: any) => b.readonly - a.readonly)
},
{ immediate: true }
)
return { selectedOptions, onUpdate }
}
})
</script>
| owncloud/web/packages/web-app-admin-settings/src/components/Users/GroupSelect.vue/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/components/Users/GroupSelect.vue",
"repo_id": "owncloud",
"token_count": 1049
} | 791 |
import { computed, Ref, unref } from 'vue'
import { useGettext } from 'vue3-gettext'
import { UserAction, useModals, useCapabilityStore } from '@ownclouders/web-pkg'
import { Group } from '@ownclouders/web-client/src/generated'
import AddToGroupsModal from '../../../components/Users/AddToGroupsModal.vue'
export const useUserActionsAddToGroups = ({ groups }: { groups: Ref<Group[]> }) => {
const { dispatchModal } = useModals()
const { $gettext, $ngettext } = useGettext()
const capabilityStore = useCapabilityStore()
const handler = ({ resources }) => {
dispatchModal({
title: $ngettext(
'Add user "%{user}" to groups',
'Add %{userCount} users to groups ',
resources.length,
{
user: resources[0].displayName,
userCount: resources.length.toString()
}
),
customComponent: AddToGroupsModal,
customComponentAttrs: () => ({
users: resources,
groups: unref(groups)
})
})
}
const actions = computed((): UserAction[] => [
{
name: 'add-to-groups',
icon: 'add',
componentType: 'button',
class: 'oc-users-actions-add-to-groups-trigger',
label: () => $gettext('Add to groups'),
isVisible: ({ resources }) => {
if (capabilityStore.graphUsersReadOnlyAttributes.includes('user.memberOf')) {
return false
}
return resources.length > 0
},
handler
}
])
return {
actions
}
}
| owncloud/web/packages/web-app-admin-settings/src/composables/actions/users/useUserActionsAddToGroups.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/composables/actions/users/useUserActionsAddToGroups.ts",
"repo_id": "owncloud",
"token_count": 603
} | 792 |
import translations from '../l10n/translations.json'
import General from './views/General.vue'
import Users from './views/Users.vue'
import Groups from './views/Groups.vue'
import Spaces from './views/Spaces.vue'
import { Ability } from '@ownclouders/web-client/src/helpers/resource/types'
import {
AppNavigationItem,
defineWebApplication,
useAbility,
useUserStore
} from '@ownclouders/web-pkg'
import { RouteRecordRaw } from 'vue-router'
// just a dummy function to trick gettext tools
function $gettext(msg) {
return msg
}
const appId = 'admin-settings'
export const routes = ({ $ability }: { $ability: Ability }) => [
{
path: '/',
redirect: () => {
if ($ability.can('read-all', 'Setting')) {
return { name: 'admin-settings-general' }
}
if ($ability.can('read-all', 'Account')) {
return { name: 'admin-settings-users' }
}
if ($ability.can('read-all', 'Group')) {
return { name: 'admin-settings-groups' }
}
if ($ability.can('read-all', 'Drive')) {
return { name: 'admin-settings-spaces' }
}
throw Error('Insufficient permissions')
}
},
{
path: '/general',
name: 'admin-settings-general',
component: General,
beforeEnter: (to, from, next) => {
if (!$ability.can('read-all', 'Setting')) {
next({ path: '/' })
}
next()
},
meta: {
authContext: 'user',
title: $gettext('General')
}
},
{
path: '/users',
name: 'admin-settings-users',
component: Users,
beforeEnter: (to, from, next) => {
if (!$ability.can('read-all', 'Account')) {
next({ path: '/' })
}
next()
},
meta: {
authContext: 'user',
title: $gettext('Users')
}
},
{
path: '/groups',
name: 'admin-settings-groups',
component: Groups,
beforeEnter: (to, from, next) => {
if (!$ability.can('read-all', 'Group')) {
next({ path: '/' })
}
next()
},
meta: {
authContext: 'user',
title: $gettext('Groups')
}
},
{
path: '/spaces',
name: 'admin-settings-spaces',
component: Spaces,
beforeEnter: (to, from, next) => {
if (!$ability.can('read-all', 'Drive')) {
next({ path: '/' })
}
next()
},
meta: {
authContext: 'user',
title: $gettext('Spaces')
}
}
]
export const navItems = ({ $ability }: { $ability: Ability }): AppNavigationItem[] => [
{
name: $gettext('General'),
icon: 'settings-4',
route: {
path: `/${appId}/general?`
},
isVisible: () => {
return $ability.can('read-all', 'Setting')
},
priority: 10
},
{
name: $gettext('Users'),
icon: 'user',
route: {
path: `/${appId}/users?`
},
isVisible: () => {
return $ability.can('read-all', 'Account')
},
priority: 20
},
{
name: $gettext('Groups'),
icon: 'group-2',
route: {
path: `/${appId}/groups?`
},
isVisible: () => {
return $ability.can('read-all', 'Group')
},
priority: 30
},
{
name: $gettext('Spaces'),
icon: 'layout-grid',
route: {
path: `/${appId}/spaces?`
},
isVisible: () => {
return $ability.can('read-all', 'Drive')
},
priority: 40
}
]
export default defineWebApplication({
setup() {
const { can } = useAbility()
const userStore = useUserStore()
return {
appInfo: {
name: $gettext('Admin Settings'),
id: appId,
icon: 'settings-4',
color: '#2b2b2b',
isFileEditor: false,
applicationMenu: {
enabled: () => {
return (
userStore.user &&
(can('read-all', 'Setting') ||
can('read-all', 'Account') ||
can('read-all', 'Group') ||
can('read-all', 'Drive'))
)
},
priority: 40
}
},
routes: routes as () => RouteRecordRaw[],
navItems,
translations
}
}
})
| owncloud/web/packages/web-app-admin-settings/src/index.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/index.ts",
"repo_id": "owncloud",
"token_count": 1856
} | 793 |
import MembersPanel from '../../../../../src/components/Spaces/SideBar/MembersPanel.vue'
import { defaultPlugins, shallowMount } from 'web-test-helpers'
import { mock } from 'vitest-mock-extended'
import { SpaceResource } from '@ownclouders/web-client/src/helpers'
import MembersRoleSection from '../../../../../src/components/Spaces/SideBar/MembersRoleSection.vue'
const spaceMock = mock<SpaceResource>({
spaceRoles: {
manager: [{ kind: 'user', displayName: 'admin' }],
editor: [
{ kind: 'user', displayName: 'einstein' },
{ kind: 'group', displayName: 'physic-haters' }
],
viewer: [{ kind: 'user', displayName: 'marie' }]
}
})
const selectors = {
membersRolePanelStub: 'members-role-section-stub'
}
describe('MembersPanel', () => {
it('should render all members accordingly to their role assignments', () => {
const { wrapper } = getWrapper()
expect(wrapper.html()).toMatchSnapshot()
})
it('should filter members accordingly to the entered search term', async () => {
const userToFilterFor = spaceMock.spaceRoles.editor[0]
const { wrapper } = getWrapper()
wrapper.vm.filterTerm = 'ein'
await wrapper.vm.$nextTick
expect(wrapper.findAll(selectors.membersRolePanelStub).length).toBe(1)
expect(
wrapper.findComponent<typeof MembersRoleSection>(selectors.membersRolePanelStub).props()
.members[0].displayName
).toEqual(userToFilterFor.displayName)
})
it('should display an empty result if no matching members found', async () => {
const { wrapper } = getWrapper()
wrapper.vm.filterTerm = 'no-match'
await wrapper.vm.$nextTick
expect(wrapper.findAll(selectors.membersRolePanelStub).length).toBe(0)
expect(wrapper.html()).toMatchSnapshot()
})
})
function getWrapper({ spaceResource = spaceMock } = {}) {
return {
wrapper: shallowMount(MembersPanel, {
global: {
plugins: [...defaultPlugins()],
provide: { resource: spaceResource }
}
})
}
}
| owncloud/web/packages/web-app-admin-settings/tests/unit/components/Spaces/SideBar/MembersPanel.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/components/Spaces/SideBar/MembersPanel.spec.ts",
"repo_id": "owncloud",
"token_count": 705
} | 794 |
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`LoginModal > renders the input including two options 1`] = `
"<div>
<oc-select-stub id="oc-select-1" filter="[Function]" disabled="false" label="Login" optionlabel="label" getoptionlabel="[Function]" searchable="true" clearable="false" loading="false" warningmessage="" fixmessageline="false" multiple="false" readonly="false" options="[object Object],[object Object]" placeholder="Select..."></oc-select-stub>
</div>"
`;
| owncloud/web/packages/web-app-admin-settings/tests/unit/components/Users/__snapshots__/LoginModal.spec.ts.snap/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/components/Users/__snapshots__/LoginModal.spec.ts.snap",
"repo_id": "owncloud",
"token_count": 152
} | 795 |
import { mockAxiosResolve } from 'web-test-helpers/src/mocks'
import { Graph, SpaceResource } from '@ownclouders/web-client'
import { mock, mockDeep } from 'vitest-mock-extended'
import { ClientService, useAppDefaults } from '@ownclouders/web-pkg'
import { defaultComponentMocks, defaultPlugins, mount } from 'web-test-helpers'
import Spaces from '../../../src/views/Spaces.vue'
import { useAppDefaultsMock } from 'web-test-helpers/src/mocks/useAppDefaultsMock'
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
queryItemAsString: vi.fn(),
useAppDefaults: vi.fn(),
useRouteQueryPersisted: vi.fn()
}))
vi.mocked(useAppDefaults).mockImplementation(() => useAppDefaultsMock({}))
const selectors = {
loadingSpinnerStub: 'app-loading-spinner-stub',
spacesListStub: 'spaces-list-stub',
noContentMessageStub: 'no-content-message-stub',
batchActionsStub: 'batch-actions-stub'
}
describe('Spaces view', () => {
describe('loading states', () => {
it('should show loading spinner if loading', () => {
const { wrapper } = getWrapper()
expect(wrapper.find(selectors.loadingSpinnerStub).exists()).toBeTruthy()
})
it('should render spaces list after loading has been finished', async () => {
const spaces = [{ id: '1', name: 'Some Space' }]
const { wrapper } = getWrapper({ spaces })
await wrapper.vm.loadResourcesTask.last
expect(wrapper.html()).toMatchSnapshot()
expect(wrapper.find(selectors.spacesListStub).exists()).toBeTruthy()
})
})
it('should render no content message if no spaces found', async () => {
const graph = mockDeep<Graph>()
graph.drives.listAllDrives.mockResolvedValue(mockAxiosResolve({ value: [] }))
const { wrapper } = getWrapper({ spaces: [] })
await wrapper.vm.loadResourcesTask.last
expect(wrapper.find(selectors.noContentMessageStub).exists()).toBeTruthy()
})
describe('batch actions', () => {
it('do not display when no space selected', async () => {
const { wrapper } = getWrapper()
await wrapper.vm.loadResourcesTask.last
expect(wrapper.find(selectors.batchActionsStub).exists()).toBeFalsy()
})
it('display when one space selected', async () => {
const spaces = [{ id: '1', name: 'Some Space' }]
const { wrapper } = getWrapper({ spaces, selectedSpaces: spaces })
await wrapper.vm.loadResourcesTask.last
await wrapper.vm.$nextTick()
expect(wrapper.find(selectors.batchActionsStub).exists()).toBeTruthy()
})
it('display when more than one space selected', async () => {
const spaces = [
{ id: '1', name: 'Some Space' },
{ id: '1', name: 'Some other Space' }
]
const { wrapper } = getWrapper({ spaces, selectedSpaces: spaces })
await wrapper.vm.loadResourcesTask.last
await wrapper.vm.$nextTick()
expect(wrapper.find(selectors.batchActionsStub).exists()).toBeTruthy()
})
})
})
function getWrapper({
spaces = [
{
id: '1',
name: 'space'
}
],
selectedSpaces = []
} = {}) {
const $clientService = mockDeep<ClientService>()
$clientService.graphAuthenticated.drives.listAllDrives.mockResolvedValue(
mockAxiosResolve({ value: spaces })
)
const mocks = {
...defaultComponentMocks(),
$clientService
}
return {
wrapper: mount(Spaces, {
global: {
plugins: [
...defaultPlugins({
piniaOptions: {
spaceSettingsStore: {
spaces: spaces.map((s) => mock<SpaceResource>(s)),
selectedSpaces
}
}
})
],
mocks,
provide: mocks,
stubs: {
AppLoadingSpinner: true,
NoContentMessage: true,
SpacesList: true,
OcBreadcrumb: true,
BatchActions: true,
ViewOptions: true
}
}
})
}
}
| owncloud/web/packages/web-app-admin-settings/tests/unit/views/Spaces.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/views/Spaces.spec.ts",
"repo_id": "owncloud",
"token_count": 1565
} | 796 |
import { defaultPlugins, getOcSelectOptions, mount, nextTicks } from 'web-test-helpers'
import App from '../../src/App.vue'
import { useLocalStorage } from '@ownclouders/web-pkg'
import { Resource } from '@ownclouders/web-client'
import { mock } from 'vitest-mock-extended'
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
useLocalStorage: vi.fn()
}))
vi.mock('epubjs', () => ({
__esModule: true,
default: vi.fn(() => {
return {
loaded: {
navigation: Promise.resolve({
toc: [
{ id: '1', label: 'Chapter 1', href: 'c1' },
{ id: '2', label: 'Chapter 2', href: 'c2' }
]
})
},
renderTo: vi.fn(() => ({
on: vi.fn(),
themes: {
register: vi.fn(),
select: vi.fn(),
fontSize: vi.fn()
},
display: vi.fn(),
prev: vi.fn(),
next: vi.fn()
}))
}
})
}))
const selectors = {
increaseFontSize: '.epub-reader-controls-font-size-increase',
decreaseFontSize: '.epub-reader-controls-font-size-decrease',
resetFontSize: '.epub-reader-controls-font-size-reset',
chaptersListItem: '.epub-reader-chapters-list-item',
chaptersSelect: '.epub-reader-controls-chapters-select',
navigateLeft: '.epub-reader-navigate-left',
navigateRight: '.epub-reader-navigate-right'
}
describe('Epub reader app', () => {
it('renders correctly', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
expect(wrapper.html()).toMatchSnapshot()
})
describe('theme', () => {
it('sets the theme based on current theme setting', async () => {
const { wrapper } = getWrapper({ localStorageGeneral: { fontSizePercentage: 50 } })
await nextTicks(2)
expect(wrapper.vm.rendition.themes.select).toHaveBeenCalledWith('light')
})
})
describe('font size', () => {
it('initializes with default font size percentage', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
expect(wrapper.vm.rendition.themes.fontSize).toHaveBeenCalledWith('100%')
})
it('initializes with local storage font size when set', async () => {
const { wrapper } = getWrapper({ localStorageGeneral: { fontSizePercentage: 50 } })
await nextTicks(2)
expect(wrapper.vm.rendition.themes.fontSize).toHaveBeenCalledWith('50%')
})
describe('increase font size button', () => {
it('increases font size when clicked', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
await wrapper.find(selectors.increaseFontSize).trigger('click')
expect(wrapper.vm.rendition.themes.fontSize).toHaveBeenCalledWith('110%')
})
it('is disabled when "MAX_FONT_SIZE_PERCENTAGE" is reached', () => {
const { wrapper } = getWrapper({ localStorageGeneral: { fontSizePercentage: 150 } })
expect(
wrapper.find<HTMLButtonElement>(selectors.increaseFontSize).element.disabled
).toBeTruthy()
})
})
describe('decrease font size button', () => {
it('decreases font size when clicked', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
await wrapper.find(selectors.decreaseFontSize).trigger('click')
expect(wrapper.vm.rendition.themes.fontSize).toHaveBeenCalledWith('90%')
})
it('is disabled when "MIN_FONT_SIZE_PERCENTAGE" is reached', () => {
const { wrapper } = getWrapper({ localStorageGeneral: { fontSizePercentage: 50 } })
expect(
wrapper.find<HTMLButtonElement>(selectors.decreaseFontSize).element.disabled
).toBeTruthy()
})
})
describe('reset font size button', () => {
it('resets font size when clicked', async () => {
const { wrapper } = getWrapper({ localStorageGeneral: { fontSizePercentage: 50 } })
await nextTicks(2)
await wrapper.find(selectors.resetFontSize).trigger('click')
expect(wrapper.vm.rendition.themes.fontSize).toHaveBeenCalledWith('100%')
})
it('shows the current font size', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
await wrapper.find(selectors.decreaseFontSize).trigger('click')
expect(wrapper.find(selectors.resetFontSize).text()).toBe('90%')
})
})
})
describe('location', () => {
it('initializes with local storage location when set', async () => {
const { wrapper } = getWrapper({
localStorageResource: {
currentLocation: { start: { cfi: 'epubcfi(/6/4!/4/4/14/2/150/2/1:23)' } }
}
})
await nextTicks(2)
expect(wrapper.vm.rendition.display).toHaveBeenCalledWith(
'epubcfi(/6/4!/4/4/14/2/150/2/1:23)'
)
})
})
describe('chapters', () => {
describe('chapters list', () => {
it('renders correctly', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
const chapterElements = wrapper.findAll(selectors.chaptersListItem)
expect(chapterElements.length).toEqual(2)
expect(chapterElements[0].text()).toEqual('Chapter 1')
expect(chapterElements[1].text()).toEqual('Chapter 2')
})
it('calls method "display" when item is clicked', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
const chapterElements = wrapper.findAll(selectors.chaptersListItem)
await chapterElements[1].find('.oc-button').trigger('click')
expect(wrapper.vm.rendition.display).toHaveBeenCalledWith('c2')
})
})
describe('chapters select', () => {
it('renders correctly', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
const chapterElements = await getOcSelectOptions(wrapper, selectors.chaptersSelect)
expect(chapterElements.length).toEqual(2)
expect(chapterElements[0].text()).toEqual('Chapter 1')
expect(chapterElements[1].text()).toEqual('Chapter 2')
})
it('calls method "display" when item is clicked', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
const chapterElements = await getOcSelectOptions(wrapper, selectors.chaptersSelect, {
close: false
})
await chapterElements[1].trigger('click')
expect(wrapper.vm.rendition.display).toHaveBeenCalledWith('c2')
})
})
})
describe('navigate', () => {
describe('keyboard navigation', () => {
it('calls method "prev" when left arrow key is pressed', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
const keyboardEvent = new KeyboardEvent('keydown', { key: 'ArrowLeft' })
document.dispatchEvent(keyboardEvent)
expect(wrapper.vm.rendition.prev).toHaveBeenCalled()
})
it('calls method "next" when right arrow key is pressed', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
const keyboardEvent = new KeyboardEvent('keydown', { key: 'ArrowRight' })
document.dispatchEvent(keyboardEvent)
expect(wrapper.vm.rendition.next).toHaveBeenCalled()
})
})
describe('navigate left button', () => {
it('calls method "prev" when clicked', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
await wrapper.find(selectors.navigateLeft).trigger('click')
expect(wrapper.vm.rendition.prev).toHaveBeenCalled()
})
})
describe('navigate right button', () => {
it('calls method "next" when clicked', async () => {
const { wrapper } = getWrapper()
await nextTicks(2)
await wrapper.find(selectors.navigateRight).trigger('click')
expect(wrapper.vm.rendition.next).toHaveBeenCalled()
})
})
})
})
function getWrapper({
propsData = {},
localStorageGeneral = {},
localStorageResource = {}
}: {
propsData?: Record<string, unknown>
localStorageGeneral?: ReturnType<typeof useLocalStorage>
localStorageResource?: ReturnType<typeof useLocalStorage>
} = {}) {
vi.mocked(useLocalStorage).mockImplementationOnce(() => localStorageGeneral)
vi.mocked(useLocalStorage).mockImplementationOnce(() => localStorageResource)
return {
wrapper: mount(App, {
props: {
applicationConfig: {},
currentContent: '',
isReadOnly: false,
resource: mock<Resource>({
id: '1'
}),
...propsData
},
global: {
plugins: [...defaultPlugins()]
}
})
}
}
| owncloud/web/packages/web-app-epub-reader/tests/unit/app.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-epub-reader/tests/unit/app.spec.ts",
"repo_id": "owncloud",
"token_count": 3480
} | 797 |
<template>
<nav id="shares-navigation" class="oc-py-s" :aria-label="$gettext('Shares pages navigation')">
<oc-list class="oc-flex oc-visible@s">
<li v-for="navItem in navItems" :key="`shares-navigation-desktop-${navItem.to}`">
<oc-button
type="router-link"
class="oc-mr-m oc-py-s shares-nav-desktop"
appearance="raw"
:to="navItem.to"
>
<oc-icon size="small" :name="navItem.icon" />
<span v-text="navItem.text" />
</oc-button>
</li>
</oc-list>
<div class="oc-hidden@s">
<oc-button id="shares_navigation_mobile" appearance="raw">
<span v-text="currentNavItem.text" />
<oc-icon name="arrow-down-s" fill-type="line" size="small" />
</oc-button>
<oc-drop toggle="#shares_navigation_mobile" mode="click" close-on-click padding-size="small">
<oc-list>
<li v-for="navItem in navItems" :key="`shares-navigation-mobile-${navItem.to}`">
<oc-button
type="router-link"
class="oc-my-xs shares-nav-mobile"
:to="navItem.to"
:class="{ 'oc-background-primary-gradient': navItem.active }"
:appearance="navItem.active ? 'raw-inverse' : 'raw'"
:variation="navItem.active ? 'primary' : 'passive'"
>
<span class="icon-box" :class="{ 'icon-box-active': navItem.active }">
<oc-icon :name="navItem.icon" />
</span>
<span v-text="navItem.text" />
</oc-button>
</li>
</oc-list>
</oc-drop>
</div>
</nav>
</template>
<script lang="ts">
import { isLocationSharesActive } from '@ownclouders/web-pkg'
import {
locationSharesViaLink,
locationSharesWithMe,
locationSharesWithOthers
} from '@ownclouders/web-pkg'
import { computed, defineComponent, unref } from 'vue'
import { useRouter } from '@ownclouders/web-pkg'
import { useActiveLocation } from '@ownclouders/web-pkg'
import { useGettext } from 'vue3-gettext'
export default defineComponent({
setup() {
const { $gettext } = useGettext()
const router = useRouter()
const sharesRoutes = [
locationSharesWithMe,
locationSharesWithOthers,
locationSharesViaLink
].reduce((routes, route) => {
routes[route.name] = router.getRoutes().find((r) => r.name === route.name)
return routes
}, {})
const sharesWithMeActive = useActiveLocation(
isLocationSharesActive,
locationSharesWithMe.name as string
)
const sharesWithOthersActive = useActiveLocation(
isLocationSharesActive,
locationSharesWithOthers.name as string
)
const sharesViaLinkActive = useActiveLocation(
isLocationSharesActive,
locationSharesViaLink.name as string
)
const navItems = computed(() => [
{
icon: 'share-forward',
to: sharesRoutes[locationSharesWithMe.name].path,
text: $gettext('Shared with me'),
active: unref(sharesWithMeActive)
},
{
icon: 'reply',
to: sharesRoutes[locationSharesWithOthers.name].path,
text: $gettext('Shared with others'),
active: unref(sharesWithOthersActive)
},
{
icon: 'link',
to: sharesRoutes[locationSharesViaLink.name].path,
text: $gettext('Shared via link'),
active: unref(sharesViaLinkActive)
}
])
const currentNavItem = computed(() => unref(navItems).find((navItem) => navItem.active))
return {
currentNavItem,
navItems
}
}
})
</script>
<style lang="scss" scoped>
#shares-navigation {
a {
gap: var(--oc-space-medium);
width: 100%;
&:focus,
&:hover {
text-decoration: none;
}
&.shares-nav-mobile {
justify-content: flex-start;
}
.icon-box {
display: inline-flex;
justify-content: center;
align-items: center;
width: 40px;
height: 40px;
}
.icon-box-active {
box-shadow: 2px 0 6px rgba(0, 0, 0, 0.14);
}
}
.shares-nav-desktop.router-link-active {
border-bottom: 2px solid var(--oc-color-swatch-primary-default) !important;
border-radius: 0;
}
}
</style>
| owncloud/web/packages/web-app-files/src/components/AppBar/SharesNavigation.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/AppBar/SharesNavigation.vue",
"repo_id": "owncloud",
"token_count": 1902
} | 798 |
<template>
<oc-select
ref="tagSelect"
v-model="selectedTags"
class="tags-select"
:multiple="true"
:disabled="readonly"
:options="availableTags"
taggable
:select-on-key-codes="selectOnKeyCodes"
:create-option="createOption"
:selectable="isOptionSelectable"
:map-keydown="keydownMethods"
@update:model-value="save"
>
<template #selected-option-container="{ option, deselect }">
<oc-tag class="tags-select-tag oc-ml-xs" :rounded="true" size="small">
<component
:is="type"
v-bind="getAdditionalAttributes(option.label)"
class="oc-flex oc-flex-middle"
@click="onTagClicked"
>
<oc-icon name="price-tag-3" class="oc-mr-xs" size="small" />
<span class="oc-text-truncate">{{ option.label }}</span>
</component>
<span class="oc-flex oc-flex-middle oc-mr-xs">
<oc-icon v-if="option.readonly" class="vs__deselect-lock" name="lock" size="small" />
<oc-button
v-else
appearance="raw"
:title="$gettext('Deselect %{label}', { label: option.label })"
:aria-label="$gettext('Deselect %{label}', { label: option.label })"
class="vs__deselect oc-mx-rm"
@mousedown.stop.prevent
@click="deselect(option)"
>
<oc-icon name="close" size="small" />
</oc-button>
</span>
</oc-tag>
</template>
<template #option="{ label, error }">
<div class="oc-flex test">
<span class="oc-flex oc-flex-center">
<oc-tag class="tags-select-tag oc-ml-xs" :rounded="true" size="small">
<oc-icon name="price-tag-3" size="small" />
<span class="oc-text-truncate">{{ label }}</span>
</oc-tag>
</span>
</div>
<div v-if="error" class="oc-text-input-danger">{{ error }}</div>
</template>
<template #no-options
><span class="oc-text-small oc-text-muted" v-text="$gettext('Enter text to create a Tag')" />
</template>
</oc-select>
</template>
<script lang="ts">
import {
computed,
defineComponent,
onMounted,
PropType,
ref,
toRef,
unref,
VNodeRef,
watch
} from 'vue'
import {
createLocationCommon,
eventBus,
isLocationPublicActive,
SideBarEventTopics,
useClientService,
useMessages,
useResourcesStore,
useRouter
} from '@ownclouders/web-pkg'
import { useGettext } from 'vue3-gettext'
import { useTask } from 'vue-concurrency'
import diff from 'lodash-es/difference'
import { Resource } from '@ownclouders/web-client'
type TagOption = {
label: string
error?: string
selectable?: boolean
}
const tagsMaxCount = 100
// the keycode property is deprecated in the JS event API, vue-select still works with it though
enum KeyCode {
Backspace = 8,
Enter = 13,
',' = 188
}
export default defineComponent({
name: 'TagsSelect',
props: {
/**
* The resource
*/
resource: {
type: Object as PropType<Resource>,
required: true
}
},
setup(props) {
const { showErrorMessage } = useMessages()
const clientService = useClientService()
const router = useRouter()
const { updateResourceField } = useResourcesStore()
const isPublicLocation = isLocationPublicActive(router, 'files-public-link')
const type = unref(isPublicLocation) ? 'span' : 'router-link'
const resource = toRef(props, 'resource')
const { $gettext } = useGettext()
const readonly = computed(
() =>
unref(resource).locked === true ||
(typeof unref(resource).canEditTags === 'function' &&
unref(resource).canEditTags() === false)
)
const selectedTags = ref<TagOption[]>([])
const availableTags = ref<TagOption[]>([])
let allTags: string[] = []
const tagSelect: VNodeRef = ref(null)
const currentTags = computed<TagOption[]>(() => {
return [...unref(resource).tags.map((t) => ({ label: t }))]
})
const onTagClicked = () => {
eventBus.publish(SideBarEventTopics.close)
}
const loadAvailableTagsTask = useTask(function* () {
const {
data: { value: tags = [] }
} = yield clientService.graphAuthenticated.tags.getTags()
allTags = tags
const selectedLabels = new Set(unref(selectedTags).map((o) => o.label))
availableTags.value = tags
.filter((t) => selectedLabels.has(t) === false)
.map((t) => ({ label: t }))
})
const revertChanges = () => {
selectedTags.value = unref(currentTags)
}
const createOption = (label: string): TagOption => {
if (!label.trim().length) {
return {
label: label.toLowerCase().trim(),
error: $gettext('Tag must not consist of blanks only'),
selectable: false
}
}
return { label: label.toLowerCase().trim() }
}
const isOptionSelectable = (option: TagOption) => {
return unref(selectedTags).length <= tagsMaxCount && option.selectable !== false
}
const showSelectNewLabel = (option: TagOption) => {
return !unref(tagSelect).$refs.select.optionExists(option)
}
const save = async (e: TagOption[] | string[]) => {
try {
selectedTags.value = e.map((x) => (typeof x === 'object' ? x : { label: x }))
const allAvailableTags = new Set([...allTags, ...unref(availableTags).map((t) => t.label)])
availableTags.value = diff(
Array.from(allAvailableTags),
unref(selectedTags).map((o) => o.label)
).map((label) => ({
label
}))
const { id, tags, fileId } = unref(resource)
const selectedTagLabels = unref(selectedTags).map((t) => t.label)
const tagsToAdd = diff(selectedTagLabels, tags)
const tagsToRemove = diff(tags, selectedTagLabels)
if (tagsToAdd.length) {
await clientService.graphAuthenticated.tags.assignTags({
resourceId: fileId,
tags: tagsToAdd
})
}
if (tagsToRemove.length) {
await clientService.graphAuthenticated.tags.unassignTags({
resourceId: fileId,
tags: tagsToRemove
})
}
updateResourceField({ id: id, field: 'tags', value: [...selectedTagLabels] })
eventBus.publish('sidebar.entity.saved')
if (unref(tagSelect) !== null) {
unref(tagSelect).$refs.search.focus()
}
allTags.push(...tagsToAdd)
} catch (e) {
console.error(e)
showErrorMessage({
title: $gettext('Failed to edit tags'),
errors: [e]
})
}
}
watch(resource, () => {
if (unref(resource)?.tags) {
revertChanges()
loadAvailableTagsTask.perform()
}
})
onMounted(() => {
if (unref(resource)?.tags) {
selectedTags.value = unref(currentTags)
}
/**
* If the user can't edit the tags, for example on a public link, there is no need to load the available tags
*/
if (!unref(readonly)) {
loadAvailableTagsTask.perform()
}
})
const keydownMethods = (map, vm) => {
const objectMapping = {
...map
}
objectMapping[KeyCode.Backspace] = async (e) => {
if (e.target.value || selectedTags.value.length === 0) {
return
}
e.preventDefault()
availableTags.value.push(selectedTags.value.pop())
await save(unref(selectedTags))
}
return objectMapping
}
const generateTagLink = (tag: string) => {
const currentTerm = unref(router.currentRoute).query?.term
return createLocationCommon('files-common-search', {
query: { provider: 'files.sdk', q_tags: tag, ...(currentTerm && { term: currentTerm }) }
})
}
const getAdditionalAttributes = (tag: string) => {
if (unref(isPublicLocation)) {
return {}
}
return {
to: generateTagLink(tag),
class: 'tags-control-tag-link'
}
}
return {
loadAvailableTagsTask,
availableTags,
tagsMaxCount,
selectedTags,
tagSelect,
currentTags,
revertChanges,
createOption,
isOptionSelectable,
showSelectNewLabel,
save,
selectOnKeyCodes: [KeyCode.Enter, KeyCode[',']],
keydownMethods,
readonly,
getAdditionalAttributes,
onTagClicked,
isPublicLocation,
type
}
}
})
</script>
<style lang="scss">
.tags-select {
.vs__actions {
display: none !important;
}
&-tag {
height: 1.5rem;
&-link {
color: var(--oc-color-swatch-passive-default);
pointer-events: visible;
}
}
}
</style>
| owncloud/web/packages/web-app-files/src/components/SideBar/Details/TagsSelect.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/SideBar/Details/TagsSelect.vue",
"repo_id": "owncloud",
"token_count": 3789
} | 799 |
<template>
<div>
<oc-loader v-if="sharesLoading" :aria-label="$gettext('Loading list of shares')" />
<template v-else>
<space-members
v-if="showSpaceMembers"
ref="peopleShares"
class="oc-background-highlight oc-p-m oc-mb-s"
/>
<file-shares v-else ref="peopleShares" class="oc-background-highlight oc-p-m oc-mb-s" />
<file-links v-if="showLinks" ref="linkShares" class="oc-background-highlight oc-p-m" />
</template>
</div>
</template>
<script lang="ts">
import { ComponentPublicInstance, defineComponent, inject, Ref } from 'vue'
import FileLinks from './FileLinks.vue'
import FileShares from './FileShares.vue'
import SpaceMembers from './SpaceMembers.vue'
import { useSharesStore } from '@ownclouders/web-pkg'
import { Resource } from '@ownclouders/web-client'
import { storeToRefs } from 'pinia'
export default defineComponent({
name: 'SharesPanel',
components: {
FileLinks,
FileShares,
SpaceMembers
},
props: {
showSpaceMembers: { type: Boolean, default: false },
showLinks: { type: Boolean, default: false }
},
emits: ['scrollToElement'],
setup() {
const sharesStore = useSharesStore()
const { loading: sharesLoading } = storeToRefs(sharesStore)
return {
sharesLoading,
resource: inject<Ref<Resource>>('resource'),
activePanel: inject<String>('activePanel')
}
},
watch: {
sharesLoading: {
handler: function (sharesLoading, old) {
// FIXME: !old can be removed as soon as https://github.com/owncloud/web/issues/7621 has been fixed
if (!this.activePanel || !old) {
return
}
this.$nextTick(() => {
const [panelName, ref] = this.activePanel.split('#')
if (!ref || !this.$refs[ref]) {
return
}
this.$emit('scrollToElement', {
element: (this.$refs[ref] as ComponentPublicInstance).$el,
panelName
})
})
},
immediate: true
}
}
})
</script>
| owncloud/web/packages/web-app-files/src/components/SideBar/Shares/SharesPanel.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/SideBar/Shares/SharesPanel.vue",
"repo_id": "owncloud",
"token_count": 835
} | 800 |
import { QueryValue, useResourcesStore, FolderViewModeConstants } from '@ownclouders/web-pkg'
import { useScrollTo } from '@ownclouders/web-pkg'
import { Ref, ref, unref, nextTick, watchEffect } from 'vue'
import { Key, KeyboardActions, ModifierKey } from '@ownclouders/web-pkg'
import { Resource } from '@ownclouders/web-client'
import { findIndex } from 'lodash-es'
import { storeToRefs } from 'pinia'
const enum Direction {
LEFT = 'left',
RIGHT = 'right'
}
export const useKeyboardTableNavigation = (
keyActions: KeyboardActions,
paginatedResources: Ref<Resource[]>,
viewMode: Ref<string | QueryValue>
) => {
const { scrollToResource } = useScrollTo()
const resourcesStore = useResourcesStore()
const { latestSelectedId } = storeToRefs(resourcesStore)
const bindKeyActionsIds = ref([])
const tileViewStart = ref(null)
const tileViewDirection = ref(null)
keyActions.bindKeyAction({ modifier: ModifierKey.Ctrl, primary: Key.A }, () =>
handleSelectAllAction()
)
keyActions.bindKeyAction({ primary: Key.Space }, () => {
resourcesStore.toggleSelection(unref(latestSelectedId))
})
keyActions.bindKeyAction({ primary: Key.Esc }, () => {
keyActions.resetSelectionCursor()
tileViewStart.value = null
resourcesStore.resetSelection()
})
const bindTilesViewKeyActions = () => {
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ primary: Key.ArrowLeft }, () => handleNavigateAction(true))
)
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ primary: Key.ArrowRight }, () => handleNavigateAction())
)
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ primary: Key.ArrowUp }, async () => {
const elementsInRow = getElementsInRow()
if (elementsInRow === -1) {
return
}
await handleNavigateAction(true, elementsInRow)
})
)
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ primary: Key.ArrowDown }, async () => {
const elementsInRow = getElementsInRow()
if (elementsInRow === -1) {
return
}
await handleNavigateAction(false, elementsInRow)
})
)
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ modifier: ModifierKey.Shift, primary: Key.ArrowLeft }, () =>
handleTilesShiftHorizontalAction(Direction.LEFT)
)
)
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ modifier: ModifierKey.Shift, primary: Key.ArrowRight }, () =>
handleTilesShiftHorizontalAction(Direction.RIGHT)
)
)
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ modifier: ModifierKey.Shift, primary: Key.ArrowUp }, () => {
handleTilesShiftUpAction()
})
)
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ modifier: ModifierKey.Shift, primary: Key.ArrowDown }, () => {
handleTilesShiftDownAction()
})
)
}
const bindTableViewKeyActions = () => {
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ primary: Key.ArrowUp }, () => handleNavigateAction(true))
)
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ primary: Key.ArrowDown }, () => handleNavigateAction())
)
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ modifier: ModifierKey.Shift, primary: Key.ArrowUp }, () =>
handleShiftUpAction()
)
)
bindKeyActionsIds.value.push(
keyActions.bindKeyAction({ modifier: ModifierKey.Shift, primary: Key.ArrowDown }, () =>
handleShiftDownAction()
)
)
}
const handleNavigateAction = async (up = false, moveBy = 1) => {
const nextId = !unref(latestSelectedId) ? getFirstResourceId() : getNextResourceId(up, moveBy)
if (nextId === -1) {
return
}
keyActions.resetSelectionCursor()
tileViewStart.value = null
resourcesStore.resetSelection()
await nextTick()
resourcesStore.addSelection(nextId)
await nextTick()
scrollToResource(nextId, { topbarElement: 'files-app-bar' })
}
const getNextResourceId = (previous = false, movedBy = 1) => {
const latestSelectedResourceIndex = paginatedResources.value.findIndex(
(resource) => resource.id === latestSelectedId.value
)
if (latestSelectedResourceIndex === -1) {
return -1
}
const step = previous ? -movedBy : movedBy
let nextResourceIndex = latestSelectedResourceIndex + step
while (nextResourceIndex >= 0 && nextResourceIndex < paginatedResources.value.length) {
if (paginatedResources.value[nextResourceIndex].processing !== true) {
return paginatedResources.value[nextResourceIndex].id
}
nextResourceIndex += step
}
if (nextResourceIndex < 0 || nextResourceIndex >= paginatedResources.value.length) {
return -1
}
return paginatedResources.value[nextResourceIndex].id
}
const getFirstResourceId = () => {
return paginatedResources.value.length ? paginatedResources.value[0].id : -1
}
const getElementsInRow = () => {
const tilesListCard = document.querySelectorAll('#tiles-view > ul > li > div')
if (tilesListCard.length === 0) {
return -1
}
const firstElement = Math.floor(tilesListCard[0].getBoundingClientRect().x)
let elementsInRow = 1
for (let i = 1; i < tilesListCard.length; i++) {
if (Math.floor(tilesListCard[i].getBoundingClientRect().x) !== firstElement) {
elementsInRow++
} else {
break
}
}
return elementsInRow
}
const handleSelectAllAction = () => {
keyActions.resetSelectionCursor()
resourcesStore.setSelection(
unref(paginatedResources)
.filter((resource) => resource.processing !== true)
.map(({ id }) => id)
)
}
const getVerticalProperties = (viewDirection: Direction) => {
const elementsInRow = getElementsInRow()
if (elementsInRow === -1) {
return {}
}
if (!unref(tileViewStart)) {
tileViewStart.value = latestSelectedId.value
tileViewDirection.value = viewDirection
}
const tilesListCard = document.querySelectorAll('#tiles-view > ul > li > div')
const currentResourceIndex = findIndex(
tilesListCard,
(tile) => tile.getAttribute('data-item-id') === unref(latestSelectedId).toString()
)
const tileViewStartIndex = findIndex(tilesListCard, (tile) => {
return tile.getAttribute('data-item-id') === unref(tileViewStart).toString()
})
const nextIndex =
viewDirection === Direction.LEFT
? currentResourceIndex - elementsInRow
: currentResourceIndex + elementsInRow
if (!tilesListCard[nextIndex]) {
return {}
}
const lastSelectedFileId = tilesListCard[nextIndex].getAttribute('data-item-id')
return {
currentResourceIndex,
nextIndex,
tilesListCard,
tileViewStartIndex,
lastSelectedFileId
}
}
const handleTilesShiftUpAction = () => {
const vp = getVerticalProperties(Direction.LEFT)
if (Object.keys(vp).length === 0) {
return
}
for (let i = vp.currentResourceIndex; i >= vp.nextIndex; i--) {
if (i === vp.tileViewStartIndex) {
continue
}
const id = vp.tilesListCard[i].getAttribute('data-item-id')
i < vp.tileViewStartIndex
? resourcesStore.addSelection(id)
: resourcesStore.removeSelection(id)
}
resourcesStore.setLastSelectedId(vp.lastSelectedFileId)
}
const handleTilesShiftDownAction = () => {
const vp = getVerticalProperties(Direction.RIGHT)
if (Object.keys(vp).length === 0) {
return
}
for (let i = vp.currentResourceIndex; i <= vp.nextIndex; i++) {
if (i === vp.tileViewStartIndex) {
continue
}
const id = vp.tilesListCard[i].getAttribute('data-item-id')
i > vp.tileViewStartIndex
? resourcesStore.addSelection(id)
: resourcesStore.removeSelection(id)
}
resourcesStore.setLastSelectedId(vp.lastSelectedFileId)
}
const handleTilesShiftHorizontalAction = (direction: Direction) => {
const nextResourceId = !unref(latestSelectedId)
? getFirstResourceId()
: getNextResourceId(direction === Direction.LEFT, 1)
if (nextResourceId === -1) {
return
}
if (unref(latestSelectedId) === unref(tileViewStart)) {
tileViewStart.value = unref(latestSelectedId)
tileViewDirection.value = direction
}
if (!unref(tileViewStart)) {
tileViewStart.value = latestSelectedId.value
tileViewDirection.value = direction
}
if (tileViewDirection.value !== direction && tileViewDirection.value !== null) {
resourcesStore.toggleSelection(unref(latestSelectedId))
resourcesStore.setLastSelectedId(nextResourceId)
}
if (tileViewDirection.value === direction) {
resourcesStore.addSelection(nextResourceId)
}
}
const handleShiftUpAction = (movedBy = 1) => {
const nextResourceId = getNextResourceId(true, movedBy)
if (nextResourceId === -1) {
return
}
if (unref(keyActions.selectionCursor) > 0) {
resourcesStore.toggleSelection(unref(latestSelectedId))
resourcesStore.setLastSelectedId(nextResourceId)
} else {
resourcesStore.addSelection(nextResourceId)
}
scrollToResource(nextResourceId, { topbarElement: 'files-app-bar' })
keyActions.selectionCursor.value = unref(keyActions.selectionCursor) - 1
}
const handleShiftDownAction = (movedBy = 1) => {
const nextResourceId = getNextResourceId(false, movedBy)
if (nextResourceId === -1) {
return
}
if (unref(keyActions.selectionCursor) < 0) {
resourcesStore.toggleSelection(unref(latestSelectedId))
resourcesStore.setLastSelectedId(nextResourceId)
} else {
resourcesStore.addSelection(nextResourceId)
}
scrollToResource(nextResourceId, { topbarElement: 'files-app-bar' })
keyActions.selectionCursor.value = unref(keyActions.selectionCursor) + 1
}
watchEffect(() => {
bindKeyActionsIds.value.forEach((id) => keyActions.removeKeyAction(id))
bindKeyActionsIds.value = []
FolderViewModeConstants.name.tiles === viewMode.value
? bindTilesViewKeyActions()
: bindTableViewKeyActions()
})
}
| owncloud/web/packages/web-app-files/src/composables/keyboardActions/useKeyboardTableNavigation.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/composables/keyboardActions/useKeyboardTableNavigation.ts",
"repo_id": "owncloud",
"token_count": 3911
} | 801 |
import Preview from './preview'
import List from './list'
import { Router } from 'vue-router'
import {
CapabilityStore,
SearchFunction,
SearchList,
SearchPreview,
SearchProvider
} from '@ownclouders/web-pkg'
function $gettext(msg) {
return msg
}
export default class Provider implements SearchProvider {
public readonly id: string
public readonly displayName: string
public readonly previewSearch: SearchPreview
public readonly listSearch: SearchList
private readonly capabilityStore: CapabilityStore
constructor(capabilityStore: CapabilityStore, router: Router, searchFunction: SearchFunction) {
this.id = 'files.sdk'
this.displayName = $gettext('Files')
this.previewSearch = new Preview(router, searchFunction)
this.listSearch = new List(searchFunction)
this.capabilityStore = capabilityStore
}
public get available(): boolean {
return this.capabilityStore.davReports.includes('search-files')
}
}
| owncloud/web/packages/web-app-files/src/search/sdk/index.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/search/sdk/index.ts",
"repo_id": "owncloud",
"token_count": 280
} | 802 |
<template>
<div class="oc-flex">
<files-view-wrapper>
<app-bar :is-side-bar-open="isSideBarOpen">
<template #navigation>
<SharesNavigation />
</template>
</app-bar>
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<no-content-message
v-if="isEmpty"
id="files-shared-via-link-empty"
class="files-empty"
icon="link"
>
<template #message>
<span v-translate>You have not shared any resource via link.</span>
</template>
</no-content-message>
<resource-table
v-else
v-model:selectedIds="selectedResourcesIds"
:is-side-bar-open="isSideBarOpen"
:fields-displayed="['name', 'sharedWith', 'sdate']"
:are-thumbnails-displayed="displayThumbnails"
:are-paths-displayed="true"
:resources="paginatedResources"
:header-position="fileListHeaderY"
:sort-by="sortBy"
:sort-dir="sortDir"
@file-click="triggerDefaultAction"
@row-mounted="rowMounted"
@sort="handleSort"
>
<template #contextMenu="{ resource }">
<context-actions
v-if="isResourceInSelection(resource)"
:action-options="{ space: getMatchingSpace(resource), resources: selectedResources }"
/>
</template>
<template #footer>
<pagination :pages="paginationPages" :current-page="paginationPage" />
<list-info
v-if="paginatedResources.length > 0"
class="oc-width-1-1 oc-my-s"
:files="totalResourcesCount.files"
:folders="totalResourcesCount.folders"
:spaces="totalResourcesCount.spaces"
:show-spaces="hasProjectSpaces"
/>
</template>
</resource-table>
</template>
</files-view-wrapper>
<file-side-bar
:is-open="isSideBarOpen"
:active-panel="sideBarActivePanel"
:space="selectedResourceSpace"
/>
</div>
</template>
<script lang="ts">
import {
FileSideBar,
useCapabilityStore,
useConfigStore,
useFileActions,
useResourcesStore
} from '@ownclouders/web-pkg'
import { VisibilityObserver } from '@ownclouders/web-pkg'
import { ImageDimension } from '@ownclouders/web-pkg'
import { debounce } from 'lodash-es'
import { AppLoadingSpinner } from '@ownclouders/web-pkg'
import { NoContentMessage } from '@ownclouders/web-pkg'
import { AppBar } from '@ownclouders/web-pkg'
import ListInfo from '../../components/FilesList/ListInfo.vue'
import { ContextActions } from '@ownclouders/web-pkg'
import FilesViewWrapper from '../../components/FilesViewWrapper.vue'
import { ResourceTable } from '@ownclouders/web-pkg'
import { Pagination } from '@ownclouders/web-pkg'
import { useResourcesViewDefaults } from '../../composables'
import { defineComponent, unref } from 'vue'
import { Resource } from '@ownclouders/web-client'
import { useGetMatchingSpace } from '@ownclouders/web-pkg'
import SharesNavigation from 'web-app-files/src/components/AppBar/SharesNavigation.vue'
import { storeToRefs } from 'pinia'
import { OutgoingShareResource } from '@ownclouders/web-client/src/helpers'
const visibilityObserver = new VisibilityObserver()
export default defineComponent({
components: {
SharesNavigation,
FilesViewWrapper,
AppBar,
ResourceTable,
AppLoadingSpinner,
NoContentMessage,
ListInfo,
Pagination,
ContextActions,
FileSideBar
},
setup() {
const capabilityStore = useCapabilityStore()
const capabilityRefs = storeToRefs(capabilityStore)
const { getMatchingSpace } = useGetMatchingSpace()
const configStore = useConfigStore()
const { options: configOptions } = storeToRefs(configStore)
const resourcesStore = useResourcesStore()
const { updateResourceField } = resourcesStore
const { totalResourcesCount } = storeToRefs(resourcesStore)
const { loadResourcesTask, selectedResourcesIds, paginatedResources } =
useResourcesViewDefaults<OutgoingShareResource, any, any[]>()
resourcesStore.$onAction((action) => {
if (action.name !== 'updateResourceField') {
return
}
if (selectedResourcesIds.value.length !== 1) return
const id = selectedResourcesIds.value[0]
const match = unref(paginatedResources).find((r) => {
return r.id === id
})
if (!match) return
loadResourcesTask.perform()
const matchedNewResource = unref(paginatedResources).find((r) => r.fileId === match.fileId)
if (!matchedNewResource) return
selectedResourcesIds.value = [matchedNewResource.id]
})
return {
...useFileActions(),
...useResourcesViewDefaults<Resource, any, any[]>(),
configOptions,
getMatchingSpace,
totalResourcesCount,
updateResourceField,
hasProjectSpaces: capabilityRefs.spacesProjects
}
},
computed: {
helpersEnabled() {
return this.configOptions.contextHelpers
},
isEmpty() {
return this.paginatedResources.length < 1
},
displayThumbnails() {
return !this.configOptions.disablePreviews
}
},
async created() {
await this.loadResourcesTask.perform()
this.scrollToResourceFromRoute(this.paginatedResources, 'files-app-bar')
},
beforeUnmount() {
visibilityObserver.disconnect()
},
methods: {
rowMounted(resource: Resource, component) {
if (!this.displayThumbnails) {
return
}
const loadPreview = async () => {
const preview = await this.$previewService.loadPreview(
{
space: this.getMatchingSpace(resource),
resource,
dimensions: ImageDimension.Thumbnail
},
true
)
if (preview) {
this.updateResourceField({ id: resource.id, field: 'thumbnail', value: preview })
}
}
const debounced = debounce(({ unobserve }) => {
unobserve()
loadPreview()
}, 250)
visibilityObserver.observe(component.$el, { onEnter: debounced, onExit: debounced.cancel })
}
}
})
</script>
| owncloud/web/packages/web-app-files/src/views/shares/SharedViaLink.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/views/shares/SharedViaLink.vue",
"repo_id": "owncloud",
"token_count": 2563
} | 803 |
import SharesNavigation from '../../../../src/components/AppBar/SharesNavigation.vue'
import { locationSharesWithMe } from '@ownclouders/web-pkg'
import { mock } from 'vitest-mock-extended'
import { RouteRecordNormalized } from 'vue-router'
import {
defaultPlugins,
defaultStubs,
shallowMount,
defaultComponentMocks,
RouteLocation
} from 'web-test-helpers'
const routes = [
mock<RouteRecordNormalized>({
path: '/files/shares/with-me/',
name: 'files-shares-with-me'
}),
mock<RouteRecordNormalized>({
path: '/files/shares/with-others/',
name: 'files-shares-with-others'
}),
mock<RouteRecordNormalized>({
path: '/files/shares/via-link/',
name: 'files-shares-via-link'
})
]
describe('SharesNavigation component', () => {
it('renders a shares navigation for both mobile and a desktop viewports', () => {
const { wrapper } = getWrapper()
expect(wrapper.html()).toMatchSnapshot()
})
})
function getWrapper({ currentRouteName = locationSharesWithMe.name } = {}) {
const mocks = defaultComponentMocks({
currentRoute: mock<RouteLocation>({ name: currentRouteName })
})
mocks.$router.getRoutes.mockImplementation(() => routes)
return {
mocks,
wrapper: shallowMount(SharesNavigation, {
global: {
stubs: defaultStubs,
renderStubDefaultSlot: true,
mocks,
provide: mocks,
plugins: [...defaultPlugins()]
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/components/AppBar/SharesNavigation.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/components/AppBar/SharesNavigation.spec.ts",
"repo_id": "owncloud",
"token_count": 538
} | 804 |
import FileDetailsMultiple from '../../../../../src/components/SideBar/Details/FileDetailsMultiple.vue'
import { defaultPlugins, shallowMount } from 'web-test-helpers'
const selectors = {
selectedFilesText: '[data-testid="selectedFilesText"]',
filesCount: '[data-testid="filesCount"]',
foldersCount: '[data-testid="foldersCount"]',
size: '[data-testid="size"]'
}
const folderA = {
id: '1',
type: 'folder',
mdate: 'Wed, 21 Oct 2015 07:28:00 GMT',
size: '740'
}
const folderB = {
id: '2',
type: 'folder',
mdate: 'Wed, 21 Oct 2015 07:28:00 GMT',
size: '740'
}
const fileA = {
id: '3',
type: 'file',
mdate: 'Wed, 21 Oct 2015 07:28:00 GMT',
size: '740'
}
const fileB = {
id: '4',
type: 'file',
mdate: 'Wed, 21 Oct 2015 07:28:00 GMT',
size: '740'
}
describe('Details Multiple Selection SideBar Item', () => {
it('should display information for two selected folders', () => {
const { wrapper } = createWrapper([folderA, folderB])
expect(wrapper.find(selectors.selectedFilesText).text()).toBe('2 items selected')
expect(wrapper.find(selectors.filesCount).text()).toBe('Files 0')
expect(wrapper.find(selectors.foldersCount).text()).toBe('Folders 2')
expect(wrapper.find(selectors.size).text()).toBe('Size 1 kB')
})
it('should display information for two selected files', () => {
const { wrapper } = createWrapper([fileA, fileB])
expect(wrapper.find(selectors.selectedFilesText).text()).toBe('2 items selected')
expect(wrapper.find(selectors.filesCount).text()).toBe('Files 2')
expect(wrapper.find(selectors.foldersCount).text()).toBe('Folders 0')
expect(wrapper.find(selectors.size).text()).toBe('Size 1 kB')
})
it('should display information for one selected file, one selected folder', () => {
const { wrapper } = createWrapper([fileA, folderA])
expect(wrapper.find(selectors.selectedFilesText).text()).toBe('2 items selected')
expect(wrapper.find(selectors.filesCount).text()).toBe('Files 1')
expect(wrapper.find(selectors.foldersCount).text()).toBe('Folders 1')
expect(wrapper.find(selectors.size).text()).toBe('Size 1 kB')
})
})
function createWrapper(resources) {
return {
wrapper: shallowMount(FileDetailsMultiple, {
global: {
plugins: [
...defaultPlugins({
piniaOptions: {
resourcesStore: { resources, selectedIds: resources.map(({ id }) => id) }
}
})
]
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/components/SideBar/Details/FileDetailsMultiple.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/components/SideBar/Details/FileDetailsMultiple.spec.ts",
"repo_id": "owncloud",
"token_count": 922
} | 805 |
import SpaceMembers from 'web-app-files/src/components/SideBar/Shares/SpaceMembers.vue'
import {
ShareTypes,
ShareRole,
CollaboratorShare,
GraphShareRoleIdMap
} from '@ownclouders/web-client/src/helpers/share'
import { mock } from 'vitest-mock-extended'
import { ProjectSpaceResource, SpaceResource } from '@ownclouders/web-client/src/helpers'
import {
defaultPlugins,
mount,
shallowMount,
defaultComponentMocks,
RouteLocation
} from 'web-test-helpers'
import { User } from '@ownclouders/web-client/src/generated'
import { useCanShare, useModals } from '@ownclouders/web-pkg'
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
useCanShare: vi.fn()
}))
const memberMocks = [
{
id: '1',
shareType: ShareTypes.spaceUser.value,
sharedWith: {
id: 'alice',
displayName: 'alice'
},
role: mock<ShareRole>({ id: GraphShareRoleIdMap.SpaceManager }),
permissions: [],
resourceId: '1',
indirect: false,
sharedBy: { id: 'admin', displayName: 'admin' }
},
{
id: '2',
shareType: ShareTypes.spaceUser.value,
sharedWith: {
onPremisesSamAccountName: 'Einstein',
displayName: 'einstein'
},
role: mock<ShareRole>({ id: GraphShareRoleIdMap.SpaceEditor }),
permissions: [],
resourceId: '1',
indirect: false,
sharedBy: { id: 'admin', displayName: 'admin' }
},
{
id: '3',
shareType: ShareTypes.spaceUser.value,
sharedWith: {
onPremisesSamAccountName: 'Marie',
displayName: 'marie'
},
role: mock<ShareRole>({ id: GraphShareRoleIdMap.SpaceViewer }),
permissions: [],
resourceId: '1',
indirect: false,
sharedBy: { id: 'admin', displayName: 'admin' }
}
] as CollaboratorShare[]
describe('SpaceMembers', () => {
describe('invite collaborator form', () => {
it('renders the form when the current user can share', () => {
const wrapper = getWrapper({ canShare: true })
expect(wrapper.find('invite-collaborator-form-stub').exists()).toBeTruthy()
})
it('does not render the form when the current user can not share', () => {
const wrapper = getWrapper({ canShare: false })
expect(wrapper.find('invite-collaborator-form-stub').exists()).toBeFalsy()
})
})
describe('existing members', () => {
it('can edit when current user can share', () => {
const wrapper = getWrapper({ canShare: true })
expect(
wrapper.findAllComponents<any>('collaborator-list-item-stub').at(1).props().modifiable
).toEqual(true)
})
it('can not edit when current user can not share', () => {
const wrapper = getWrapper({ canShare: false })
expect(
wrapper.findAllComponents<any>('collaborator-list-item-stub').at(1).props().modifiable
).toEqual(false)
})
it('can not edit current user when they are the only space manager', () => {
const wrapper = getWrapper({ spaceMembers: [memberMocks[0]], canShare: true })
expect(
wrapper.findAllComponents<any>('collaborator-list-item-stub').at(0).props().modifiable
).toEqual(false)
})
})
describe('deleting members', () => {
it('reacts on delete events by collaborator list items', async () => {
const user = mock<User>({ id: 'admin' })
const wrapper = getWrapper({ user })
wrapper.findComponent<any>('collaborator-list-item-stub').vm.$emit('onDelete')
await wrapper.vm.$nextTick()
const { dispatchModal } = useModals()
expect(dispatchModal).toHaveBeenCalledTimes(1)
})
})
describe('filter', () => {
it('toggles the filter on click', async () => {
const space = mock<ProjectSpaceResource>({ isManager: () => true })
const wrapper = getWrapper({ mountType: mount, space })
expect(wrapper.vm.isFilterOpen).toBeFalsy()
await wrapper.find('.open-filter-btn').trigger('click')
expect(wrapper.vm.isFilterOpen).toBeTruthy()
})
})
})
function getWrapper({
mountType = shallowMount,
space = mock<SpaceResource>(),
spaceMembers = memberMocks,
user = mock<User>(),
currentRouteName = 'files-spaces-generic',
canShare = true
} = {}) {
vi.mocked(useCanShare).mockReturnValue({ canShare: () => canShare })
const mocks = defaultComponentMocks({
currentRoute: mock<RouteLocation>({ name: currentRouteName })
})
return mountType(SpaceMembers, {
global: {
plugins: [
...defaultPlugins({
piniaOptions: {
userState: { user },
spacesState: { spaceMembers },
configState: {
options: { contextHelpers: true, sidebar: { shares: { showAllOnLoad: true } } }
}
}
})
],
mocks,
provide: {
...mocks,
space,
resource: space
},
stubs: {
OcButton: false,
'oc-icon': true,
'oc-spinner': true,
'avatar-image': true,
'role-dropdown': true,
'edit-dropdown': true,
'invite-collaborator-form': true,
'collaborator-list-item': true
}
}
})
}
| owncloud/web/packages/web-app-files/tests/unit/components/SideBar/Shares/SpaceMembers.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/components/SideBar/Shares/SpaceMembers.spec.ts",
"repo_id": "owncloud",
"token_count": 2030
} | 806 |
import FilesDrop from '../../../src/views/FilesDrop.vue'
import {
defaultPlugins,
mount,
defaultComponentMocks,
defaultStubs,
RouteLocation
} from 'web-test-helpers'
import { mock, mockDeep } from 'vitest-mock-extended'
import { ClientService } from '@ownclouders/web-pkg'
import { ListFilesResult } from '@ownclouders/web-client/src/webdav/listFiles'
describe('FilesDrop view', () => {
describe('different files view states', () => {
it('shows the loading spinner during loading', () => {
const { wrapper } = getMountedWrapper()
expect(wrapper.find('app-loading-spinner').exists()).toBeTruthy()
})
it('shows the "resource-upload"-component after loading', async () => {
const { wrapper } = getMountedWrapper()
wrapper.vm.loading = false
await wrapper.vm.$nextTick()
expect(wrapper.find('app-loading-spinner').exists()).toBeFalsy()
expect(wrapper.find('resource-upload-stub').exists()).toBeTruthy()
})
})
})
function getMountedWrapper() {
const $clientService = mockDeep<ClientService>()
$clientService.webdav.listFiles.mockResolvedValue(mock<ListFilesResult>())
const defaultMocks = {
...defaultComponentMocks({
currentRoute: mock<RouteLocation>({ name: 'files-common-favorites' })
}),
$clientService: $clientService
}
return {
mocks: defaultMocks,
wrapper: mount(FilesDrop, {
global: {
plugins: [...defaultPlugins()],
mocks: defaultMocks,
provide: defaultMocks,
stubs: defaultStubs
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/views/FilesDrop.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/views/FilesDrop.spec.ts",
"repo_id": "owncloud",
"token_count": 577
} | 807 |
import translations from '../l10n/translations.json'
import { extensions } from './extensions'
import { useGettext } from 'vue3-gettext'
import { defineWebApplication } from '@ownclouders/web-pkg'
export default defineWebApplication({
setup(args) {
const { $gettext } = useGettext()
return {
appInfo: {
id: 'importer',
name: $gettext('Importer')
},
extensions: extensions(args),
translations
}
}
})
| owncloud/web/packages/web-app-importer/src/index.ts/0 | {
"file_path": "owncloud/web/packages/web-app-importer/src/index.ts",
"repo_id": "owncloud",
"token_count": 173
} | 808 |
<template>
<object class="pdf-viewer oc-width-1-1 oc-height-1-1" :data="url" :type="objectType" />
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
props: {
url: {
type: String,
required: true
}
},
setup() {
const isSafari =
navigator.userAgent?.includes('Safari') && !navigator.userAgent?.includes('Chrome')
const objectType = isSafari ? undefined : 'application/pdf'
return {
objectType
}
}
})
</script>
<style scoped>
.pdf-viewer {
border: none;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
| owncloud/web/packages/web-app-pdf-viewer/src/App.vue/0 | {
"file_path": "owncloud/web/packages/web-app-pdf-viewer/src/App.vue",
"repo_id": "owncloud",
"token_count": 252
} | 809 |
import { PartialComponentProps, mount } from 'web-test-helpers'
import App from '../../src/App.vue'
vi.mock('@ownclouders/web-pkg')
describe('Text editor app', () => {
it('shows the editor', () => {
const { wrapper } = getWrapper({
applicationConfig: {}
})
expect(wrapper.html()).toMatchSnapshot()
})
})
function getWrapper(props: PartialComponentProps<typeof App>) {
return {
wrapper: mount(App, {
props: {
applicationConfig: {},
currentContent: '',
isReadOnly: false,
resource: undefined,
...props
}
})
}
}
| owncloud/web/packages/web-app-text-editor/tests/unit/app.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-text-editor/tests/unit/app.spec.ts",
"repo_id": "owncloud",
"token_count": 245
} | 810 |
.gitignore
.npmignore
.openapi-generator-ignore
api.ts
base.ts
common.ts
configuration.ts
git_push.sh
index.ts
| owncloud/web/packages/web-client/src/generated/.openapi-generator/FILES/0 | {
"file_path": "owncloud/web/packages/web-client/src/generated/.openapi-generator/FILES",
"repo_id": "owncloud",
"token_count": 45
} | 811 |
import { DavFileInfoResponse } from '@ownclouders/web-client/src/webdav/constants'
import { Identity, User } from '../../generated'
import { MongoAbility, SubjectRawRule } from '@casl/ability'
import { DAVResultResponseProps, FileStat } from 'webdav'
import { Audio, GeoCoordinates } from '../../generated'
export type AbilityActions =
| 'create'
| 'create-all'
| 'delete'
| 'delete-all'
| 'read'
| 'read-all'
| 'set-quota'
| 'set-quota-all'
| 'update'
| 'update-all'
export type AbilitySubjects =
| 'Account'
| 'Drive'
| 'Favorite'
| 'Group'
| 'Language'
| 'Logo'
| 'PublicLink'
| 'ReadOnlyPublicLinkPassword'
| 'Role'
| 'Setting'
| 'Share'
export type Ability = MongoAbility<[AbilityActions, AbilitySubjects]>
export type AbilityRule = SubjectRawRule<AbilityActions, AbilitySubjects, any>
export interface SpaceRole extends Identity {
kind: 'user' | 'group'
isMember(u: User): boolean
}
export interface SpaceRoles {
viewer: SpaceRole[]
editor: SpaceRole[]
manager: SpaceRole[]
}
// TODO: add more fields to the resource interface. Extend into different resource types: FileResource, FolderResource, ShareResource, IncomingShareResource, OutgoingShareResource, ...
export interface Resource {
id: string
fileId?: string
parentFolderId?: string
storageId?: string
readonly nodeId?: string
name?: string
tags?: string[]
audio?: Audio
location?: GeoCoordinates
disabled?: boolean
path: string
webDavPath?: string
downloadURL?: string
type?: string
thumbnail?: string
processing?: boolean
locked?: boolean
lockOwnerName?: string
lockTime?: string
spaceRoles?: SpaceRoles
spaceQuota?: any
spaceImageData?: any
spaceReadmeData?: any
mimeType?: string
isFolder?: boolean
sdate?: string // FIXME: move to `ShareResource`
mdate?: string
indicators?: any[]
size?: number | string // FIXME
permissions?: string
starred?: boolean
etag?: string
shareId?: string // FIXME: this originates from the old OCS api, should be removed in the future
shareRoot?: string // FIXME: this originates from the old OCS api, should be removed in the future
shareTypes?: number[]
privateLink?: string
description?: string
driveType?: 'mountpoint' | 'personal' | 'project' | 'share' | 'public' | (string & unknown)
driveAlias?: string
matchingSpace?: any
owner?: Identity
extension?: string
ddate?: string
canCreate?(): boolean
canUpload?({ user }: { user?: User }): boolean
canDownload?(): boolean
canShare?({ user, ability }?: { user?: User; ability?: Ability }): boolean
canRename?({ user }?: { user?: User; ability?: Ability }): boolean
canBeDeleted?({ user }?: { user?: User; ability?: Ability }): boolean
canBeRestored?(): boolean
canDeny?(): boolean
canEditDescription?({ user }: { user?: User; ability?: Ability }): boolean
canRestore?({ user }: { user?: User; ability?: any }): boolean
canDisable?({ user }: { user?: User; ability?: any }): boolean
canEditImage?({ user }: { user?: User }): boolean
canEditReadme?({ user }: { user?: User }): boolean
canRemoveFromTrashbin?({ user }: { user?: User }): boolean
canEditSpaceQuota?(): boolean
canEditTags?(): boolean
isReceivedShare?(): boolean
isShareRoot?(): boolean
isMounted?(): boolean
getDomSelector?(): string
}
// These interfaces have empty (unused) __${type}SpaceResource properties which are only
// there to make the types differ, in order to make TypeScript type narrowing work correctly
// With empty types TypeScript does not accept this code
// ```
// if(isPublicSpaceResource(resource)) { console.log(resource.id) } else { console.log(resource.id) }
// ```
// because in the else block resource gets the type never. If this is changed in a later TypeScript version
// or all types get different members, the underscored props can be removed.
export interface FolderResource extends Resource {
__folderResource?: any
}
export interface FileResource extends Resource {
__fileResource?: any
}
export interface WebDavResponseTusSupport {
extension?: string[]
maxSize?: number
resumable?: string
version?: string[]
}
export interface WebDavResponseResource extends Omit<FileStat, 'props'> {
props?: Omit<DAVResultResponseProps, 'getcontentlength'> & DavFileInfoResponse
processing?: boolean
tusSupport?: WebDavResponseTusSupport
}
| owncloud/web/packages/web-client/src/helpers/resource/types.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/helpers/resource/types.ts",
"repo_id": "owncloud",
"token_count": 1300
} | 812 |
import { AxiosInstance } from 'axios'
import { urlJoin } from '../utils'
import convert from 'xml-js'
import { User } from '../generated'
import { Ref, unref } from 'vue'
import { pbkdf2Sync } from 'crypto'
export interface UrlSignOptions {
axiosClient: AxiosInstance
baseURI: string
user: Ref<User>
}
export class UrlSign {
private axiosClient: AxiosInstance
private baseURI: string
private user: Ref<User>
private signingKey: string
private ALGORITHM = 'sha512'
private TTL = 1200
private HASH_LENGTH = 32
private ITERATION_COUNT = 10000
constructor({ axiosClient, baseURI, user }: UrlSignOptions) {
this.axiosClient = axiosClient
this.baseURI = baseURI
this.user = user
}
public async signUrl(url: string) {
const signedUrl = new URL(url)
signedUrl.searchParams.set('OC-Credential', unref(this.user).onPremisesSamAccountName)
signedUrl.searchParams.set('OC-Date', new Date().toISOString())
signedUrl.searchParams.set('OC-Expires', this.TTL.toString())
signedUrl.searchParams.set('OC-Verb', 'GET')
const hashedKey = await this.createHashedKey(signedUrl.toString())
signedUrl.searchParams.set('OC-Algo', `PBKDF2/${this.ITERATION_COUNT}-SHA512`)
signedUrl.searchParams.set('OC-Signature', hashedKey)
return signedUrl.toString()
}
private async getSignKey() {
if (this.signingKey) {
return this.signingKey
}
const data = await this.axiosClient.get(
urlJoin(this.baseURI, 'ocs/v1.php/cloud/user/signing-key'),
{
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}
)
const parsedXML = convert.xml2js(data.data, { compact: true }) as any
this.signingKey = parsedXML.ocs.data['signing-key']._text
return this.signingKey
}
private async createHashedKey(url: string) {
const signignKey = await this.getSignKey()
const hashedKey = pbkdf2Sync(
url,
signignKey,
this.ITERATION_COUNT,
this.HASH_LENGTH,
this.ALGORITHM
)
return hashedKey.toString('hex')
}
}
| owncloud/web/packages/web-client/src/ocs/urlSign.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/ocs/urlSign.ts",
"repo_id": "owncloud",
"token_count": 800
} | 813 |
import { Resource, SpaceResource } from '../helpers'
import { ListFilesFactory, ListFilesOptions } from './listFiles'
import { WebDavOptions } from './types'
export const GetFileInfoFactory = (
listFilesFactory: ReturnType<typeof ListFilesFactory>,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
options?: WebDavOptions
) => {
return {
async getFileInfo(
space: SpaceResource,
resource?: { path?: string; fileId?: string | number },
options?: ListFilesOptions
): Promise<Resource> {
return (
await listFilesFactory.listFiles(space, resource, {
depth: 0,
...options
})
).resource
}
}
}
| owncloud/web/packages/web-client/src/webdav/getFileInfo.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/webdav/getFileInfo.ts",
"repo_id": "owncloud",
"token_count": 256
} | 814 |
import { mock, mockDeep } from 'vitest-mock-extended'
import {
Ability,
Resource,
WebDavResponseResource,
buildResource,
extractDomSelector,
extractExtensionFromFile,
extractNameWithoutExtension
} from '../../../../src/helpers'
import { DavPermission, DavProperty } from '../../../../src/webdav/constants'
describe('extractDomSelector', () => {
it.each([
{ input: '', expected: '' },
{ input: '1', expected: '1' },
{ input: 'a', expected: 'a' },
{ input: '!=?', expected: '' },
{ input: '-_', expected: '-_' },
{ input: '1a!=?-_', expected: '1a-_' },
{
input: 'f2dc18fa-ca05-11ec-8c55-0f9df469d22f',
expected: 'f2dc18fa-ca05-11ec-8c55-0f9df469d22f'
}
])(
'creates a string that does not break when being used as query selector',
({ input, expected }) => {
expect(extractDomSelector(input)).toBe(expected)
}
)
})
const resourceWithoutExtension = {
name: 'file'
}
const resourceNameWithExtension = {
name: 'file.txt',
extension: 'txt'
}
const resourceNameWithExtensionAndDots = {
name: 'file.dot.txt',
extension: 'txt'
}
describe('filterResources', () => {
describe('extractNameWithoutExtension', () => {
it('should return resource name when there is no extension', () => {
expect(extractNameWithoutExtension(resourceWithoutExtension as Resource)).toEqual(
resourceWithoutExtension.name
)
})
it('should return resource name without extension when there is an extension', () => {
expect(extractNameWithoutExtension(resourceNameWithExtension as Resource)).toEqual('file')
})
it('should return resource name with dots without extension when there is an extension', () => {
expect(extractNameWithoutExtension(resourceNameWithExtensionAndDots as Resource)).toEqual(
'file.dot'
)
})
})
describe('extractExtensionFromFile', () => {
it('should return simple file extension', () => {
expect(extractExtensionFromFile({ name: 'test.png' } as Resource)).toEqual('png')
})
it('should return complex file extension', () => {
expect(extractExtensionFromFile({ name: 'test.tar.gz' } as Resource)).toEqual('tar.gz')
})
it('should return unknown file extension', () => {
expect(extractExtensionFromFile({ name: 'test.unknown' } as Resource)).toEqual('unknown')
})
it('should return no file extension', () => {
expect(extractExtensionFromFile({ name: 'test' } as Resource)).toEqual('')
})
it.each([
{ name: 'afolder', isFolder: true },
{ name: 'afolder', type: 'dir' },
{ name: 'afolder', type: 'folder' }
])('should return empty string if folder', (resource) => {
expect(extractExtensionFromFile(resource as Resource)).toEqual('')
})
})
})
describe('buildResource', () => {
describe('canShare', () => {
it('is true when ability and share permissions are given', () => {
const webDavResponse = mockDeep<WebDavResponseResource>({
props: {
[DavProperty.Permissions]: DavPermission.Shareable,
[DavProperty.Tags]: undefined
}
})
const resource = buildResource(webDavResponse)
const ability = mock<Ability>()
ability.can.mockReturnValue(true)
expect(resource.canShare({ ability })).toBeTruthy()
expect(ability.can).toHaveBeenCalledWith('create-all', 'Share')
})
it('is false when ability is not given', () => {
const webDavResponse = mockDeep<WebDavResponseResource>({
props: {
[DavProperty.Permissions]: DavPermission.Shareable,
[DavProperty.Tags]: undefined
}
})
const resource = buildResource(webDavResponse)
const ability = mock<Ability>()
ability.can.mockReturnValue(false)
expect(resource.canShare({ ability })).toBeFalsy()
expect(ability.can).toHaveBeenCalledWith('create-all', 'Share')
})
it('is false when share permissions are not given', () => {
const webDavResponse = mockDeep<WebDavResponseResource>({
props: {
[DavProperty.Permissions]: '',
[DavProperty.Tags]: undefined
}
})
const resource = buildResource(webDavResponse)
const ability = mock<Ability>()
ability.can.mockReturnValue(true)
expect(resource.canShare({ ability })).toBeFalsy()
expect(ability.can).toHaveBeenCalledWith('create-all', 'Share')
})
})
})
| owncloud/web/packages/web-client/tests/unit/helpers/resource/functions.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-client/tests/unit/helpers/resource/functions.spec.ts",
"repo_id": "owncloud",
"token_count": 1679
} | 815 |
export * from './useGroupingSettings'
export * from './useLoadTokenInfo'
| owncloud/web/packages/web-pkg/src/cern/composables/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/cern/composables/index.ts",
"repo_id": "owncloud",
"token_count": 22
} | 816 |
<template>
<li v-oc-tooltip="componentProps.disabled ? action.disabledTooltip?.(actionOptions) : ''">
<oc-button
v-oc-tooltip="showTooltip || action.hideLabel ? action.label(actionOptions) : ''"
:type="action.componentType"
v-bind="componentProps"
:class="[action.class, 'action-menu-item', 'oc-py-s', 'oc-px-m', 'oc-width-1-1']"
:aria-label="componentProps.disabled ? action.disabledTooltip?.(actionOptions) : ''"
data-testid="action-handler"
size="small"
justify-content="left"
v-on="componentListeners"
>
<oc-img
v-if="action.img"
data-testid="action-img"
:src="action.img"
alt=""
class="oc-icon oc-icon-m"
/>
<oc-img
v-else-if="hasExternalImageIcon"
data-testid="action-img"
:src="action.icon"
alt=""
class="oc-icon oc-icon-m"
/>
<oc-icon
v-else-if="action.icon"
data-testid="action-icon"
:name="action.icon"
:fill-type="action.iconFillType || 'line'"
size="medium"
/>
<span
v-if="!action.hideLabel"
class="oc-files-context-action-label"
data-testid="action-label"
>
{{ action.label(actionOptions) }}
</span>
<span
v-if="action.shortcut && shortcutHint"
class="oc-files-context-action-shortcut"
v-text="action.shortcut"
/>
<span
v-if="action.opensInNewWindow"
data-testid="action-sr-hint"
class="oc-invisible-sr"
v-text="$gettext('(Opens in new window)')"
/>
</oc-button>
</li>
</template>
<script lang="ts">
import { computed, defineComponent, PropType } from 'vue'
import { Action, ActionOptions } from '../../composables/actions'
export default defineComponent({
name: 'ActionMenuItem',
props: {
action: {
type: Object as PropType<Action>,
required: true
},
actionOptions: {
type: Object as PropType<ActionOptions>,
required: true
},
appearance: {
type: String,
default: 'raw'
},
variation: {
type: String,
default: 'passive'
},
shortcutHint: {
type: Boolean,
default: true,
required: false
},
showTooltip: {
type: Boolean,
default: false,
required: false
}
},
setup(props) {
const componentProps = computed(() => {
const properties = {
appearance: props.action.appearance || props.appearance,
variation: props.action.variation || props.variation,
...(props.action.isDisabled && {
disabled: props.action.isDisabled(props.actionOptions)
}),
...(props.action.id && { id: props.action.id })
}
if (props.action.componentType === 'router-link' && props.action.route) {
return {
...properties,
to: props.action.route(props.actionOptions)
}
}
return properties
})
return {
componentProps
}
},
computed: {
hasExternalImageIcon() {
return this.action.icon && /^https?:\/\//i.test(this.action.icon)
},
componentListeners() {
if (typeof this.action.handler !== 'function' || this.action.componentType !== 'button') {
return {}
}
const callback = () =>
this.action.handler({
...this.actionOptions
})
if (this.action.keepOpen) {
return {
click: (event) => {
event.stopPropagation()
callback()
}
}
}
return {
click: callback
}
}
}
})
</script>
<style lang="scss">
.action-menu-item {
vertical-align: middle;
}
.oc-files-context-action-shortcut {
justify-content: right !important;
font-size: var(--oc-font-size-small);
font-weight: bold !important;
opacity: 0.7;
}
</style>
| owncloud/web/packages/web-pkg/src/components/ContextActions/ActionMenuItem.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/ContextActions/ActionMenuItem.vue",
"repo_id": "owncloud",
"token_count": 1790
} | 817 |
export { default as ContextActions } from './ContextActions.vue'
export { default as ResourceGhostElement } from './ResourceGhostElement.vue'
export { default as ResourceTable } from './ResourceTable.vue'
export { default as ResourceListItem } from './ResourceListItem.vue'
export { default as ResourceIcon } from './ResourceIcon.vue'
export { default as ResourceTile } from './ResourceTile.vue'
export { default as ResourceTiles } from './ResourceTiles.vue'
export { default as ResourceLink } from './ResourceLink.vue'
export { default as ResourceName } from './ResourceName.vue'
export { default as ResourceSize } from './ResourceSize.vue'
| owncloud/web/packages/web-pkg/src/components/FilesList/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/FilesList/index.ts",
"repo_id": "owncloud",
"token_count": 178
} | 818 |
<template>
<resource-list-item
:resource="resource"
:path-prefix="pathPrefix"
:is-path-displayed="true"
:folder-link="folderLink"
:is-extension-displayed="areFileExtensionsShown"
:parent-folder-link-icon-additional-attributes="parentFolderLinkIconAdditionalAttributes"
:parent-folder-name="parentFolderName"
:is-thumbnail-displayed="displayThumbnails"
v-bind="additionalAttrs"
/>
</template>
<script lang="ts">
import { ImageDimension } from '../../constants'
import { VisibilityObserver } from '../../observer'
import { debounce } from 'lodash-es'
import { computed, defineComponent, PropType, ref, unref } from 'vue'
import {
useGetMatchingSpace,
useFileActions,
useFolderLink,
useConfigStore,
useResourcesStore
} from '../../composables'
import { Resource } from '@ownclouders/web-client/src/helpers'
import { isResourceTxtFileAlmostEmpty } from '../../helpers'
import ResourceListItem from '../FilesList/ResourceListItem.vue'
import { SearchResultValue } from './types'
import { storeToRefs } from 'pinia'
const visibilityObserver = new VisibilityObserver()
export default defineComponent({
components: { ResourceListItem },
props: {
searchResult: {
type: Object as PropType<SearchResultValue>,
default: function () {
return {}
}
},
isClickable: {
type: Boolean,
default: true
}
},
setup(props) {
const { triggerDefaultAction } = useFileActions()
const { getMatchingSpace } = useGetMatchingSpace()
const {
getPathPrefix,
getParentFolderName,
getParentFolderLink,
getParentFolderLinkIconAdditionalAttributes,
getFolderLink
} = useFolderLink()
const configStore = useConfigStore()
const { options: configOptions } = storeToRefs(configStore)
const resourcesStore = useResourcesStore()
const previewData = ref()
const areFileExtensionsShown = computed(() => resourcesStore.areFileExtensionsShown)
const resource = computed((): Resource => {
return {
...(props.searchResult.data as Resource),
...(unref(previewData) &&
({
thumbnail: unref(previewData)
} as Resource))
}
})
const space = computed(() => getMatchingSpace(unref(resource)))
const resourceDisabled = computed(() => {
return unref(resource).disabled === true
})
const resourceClicked = () => {
triggerDefaultAction({
space: unref(space),
resources: [unref(resource)]
})
}
const additionalAttrs = computed(() => {
if (!props.isClickable) {
return {
isResourceClickable: false
}
}
return {
parentFolderLink: getParentFolderLink(unref(resource)),
onClick: resourceClicked
}
})
return {
configOptions,
space,
previewData,
resource,
resourceDisabled,
resourceClicked,
parentFolderLink: getParentFolderLink(unref(resource)),
folderLink: getFolderLink(unref(resource)),
pathPrefix: getPathPrefix(unref(resource)),
parentFolderName: getParentFolderName(unref(resource)),
parentFolderLinkIconAdditionalAttributes: getParentFolderLinkIconAdditionalAttributes(
unref(resource)
),
additionalAttrs,
areFileExtensionsShown
}
},
computed: {
displayThumbnails() {
return !this.configOptions.disablePreviews && !isResourceTxtFileAlmostEmpty(this.resource)
}
},
mounted() {
if (this.resourceDisabled) {
this.$el.parentElement.classList.add('disabled')
}
if (!this.displayThumbnails) {
return
}
const loadPreview = async () => {
const preview = await this.$previewService.loadPreview(
{
space: this.space,
resource: this.resource,
dimensions: ImageDimension.Thumbnail
},
true
)
preview && (this.previewData = preview)
}
const debounced = debounce(({ unobserve }) => {
unobserve()
loadPreview()
}, 250)
visibilityObserver.observe(this.$el, { onEnter: debounced, onExit: debounced.cancel })
},
beforeUnmount() {
visibilityObserver.disconnect()
}
})
</script>
| owncloud/web/packages/web-pkg/src/components/Search/ResourcePreview.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/Search/ResourcePreview.vue",
"repo_id": "owncloud",
"token_count": 1615
} | 819 |
export * from './Spaces'
export * from './Files'
export * from './types'
export { default as CompareSaveDialog } from './CompareSaveDialog.vue'
export { default as SideBar } from './SideBar.vue'
export { default as FileSideBar } from './FileSideBar.vue'
export { default as WebDavDetails } from './WebDavDetails.vue'
| owncloud/web/packages/web-pkg/src/components/SideBar/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/SideBar/index.ts",
"repo_id": "owncloud",
"token_count": 102
} | 820 |
import { SpaceResource } from '@ownclouders/web-client/src/helpers'
import { computed, nextTick, unref } from 'vue'
import { useClientService } from '../../clientService'
import { useRouter } from '../../router'
import { FileAction } from '../../../'
import { useGettext } from 'vue3-gettext'
import { resolveFileNameDuplicate } from '../../../helpers/resource'
import { join } from 'path'
import { WebDAV } from '@ownclouders/web-client/src/webdav'
import { isLocationSpacesActive } from '../../../router'
import { getIndicators } from '../../../helpers/statusIndicators'
import { useScrollTo } from '../../scrollTo'
import { useMessages, useModals, useResourcesStore } from '../../../composables/piniaStores'
import { storeToRefs } from 'pinia'
export const useFileActionsCreateNewFolder = ({ space }: { space?: SpaceResource } = {}) => {
const { showMessage, showErrorMessage } = useMessages()
const router = useRouter()
const { dispatchModal } = useModals()
const { $gettext } = useGettext()
const { scrollToResource } = useScrollTo()
const resourcesStore = useResourcesStore()
const { resources, currentFolder, ancestorMetaData } = storeToRefs(resourcesStore)
const clientService = useClientService()
const checkNewFolderName = (folderName: string, setError: (error: string) => void) => {
if (folderName.trim() === '') {
return setError($gettext('Folder name cannot be empty'))
}
if (/[/]/.test(folderName)) {
return setError($gettext('Folder name cannot contain "/"'))
}
if (folderName === '.') {
return setError($gettext('Folder name cannot be equal to "."'))
}
if (folderName === '..') {
return setError($gettext('Folder name cannot be equal to ".."'))
}
const exists = unref(resources).find((file) => file.name === folderName)
if (exists) {
return setError($gettext('%{name} already exists', { name: folderName }, true))
}
return setError(null)
}
const loadIndicatorsForNewFile = computed(() => {
return isLocationSpacesActive(router, 'files-spaces-generic') && space.driveType !== 'share'
})
const addNewFolder = async (folderName: string) => {
folderName = folderName.trimEnd()
try {
const path = join(unref(currentFolder).path, folderName)
const resource = await (clientService.webdav as WebDAV).createFolder(space, {
path
})
if (unref(loadIndicatorsForNewFile)) {
resource.indicators = getIndicators({ resource, ancestorMetaData: unref(ancestorMetaData) })
}
resourcesStore.upsertResource(resource)
showMessage({ title: $gettext('"%{folderName}" was created successfully', { folderName }) })
await nextTick()
scrollToResource(resource.id, { forceScroll: true, topbarElement: 'files-app-bar' })
} catch (error) {
console.error(error)
showErrorMessage({
title: $gettext('Failed to create folder'),
errors: [error]
})
}
}
const handler = () => {
let defaultName = $gettext('New folder')
if (unref(resources).some((f) => f.name === defaultName)) {
defaultName = resolveFileNameDuplicate(defaultName, '', unref(resources))
}
dispatchModal({
title: $gettext('Create a new folder'),
confirmText: $gettext('Create'),
hasInput: true,
inputValue: defaultName,
inputLabel: $gettext('Folder name'),
onConfirm: addNewFolder,
onInput: checkNewFolderName
})
}
const actions = computed((): FileAction[] => {
return [
{
name: 'create-folder',
icon: 'folder',
handler,
label: () => {
return $gettext('New Folder')
},
isVisible: () => {
return unref(currentFolder)?.canCreate()
},
componentType: 'button',
class: 'oc-files-actions-create-new-folder'
}
]
})
return {
actions,
checkNewFolderName,
addNewFolder
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsCreateNewFolder.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsCreateNewFolder.ts",
"repo_id": "owncloud",
"token_count": 1446
} | 821 |
import { isLocationSpacesActive } from '../../../router'
import { usePreviewService } from '../../previewService'
import { useClientService } from '../../clientService'
import { useLoadingService } from '../../loadingService'
import { useRouter } from '../../router'
import { useGettext } from 'vue3-gettext'
import { computed } from 'vue'
import { FileAction, FileActionOptions } from '../types'
import { Drive } from '@ownclouders/web-client/src/generated'
import { buildSpace } from '@ownclouders/web-client/src/helpers'
import { useMessages, useSpacesStore, useUserStore } from '../../piniaStores'
export const useFileActionsSetImage = () => {
const { showMessage, showErrorMessage } = useMessages()
const userStore = useUserStore()
const router = useRouter()
const { $gettext } = useGettext()
const clientService = useClientService()
const loadingService = useLoadingService()
const previewService = usePreviewService()
const spacesStore = useSpacesStore()
const handler = async ({ space, resources }: FileActionOptions) => {
const graphClient = clientService.graphAuthenticated
const storageId = space?.id as string
const sourcePath = resources[0].path
const destinationPath = `/.space/${resources[0].name}`
const { copyFiles, getFileInfo, createFolder } = clientService.webdav
try {
try {
await getFileInfo(space, { path: '.space' })
} catch (_) {
await createFolder(space, { path: '.space' })
}
if (sourcePath !== destinationPath) {
await copyFiles(
space,
{ path: sourcePath },
space,
{ path: destinationPath },
{ overwrite: true }
)
}
const file = await getFileInfo(space, { path: destinationPath })
const { data: updatedDriveData } = await graphClient.drives.updateDrive(
storageId,
{
special: [
{
specialFolder: {
name: 'image'
},
id: file.id as string
}
]
} as Drive,
{}
)
spacesStore.updateSpaceField({
id: storageId,
field: 'spaceImageData',
value: buildSpace(updatedDriveData).spaceImageData
})
showMessage({ title: $gettext('Space image was set successfully') })
} catch (error) {
console.error(error)
showErrorMessage({
title: $gettext('Failed to set space image'),
errors: [error]
})
}
}
const actions = computed((): FileAction[] => [
{
name: 'set-space-image',
icon: 'image-edit',
handler: (args) => loadingService.addTask(() => handler(args)),
label: () => {
return $gettext('Set as space image')
},
isVisible: ({ space, resources }) => {
if (resources.length !== 1) {
return false
}
if (!resources[0].mimeType) {
return false
}
if (!previewService.isMimetypeSupported(resources[0].mimeType, true)) {
return false
}
if (!isLocationSpacesActive(router, 'files-spaces-generic')) {
return false
}
if (!space) {
return false
}
return space.canEditImage({ user: userStore.user })
},
componentType: 'button',
class: 'oc-files-actions-set-space-image-trigger'
}
])
return {
actions
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsSetImage.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsSetImage.ts",
"repo_id": "owncloud",
"token_count": 1393
} | 822 |
import { computed } from 'vue'
import { SpaceAction, SpaceActionOptions } from '../types'
import { useGettext } from 'vue3-gettext'
import { useAbility } from '../../ability'
import { SpaceResource, isProjectSpaceResource } from '@ownclouders/web-client/src/helpers'
import { QuotaModal } from '../../../components'
import { useModals } from '../../piniaStores'
export const useSpaceActionsEditQuota = () => {
const { dispatchModal } = useModals()
const { $gettext } = useGettext()
const ability = useAbility()
const getModalTitle = ({ resources }: { resources: SpaceResource[] }) => {
if (resources.length === 1) {
return $gettext('Change quota for Space "%{name}"', {
name: resources[0].name
})
}
return $gettext('Change quota for %{count} Spaces', {
count: resources.length.toString()
})
}
const handler = ({ resources }: SpaceActionOptions) => {
dispatchModal({
title: getModalTitle({ resources }),
customComponent: QuotaModal,
customComponentAttrs: () => ({
spaces: resources,
resourceType: 'space'
})
})
}
const actions = computed((): SpaceAction[] => [
{
name: 'editQuota',
icon: 'cloud',
label: () => {
return $gettext('Edit quota')
},
handler,
isVisible: ({ resources }) => {
if (!resources || !resources.length) {
return false
}
if (resources.some((r) => !isProjectSpaceResource(r) || r.spaceQuota === false)) {
return false
}
return ability.can('set-quota-all', 'Drive')
},
componentType: 'button',
class: 'oc-files-actions-edit-quota-trigger'
}
])
return {
actions
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsEditQuota.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsEditQuota.ts",
"repo_id": "owncloud",
"token_count": 673
} | 823 |
import { unref } from 'vue'
import { Resource } from '@ownclouders/web-client'
import { MaybeRef } from '../../utils'
import { ClientService } from '../../services'
import { FileContext } from './types'
import { FileResource, SpaceResource } from '@ownclouders/web-client/src/helpers'
import { useClientService } from '../clientService'
import { ListFilesOptions } from '@ownclouders/web-client/src/webdav/listFiles'
import { WebDAV } from '@ownclouders/web-client/src/webdav'
interface AppFileHandlingOptions {
clientService: ClientService
}
export type FileContentOptions = { responseType?: 'arrayBuffer' | 'blob' | 'text' } & Record<
string,
any
>
export type UrlForResourceOptions = Omit<Parameters<WebDAV['getFileUrl']>[2], 'isUrlSigningEnabled'>
export interface AppFileHandlingResult {
getUrlForResource(
space: SpaceResource,
resource: Resource,
options?: UrlForResourceOptions
): Promise<string>
revokeUrl(url: string): void
getFileInfo(fileContext: MaybeRef<FileContext>, options?: ListFilesOptions): Promise<Resource>
getFileContents(fileContext: MaybeRef<FileContext>, options?: FileContentOptions): Promise<any>
putFileContents(
fileContext: MaybeRef<FileContext>,
putFileOptions: { content?: string } & Record<string, any>
): Promise<FileResource>
}
export function useAppFileHandling({
clientService: { webdav }
}: AppFileHandlingOptions): AppFileHandlingResult {
const clientService = useClientService()
const getUrlForResource = (space: SpaceResource, resource: Resource, options?: any) => {
return clientService.webdav.getFileUrl(space, resource, {
...options
})
}
const revokeUrl = (url: string) => {
return clientService.webdav.revokeUrl(url)
}
// TODO: support query parameters
const getFileContents = (
fileContext: MaybeRef<FileContext>,
options: { responseType?: 'arrayBuffer' | 'blob' | 'text' } & Record<string, any>
) => {
return webdav.getFileContents(
unref(unref(fileContext).space),
{
path: unref(unref(fileContext).item)
},
{
...options
}
)
}
const getFileInfo = (
fileContext: MaybeRef<FileContext>,
options: ListFilesOptions = {}
): Promise<Resource> => {
return webdav.getFileInfo(
unref(unref(fileContext).space),
{
path: unref(unref(fileContext).item),
fileId: unref(unref(fileContext).itemId)
},
options
)
}
const putFileContents = (
fileContext: MaybeRef<FileContext>,
options: { content?: string } & Record<string, any>
) => {
return webdav.putFileContents(unref(unref(fileContext).space), {
path: unref(unref(fileContext).item),
...options
})
}
return {
getUrlForResource,
revokeUrl,
getFileContents,
getFileInfo,
putFileContents
}
}
| owncloud/web/packages/web-pkg/src/composables/appDefaults/useAppFileHandling.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/appDefaults/useAppFileHandling.ts",
"repo_id": "owncloud",
"token_count": 999
} | 824 |
export * from './useDownloadFile'
| owncloud/web/packages/web-pkg/src/composables/download/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/download/index.ts",
"repo_id": "owncloud",
"token_count": 10
} | 825 |
export * from './useKeyboardActions'
| owncloud/web/packages/web-pkg/src/composables/keyboardActions/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/keyboardActions/index.ts",
"repo_id": "owncloud",
"token_count": 12
} | 826 |
import { Capabilities } from '@ownclouders/web-client/src/ocs'
import { defineStore } from 'pinia'
import { computed, ref, unref } from 'vue'
import merge from 'lodash-es/merge'
import { SharePermissionBit } from '@ownclouders/web-client/src/helpers'
const defaultValues = {
core: {
'support-sse': false,
'support-url-signing': false
},
dav: {},
files: {
app_providers: [],
favorites: false,
permanent_deletion: true,
tags: false,
privateLinks: false,
tus_support: {
extension: '',
http_method_override: false,
max_chunk_size: 0
}
},
files_sharing: {
allow_custom: true,
api_enabled: true,
can_rename: true,
deny_access: false,
public: {
alias: false,
can_contribute: true,
can_edit: false,
default_permissions: SharePermissionBit.Read,
enabled: true,
password: {
enforced_for: { read_only: false, upload_only: false, read_write: false }
}
},
resharing: true,
resharing_default: true
},
graph: {
'personal-data-export': false,
users: {
change_password_self_disabled: true,
create_disabled: false,
delete_disabled: false,
read_only_attributes: []
}
},
notifications: {
'ocs-endpoints': []
},
password_policy: {},
search: {
property: {
mediatype: {},
mtime: {}
}
},
spaces: {
enabled: false,
max_quota: 0,
projects: false
}
} satisfies Partial<Capabilities['capabilities']>
export const useCapabilityStore = defineStore('capabilities', () => {
const isInitialized = ref(false)
const capabilities = ref<Capabilities['capabilities']>(defaultValues)
const setCapabilities = (data: Capabilities) => {
capabilities.value = merge({ ...defaultValues }, data.capabilities)
isInitialized.value = true
}
const supportUrlSigning = computed(() => unref(capabilities).core['support-url-signing'])
const supportSSE = computed(() => unref(capabilities).core['support-sse'])
const personalDataExport = computed(() => unref(capabilities).graph['personal-data-export'])
const status = computed(() => unref(capabilities).core.status)
const davReports = computed(() => unref(capabilities).dav.reports)
const davTrashbin = computed(() => unref(capabilities).dav.trashbin)
const spacesMaxQuota = computed(() => unref(capabilities).spaces.max_quota)
const spacesProjects = computed(() => unref(capabilities).spaces.projects)
const graphUsersCreateDisabled = computed(() => unref(capabilities).graph.users.create_disabled)
const graphUsersDeleteDisabled = computed(() => unref(capabilities).graph.users.delete_disabled)
const graphUsersChangeSelfPasswordDisabled = computed(
() => unref(capabilities).graph.users.change_password_self_disabled
)
const graphUsersReadOnlyAttributes = computed(
() => unref(capabilities).graph.users.read_only_attributes
)
const filesAppProviders = computed(() => unref(capabilities).files.app_providers)
const filesFavorites = computed(() => unref(capabilities).files.favorites)
const filesThumbnail = computed(() => unref(capabilities).files.thumbnail)
const filesArchivers = computed(() => unref(capabilities).files.archivers)
const filesPrivateLinks = computed(() => unref(capabilities).files.privateLinks)
const filesPermanentDeletion = computed(() => unref(capabilities).files.permanent_deletion)
const filesTags = computed(() => unref(capabilities).files.tags)
const filesUndelete = computed(() => unref(capabilities).files.undelete)
const sharingApiEnabled = computed(() => unref(capabilities).files_sharing.api_enabled)
const sharingDenyAccess = computed(() => unref(capabilities).files_sharing.deny_access)
const sharingCanRename = computed(() => unref(capabilities).files_sharing.can_rename)
const sharingAllowCustom = computed(() => unref(capabilities).files_sharing.allow_custom)
const sharingPublicEnabled = computed(() => unref(capabilities).files_sharing.public?.enabled)
const sharingPublicCanEdit = computed(() => unref(capabilities).files_sharing.public?.can_edit)
const sharingPublicCanContribute = computed(
() => unref(capabilities).files_sharing.public?.can_contribute
)
const sharingPublicAlias = computed(() => unref(capabilities).files_sharing.public?.alias)
const sharingPublicDefaultPermissions = computed(
() => unref(capabilities).files_sharing.public?.default_permissions
)
const sharingPublicPasswordEnforcedFor = computed(
() => unref(capabilities).files_sharing.public?.password.enforced_for
)
const sharingPublicExpireDate = computed(
() => unref(capabilities).files_sharing.public?.expire_date
)
const sharingResharing = computed(() => unref(capabilities).files_sharing.resharing)
const sharingResharingDefault = computed(
() => unref(capabilities).files_sharing.resharing_default
)
const sharingSearchMinLength = computed(() => unref(capabilities).files_sharing.search_min_length)
const sharingUserExpireDate = computed(() => unref(capabilities).files_sharing.user?.expire_date)
const sharingUserProfilePicture = computed(
() => unref(capabilities).files_sharing.user?.profile_picture
)
const sharingGroupExpireDate = computed(
() => unref(capabilities).files_sharing.group?.expire_date
)
const tusMaxChunkSize = computed(() => unref(capabilities).files.tus_support?.max_chunk_size)
const tusExtension = computed(() => unref(capabilities).files.tus_support?.extension)
const tusHttpMethodOverride = computed(
() => unref(capabilities).files.tus_support?.http_method_override
)
const notificationsOcsEndpoints = computed(
() => unref(capabilities).notifications['ocs-endpoints']
)
const passwordPolicy = computed(() => unref(capabilities).password_policy)
const searchLastMofifiedDate = computed(() => unref(capabilities).search.property?.mtime)
const searchMediaType = computed(() => unref(capabilities).search.property?.mediatype)
const searchContent = computed(() => unref(capabilities).search.property?.content)
return {
isInitialized,
capabilities,
setCapabilities,
// getters
status,
supportUrlSigning,
supportSSE,
personalDataExport,
davReports,
davTrashbin,
spacesMaxQuota,
spacesProjects,
graphUsersCreateDisabled,
graphUsersDeleteDisabled,
graphUsersChangeSelfPasswordDisabled,
graphUsersReadOnlyAttributes,
filesAppProviders,
filesFavorites,
filesThumbnail,
filesArchivers,
filesPrivateLinks,
filesPermanentDeletion,
filesTags,
filesUndelete,
sharingResharing,
sharingResharingDefault,
sharingApiEnabled,
sharingDenyAccess,
sharingCanRename,
sharingAllowCustom,
sharingPublicEnabled,
sharingPublicCanEdit,
sharingPublicCanContribute,
sharingPublicAlias,
sharingPublicDefaultPermissions,
sharingPublicPasswordEnforcedFor,
sharingPublicExpireDate,
sharingSearchMinLength,
sharingUserExpireDate,
sharingUserProfilePicture,
sharingGroupExpireDate,
tusMaxChunkSize,
tusExtension,
tusHttpMethodOverride,
notificationsOcsEndpoints,
passwordPolicy,
searchLastMofifiedDate,
searchMediaType,
searchContent
}
})
export type CapabilityStore = ReturnType<typeof useCapabilityStore>
| owncloud/web/packages/web-pkg/src/composables/piniaStores/capabilities.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/piniaStores/capabilities.ts",
"repo_id": "owncloud",
"token_count": 2464
} | 827 |
export enum PortalTargetEventTopics {
mounted = 'portal-target.mounted'
}
| owncloud/web/packages/web-pkg/src/composables/portalTarget/eventTopics.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/portalTarget/eventTopics.ts",
"repo_id": "owncloud",
"token_count": 22
} | 828 |
import { computed, Ref, unref } from 'vue'
import { useRouter } from './useRouter'
import { ParamValue } from './types'
import { queryItemAsString } from '../appDefaults'
export const useRouteParam = (name: string, defaultValue?: ParamValue): Ref<ParamValue> => {
const router = useRouter()
return computed({
get() {
return queryItemAsString(unref(router.currentRoute).params[name]) || defaultValue
},
async set(v) {
if (unref(router.currentRoute).params[name] === v) {
return
}
await router.replace({
params: {
...unref(router.currentRoute).params,
[name]: v
}
})
}
})
}
| owncloud/web/packages/web-pkg/src/composables/router/useRouteParam.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/router/useRouteParam.ts",
"repo_id": "owncloud",
"token_count": 270
} | 829 |
export * from './eventTopics'
export * from './useSideBar'
| owncloud/web/packages/web-pkg/src/composables/sideBar/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/sideBar/index.ts",
"repo_id": "owncloud",
"token_count": 19
} | 830 |
export * from './types'
| owncloud/web/packages/web-pkg/src/errors/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/errors/index.ts",
"repo_id": "owncloud",
"token_count": 8
} | 831 |
import { urlJoin } from '@ownclouders/web-client/src/utils'
/**
* Return all absolute parent paths.
*
* For example if passing in "a/b/c" it will return
* ["/a/b", "/a", ""]
* If an empty string or "/" is passed in, an empty array is returned.
*
* @param {String} path path to process
* @param {Boolean} includeCurrent whether to include the current path (with leading slash)
* @return {Array.<String>} parent paths
*/
export function getParentPaths(path = '', includeCurrent = false) {
// remove potential leading and trailing slash from current path (so that the resulting array doesn't start with an empty string).
// then reintroduce the leading slash, because we know that we need it.
const s = urlJoin(path, {
leadingSlash: true
})
if (s === '/') {
return []
}
const paths: string[] = []
const sections = s.split('/')
if (includeCurrent) {
paths.push(s)
}
sections.pop()
while (sections.length > 0) {
if (!sections.join('/')) {
sections.pop()
continue
}
paths.push(sections.join('/'))
sections.pop()
}
return paths
}
| owncloud/web/packages/web-pkg/src/helpers/path.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/helpers/path.ts",
"repo_id": "owncloud",
"token_count": 360
} | 832 |
export * from './link'
export * from './sharedAncestorRoute'
| owncloud/web/packages/web-pkg/src/helpers/share/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/helpers/share/index.ts",
"repo_id": "owncloud",
"token_count": 20
} | 833 |
import { RouteComponents } from './router'
import { RouteLocationNamedRaw, RouteRecordRaw } from 'vue-router'
import { createLocation, isLocationActiveDirector, $gettext } from './utils'
type shareTypes = 'files-public-link' | 'files-public-upload'
export const createLocationPublic = (name: shareTypes, location = {}): RouteLocationNamedRaw =>
createLocation(name, location)
export const locationPublicLink = createLocationPublic('files-public-link')
export const locationPublicUpload = createLocationPublic('files-public-upload')
export const isLocationPublicActive = isLocationActiveDirector<shareTypes>(
locationPublicLink,
locationPublicUpload
)
export const buildRoutes = (components: RouteComponents): RouteRecordRaw[] => [
{
path: '/link',
component: components.App,
meta: {
auth: false
},
children: [
{
name: locationPublicLink.name,
path: ':driveAliasAndItem(.*)?',
component: components.Spaces.DriveResolver,
meta: {
authContext: 'publicLink',
patchCleanPath: true
}
}
]
},
{
path: '/upload',
component: components.App,
meta: {
auth: false
},
children: [
{
name: locationPublicUpload.name,
path: ':token?',
component: components.FilesDrop,
meta: {
authContext: 'publicLink',
title: $gettext('Public file upload')
}
}
]
}
]
| owncloud/web/packages/web-pkg/src/router/public.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/router/public.ts",
"repo_id": "owncloud",
"token_count": 552
} | 834 |
import { isNaN, isNumber, isObject, isString, isBoolean } from 'lodash-es'
import { Language } from 'vue3-gettext'
export interface PasswordPolicyRuleOptions {
minLength?: number
maxLength?: number
characters?: string
}
export interface PasswordPolicyRuleExplained {
code: string
message: string
format: (number | string)[]
verified?: boolean
}
export interface PasswordPolicyRule {
assert(options: PasswordPolicyRuleOptions, password: string): boolean
explain(options: PasswordPolicyRuleOptions, verified?: boolean): PasswordPolicyRuleExplained
missing(options: PasswordPolicyRuleOptions, password: string): PasswordPolicyRuleExplained
validate(options?: PasswordPolicyRuleOptions): boolean
}
export class MustNotBeEmptyRule implements PasswordPolicyRule {
protected $gettext
constructor({ $gettext }: Language) {
this.$gettext = $gettext
}
explain(options: PasswordPolicyRuleOptions, verified: boolean): PasswordPolicyRuleExplained {
return {
code: 'mustNotBeEmpty',
message: this.$gettext('Must not be empty'),
format: [],
...(isBoolean(verified) && { verified })
}
}
assert(options: PasswordPolicyRuleOptions, password: string): boolean {
return password.length > 0
}
validate(): boolean {
return true
}
missing(options: PasswordPolicyRuleOptions, password: string): PasswordPolicyRuleExplained {
return this.explain(options, this.assert(options, password))
}
}
export class MustContainRule implements PasswordPolicyRule {
protected $gettext
constructor({ $gettext }: Language) {
this.$gettext = $gettext
}
explain(options: PasswordPolicyRuleOptions, verified: boolean): PasswordPolicyRuleExplained {
return {
code: 'mustContain',
message: this.$gettext('At least %{param1} of the special characters: %{param2}'),
format: [options.minLength, options.characters],
...(isBoolean(verified) && { verified })
}
}
assert(options: PasswordPolicyRuleOptions, password: string) {
const charsCount = Array.from(password).filter((char) =>
options.characters.includes(char)
).length
return charsCount >= options.minLength
}
validate(options: PasswordPolicyRuleOptions): boolean {
if (!isObject(options)) {
throw new Error('options should be an object')
}
if (!isNumber(options.minLength) || isNaN(options.minLength)) {
throw new Error('minLength should be a non-zero number')
}
if (!isString(options.characters)) {
throw new Error('characters should be a character sequence')
}
return true
}
missing(options, password) {
return this.explain(options, this.assert(options, password))
}
}
export class AtMostBaseRule implements PasswordPolicyRule {
protected $ngettext
constructor({ $ngettext }: Language) {
this.$ngettext = $ngettext
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
assert(options: PasswordPolicyRuleOptions, password: string): boolean {
throw new Error('Method not implemented.')
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
explain(options: PasswordPolicyRuleOptions, verified?: boolean): PasswordPolicyRuleExplained {
throw new Error('Method not implemented.')
}
validate(options: PasswordPolicyRuleOptions): boolean {
if (!isObject(options)) {
throw new Error('options should be an object')
}
if (!isNumber(options.maxLength) || isNaN(options.maxLength)) {
throw new Error('maxLength should be a non-zero number')
}
return true
}
missing(options: PasswordPolicyRuleOptions, password: string): PasswordPolicyRuleExplained {
return this.explain(options, this.assert(options, password))
}
}
export class AtMostCharactersRule extends AtMostBaseRule {
constructor(args: Language) {
super(args)
}
explain(options: PasswordPolicyRuleOptions, verified: boolean): PasswordPolicyRuleExplained {
return {
code: 'atMostCharacters',
message: this.$ngettext(
'At most %{param1} character long',
'At most %{param1} characters long',
options.maxLength
),
format: [options.maxLength],
...(isBoolean(verified) && { verified })
}
}
assert(options: PasswordPolicyRuleOptions, password: string): boolean {
return password.length <= options.maxLength
}
}
export class AtLeastBaseRule implements PasswordPolicyRule {
protected $ngettext
constructor({ $ngettext }: Language) {
this.$ngettext = $ngettext
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
assert(options: PasswordPolicyRuleOptions, password: string): boolean {
throw new Error('Method not implemented.')
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
explain(options: PasswordPolicyRuleOptions, verified?: boolean): PasswordPolicyRuleExplained {
throw new Error('Method not implemented.')
}
validate(options: PasswordPolicyRuleOptions): boolean {
if (!isObject(options)) {
throw new Error('options should be an object')
}
if (!isNumber(options.minLength) || isNaN(options.minLength)) {
throw new Error('minLength should be a non-zero number')
}
return true
}
missing(options: PasswordPolicyRuleOptions, password: string): PasswordPolicyRuleExplained {
return this.explain(options, this.assert(options, password))
}
}
export class AtLeastCharactersRule extends AtLeastBaseRule implements PasswordPolicyRule {
constructor(args: Language) {
super(args)
}
explain(options: PasswordPolicyRuleOptions, verified: boolean): PasswordPolicyRuleExplained {
return {
code: 'atLeastCharacters',
message: this.$ngettext(
'At least %{param1} character long',
'At least %{param1} characters long',
options.minLength
),
format: [options.minLength],
...(isBoolean(verified) && { verified })
}
}
assert(options: PasswordPolicyRuleOptions, password: string): boolean {
return password.length >= options.minLength
}
}
export class AtLeastUppercaseCharactersRule extends AtLeastBaseRule {
constructor(args: Language) {
super(args)
}
explain(options: PasswordPolicyRuleOptions, verified: boolean): PasswordPolicyRuleExplained {
return {
code: 'atLeastUppercaseCharacters',
message: this.$ngettext(
'At least %{param1} uppercase character',
'At least %{param1} uppercase characters',
options.minLength
),
format: [options.minLength],
...(isBoolean(verified) && { verified })
}
}
assert(options: PasswordPolicyRuleOptions, password: string): boolean {
const uppercaseCount = (password || '').match(/[A-Z\xC0-\xD6\xD8-\xDE]/g)?.length
return uppercaseCount >= options.minLength
}
}
export class AtLeastLowercaseCharactersRule extends AtLeastBaseRule {
constructor(args: Language) {
super(args)
}
explain(options: PasswordPolicyRuleOptions, verified: boolean): PasswordPolicyRuleExplained {
return {
code: 'atLeastLowercaseCharacters',
message: this.$ngettext(
'At least %{param1} lowercase character',
'At least %{param1} lowercase characters',
options.minLength
),
format: [options.minLength],
...(isBoolean(verified) && { verified })
}
}
assert(options: PasswordPolicyRuleOptions, password: string): boolean {
const lowercaseCount = (password || '').match(/[a-z\xDF-\xF6\xF8-\xFF]/g)?.length
return lowercaseCount >= options.minLength
}
}
export class AtLeastDigitsRule extends AtLeastBaseRule {
constructor(args: Language) {
super(args)
}
explain(options: PasswordPolicyRuleOptions, verified: boolean): PasswordPolicyRuleExplained {
return {
code: 'atLeastDigits',
message: this.$ngettext(
'At least %{param1} number',
'At least %{param1} numbers',
options.minLength
),
format: [options.minLength],
...(isBoolean(verified) && { verified })
}
}
assert(options: PasswordPolicyRuleOptions, password: string): boolean {
const digitCount = (password || '').match(/\d/g)?.length
return digitCount >= options.minLength
}
}
| owncloud/web/packages/web-pkg/src/services/passwordPolicy/rules.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/services/passwordPolicy/rules.ts",
"repo_id": "owncloud",
"token_count": 2724
} | 835 |
import { defaultComponentMocks, defaultPlugins, shallowMount } from 'web-test-helpers'
import AppBanner from '../../../src/components/AppBanner.vue'
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import { useSessionStorage } from '@vueuse/core'
import { ref } from 'vue'
vi.mock('@vueuse/core')
// @vitest-environment jsdom
describe('AppBanner', () => {
it('generates app url with correct app scheme', () => {
const baseElement = document.createElement('base')
baseElement.href = '/'
document.getElementsByTagName('head')[0].appendChild(baseElement)
delete window.location
window.location = new URL('https://localhost') as any
const { wrapper } = getWrapper({
fileId: '1337',
sessionStorageReturnValue: null
})
expect(wrapper.find('.app-banner-cta').attributes().href).toBe('owncloud://localhost/f/1337')
})
it('does not show when banner was closed', () => {
const { wrapper } = getWrapper({
fileId: '1337',
sessionStorageReturnValue: '1'
})
expect(wrapper.find('.app-banner').attributes().hidden).toBe('')
})
it('shows when banner was not yet closed', () => {
const { wrapper } = getWrapper({
fileId: '1337',
sessionStorageReturnValue: null
})
expect(wrapper.find('.app-banner').attributes().hidden).toBe(undefined)
})
})
function getWrapper({ fileId, sessionStorageReturnValue }) {
const router = createRouter({
routes: [
{
path: '/f',
component: {}
}
],
history: ('/' && createWebHistory('/')) || createWebHashHistory()
})
vi.mocked(useSessionStorage).mockImplementation(() => {
return ref<string>(sessionStorageReturnValue)
})
const mocks = { ...defaultComponentMocks(), $router: router }
return {
wrapper: shallowMount(AppBanner, {
props: {
fileId
},
global: {
plugins: [
...defaultPlugins({
piniaOptions: {
themeState: {
currentTheme: {
appBanner: {
title: 'ownCloud',
publisher: 'ownCloud GmbH',
additionalInformation: '',
ctaText: 'OPEN',
icon: 'themes/owncloud/assets/owncloud-app-icon.png',
appScheme: 'owncloud'
}
}
}
}
})
],
mocks,
provide: mocks
}
})
}
}
| owncloud/web/packages/web-pkg/tests/unit/components/AppBanner.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/components/AppBanner.spec.ts",
"repo_id": "owncloud",
"token_count": 1098
} | 836 |
import { defaultComponentMocks, defaultPlugins, defaultStubs, mount } from 'web-test-helpers'
import { mock } from 'vitest-mock-extended'
import { Resource, SpaceResource } from '@ownclouders/web-client/src/helpers'
import ContextActions from '../../../../src/components/FilesList/ContextActions.vue'
import {
useFileActionsEnableSync,
useFileActionsCopyQuickLink,
useFileActionsRename,
useFileActionsCopy
} from '../../../../src/composables'
import { computed } from 'vue'
import { Action } from '../../../../src/composables/actions'
// vi.mock('../../../../src/composables/actions/files', async (importOriginal) => {
// const original = await importOriginal()
// return createMockActionComposables(importOriginal())
// })
// vi.mock('../../../../src/composables/actions/files/useFileActionsSetReadme', (importOriginal) => {
// const original = await importOriginal()
// return createMockActionComposables(importOriginal())
// })
describe.skip('ContextActions', () => {
describe('menu sections', () => {
it('do not render when no action enabled', () => {
const { wrapper } = getWrapper()
expect(wrapper.findAll('action-menu-item-stub').length).toBe(0)
})
it('render enabled actions', () => {
const enabledComposables = [
useFileActionsEnableSync,
useFileActionsCopyQuickLink,
useFileActionsRename,
useFileActionsCopy
]
for (const composable of enabledComposables) {
vi.mocked(composable).mockImplementation(() => ({
actions: computed(() => [mock<Action>({ isVisible: () => true })])
}))
}
const { wrapper } = getWrapper()
expect(wrapper.findAll('action-menu-item-stub').length).toBe(enabledComposables.length)
})
})
})
function getWrapper() {
const mocks = {
...defaultComponentMocks()
}
return {
mocks,
wrapper: mount(ContextActions, {
props: {
actionOptions: {
space: mock<SpaceResource>(),
resources: [mock<Resource>()]
}
},
global: {
mocks,
provide: { ...mocks, currentSpace: mock<SpaceResource>() },
stubs: { ...defaultStubs, 'action-menu-item': true },
plugins: [...defaultPlugins()]
}
})
}
}
| owncloud/web/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts",
"repo_id": "owncloud",
"token_count": 866
} | 837 |
import LinkRoleDropdown from '../../../src/components/LinkRoleDropdown.vue'
import { defaultComponentMocks, defaultPlugins, mount } from 'web-test-helpers'
import { mock } from 'vitest-mock-extended'
import { ShareRole } from '@ownclouders/web-client/src/helpers'
import { SharingLinkType } from '@ownclouders/web-client/src/generated'
import { useLinkTypes } from '../../../src/composables/links/useLinkTypes'
vi.mock('../../../src/composables/links/useLinkTypes', () => ({
useLinkTypes: vi.fn()
}))
const selectors = {
currentRole: '.link-current-role',
roleOption: '.role-dropdown-list li',
roleOptionLabel: '.role-dropdown-list-option-label'
}
describe('LinkRoleDropdown', () => {
it('renders the label of the corresponding role to the given link type', () => {
const modelValue = SharingLinkType.Internal
const { wrapper } = getWrapper({ modelValue })
expect(wrapper.find(selectors.currentRole).text()).toEqual(modelValue)
})
it('renders all available role options based on the link types', () => {
const modelValue = SharingLinkType.Internal
const availableLinkTypeOptions = [SharingLinkType.Internal, SharingLinkType.View]
const { wrapper } = getWrapper({ modelValue, availableLinkTypeOptions })
expect(wrapper.findAll(selectors.roleOption).length).toEqual(availableLinkTypeOptions.length)
availableLinkTypeOptions.forEach((role, index) => {
expect(wrapper.findAll(selectors.roleOptionLabel).at(index).text()).toEqual(role)
})
})
})
function getWrapper({ modelValue = mock<SharingLinkType>(), availableLinkTypeOptions = [] } = {}) {
vi.mocked(useLinkTypes).mockReturnValue(
mock<ReturnType<typeof useLinkTypes>>({
getLinkRoleByType: (value) =>
mock<ShareRole>({ displayName: value, description: value, label: value })
})
)
const mocks = { ...defaultComponentMocks() }
return {
mocks,
wrapper: mount(LinkRoleDropdown, {
props: {
modelValue,
availableLinkTypeOptions
},
global: {
plugins: [...defaultPlugins()],
mocks,
provide: mocks
}
})
}
}
| owncloud/web/packages/web-pkg/tests/unit/components/LinkRoleDropdown.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/components/LinkRoleDropdown.spec.ts",
"repo_id": "owncloud",
"token_count": 739
} | 838 |
import FileSideBar from '../../../../src/components/SideBar/FileSideBar.vue'
import { Resource } from '@ownclouders/web-client/src/helpers'
import { mock } from 'vitest-mock-extended'
import {
defaultComponentMocks,
defaultPlugins,
RouteLocation,
shallowMount
} from 'web-test-helpers'
import { defineComponent, ref } from 'vue'
import { useSelectedResources } from '../../../../src/composables/selection'
const InnerSideBarComponent = defineComponent({
props: { availablePanels: { type: Array, required: true } },
template: '<div id="foo"><slot name="header"></slot></div>'
})
vi.mock('../../../../src/composables/selection', () => ({ useSelectedResources: vi.fn() }))
const selectors = {
sideBar: '.files-side-bar',
fileInfoStub: 'file-info-stub',
spaceInfoStub: 'space-info-stub'
}
describe('FileSideBar', () => {
describe('isOpen', () => {
it.each([true, false])(
'should show or hide the sidebar according to the isOpen prop',
(isOpen) => {
const { wrapper } = createWrapper({ isOpen })
expect(wrapper.find(selectors.sideBar).exists()).toBe(isOpen)
}
)
})
describe('file info header', () => {
it('should show when one resource selected', async () => {
const item = mock<Resource>({ path: '/someFolder' })
const { wrapper } = createWrapper({ item })
wrapper.vm.loadedResource = item
await wrapper.vm.$nextTick()
expect(wrapper.find(selectors.fileInfoStub).exists()).toBeTruthy()
})
it('not show when no resource selected', () => {
const { wrapper } = createWrapper()
expect(wrapper.find(selectors.fileInfoStub).exists()).toBeFalsy()
})
it('should not show when selected resource is a project space', async () => {
const item = mock<Resource>({ path: '/someFolder', driveType: 'project' })
const { wrapper } = createWrapper({ item })
wrapper.vm.loadedResource = item
await wrapper.vm.$nextTick()
expect(wrapper.find(selectors.fileInfoStub).exists()).toBeFalsy()
})
})
describe('space info header', () => {
it('should show when one project space resource selected', async () => {
const item = mock<Resource>({ path: '/someFolder', driveType: 'project' })
const { wrapper } = createWrapper({ item })
wrapper.vm.loadedResource = item
await wrapper.vm.$nextTick()
expect(wrapper.find(selectors.spaceInfoStub).exists()).toBeTruthy()
})
it('not show when no resource selected', () => {
const { wrapper } = createWrapper()
expect(wrapper.find(selectors.spaceInfoStub).exists()).toBeFalsy()
})
it('should not show when selected resource is not a project space', async () => {
const item = mock<Resource>({ path: '/someFolder' })
const { wrapper } = createWrapper({ item })
wrapper.vm.loadedResource = item
await wrapper.vm.$nextTick()
expect(wrapper.find(selectors.spaceInfoStub).exists()).toBeFalsy()
})
})
})
function createWrapper({
item = undefined,
isOpen = true
}: { item?: Resource; isOpen?: boolean } = {}) {
vi.mocked(useSelectedResources).mockReturnValue(
mock<ReturnType<typeof useSelectedResources>>({
selectedResources: item ? ref([item]) : ref([])
})
)
const mocks = defaultComponentMocks({
currentRoute: mock<RouteLocation>({ name: 'files-spaces-generic' })
})
return {
wrapper: shallowMount(FileSideBar, {
props: {
isOpen
},
global: {
plugins: [...defaultPlugins()],
renderStubDefaultSlot: true,
stubs: {
InnerSideBar: InnerSideBarComponent
},
mocks,
provide: mocks
}
})
}
}
| owncloud/web/packages/web-pkg/tests/unit/components/sidebar/FileSideBar.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/components/sidebar/FileSideBar.spec.ts",
"repo_id": "owncloud",
"token_count": 1362
} | 839 |
import { mock } from 'vitest-mock-extended'
import { unref } from 'vue'
import { useFileActionsDownloadArchive } from '../../../../../src/composables/actions'
import { Resource } from '@ownclouders/web-client'
import { defaultComponentMocks, RouteLocation, getComposableWrapper } from 'web-test-helpers'
import { useArchiverService } from '../../../../../src/composables'
import { ArchiverService } from '../../../../../src'
import { ref } from 'vue'
vi.mock('../../../../../src/composables/archiverService/useArchiverService')
describe('downloadArchive', () => {
describe('search context', () => {
describe('computed property "actions"', () => {
describe('handler', () => {
it.each([
{
resources: [
{ id: '1', fileId: '1', canDownload: () => true },
{ id: '2', fileId: '2', canDownload: () => true }
] as Resource[],
downloadableResourceIds: ['1', '2']
},
{
resources: [
{ id: '1', fileId: '1', canDownload: () => true },
{ id: '2', fileId: '2', canDownload: () => true },
{ id: '3', fileId: '3', canDownload: () => true },
{ id: '4', fileId: '4', canDownload: () => false },
{ id: '5', fileId: '5', canDownload: () => true, driveType: 'project' }
] as Resource[],
downloadableResourceIds: ['1', '2', '3']
}
])('should filter non downloadable resources', ({ resources, downloadableResourceIds }) => {
const triggerDownloadMock = vi.fn().mockResolvedValue(true)
getWrapper({
searchLocation: true,
triggerDownloadMock,
setup: () => {
const { actions } = useFileActionsDownloadArchive()
unref(actions)[0].handler({ space: null, resources })
expect(triggerDownloadMock).toHaveBeenCalledWith({ fileIds: downloadableResourceIds })
}
})
})
})
})
})
})
function getWrapper({
searchLocation = false,
triggerDownloadMock = vi.fn() as (...args) => unknown,
setup = () => undefined
} = {}) {
const routeName = searchLocation ? 'files-common-search' : 'files-spaces-generic'
vi.mocked(useArchiverService).mockImplementation(() => {
return {
triggerDownload: triggerDownloadMock,
fileIdsSupported: ref(true)
} as ArchiverService
})
const mocks = {
...defaultComponentMocks({ currentRoute: mock<RouteLocation>({ name: routeName }) }),
space: { driveType: 'personal', spaceRoles: { viewer: [], editor: [], manager: [] } }
}
return {
wrapper: getComposableWrapper(setup, {
mocks,
provide: mocks
})
}
}
| owncloud/web/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsDownloadArchive.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsDownloadArchive.spec.ts",
"repo_id": "owncloud",
"token_count": 1147
} | 840 |
import { useSpaceActionsNavigateToTrash } from '../../../../../src'
import { mock } from 'vitest-mock-extended'
import { defaultComponentMocks, RouteLocation, getComposableWrapper } from 'web-test-helpers'
import { unref } from 'vue'
import { SpaceResource } from '@ownclouders/web-client/src'
describe('navigateToSpace', () => {
describe('isVisible property', () => {
it('should be false when no resource given', () => {
getWrapper({
setup: ({ actions }) => {
expect(unref(actions)[0].isVisible({ resources: [] })).toBe(false)
}
})
})
it('should be false when the space is disabled', () => {
getWrapper({
setup: ({ actions }) => {
expect(
unref(actions)[0].isVisible({
resources: [
mock<SpaceResource>({
disabled: true,
driveType: 'project'
})
]
})
).toBe(false)
}
})
})
it('should be false when the space is no project space', () => {
getWrapper({
setup: ({ actions }) => {
expect(
unref(actions)[0].isVisible({
resources: [
mock<SpaceResource>({
disabled: false,
driveType: 'personal'
})
]
})
).toBe(false)
}
})
})
})
describe('handler', () => {
it('should redirect to respective trash', () => {
const { mocks } = getWrapper({
setup: async ({ actions }) => {
await unref(actions)[0].handler({
resources: [mock<SpaceResource>()]
})
expect(mocks.$router.push).toHaveBeenCalled()
}
})
})
})
})
function getWrapper({
setup
}: {
setup: (instance: ReturnType<typeof useSpaceActionsNavigateToTrash>) => void
}) {
const mocks = defaultComponentMocks({
currentRoute: mock<RouteLocation>({ name: 'files-spaces-projects' })
})
return {
mocks,
wrapper: getComposableWrapper(
() => {
const instance = useSpaceActionsNavigateToTrash()
setup(instance)
},
{
mocks,
provide: mocks
}
)
}
}
| owncloud/web/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsNavigateToTrash.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsNavigateToTrash.spec.ts",
"repo_id": "owncloud",
"token_count": 1073
} | 841 |
import { createTestingPinia, getComposableWrapper } from 'web-test-helpers'
import { RawConfig, useAppsStore, useConfigStore } from '../../../../src/composables/piniaStores'
describe('useConfigStore', () => {
beforeEach(() => {
createTestingPinia({ stubActions: false })
})
it('has initial options as defaults', () => {
getWrapper({
setup: (instance) => {
expect(Object.keys(instance.options).length).toBeGreaterThan(0)
}
})
})
describe('method "loadConfig"', () => {
it('sets given options and overwrites defaults', () => {
getWrapper({
setup: (instance) => {
expect(instance.options.openLinksWithDefaultApp).toBeTruthy()
const data = { options: { openLinksWithDefaultApp: false } } as RawConfig
instance.loadConfig(data)
expect(instance.options.openLinksWithDefaultApp).toBeFalsy()
}
})
})
it('loads config for external apps', () => {
getWrapper({
setup: (instance) => {
const externalApp = { id: '1', config: { foo: 'bar' } }
const data = {
server: 'https://foo.bar',
theme: undefined,
options: { openLinksWithDefaultApp: false },
external_apps: [externalApp]
} as RawConfig
instance.loadConfig(data)
const appsStore = useAppsStore()
expect(appsStore.loadExternalAppConfig).toHaveBeenCalledWith({
appId: externalApp.id,
config: externalApp.config
})
}
})
})
})
describe('serverUrl', () => {
it('defaults to "window.location.origin" if no server url given', () => {
getWrapper({
setup: (instance) => {
const data = { theme: '' } as RawConfig
instance.loadConfig(data)
expect(instance.serverUrl).toEqual(`${window.location.origin}/`)
}
})
})
})
})
function getWrapper({ setup }: { setup: (instance: ReturnType<typeof useConfigStore>) => void }) {
return {
wrapper: getComposableWrapper(
() => {
const instance = useConfigStore()
setup(instance)
},
{ pluginOptions: { pinia: false } }
)
}
}
| owncloud/web/packages/web-pkg/tests/unit/composables/piniaStores/cofig.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/composables/piniaStores/cofig.spec.ts",
"repo_id": "owncloud",
"token_count": 934
} | 842 |
import { DateTime, Settings } from 'luxon'
import {
formatDateFromDateTime,
formatDateFromJSDate,
formatDateFromHTTP,
formatDateFromISO,
formatDateFromRFC,
formatRelativeDateFromDateTime,
formatRelativeDateFromJSDate,
formatRelativeDateFromISO,
formatRelativeDateFromRFC
} from '../../../src/helpers/datetime'
describe('datetime helper', () => {
const language = 'en'
const dateFormat = DateTime.DATETIME_MED
beforeEach(() => {
Settings.defaultZone = 'utc'
})
describe('formatDateFromDateTime', () => {
it('should give correct output', () => {
expect(
formatDateFromDateTime(DateTime.fromISO('2010-10-22T21:38:00'), language, dateFormat)
).toBe('Oct 22, 2010, 9:38 PM')
})
})
describe('formatDateFromJSDate', () => {
it('should give correct output', () => {
expect(formatDateFromJSDate(new Date('2010-10-22T21:38:00'), language, dateFormat)).toBe(
'Oct 22, 2010, 9:38 PM'
)
})
it('should fail for null', () => {
expect(formatDateFromJSDate(null, language, dateFormat)).toBe('Invalid DateTime')
})
})
describe('formatDateFromHTTP', () => {
it('should give correct output', () => {
expect(formatDateFromHTTP('Tue, 15 Nov 1994 12:45:26 GMT', language, dateFormat)).toBe(
'Nov 15, 1994, 12:45 PM'
)
})
it('should fail for invalid http date', () => {
expect(formatDateFromHTTP('Some not http date 123', language, dateFormat)).toBe(
'Invalid DateTime'
)
})
})
describe('formatDateFromISO', () => {
it('should give correct output', () => {
expect(formatDateFromISO('2010-10-22T21:38:00', language, dateFormat)).toBe(
'Oct 22, 2010, 9:38 PM'
)
})
it('should fail for invalid iso date', () => {
expect(formatDateFromISO('some invalid iso date 123', language, dateFormat)).toBe(
'Invalid DateTime'
)
})
})
describe('formatDateFromRFC', () => {
it('should give correct output', () => {
expect(formatDateFromRFC('01 Jun 2016 14:31:46 -0700', language, dateFormat)).toBe(
'Jun 1, 2016, 9:31 PM'
)
})
it('should fail for invalid rfc date', () => {
expect(formatDateFromRFC('some invalid rfc 123', language, dateFormat)).toBe(
'Invalid DateTime'
)
})
})
describe('formatRelativeDateFromDateTime', () => {
it('should return correct relative time', () => {
expect(formatRelativeDateFromDateTime(DateTime.now().minus({ years: 12 }), language)).toBe(
'12 years ago'
)
})
})
describe('formatRelativeDateFromJSDate', () => {
it('should return correct relative time', () => {
expect(
formatRelativeDateFromJSDate(DateTime.now().minus({ years: 12 }).toJSDate(), language)
).toBe('12 years ago')
})
it('should return null if date is null', () => {
expect(formatRelativeDateFromJSDate(null, language)).toBe(null)
})
})
describe('formatRelativeDateFromISO', () => {
it('should return correct relative time', () => {
expect(formatRelativeDateFromISO(DateTime.now().minus({ years: 12 }).toISO(), language)).toBe(
'12 years ago'
)
})
it('should return null if invalid iso', () => {
expect(formatRelativeDateFromISO('some invalid iso 123', language)).toBe(null)
})
})
describe('formatRelativeDateFromRFC', () => {
it('should return correct relative time', () => {
expect(
formatRelativeDateFromRFC(DateTime.now().minus({ years: 12 }).toRFC2822(), language)
).toBe('12 years ago')
})
it('should return null if invalid rfc', () => {
expect(formatRelativeDateFromRFC('some invalid rfc 123', language)).toBe(null)
})
})
})
| owncloud/web/packages/web-pkg/tests/unit/helpers/datetime.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/helpers/datetime.spec.ts",
"repo_id": "owncloud",
"token_count": 1419
} | 843 |
import { ArchiverService } from '../../../src/services'
import { RuntimeError } from '../../../src/errors'
import { mock, mockDeep } from 'vitest-mock-extended'
import { ClientService } from '../../../src/services'
import { unref, ref, Ref } from 'vue'
import { AxiosResponse } from 'axios'
import { ArchiverCapability } from '@ownclouders/web-client/src/ocs/capabilities'
const serverUrl = 'https://demo.owncloud.com'
const getArchiverServiceInstance = (capabilities: Ref<ArchiverCapability[]>) => {
const clientServiceMock = mockDeep<ClientService>()
clientServiceMock.httpUnAuthenticated.get.mockResolvedValue({
data: new ArrayBuffer(8),
headers: { 'content-disposition': 'filename="download.tar"' }
} as unknown as AxiosResponse)
clientServiceMock.ocsUserContext.signUrl.mockImplementation((url) => Promise.resolve(url))
return new ArchiverService(clientServiceMock, serverUrl, capabilities)
}
describe('archiver', () => {
describe('availability', () => {
it('is unavailable if no version given via capabilities', () => {
const capabilities = ref([mock<ArchiverCapability>({ version: undefined })])
expect(unref(getArchiverServiceInstance(capabilities).available)).toBe(false)
})
it('is available if a version is given via capabilities', () => {
const capabilities = ref([mock<ArchiverCapability>({ version: '1' })])
expect(unref(getArchiverServiceInstance(capabilities).available)).toBe(true)
})
})
it('does not trigger downloads when unavailable', async () => {
const capabilities = ref([mock<ArchiverCapability>({ version: undefined })])
const archiverService = getArchiverServiceInstance(capabilities)
await expect(archiverService.triggerDownload({})).rejects.toThrow(
new RuntimeError('no archiver available')
)
})
describe('with one v2 archiver capability', () => {
const archiverUrl = [serverUrl, 'archiver'].join('/')
const capabilities = ref([
{
enabled: true,
version: 'v2.3.5',
archiver_url: archiverUrl,
formats: [],
max_num_files: '42',
max_size: '1073741824'
}
])
it('is announcing itself as supporting fileIds', () => {
const archiverService = getArchiverServiceInstance(capabilities)
expect(unref(archiverService.fileIdsSupported)).toBe(true)
})
it('fails to trigger a download if no files were given', async () => {
const archiverService = getArchiverServiceInstance(capabilities)
await expect(archiverService.triggerDownload({})).rejects.toThrow(
new RuntimeError('requested archive with empty list of resources')
)
})
it('returns a download url for a valid archive download trigger', async () => {
const archiverService = getArchiverServiceInstance(capabilities)
window.URL.createObjectURL = vi.fn(() => '')
const fileId = 'asdf'
const url = await archiverService.triggerDownload({ fileIds: [fileId] })
expect(window.URL.createObjectURL).toHaveBeenCalled()
expect(url.startsWith(archiverUrl)).toBeTruthy()
expect(url.indexOf(`id=${fileId}`)).toBeGreaterThan(-1)
})
})
describe('with one v1 archiver capability', () => {
const archiverUrl = [serverUrl, 'archiver'].join('/')
const capabilities = ref([
{
enabled: true,
version: 'v1.2.3',
archiver_url: archiverUrl,
formats: [],
max_num_files: '42',
max_size: '1073741824'
}
])
it('is announcing itself as not supporting fileIds', () => {
const archiverService = getArchiverServiceInstance(capabilities)
expect(unref(archiverService.fileIdsSupported)).toBe(false)
})
it('fails to trigger a download if no files were given', async () => {
const archiverService = getArchiverServiceInstance(capabilities)
await expect(archiverService.triggerDownload({})).rejects.toThrow(
new RuntimeError('requested archive with empty list of resources')
)
})
it('returns a download url for a valid archive download trigger', async () => {
const archiverService = getArchiverServiceInstance(capabilities)
window.URL.createObjectURL = vi.fn(() => '')
const dir = '/some/path'
const fileName = 'qwer'
const url = await archiverService.triggerDownload({ dir, files: [fileName] })
expect(window.URL.createObjectURL).toHaveBeenCalled()
expect(url.startsWith(archiverUrl)).toBeTruthy()
expect(url.indexOf(`files[]=${fileName}`)).toBeGreaterThan(-1)
expect(url.indexOf(`dir=${encodeURIComponent(dir)}`)).toBeGreaterThan(-1)
expect(url.indexOf('downloadStartSecret=')).toBeGreaterThan(-1)
})
})
describe('with multiple archiver capabilities of different versions', () => {
const archiverUrl = [serverUrl, 'archiver'].join('/')
const capabilityV1 = {
enabled: true,
version: 'v1.2.3',
archiver_url: archiverUrl + '/v1',
formats: [],
max_num_files: '42',
max_size: '1073741824'
}
const capabilityV2 = {
enabled: true,
version: 'v2.3.5',
archiver_url: archiverUrl + '/v2',
formats: [],
max_num_files: '42',
max_size: '1073741824'
}
const capabilityV3 = {
enabled: false,
version: 'v3.2.5',
archiver_url: archiverUrl + '/v3',
formats: [],
max_num_files: '42',
max_size: '1073741824'
}
it('uses the highest major version', async () => {
const capabilities = ref([capabilityV1, capabilityV2, capabilityV3])
const archiverService = getArchiverServiceInstance(capabilities)
const downloadUrl = await archiverService.triggerDownload({ fileIds: ['any'] })
expect(downloadUrl.startsWith(capabilityV2.archiver_url)).toBeTruthy()
})
})
})
| owncloud/web/packages/web-pkg/tests/unit/services/archiver.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/services/archiver.spec.ts",
"repo_id": "owncloud",
"token_count": 2145
} | 844 |
<template>
<portal-target name="app.app-banner" multiple />
<div id="web">
<oc-hidden-announcer :announcement="announcement" level="polite" />
<skip-to target="web-content-main">
<span v-text="$gettext('Skip to main')" />
</skip-to>
<component :is="layout"></component>
<modal-wrapper />
</div>
</template>
<script lang="ts">
import SkipTo from './components/SkipTo.vue'
import ModalWrapper from './components/ModalWrapper.vue'
import { useLayout } from './composables/layout'
import { computed, defineComponent, unref, watch } from 'vue'
import { additionalTranslations } from './helpers/additionalTranslations' // eslint-disable-line
import { eventBus, useResourcesStore, useRouter, useThemeStore } from '@ownclouders/web-pkg'
import { useHead } from './composables/head'
import { RouteLocation } from 'vue-router'
import { storeToRefs } from 'pinia'
import { isEqual } from 'lodash-es'
export default defineComponent({
components: {
SkipTo,
ModalWrapper
},
setup() {
const resourcesStore = useResourcesStore()
const themeStore = useThemeStore()
const { currentTheme } = storeToRefs(themeStore)
const router = useRouter()
useHead()
const activeRoute = computed(() => router.resolve(unref(router.currentRoute)))
const { layout } = useLayout({ router })
watch(
() => unref(activeRoute),
(newRoute, oldRoute) => {
const getAppContextFromRoute = (route: RouteLocation): string[] => {
return route?.path?.split('/').slice(1, 4)
}
const oldAppContext = getAppContextFromRoute(oldRoute)
const newAppContext = getAppContextFromRoute(newRoute)
if (isEqual(oldAppContext, newAppContext)) {
return
}
if ('driveAliasAndItem' in newRoute.params) {
return
}
/*
* If app context has been changed and no file context is set, we will reset current folder.
*/
resourcesStore.setCurrentFolder(null)
}
)
return {
layout,
currentTheme
}
},
data() {
return {
windowWidth: 0,
announcement: '',
activeBlobStyle: {}
}
},
watch: {
$route: {
immediate: true,
handler: function (to) {
const extracted = this.extractPageTitleFromRoute(to)
if (!extracted) {
return
}
const { shortDocumentTitle, fullDocumentTitle } = extracted
this.announceRouteChange(shortDocumentTitle)
document.title = fullDocumentTitle
}
}
},
mounted() {
eventBus.subscribe(
'runtime.documentTitle.changed',
({ shortDocumentTitle, fullDocumentTitle }) => {
document.title = fullDocumentTitle
this.announceRouteChange(shortDocumentTitle)
}
)
},
methods: {
announceRouteChange(pageTitle) {
this.announcement = this.$gettext('Navigated to %{ pageTitle }', { pageTitle })
},
extractPageTitleFromRoute(route) {
const routeTitle = route.meta.title ? this.$gettext(route.meta.title) : undefined
if (!routeTitle) {
return
}
const glue = ' - '
const titleSegments = [routeTitle]
return {
shortDocumentTitle: titleSegments.join(glue),
fullDocumentTitle: [...titleSegments, this.currentTheme.common.name].join(glue)
}
}
}
})
</script>
<style lang="scss">
body {
margin: 0;
}
#web {
background-color: var(--oc-color-swatch-brand-default);
height: 100vh;
max-height: 100vh;
overflow-y: hidden;
.mark-highlight {
font-weight: 600;
}
}
iframe {
border: 0;
}
</style>
| owncloud/web/packages/web-runtime/src/App.vue/0 | {
"file_path": "owncloud/web/packages/web-runtime/src/App.vue",
"repo_id": "owncloud",
"token_count": 1439
} | 845 |
<template>
<header
id="oc-topbar"
:class="{ 'open-app': contentOnLeftPortal }"
:aria-label="$gettext('Top bar')"
>
<div class="oc-topbar-left oc-flex oc-flex-middle oc-flex-start">
<applications-menu
v-if="appMenuItems.length && !isEmbedModeEnabled"
:applications-list="appMenuItems"
/>
<router-link ref="navigationSidebarLogo" :to="homeLink" class="oc-width-1-1">
<oc-img
v-oc-tooltip="$gettext('Back to home')"
:src="currentTheme.logo.topbar"
:alt="sidebarLogoAlt"
class="oc-logo-image"
/>
</router-link>
</div>
<div v-if="!contentOnLeftPortal" class="oc-topbar-center">
<portal-target name="app.runtime.header" multiple />
</div>
<div class="oc-topbar-right oc-flex oc-flex-middle">
<portal-target name="app.runtime.header.right" multiple />
</div>
<template v-if="!isEmbedModeEnabled">
<portal to="app.runtime.header.right" :order="50">
<feedback-link v-if="isFeedbackLinkEnabled" v-bind="feedbackLinkOptions" />
</portal>
<portal to="app.runtime.header.right" :order="100">
<notifications v-if="isNotificationBellEnabled" />
<side-bar-toggle v-if="isSideBarToggleVisible" :disabled="isSideBarToggleDisabled" />
<user-menu :applications-list="userMenuItems" />
</portal>
</template>
<portal-target name="app.runtime.header.left" @change="updateLeftPortal" />
</header>
</template>
<script lang="ts">
import { storeToRefs } from 'pinia'
import { computed, unref, PropType, ref } from 'vue'
import { useGettext } from 'vue3-gettext'
import ApplicationsMenu from './ApplicationsMenu.vue'
import UserMenu from './UserMenu.vue'
import Notifications from './Notifications.vue'
import FeedbackLink from './FeedbackLink.vue'
import SideBarToggle from './SideBarToggle.vue'
import {
useAbility,
useAuthStore,
useCapabilityStore,
useConfigStore,
useEmbedMode,
useRouter,
useThemeStore
} from '@ownclouders/web-pkg'
import { isRuntimeRoute } from '../../router'
export default {
components: {
ApplicationsMenu,
FeedbackLink,
Notifications,
SideBarToggle,
UserMenu
},
props: {
applicationsList: {
type: Array as PropType<any[]>,
required: false,
default: () => []
}
},
setup(props) {
const capabilityStore = useCapabilityStore()
const themeStore = useThemeStore()
const { currentTheme } = storeToRefs(themeStore)
const configStore = useConfigStore()
const { options: configOptions } = storeToRefs(configStore)
const authStore = useAuthStore()
const language = useGettext()
const router = useRouter()
const ability = useAbility()
const { isEnabled: isEmbedModeEnabled } = useEmbedMode()
const logoWidth = ref('150px')
const isNotificationBellEnabled = computed(() => {
return (
authStore.userContextReady && capabilityStore.notificationsOcsEndpoints.includes('list')
)
})
const homeLink = computed(() => {
if (authStore.publicLinkContextReady && !authStore.userContextReady) {
return {
name: 'resolvePublicLink',
params: { token: authStore.publicLinkToken }
}
}
return '/'
})
const isSideBarToggleVisible = computed(() => {
return authStore.userContextReady || authStore.publicLinkContextReady
})
const isSideBarToggleDisabled = computed(() => {
return isRuntimeRoute(unref(router.currentRoute))
})
const isNavItemPermitted = (permittedMenus, navItem) => {
if (navItem.menu) {
return permittedMenus.includes(navItem.menu)
}
return permittedMenus.includes(null)
}
/**
* Returns well-formed menuItem objects by a list of extensions.
* The following properties must be accessible in the wrapping code:
* - applicationsList
* - $language
*
* @param {Array} permittedMenus
* @param {String} activeRoutePath
* @returns {*}
*/
const getMenuItems = (permittedMenus, activeRoutePath) => {
return props.applicationsList
.filter((app) => {
if (app.type === 'extension') {
return (
app.applicationMenu.enabled instanceof Function &&
app.applicationMenu.enabled(ability) &&
!permittedMenus.includes('user')
)
}
return isNavItemPermitted(permittedMenus, app)
})
.map((item) => {
const lang = language.current
// TODO: move language resolution to a common function
// FIXME: need to handle logic for variants like en_US vs en_GB
let title = item.title ? item.title.en : item.name
let color = item.color
let icon
let iconUrl
if (item.title && item.title[lang]) {
title = item.title[lang]
}
if (!item.icon) {
icon = 'deprecated' // "broken" icon
} else if (item.icon.indexOf('.') < 0) {
// not a file name or URL, treat as a material icon name instead
icon = item.icon
} else {
iconUrl = item.icon
}
const app: any = {
id: item.id,
icon: icon,
iconUrl: iconUrl,
title: title,
color: color,
applicationMenu: item.applicationMenu,
defaultExtension: item.defaultExtension
}
if (item.url) {
app.url = item.url
app.target = ['_blank', '_self', '_parent', '_top'].includes(item.target)
? item.target
: '_blank'
} else if (item.path) {
app.path = item.path
app.active = activeRoutePath?.startsWith(app.path)
} else {
app.path = `/${item.id}`
app.active = activeRoutePath?.startsWith(app.path)
}
return app
})
}
const activeRoutePath = computed(() => router.resolve(unref(router.currentRoute)).path)
const userMenuItems = computed(() => getMenuItems(['user'], unref(activeRoutePath)))
const appMenuItems = computed(() =>
getMenuItems([null, 'apps', 'appSwitcher'], unref(activeRoutePath))
)
const contentOnLeftPortal = ref(false)
const updateLeftPortal = (newContent) => {
contentOnLeftPortal.value = newContent.hasContent
}
return {
configOptions,
contentOnLeftPortal,
currentTheme,
updateLeftPortal,
isNotificationBellEnabled,
userMenuItems,
appMenuItems,
logoWidth,
isEmbedModeEnabled,
isSideBarToggleVisible,
isSideBarToggleDisabled,
homeLink
}
},
computed: {
sidebarLogoAlt() {
return this.$gettext('Navigate to personal files page')
},
isFeedbackLinkEnabled() {
return !this.configOptions.disableFeedbackLink
},
feedbackLinkOptions() {
const feedback = this.configOptions.feedbackLink
if (!this.isFeedbackLinkEnabled || !feedback) {
return {}
}
return {
...(feedback.href && { href: feedback.href }),
...(feedback.ariaLabel && { ariaLabel: feedback.ariaLabel }),
...(feedback.description && { description: feedback.description })
}
}
},
async created() {
const image = new Image()
const imageDimensions = (await new Promise((resolve) => {
image.onload = () => {
resolve({
height: image.height,
width: image.width
})
}
image.src = this.currentTheme.logo.topbar
})) as { height: number; width: number }
// max-height of logo is 38px, so we calculate the width based on the ratio of the image
// and add 70px to account for the width of the left side of the topbar
this.logoWidth = `${imageDimensions.width / (imageDimensions.height / 38) + 70}px`
}
}
</script>
<style lang="scss">
#oc-topbar {
align-items: center;
display: grid;
grid-template-areas: 'logo center right' 'secondRow secondRow secondRow';
grid-template-columns: 30% 30% 40%;
grid-template-rows: 52px auto;
padding: 0 1rem;
position: sticky;
z-index: 5;
@media (min-width: $oc-breakpoint-small-default) {
column-gap: 10px;
grid-template-columns: v-bind(logoWidth) 9fr 1fr;
grid-template-rows: 1;
height: 52px;
justify-content: center;
padding: 0 1.1rem;
}
&.open-app {
grid-template-columns: 30% 30% 40%;
@media (min-width: $oc-breakpoint-small-default) {
grid-template-columns: v-bind(logoWidth) 1fr 1fr;
}
}
img {
max-height: 38px;
image-rendering: auto;
image-rendering: crisp-edges;
image-rendering: pixelated;
image-rendering: -webkit-optimize-contrast;
user-select: none;
}
.oc-topbar-left {
gap: 10px;
grid-area: logo;
@media (min-width: $oc-breakpoint-small-default) {
gap: 20px;
}
}
.oc-topbar-center {
display: flex;
grid-area: center;
justify-content: flex-end;
@media (min-width: $oc-breakpoint-small-default) {
justify-content: center;
}
}
.oc-topbar-right {
gap: 10px;
grid-area: right;
justify-content: space-between;
@media (min-width: $oc-breakpoint-small-default) {
gap: 20px;
justify-content: flex-end;
}
}
}
</style>
| owncloud/web/packages/web-runtime/src/components/Topbar/TopBar.vue/0 | {
"file_path": "owncloud/web/packages/web-runtime/src/components/Topbar/TopBar.vue",
"repo_id": "owncloud",
"token_count": 3985
} | 846 |
import { Router, RouteRecordRaw } from 'vue-router'
import { App, Component } from 'vue'
import { AppNavigationItem, ApplicationTranslations } from '@ownclouders/web-pkg'
/** RuntimeApi defines the publicly available runtime api */
export interface RuntimeApi {
announceRoutes: (routes: RouteRecordRaw[]) => void
announceNavigationItems: (navigationItems: AppNavigationItem[]) => void
announceTranslations: (appTranslations: ApplicationTranslations) => void
requestRouter: () => Router
openPortal: (
instance: App,
toApp: string,
toPortal: string,
order: number,
components: Component[]
) => void
}
| owncloud/web/packages/web-runtime/src/container/types.ts/0 | {
"file_path": "owncloud/web/packages/web-runtime/src/container/types.ts",
"repo_id": "owncloud",
"token_count": 194
} | 847 |
<template>
<div
class="oc-login oc-height-viewport"
:style="{ backgroundImage: 'url(' + backgroundImg + ')' }"
>
<h1 class="oc-invisible-sr" v-text="pageTitle" />
<router-view />
</div>
</template>
<script lang="ts">
import { storeToRefs } from 'pinia'
import { computed, defineComponent, unref } from 'vue'
import { useGettext } from 'vue3-gettext'
import { useRouteMeta, useThemeStore } from '@ownclouders/web-pkg'
export default defineComponent({
name: 'PlainLayout',
setup() {
const { $gettext } = useGettext()
const themeStore = useThemeStore()
const { currentTheme } = storeToRefs(themeStore)
const title = useRouteMeta('title')
const pageTitle = computed(() => {
return $gettext(unref(title) || '')
})
const backgroundImg = computed(() => currentTheme.value.loginPage.backgroundImg)
return {
pageTitle,
backgroundImg
}
}
})
</script>
| owncloud/web/packages/web-runtime/src/layouts/Plain.vue/0 | {
"file_path": "owncloud/web/packages/web-runtime/src/layouts/Plain.vue",
"repo_id": "owncloud",
"token_count": 348
} | 848 |
export * from './authService'
| owncloud/web/packages/web-runtime/src/services/auth/index.ts/0 | {
"file_path": "owncloud/web/packages/web-runtime/src/services/auth/index.ts",
"repo_id": "owncloud",
"token_count": 9
} | 849 |
import ApplicationsMenu from 'web-runtime/src/components/Topbar/ApplicationsMenu.vue'
import {
RouteLocation,
defaultComponentMocks,
defaultPlugins,
shallowMount
} from 'web-test-helpers'
import { mock } from 'vitest-mock-extended'
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
useFileActions: vi.fn(() => ({ openEditor: vi.fn() }))
}))
const menuLinks = [
{
icon: 'folder',
iconUrl: undefined,
title: 'Files',
path: '/files'
},
{
icon: 'some-icon',
iconUrl: undefined,
title: 'External',
url: 'http://some.org',
target: '_blank'
}
]
describe('ApplicationsMenu component', () => {
it('should render navigation with button and menu items in dropdown', () => {
const { wrapper } = getWrapper(menuLinks)
expect(wrapper.html()).toMatchSnapshot()
})
})
function getWrapper(applicationsList = []) {
const mocks = {
...defaultComponentMocks({
currentRoute: mock<RouteLocation>({ query: { app: 'admin-settings' } })
}),
space: { driveType: 'personal', spaceRoles: { viewer: [], editor: [], manager: [] } }
}
return {
wrapper: shallowMount(ApplicationsMenu, {
props: {
applicationsList
},
global: {
renderStubDefaultSlot: true,
mocks,
provide: mocks,
plugins: [...defaultPlugins()]
}
})
}
}
| owncloud/web/packages/web-runtime/tests/unit/components/Topbar/ApplicationsMenu.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-runtime/tests/unit/components/Topbar/ApplicationsMenu.spec.ts",
"repo_id": "owncloud",
"token_count": 541
} | 850 |
import { loadTheme } from 'web-runtime/src/helpers/theme'
import defaultTheme from 'web-runtime/themes/owncloud/theme.json'
import merge from 'lodash-es/merge'
import { ThemingConfig, WebThemeConfig } from '@ownclouders/web-pkg'
import { mock } from 'vitest-mock-extended'
vi.mock('@ownclouders/web-pkg', async (importOriginal) => {
const actual = await importOriginal()
return {
...(actual as any),
ThemingConfig: {
parse: vi.fn((arg) => arg),
safeParse: (arg) => (actual as any).ThemingConfig.safeParse(arg)
}
}
})
vi.spyOn(console, 'error').mockImplementation(() => undefined)
const defaultOwnCloudTheme = {
defaults: {
...defaultTheme.clients.web.defaults,
common: defaultTheme.common
},
themes: defaultTheme.clients.web.themes
}
describe('theme loading and error reporting', () => {
it('the locally included theme should be valid', () => {
const { success } = ThemingConfig.safeParse(defaultTheme)
expect(success).toBeTruthy()
})
it('the default web theme should be valid', () => {
const { success } = WebThemeConfig.safeParse(defaultOwnCloudTheme)
expect(success).toBeTruthy()
})
it('should load the default theme if location is empty', async () => {
const theme = await loadTheme()
expect(theme).toMatchObject(defaultOwnCloudTheme)
})
it('should load the default theme if location is not a json file extension', async () => {
const theme = await loadTheme('some_location_without_json_file_ending.xml')
expect(theme).toMatchObject(defaultOwnCloudTheme)
})
it('should load the default theme if location is not found', async () => {
vi.spyOn(global, 'fetch').mockResolvedValue(mock<Response>({ status: 404 }))
const theme = await loadTheme('http://www.owncloud.com/unknown.json')
expect(theme).toMatchObject(defaultOwnCloudTheme)
})
it('should load the default theme if location is not a valid json file', async () => {
const customTheme = merge({}, defaultTheme, { default: { logo: { login: 'custom.svg' } } })
vi.spyOn(global, 'fetch').mockResolvedValue(
mock<Response>({ status: 404, json: () => Promise.resolve(customTheme) })
)
const theme = await loadTheme('http://www.owncloud.com/invalid.json')
expect(theme).toMatchObject(defaultOwnCloudTheme)
})
it('should load the default theme if server errors', async () => {
vi.spyOn(global, 'fetch').mockRejectedValue(new Error())
const theme = await loadTheme('http://www.owncloud.com')
expect(theme).toMatchObject(defaultOwnCloudTheme)
})
it('should load the custom theme if a custom location is given', async () => {
const customTheme = merge({}, defaultOwnCloudTheme, {
defaults: { logo: { login: 'custom.svg' } }
})
vi.spyOn(global, 'fetch').mockResolvedValue(
mock<Response>({
status: 404,
json: () =>
Promise.resolve({
common: defaultTheme.common,
clients: {
web: {
defaults: customTheme.defaults,
themes: customTheme.themes
}
}
})
})
)
const theme1 = await loadTheme('http://www.owncloud.com/custom.json')
const theme2 = await loadTheme('/custom.json')
expect(theme1).toMatchObject(customTheme)
expect(theme2).toMatchObject(customTheme)
})
})
| owncloud/web/packages/web-runtime/tests/unit/helpers/theme.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-runtime/tests/unit/helpers/theme.spec.ts",
"repo_id": "owncloud",
"token_count": 1214
} | 851 |
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 27.3.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="67.717 66.948 435.782 206.158" enable-background="new 67.717 66.948 435.782 206.158" xml:space="preserve">
<g>
</g>
<g>
</g>
<g>
</g>
<g>
<g>
<g>
<g>
<path fill="#001A41" d="M92.966,222.607c-13.922,0-25.249,11.327-25.249,25.249c0,13.922,11.327,25.249,25.249,25.249
c13.922,0,25.249-11.327,25.249-25.249C118.215,233.934,106.888,222.607,92.966,222.607z M92.966,266.605
c-10.338,0-18.749-8.411-18.749-18.749c0-10.338,8.411-18.749,18.749-18.749s18.749,8.411,18.749,18.749
C111.715,258.193,103.304,266.605,92.966,266.605z"/>
<path fill="#001A41" d="M185.465,224.4h-1.25v1.25v30.074c0,5.995-4.878,10.873-10.875,10.873
c-5.996,0-10.875-4.878-10.875-10.873V225.65v-1.25h-1.25h-4h-1.25v1.25v30.074c0,5.995-4.878,10.873-10.875,10.873
c-5.996,0-10.873-4.878-10.873-10.873V225.65v-1.25h-1.25h-4h-1.25v1.25v30.074c0,9.579,7.793,17.373,17.373,17.373
c5.821,0,10.97-2.888,14.125-7.294c3.155,4.406,8.303,7.294,14.125,7.294c9.58,0,17.375-7.794,17.375-17.373V225.65v-1.25h-1.25
H185.465z"/>
<path fill="#001A41" d="M225.97,222.402c-13.923,0-25.25,11.327-25.25,25.25v22.201v1.25h1.25h4h1.25v-1.25v-22.201
c0-10.339,8.411-18.75,18.75-18.75c10.34,0,18.752,8.411,18.752,18.75v22.201v1.25h1.25h4h1.25v-1.25v-22.201
C251.222,233.73,239.894,222.402,225.97,222.402z"/>
</g>
<g>
<path fill="#001A41" d="M360.478,222.605c-13.924,0-25.251,11.327-25.251,25.251c0,13.924,11.327,25.251,25.251,25.251
c13.924,0,25.251-11.327,25.251-25.251C385.729,233.932,374.402,222.605,360.478,222.605z M360.478,266.607
c-10.339,0-18.751-8.412-18.751-18.751c0-10.339,8.412-18.751,18.751-18.751c10.339,0,18.751,8.412,18.751,18.751
C379.229,258.194,370.817,266.607,360.478,266.607z"/>
<path fill="#001A41" d="M438.977,224.4h-1.25v1.25v22.205c0,10.338-8.412,18.748-18.752,18.748
c-10.339,0-18.75-8.41-18.75-18.748V225.65v-1.25h-1.25h-4h-1.25v1.25v22.205c0,13.922,11.327,25.248,25.25,25.248
c13.924,0,25.252-11.326,25.252-25.248V225.65v-1.25h-1.25H438.977z"/>
<path fill="#001A41" d="M503.499,185.647v-1.25h-1.25h-4h-1.25v1.25v36.926l-18.959,0.021c-13.922,0-25.249,11.327-25.249,25.25
c0,13.922,11.327,25.248,25.25,25.248h7.849c7.832,0,17.433-7.726,17.608-17.319L503.499,185.647z M496.998,255.655
c-0.103,5.633-6.345,10.936-11.108,10.936h-7.849c-10.339,0-18.75-8.41-18.75-18.748c0-10.339,8.412-18.75,18.752-18.75
l18.973-0.022C497.046,235.119,497.104,249.854,496.998,255.655z"/>
<path fill="#001A41" d="M318.481,255.725v-49.742c-2.264-1.143-4.435-2.439-6.5-3.881v53.623
c0,9.579,7.794,17.373,17.373,17.373h1.25v-1.25v-4v-1.25h-1.25C323.359,266.598,318.481,261.72,318.481,255.725z"/>
<path fill="#001A41" d="M266.883,234.69c0-9.693,4.35-18.386,11.193-24.244c-2.155-0.829-4.155-1.969-5.948-3.365
c-7.234,6.99-11.745,16.779-11.745,27.609c0,21.182,17.233,38.414,38.416,38.414h1.25v-1.25v-4v-1.25h-1.25
C281.201,266.604,266.883,252.287,266.883,234.69z"/>
</g>
</g>
<path fill="#001A41" d="M268.223,110.634c-1.522-2.671-2.403-5.752-2.403-9.039c0-10.108,8.224-18.332,18.332-18.332
c3.739,0,7.218,1.131,10.12,3.061c-2.154,4.854-3.362,10.22-3.362,15.864c0,1.04,0.053,2.066,0.133,3.086
c-0.715-0.036-1.436-0.055-2.16-0.055C281.381,105.219,274.336,107.193,268.223,110.634z M264.181,181.74
c-10.626-7.684-17.56-20.174-17.56-34.26c0-3.6,0.455-7.096,1.306-10.434c-0.352-0.011-0.704-0.027-1.059-0.027
c-19.433,0-35.242,15.81-35.242,35.243c0,19.432,15.809,35.242,35.242,35.242c7.406,0,14.282-2.303,19.961-6.221
c-2.343-3.633-3.709-7.953-3.709-12.588C263.12,186.274,263.492,183.938,264.181,181.74z M265.762,177.94
c3.165-6.053,8.908-10.551,15.766-12.021c0.648-0.141,1.308-0.248,1.975-0.332c0.659-0.084,1.325-0.141,1.999-0.166
c0.305-0.012,0.61-0.023,0.918-0.023c1.081,0,2.144,0.08,3.186,0.223c-0.326-2.377-0.508-4.801-0.508-7.266
c0-11.844,3.885-22.794,10.441-31.655c-1.485-1.85-2.811-3.833-3.945-5.936c-0.318-0.591-0.621-1.191-0.91-1.801
c-0.289-0.607-0.56-1.225-0.818-1.85c-1.023-2.479-1.794-5.086-2.293-7.789c-0.89-0.062-1.784-0.104-2.689-0.104
c-6.622,0-12.856,1.692-18.294,4.665c-0.601,0.329-1.189,0.676-1.77,1.035c-0.573,0.355-1.135,0.727-1.688,1.109
c-6.204,4.305-11.075,10.393-13.872,17.52c-0.246,0.627-0.477,1.262-0.69,1.904c-0.212,0.641-0.409,1.287-0.588,1.941
c-0.88,3.216-1.359,6.596-1.359,10.086C250.621,159.897,256.57,170.945,265.762,177.94z M389.238,132.814
c5.098-2.678,10.803-4.343,16.852-4.73c-1.563-17.998-16.703-32.169-35.1-32.169c-0.704,0-1.401,0.026-2.095,0.067
c0.322,2.022,0.495,4.094,0.495,6.206c0,3.276-0.409,6.458-1.17,9.503C377.065,116.599,384.378,123.941,389.238,132.814z
M295.35,107.744c0.113,0.71,0.253,1.411,0.407,2.106c0.357,1.599,0.816,3.157,1.382,4.667c0.251,0.67,0.525,1.326,0.815,1.977
c0.284,0.637,0.587,1.265,0.908,1.882c0.938,1.806,2.023,3.521,3.247,5.127c2.46-2.842,5.207-5.428,8.208-7.698
c0.565-0.428,1.144-0.84,1.727-1.245c0.58-0.404,1.17-0.794,1.767-1.175c8.093-5.169,17.661-8.215,27.925-8.347
c0.233-0.003,0.462-0.018,0.694-0.018c0.667,0,1.328,0.026,1.99,0.05c0.912,0.034,1.819,0.091,2.72,0.17
c6.16,0.542,12.02,2.136,17.404,4.601c0.549-2.466,0.847-5.024,0.847-7.652c0-1.954-0.167-3.87-0.475-5.739
c-0.109-0.661-0.238-1.316-0.384-1.965c-0.146-0.654-0.311-1.301-0.494-1.939c-4.206-14.757-17.801-25.596-33.889-25.596
c-13.273,0-24.852,7.378-30.861,18.247c-0.335,0.605-0.654,1.221-0.954,1.848c-0.311,0.651-0.597,1.316-0.868,1.989
c-1.643,4.068-2.558,8.506-2.558,13.155c0,1.178,0.06,2.342,0.174,3.49C295.152,106.373,295.242,107.061,295.35,107.744z
M454.084,167.342c-1.056,0-2.084,0.109-3.094,0.271c0.055,0.873,0.091,1.75,0.091,2.635c0,11.225-4.407,21.432-11.571,29.008
c3.542,4.086,8.755,6.686,14.574,6.686c10.642,0,19.3-8.658,19.3-19.299C473.384,176,464.725,167.342,454.084,167.342z
M447.042,168.692c-0.028-0.699-0.073-1.393-0.139-2.082c-0.064-0.688-0.145-1.369-0.247-2.047
c-2.687-17.962-17.906-31.874-36.444-32.542c-0.463-0.017-0.925-0.035-1.392-0.035c-0.204,0-0.405,0.012-0.608,0.016
c-0.672,0.01-1.339,0.039-2.002,0.084c-5.455,0.369-10.6,1.885-15.194,4.311c2.766,6.096,4.42,12.797,4.695,19.848
c0.027,0.701,0.054,1.402,0.054,2.11c0,0.207-0.014,0.41-0.016,0.615c-0.011,0.9-0.042,1.793-0.097,2.682
c-0.814,13.27-6.496,25.238-15.286,34.143c7.009,7.799,17.167,12.715,28.454,12.715c9.745,0,18.646-3.668,25.409-9.688
c0.512-0.457,1.015-0.924,1.502-1.406c0.491-0.486,0.971-0.984,1.435-1.498c6.157-6.793,9.914-15.801,9.914-25.668
C447.081,169.727,447.062,169.209,447.042,168.692z M297.376,186.836c-0.38-0.598-0.747-1.203-1.103-1.816
c-2.711-4.674-4.733-9.791-5.925-15.219c-1.269-0.264-2.583-0.404-3.928-0.404c-0.143,0-0.281,0.018-0.423,0.021
c-0.674,0.014-1.338,0.064-1.994,0.146c-0.671,0.084-1.33,0.205-1.978,0.355c-5.686,1.332-10.399,5.178-12.918,10.303
c-0.297,0.605-0.562,1.227-0.796,1.865c-0.232,0.635-0.431,1.283-0.597,1.945c-0.373,1.496-0.593,3.053-0.593,4.662
c0,3.709,1.07,7.166,2.892,10.109c0.357,0.578,0.74,1.135,1.153,1.668c0.405,0.523,0.833,1.027,1.289,1.506
c3.518,3.697,8.471,6.016,13.965,6.016c8.175,0,15.162-5.119,17.97-12.314c-2.142-2.182-4.097-4.545-5.841-7.066
C298.145,188.029,297.757,187.436,297.376,186.836z M391.602,162.174c0.064-0.846,0.108-1.695,0.13-2.551
c0.011-0.422,0.032-0.844,0.032-1.27c0-7.079-1.51-13.807-4.206-19.898c-0.275-0.621-0.558-1.237-0.857-1.845
c-0.294-0.596-0.593-1.189-0.91-1.771c-4.36-8.008-10.882-14.67-18.767-19.225c-0.584-0.338-1.174-0.664-1.772-0.978
c-0.598-0.313-1.199-0.618-1.812-0.907c-6.053-2.861-12.777-4.519-19.867-4.682c-0.381-0.008-0.76-0.028-1.143-0.028
c-0.474,0-0.941,0.022-1.412,0.036c-0.85,0.023-1.692,0.068-2.53,0.136c-7.775,0.618-15.049,3.036-21.398,6.853
c-0.591,0.355-1.172,0.727-1.747,1.106c-0.58,0.382-1.15,0.779-1.712,1.185c-3.29,2.375-6.276,5.141-8.891,8.234
c-0.436,0.517-0.861,1.047-1.277,1.582c-0.411,0.529-0.811,1.066-1.2,1.611c-5.762,8.072-9.166,17.939-9.166,28.59
c0,2.811,0.249,5.564,0.703,8.248c0.13,0.771,0.277,1.539,0.443,2.299c0.182,0.828,0.385,1.648,0.607,2.463
c1.231,4.498,3.076,8.744,5.454,12.635c0.359,0.59,0.733,1.17,1.117,1.742c0.386,0.574,0.787,1.139,1.196,1.697
c0.922,1.258,1.902,2.471,2.937,3.635c0.564,0.635,1.142,1.256,1.737,1.861c0.546,0.555,1.105,1.096,1.677,1.625
c8.801,8.137,20.558,13.123,33.461,13.123c12.431,0,23.794-4.631,32.479-12.246c0.501-0.438,0.991-0.887,1.474-1.346
c0.494-0.469,0.978-0.947,1.453-1.436c7.221-7.451,12.113-17.16,13.507-27.957C391.45,163.861,391.537,163.022,391.602,162.174z"
/>
</g>
<g display="none">
<g display="inline">
<path fill="#001A41" d="M129.103,318.727c0.831,0.783,1.781,1.419,2.85,1.905c1.068,0.487,2.137,0.73,3.206,0.73
c1.33,0,2.338-0.272,3.027-0.819c0.688-0.546,1.033-1.27,1.033-2.173c0-0.475-0.089-0.878-0.267-1.211
c-0.178-0.332-0.428-0.623-0.748-0.872c-0.321-0.25-0.701-0.481-1.14-0.695c-0.44-0.214-0.921-0.427-1.443-0.641l-3.206-1.39
c-0.57-0.236-1.134-0.534-1.692-0.89c-0.558-0.356-1.063-0.784-1.514-1.283c-0.451-0.498-0.813-1.08-1.086-1.745
c-0.273-0.664-0.41-1.425-0.41-2.279c0-0.926,0.196-1.786,0.588-2.582s0.932-1.49,1.621-2.084
c0.688-0.593,1.514-1.057,2.476-1.389c0.961-0.333,2.012-0.499,3.152-0.499c1.354,0,2.659,0.268,3.918,0.802
c1.258,0.534,2.338,1.252,3.241,2.154l-2.102,2.636c-0.76-0.617-1.544-1.104-2.351-1.46s-1.709-0.534-2.707-0.534
c-1.116,0-2.007,0.243-2.671,0.729c-0.666,0.487-0.998,1.158-0.998,2.013c0,0.451,0.101,0.837,0.303,1.158
c0.202,0.32,0.475,0.605,0.819,0.854c0.344,0.249,0.742,0.476,1.193,0.677c0.451,0.202,0.914,0.397,1.389,0.588l3.17,1.317
c0.688,0.285,1.318,0.618,1.888,0.997c0.57,0.381,1.062,0.819,1.478,1.318c0.415,0.499,0.742,1.074,0.979,1.728
c0.237,0.653,0.356,1.407,0.356,2.262c0,0.95-0.19,1.841-0.57,2.671c-0.38,0.832-0.932,1.562-1.656,2.19
c-0.725,0.63-1.603,1.129-2.636,1.496c-1.033,0.368-2.203,0.553-3.508,0.553c-1.567,0-3.081-0.298-4.541-0.891
c-1.46-0.594-2.749-1.437-3.865-2.529L129.103,318.727z"/>
<path fill="#001A41" d="M153.38,304.729h-6.731v-3.49h17.595v3.49h-6.732v19.804h-4.132V304.729z"/>
<path fill="#001A41" d="M176.628,324.961c-1.52,0-2.909-0.279-4.167-0.837c-1.259-0.558-2.339-1.365-3.241-2.423
c-0.903-1.056-1.603-2.333-2.102-3.828c-0.499-1.496-0.748-3.193-0.748-5.094c0-1.876,0.25-3.556,0.748-5.04
c0.499-1.483,1.199-2.736,2.102-3.758c0.902-1.021,1.982-1.804,3.241-2.351c1.258-0.546,2.647-0.819,4.167-0.819
c1.519,0,2.908,0.273,4.167,0.819c1.258,0.547,2.345,1.33,3.259,2.351c0.914,1.021,1.621,2.274,2.119,3.758
c0.499,1.484,0.748,3.164,0.748,5.04c0,1.9-0.25,3.598-0.748,5.094c-0.499,1.495-1.206,2.772-2.119,3.828
c-0.915,1.058-2.001,1.865-3.259,2.423C179.536,324.681,178.147,324.961,176.628,324.961z M176.628,321.363
c0.926,0,1.757-0.201,2.493-0.605c0.736-0.403,1.365-0.979,1.888-1.728c0.522-0.748,0.926-1.65,1.211-2.707
c0.285-1.057,0.428-2.238,0.428-3.544c0-2.612-0.541-4.66-1.621-6.145c-1.081-1.483-2.547-2.226-4.399-2.226
s-3.319,0.742-4.399,2.226c-1.081,1.484-1.621,3.532-1.621,6.145c0,1.306,0.143,2.487,0.427,3.544
c0.285,1.057,0.688,1.959,1.211,2.707s1.152,1.324,1.888,1.728C174.87,321.162,175.702,321.363,176.628,321.363z"/>
<path fill="#001A41" d="M204.089,324.533l-5.022-9.118h-3.562v9.118h-4.131v-23.294h7.872c1.211,0,2.338,0.119,3.383,0.355
c1.045,0.238,1.947,0.624,2.707,1.158c0.76,0.534,1.359,1.241,1.799,2.119c0.439,0.879,0.659,1.971,0.659,3.276
c0,1.781-0.422,3.219-1.265,4.311c-0.843,1.092-1.965,1.876-3.366,2.351l5.556,9.724H204.089z M195.505,312.137h3.312
c1.591,0,2.808-0.332,3.651-0.997c0.843-0.664,1.265-1.662,1.265-2.992c0-1.354-0.422-2.291-1.265-2.813
c-0.843-0.521-2.06-0.783-3.651-0.783h-3.312V312.137z"/>
<path fill="#001A41" d="M212.812,301.239h14.033v3.49h-9.902v5.948h8.371v3.49h-8.371v6.875h10.258v3.49h-14.39V301.239z"/>
<path fill="#001A41" d="M232.388,322.182c0-0.808,0.255-1.473,0.766-1.995c0.51-0.521,1.146-0.783,1.906-0.783
c0.759,0,1.389,0.262,1.888,0.783c0.499,0.522,0.748,1.188,0.748,1.995s-0.25,1.473-0.748,1.994
c-0.499,0.522-1.128,0.784-1.888,0.784c-0.76,0-1.396-0.262-1.906-0.784C232.643,323.655,232.388,322.99,232.388,322.182z"/>
</g>
<g display="inline">
<path fill="#001A41" d="M254.836,318.727c0.831,0.783,1.781,1.419,2.85,1.905c1.068,0.487,2.137,0.73,3.206,0.73
c1.33,0,2.338-0.272,3.027-0.819c0.688-0.546,1.033-1.27,1.033-2.173c0-0.475-0.089-0.878-0.267-1.211
c-0.178-0.332-0.428-0.623-0.748-0.872c-0.321-0.25-0.701-0.481-1.14-0.695c-0.44-0.214-0.921-0.427-1.443-0.641l-3.206-1.39
c-0.57-0.236-1.134-0.534-1.692-0.89c-0.558-0.356-1.063-0.784-1.514-1.283c-0.451-0.498-0.813-1.08-1.086-1.745
c-0.273-0.664-0.41-1.425-0.41-2.279c0-0.926,0.196-1.786,0.588-2.582s0.932-1.49,1.621-2.084
c0.688-0.593,1.514-1.057,2.476-1.389c0.961-0.333,2.012-0.499,3.152-0.499c1.354,0,2.659,0.268,3.918,0.802
c1.258,0.534,2.338,1.252,3.241,2.154l-2.102,2.636c-0.76-0.617-1.544-1.104-2.351-1.46s-1.709-0.534-2.707-0.534
c-1.116,0-2.007,0.243-2.671,0.729c-0.666,0.487-0.998,1.158-0.998,2.013c0,0.451,0.101,0.837,0.303,1.158
c0.202,0.32,0.475,0.605,0.819,0.854c0.344,0.249,0.742,0.476,1.193,0.677c0.451,0.202,0.914,0.397,1.389,0.588l3.17,1.317
c0.688,0.285,1.318,0.618,1.888,0.997c0.57,0.381,1.062,0.819,1.478,1.318c0.415,0.499,0.742,1.074,0.979,1.728
c0.237,0.653,0.356,1.407,0.356,2.262c0,0.95-0.19,1.841-0.57,2.671c-0.38,0.832-0.932,1.562-1.656,2.19
c-0.725,0.63-1.603,1.129-2.636,1.496c-1.033,0.368-2.203,0.553-3.508,0.553c-1.567,0-3.081-0.298-4.541-0.891
c-1.46-0.594-2.749-1.437-3.865-2.529L254.836,318.727z"/>
<path fill="#001A41" d="M273.393,301.239h4.131v9.367h9.439v-9.367h4.132v23.294h-4.132v-10.329h-9.439v10.329h-4.131V301.239z"
/>
<path fill="#001A41" d="M308.868,318.228h-7.836l-1.816,6.305h-4.203l7.587-23.294h4.844l7.587,23.294h-4.346L308.868,318.228z
M307.942,314.987l-0.819-2.85c-0.38-1.234-0.742-2.505-1.087-3.811c-0.344-1.306-0.683-2.601-1.015-3.883h-0.143
c-0.333,1.307-0.665,2.606-0.997,3.9c-0.333,1.295-0.689,2.559-1.068,3.793l-0.819,2.85H307.942z"/>
<path fill="#001A41" d="M331.628,324.533l-5.022-9.118h-3.562v9.118h-4.132v-23.294h7.872c1.211,0,2.338,0.119,3.384,0.355
c1.044,0.238,1.946,0.624,2.707,1.158c0.76,0.534,1.358,1.241,1.799,2.119c0.438,0.879,0.658,1.971,0.658,3.276
c0,1.781-0.422,3.219-1.265,4.311s-1.965,1.876-3.365,2.351l5.557,9.724H331.628z M323.044,312.137h3.312
c1.591,0,2.808-0.332,3.651-0.997c0.842-0.664,1.264-1.662,1.264-2.992c0-1.354-0.422-2.291-1.264-2.813
c-0.844-0.521-2.061-0.783-3.651-0.783h-3.312V312.137z"/>
<path fill="#001A41" d="M340.854,301.239h14.034v3.49h-9.902v5.948h8.37v3.49h-8.37v6.875h10.258v3.49h-14.39V301.239z"/>
<path fill="#001A41" d="M360.372,322.182c0-0.808,0.255-1.473,0.766-1.995c0.511-0.521,1.146-0.783,1.905-0.783
s1.39,0.262,1.888,0.783c0.499,0.522,0.748,1.188,0.748,1.995s-0.249,1.473-0.748,1.994c-0.498,0.522-1.128,0.784-1.888,0.784
s-1.395-0.262-1.905-0.784C360.627,323.655,360.372,322.99,360.372,322.182z"/>
</g>
<g display="inline">
<path fill="#001A41" d="M378.258,301.239h4.238l2.03,11.754c0.189,1.259,0.379,2.505,0.569,3.739
c0.19,1.235,0.38,2.471,0.57,3.705h0.143c0.261-1.234,0.517-2.476,0.766-3.723c0.249-1.246,0.504-2.487,0.766-3.722l2.85-11.754
h3.598l2.85,11.754c0.261,1.211,0.521,2.439,0.783,3.687c0.261,1.246,0.522,2.499,0.783,3.758h0.143
c0.19-1.259,0.374-2.505,0.553-3.74c0.178-1.234,0.361-2.47,0.552-3.704l2.03-11.754h3.953l-4.452,23.294h-5.129l-2.885-12.253
c-0.19-0.901-0.374-1.799-0.552-2.688c-0.179-0.891-0.339-1.787-0.481-2.689h-0.143c-0.166,0.902-0.338,1.799-0.517,2.689
c-0.178,0.89-0.362,1.787-0.552,2.688l-2.813,12.253h-5.022L378.258,301.239z"/>
<path fill="#001A41" d="M418.256,324.961c-1.52,0-2.908-0.279-4.167-0.837s-2.339-1.365-3.241-2.423
c-0.902-1.056-1.603-2.333-2.102-3.828c-0.499-1.496-0.748-3.193-0.748-5.094c0-1.876,0.249-3.556,0.748-5.04
c0.499-1.483,1.199-2.736,2.102-3.758c0.902-1.021,1.982-1.804,3.241-2.351c1.259-0.546,2.647-0.819,4.167-0.819
s2.909,0.273,4.168,0.819c1.258,0.547,2.345,1.33,3.259,2.351c0.914,1.021,1.621,2.274,2.119,3.758
c0.499,1.484,0.748,3.164,0.748,5.04c0,1.9-0.249,3.598-0.748,5.094c-0.498,1.495-1.205,2.772-2.119,3.828
c-0.914,1.058-2.001,1.865-3.259,2.423C421.165,324.681,419.775,324.961,418.256,324.961z M418.256,321.363
c0.927,0,1.758-0.201,2.493-0.605c0.736-0.403,1.365-0.979,1.889-1.728c0.521-0.748,0.926-1.65,1.211-2.707
c0.284-1.057,0.427-2.238,0.427-3.544c0-2.612-0.54-4.66-1.62-6.145c-1.081-1.483-2.547-2.226-4.399-2.226
c-1.852,0-3.318,0.742-4.398,2.226c-1.081,1.484-1.621,3.532-1.621,6.145c0,1.306,0.143,2.487,0.428,3.544
s0.688,1.959,1.211,2.707s1.151,1.324,1.888,1.728C416.499,321.162,417.33,321.363,418.256,321.363z"/>
<path fill="#001A41" d="M445.824,324.533l-5.022-9.118h-3.562v9.118h-4.132v-23.294h7.872c1.211,0,2.338,0.119,3.384,0.355
c1.044,0.238,1.946,0.624,2.707,1.158c0.76,0.534,1.358,1.241,1.799,2.119c0.438,0.879,0.658,1.971,0.658,3.276
c0,1.781-0.422,3.219-1.265,4.311s-1.965,1.876-3.365,2.351l5.557,9.724H445.824z M437.24,312.137h3.312
c1.591,0,2.808-0.332,3.651-0.997c0.842-0.664,1.264-1.662,1.264-2.992c0-1.354-0.422-2.291-1.264-2.813
c-0.844-0.521-2.061-0.783-3.651-0.783h-3.312V312.137z"/>
<path fill="#001A41" d="M455.05,301.239h4.132v10.578h0.107l8.299-10.578h4.595l-7.159,9.082l8.37,14.212h-4.56l-6.304-10.971
l-3.349,4.168v6.803h-4.132V301.239z"/>
<path fill="#001A41" d="M477.097,322.182c0-0.808,0.255-1.473,0.766-1.995c0.511-0.521,1.146-0.783,1.905-0.783
s1.39,0.262,1.888,0.783c0.499,0.522,0.748,1.188,0.748,1.995s-0.249,1.473-0.748,1.994c-0.498,0.522-1.128,0.784-1.888,0.784
s-1.395-0.262-1.905-0.784C477.352,323.655,477.097,322.99,477.097,322.182z"/>
</g>
</g>
</g>
</svg>
| owncloud/web/packages/web-runtime/themes/owncloud/assets/logo_dark.svg/0 | {
"file_path": "owncloud/web/packages/web-runtime/themes/owncloud/assets/logo_dark.svg",
"repo_id": "owncloud",
"token_count": 12250
} | 852 |
diff --git a/package.json b/package.json
index 6fd32604012caa07c4a724d8308246af14bd8b96..3b4514b47a3cefce0f26e2448c69f8f1f874e798 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
"Pinned vue-good-table to 2.21.0. 2.21.1+ no longer use scoped styles, which is why we pulled it in to test 3rd party scoped libraries."
],
"dependencies": {
- "cheerio": "^1.0.0-rc.3",
+ "cheerio": "^1.0.0-rc.12",
"htmlparser2": "^7.1.1",
"js-beautify": "^1.14.0",
"lodash.clonedeep": "^4.5.0"
diff --git a/src/helpers.js b/src/helpers.js
index ff6cdff9df5068d806fdaf980707bb0213ea31ea..12fb021c2c4e19353ebfc553dd8efc8b6b64963a 100644
--- a/src/helpers.js
+++ b/src/helpers.js
@@ -121,7 +121,8 @@ const helpers = {
xmlMode: false
};
const dom = htmlparser2.parseDOM(html, xmlOptions);
- const $ = cheerio.load(dom, { xml: xmlOptions });
+ // const $ = cheerio.load(dom, { xml: xmlOptions });
+ const $ = cheerio.load(html, null, false);
return $;
},
| owncloud/web/patches/jest-serializer-vue-tjw@3.19.0.patch/0 | {
"file_path": "owncloud/web/patches/jest-serializer-vue-tjw@3.19.0.patch",
"repo_id": "owncloud",
"token_count": 479
} | 853 |
const events = require('events')
class UseStrategy extends events.EventEmitter {
/**
* UseStrategy can enable strategy for given `Element` object,
* or, from given strategy param.
*
* @param {string|Object} [strategy]
*
* @example When you don't know strategy of given element before-hand
* useSelector(menuButton).assert.elementNotPresent.useCss() // rollback to default css
* useSelector(selector).assert.elementNotPresent.useCss() // selector is string
* useSelector({locateStrategy: selector})
*/
command(strategy = this.client.locateStrategy) {
if (typeof strategy === 'object' && strategy.locateStrategy) {
strategy = strategy.locateStrategy
}
this.client.setLocateStrategy(strategy)
this.emit('complete')
}
}
module.exports = UseStrategy
| owncloud/web/tests/acceptance/customCommands/useStrategy.js/0 | {
"file_path": "owncloud/web/tests/acceptance/customCommands/useStrategy.js",
"repo_id": "owncloud",
"token_count": 266
} | 854 |
Feature: display image in preview app on the webUI
Background:
Given user "Alice" has been created with default attributes and without skeleton files in the server
@ocisSmokeTest
Scenario Outline: preview of image files with preview app is possible
Given user "Alice" has uploaded file "<image-file>" to "<image-file>" in the server
And user "Alice" has logged in using the webUI
When the user views the file "<image-file>" in the preview app using the webUI
Then the file "<image-file>" should be displayed in the preview app webUI
Examples:
| image-file |
| testavatar.jpg |
| testavatar.png |
| testavatar.jpeg |
Scenario: preview of video with preview app is possible
Given user "Alice" has uploaded file "test_video.mp4" to "test_video.mp4" in the server
And user "Alice" has logged in using the webUI
When the user views the file "test_video.mp4" in the preview app using the webUI
Then the file "test_video.mp4" should be displayed in the preview app webUI
Scenario: video playback in public share
Given user "Alice" has created folder "simple-empty-folder" in the server
And user "Alice" has uploaded file "test_video.mp4" to "simple-empty-folder/test_video.mp4" in the server
And user "Alice" has created a public link with following settings in the server
| path | simple-empty-folder |
When the public uses the webUI to access the last public link created by user "Alice" in a new session
And the public views the file "test_video.mp4" in the preview app using the webUI
Then the file "test_video.mp4" should be displayed in the preview app webUI
Scenario: image preview in public share
Given user "Alice" has created folder "simple-empty-folder" in the server
And user "Alice" has uploaded file "testavatar.jpg" to "simple-empty-folder/testavatar.jpg" in the server
And user "Alice" has created a public link with following settings in the server
| path | simple-empty-folder |
When the public uses the webUI to access the last public link created by user "Alice" in a new session
And the public views the file "testavatar.jpg" in the preview app using the webUI
Then the file "testavatar.jpg" should be displayed in the preview app webUI
Scenario Outline: navigate to next and previous media resource with preview app is possible
Given user "Alice" has uploaded file "<resource-one>" to "<resource-one>" in the server
And user "Alice" has uploaded file "<resource-two>" to "<resource-two>" in the server
And user "Alice" has logged in using the webUI
When the user views the file "<resource-one>" in the preview app using the webUI
And the user navigates to the next media resource using the webUI
Then the file "<resource-two>" should be displayed in the preview app webUI
When the user navigates to the previous media resource using the webUI
Then the file "<resource-one>" should be displayed in the preview app webUI
Examples:
| resource-one | resource-two |
| test_video0.mp4 | test_video1.mp4 |
| testavatar.jpg | testavatar.png |
Scenario: preview of mp3 file with preview app by clicking on the file name
Given user "Alice" has uploaded file "testimage.mp3" to "testimage.mp3" in the server
And user "Alice" has logged in using the webUI
When the user views the file "testimage.mp3" in the preview app by clicking on the file name using the webUI
Then the file "testimage.mp3" should be displayed in the preview app webUI
Scenario: preview of mp3 file with preview app is possible
Given user "Alice" has uploaded file "testimage.mp3" to "testimage.mp3" in the server
And user "Alice" has logged in using the webUI
When the user views the file "testimage.mp3" in the preview app using the webUI
Then the file "testimage.mp3" should be displayed in the preview app webUI
Scenario: preview of image in file list view for .jpeg format file
Given user "Alice" has uploaded file "testavatar.jpeg" to "testavatar.jpeg" in the server
And user "Alice" has logged in using the webUI
When the user browses to the files page
When the user views the file "testavatar.jpeg" in the preview app using the webUI
Then the file "testavatar.jpeg" should be displayed in the preview app webUI
@issue-ocis-1490 @issue-4667
Scenario: preview of image in file list view for .ogg format file
Given user "Alice" has uploaded file "sampleOgg.ogg" to "sampleOgg.ogg" in the server
And user "Alice" has logged in using the webUI
When the user browses to the files page
When the user views the file "sampleOgg.ogg" in the preview app using the webUI
Then the file "sampleOgg.ogg" should be displayed in the preview app webUI
@issue-ocis-1490
Scenario: preview of image in file list view for .gif format file
Given user "Alice" has uploaded file "sampleGif.gif" to "sampleGif.gif" in the server
And user "Alice" has logged in using the webUI
When the user browses to the files page
When the user views the file "sampleGif.gif" in the preview app using the webUI
Then the file "sampleGif.gif" should be displayed in the preview app webUI
@issue-ocis-1490 @issue-4667
Scenario: preview of image in file list view for .webm format file
Given user "Alice" has uploaded file "sampleWebm.webm" to "sampleWebm.webm" in the server
And user "Alice" has logged in using the webUI
When the user browses to the files page
When the user views the file "sampleWebm.webm" in the preview app using the webUI
Then the file "sampleWebm.webm" should be displayed in the preview app webUI
Scenario Outline: preview of image files with extensions in UpperCase with preview app
Given user "Alice" has uploaded file "<image-file>" to "<to-file-name>" in the server
And user "Alice" has logged in using the webUI
When the user browses to the files page
When the user views the file "<to-file-name>" in the preview app by clicking on the file name using the webUI
Then the file "<to-file-name>" should be displayed in the preview app webUI
Examples:
| image-file | to-file-name |
| testavatar.jpg | testavatar.JPG |
| testavatar.png | testavatar.PNG |
| testavatar.jpeg | testavatar.JPEG |
Scenario: Open jpeg file with preview app in shared-with-others page
Given user "Brian" has been created with default attributes and without skeleton files in the server
And user "Brian" has uploaded file "testavatar.jpeg" to "testavatar.jpeg" in the server
And user "Brian" has shared file "testavatar.jpeg" with user "Alice" with "all" permissions in the server
And user "Brian" has logged in using the webUI
And the user browses to the shared-with-others page
When the user views the file "testavatar.jpeg" in the preview app by clicking on the file name using the webUI
Then the file "testavatar.jpeg" should be displayed in the preview app webUI
Scenario: Open jpeg file with preview app in shared-with-me page
Given user "Brian" has been created with default attributes and without skeleton files in the server
And user "Brian" has uploaded file "testavatar.jpeg" to "testavatar.jpeg" in the server
And user "Brian" has shared file "testavatar.jpeg" with user "Alice" with "all" permissions in the server
And user "Alice" has logged in using the webUI
And the user browses to the shared-with-me page
When the user views the file "testavatar.jpeg" in the preview app by clicking on the file name using the webUI
Then the file "testavatar.jpeg" should be displayed in the preview app webUI
| owncloud/web/tests/acceptance/features/webUIPreview/mediaPreview.feature/0 | {
"file_path": "owncloud/web/tests/acceptance/features/webUIPreview/mediaPreview.feature",
"repo_id": "owncloud",
"token_count": 2343
} | 855 |
Feature: Session storage for public link
As a public
I should be able to save the session of the public link files page
So that I can easily access my files
Background:
Given user "Alice" has been created with default attributes and without skeleton files in the server
Scenario: Public accesses the public link files page and refreshes the page
Given user "Alice" has created folder "simple-folder" in the server
And user "Alice" has created file "simple-folder/lorem.txt" in the server
And user "Alice" has shared folder "simple-folder" with link with "read" permissions and password "#Passw0rd" in the server
When the public uses the webUI to access the last public link created by user "Alice" with password "#Passw0rd" in a new session
Then file "lorem.txt" should be listed on the webUI
Scenario: Public accesses the public link files page in a new session after visiting once (folder share)
Given user "Alice" has created folder "simple-folder" in the server
And user "Alice" has created file "simple-folder/lorem.txt" in the server
And user "Alice" has shared folder "simple-folder" with link with "read" permissions and password "#Passw0rd" in the server
When the public uses the webUI to access the last public link created by user "Alice" with password "#Passw0rd" in a new session
Then file "lorem.txt" should be listed on the webUI
@skipOnOC10
Scenario: Public accesses the public link files page in a new session after visiting once (file share)
Given user "Alice" has created file "lorem.txt" in the server
And user "Alice" has shared folder "lorem.txt" with link with "read" permissions and password "#Passw0rd" in the server
When the public uses the webUI to access the last public link created by user "Alice" with password "#Passw0rd" in a new session
And the user closes the text editor using the webUI
Then file "lorem.txt" should be listed on the webUI as single share
Scenario: Public link author changes the password when the public is in public link files page session (folder share)
Given user "Alice" has created folder "simple-folder" in the server
And user "Alice" has created file "simple-folder/lorem.txt" in the server
And user "Alice" has shared folder "simple-folder" with link with "read" permissions and password "#Passw0rd" in the server
When the public uses the webUI to access the last public link created by user "Alice" with password "#Passw0rd" in a new session
Then file "lorem.txt" should be listed on the webUI
And user "Alice" changes the password of last public link to "#Passw0rd123" using the Sharing API in the server
When the user reloads the current page of the webUI
Then the password input for the public link should appear on the webUI
When the user accesses the public link with password "#Passw0rd123" using the webUI
Then file "lorem.txt" should be listed on the webUI
@skipOnOC10
Scenario: Public link author changes the password when the public is in public link files page session (file share)
Given user "Alice" has created file "lorem.txt" in the server
And user "Alice" has shared folder "lorem.txt" with link with "read" permissions and password "#Passw0rd" in the server
When the public uses the webUI to access the last public link created by user "Alice" with password "#Passw0rd" in a new session
And the user closes the text editor using the webUI
Then file "lorem.txt" should be listed on the webUI as single share
And user "Alice" changes the password of last public link to "#Passw0rd123" using the Sharing API in the server
When the user reloads the current page of the webUI
Then the password input for the public link should appear on the webUI
When the user accesses the public link with password "#Passw0rd123" using the webUI
Then file "lorem.txt" should be listed on the webUI as single share
| owncloud/web/tests/acceptance/features/webUISharingPublicManagement/sharingPublicSession.feature/0 | {
"file_path": "owncloud/web/tests/acceptance/features/webUISharingPublicManagement/sharingPublicSession.feature",
"repo_id": "owncloud",
"token_count": 1083
} | 856 |
const httpHelper = require('./httpHelper')
module.exports = {
SHARE_TYPES: Object.freeze({
user: 0,
group: 1,
public_link: 3,
federated_cloud_share: 6
}),
PERMISSION_TYPES: Object.freeze({
read: 1,
update: 2,
create: 4,
delete: 8,
share: 16,
all: 31
}),
SHARE_STATE: Object.freeze({
accepted: 0,
pending: 1,
declined: 2
}),
COLLABORATOR_PERMISSION_ARRAY: ['share', 'update', 'create', 'delete'],
/**
* if the given string starts with a `+` or `-` the function will calculate the date (from today) and return the string of the new date
* @param {string} dateString
* @returns {string}
*/
calculateDate: function (dateString) {
if (dateString.startsWith('+') || dateString.startsWith('-')) {
dateString = parseInt(dateString)
const date = new Date()
date.setDate(date.getDate() + dateString)
dateString =
date.getFullYear() +
'-' +
String(date.getMonth() + 1).padStart(2, '0') +
'-' +
String(date.getDate()).padStart(2, '0') +
' 00:00:00'
}
return dateString
},
/**
* Given the string that can be parsed into Date, returns the string that should be displayed in the UI input fields
* @param {string} date
* @returns {string}
*/
calculateDateString: function (date) {
const months = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
]
const expectedDate = new Date(Date.parse(date))
const expectedMonth = months[expectedDate.getMonth()]
return `${expectedMonth} ${expectedDate.getDate().toString()}, ${expectedDate.getFullYear()}`
},
/**
* Asynchronously fetches the last public link created by the given link creator
*
* @async
* @param {string} linkCreator link creator
* @return {Promise<Object>} last share token
*/
fetchLastPublicLinkShare: async function (linkCreator) {
const self = this
const apiURL = 'apps/files_sharing/api/v1/shares'
let lastShareToken
let lastShare
await httpHelper
.getOCS(apiURL, linkCreator)
.then((res) => res.json())
.then(function (sharesResult) {
httpHelper.checkOCSStatus(
sharesResult,
'Could not get shares. Message: ' + sharesResult.ocs.meta.message
)
const shares = sharesResult.ocs.data
let lastShareSTime = 0
for (const share of shares) {
if (share.share_type === self.SHARE_TYPES.public_link && share.stime > lastShareSTime) {
lastShareSTime = share.stime
lastShareToken = share.token
lastShare = share
}
}
if (lastShareToken === null) {
throw Error(
'Could not find public shares. All shares: ' + JSON.stringify(shares, null, 2)
)
}
})
return lastShare
}
}
| owncloud/web/tests/acceptance/helpers/sharingHelper.js/0 | {
"file_path": "owncloud/web/tests/acceptance/helpers/sharingHelper.js",
"repo_id": "owncloud",
"token_count": 1261
} | 857 |
const util = require('util')
const { client } = require('nightwatch-api')
const filesList = client.page.FilesPageElement.filesList()
const filesActionsMenu = client.page.FilesPageElement.fileActionsMenu()
module.exports = {
commands: {
openPreview: async function (fileName) {
await filesList.openFileActionsMenu(fileName)
await filesActionsMenu.preview()
return this
},
openPreviewFromDetailsView: async function (fileName) {
await filesActionsMenu.preview()
return this
},
waitForPreviewLoaded: function (fileName) {
const image = util.format(this.elements.mediaImage.selector, fileName)
return this.useXpath().waitForElementVisible(image).useCss()
},
isPreviewPresent: async function () {
let isPresent = false
await this.useXpath().waitForElementVisible(
{
selector: this.elements.actionBar.selector,
abortOnFailure: false
},
(result) => {
isPresent = !!result.value
}
)
return isPresent
},
nextMediaResource: function () {
const nextButtonXpath = this.elements.actionBar.selector + this.elements.nextButton.selector
return this.useXpath()
.waitForElementVisible(nextButtonXpath)
.waitForAnimationToFinish()
.click(nextButtonXpath)
.waitForAjaxCallsToStartAndFinish()
.useCss()
},
previousMediaResource: function () {
const previousButtonXpath =
this.elements.actionBar.selector + this.elements.previousButton.selector
return this.useXpath()
.waitForElementVisible(previousButtonXpath)
.click(previousButtonXpath)
.waitForAjaxCallsToStartAndFinish()
.useCss()
},
downloadMediaResource: function () {
const downloadButtonXpath = this.elements.downLoadButton.selector
return this.useXpath()
.waitForElementVisible(downloadButtonXpath)
.click(downloadButtonXpath)
.waitForAjaxCallsToStartAndFinish()
.useCss()
},
closeMediaResource: function () {
const closeButtonXpath = this.elements.closeButton.selector
return this.useXpath()
.waitForElementVisible(closeButtonXpath)
.click(closeButtonXpath)
.waitForAjaxCallsToStartAndFinish()
.useCss()
}
},
elements: {
actionBar: {
selector: '//div[contains(@class, "preview-controls-action-bar")]',
locateStrategy: 'xpath'
},
nextButton: {
selector: `//button[contains(@class, "preview-controls-next")]`,
locateStrategy: 'xpath'
},
previousButton: {
selector: `//button[contains(@class, "preview-controls-previous")]`,
locateStrategy: 'xpath'
},
downLoadButton: {
selector: `//button[contains(@id, "preview-download")]`,
locateStrategy: 'xpath'
},
closeButton: {
selector: `//button[@id='app-top-bar-close']`,
locateStrategy: 'xpath'
},
mediaImage: {
selector: `//div[@id='app-top-bar-resource']//span[@data-test-resource-name='%s']`,
locateStrategy: 'xpath'
}
}
}
| owncloud/web/tests/acceptance/pageObjects/FilesPageElement/previewPage.js/0 | {
"file_path": "owncloud/web/tests/acceptance/pageObjects/FilesPageElement/previewPage.js",
"repo_id": "owncloud",
"token_count": 1295
} | 858 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.