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="M20 13c.552 0 1 .448 1 1v6c0 .552-.448 1-1 1H4c-.552 0-1-.448-1-1v-6c0-.552.448-1 1-1h16zm-1 2H5v4h14v-4zM12 1c2.761 0 5 2.239 5 5s-2.239 5-5 5-5-2.239-5-5 2.239-5 5-5zm1 2h-2v1.999L9 5v2l2-.001V9h2V6.999L15 7V5l-2-.001V3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/insert-row-top.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/insert-row-top.svg",
"repo_id": "owncloud",
"token_count": 240
} | 697 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M17 17h5v2h-3v3h-2v-5zM7 7H2V5h3V2h2v5zm11.364 8.536L16.95 14.12l1.414-1.414a5 5 0 1 0-7.071-7.071L9.879 7.05 8.464 5.636 9.88 4.222a7 7 0 0 1 9.9 9.9l-1.415 1.414zm-2.828 2.828l-1.415 1.414a7 7 0 0 1-9.9-9.9l1.415-1.414L7.05 9.88l-1.414 1.414a5 5 0 1 0 7.071 7.071l1.414-1.414 1.415 1.414zm-.708-10.607l1.415 1.415-7.071 7.07-1.415-1.414 7.071-7.07z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/link-unlink.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/link-unlink.svg",
"repo_id": "owncloud",
"token_count": 326
} | 698 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M22 14h-2V7.238l-7.928 7.1L4 7.216V19h10v2H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v10zM4.511 5l7.55 6.662L19.502 5H4.511zM19 22l-3.536-3.536 1.415-1.414L19 19.172l3.536-3.536 1.414 1.414L19 22z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/mail-check-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/mail-check-line.svg",
"repo_id": "owncloud",
"token_count": 218
} | 699 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M20 7.238l-7.928 7.1L4 7.216V19h10v2H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v9h-2V7.238zM19.501 5H4.511l7.55 6.662L19.502 5zM17.05 19.548a3.017 3.017 0 0 1 0-1.096l-1.014-.586 1-1.732 1.014.586c.278-.238.599-.425.95-.55V15h2v1.17c.351.125.672.312.95.55l1.014-.586 1 1.732-1.014.586a3.017 3.017 0 0 1 0 1.096l1.014.586-1 1.732-1.014-.586a2.997 2.997 0 0 1-.95.55V23h-2v-1.17a2.997 2.997 0 0 1-.95-.55l-1.014.586-1-1.732 1.014-.586zM20 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/mail-settings-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/mail-settings-line.svg",
"repo_id": "owncloud",
"token_count": 381
} | 700 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M11 17.938A8.001 8.001 0 0 1 12 2a8 8 0 0 1 1 15.938V21h-2v-3.062zM12 16a6 6 0 1 0 0-12 6 6 0 0 0 0 12zm-7 6h14v2H5v-2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/map-pin-4-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/map-pin-4-line.svg",
"repo_id": "owncloud",
"token_count": 163
} | 701 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M15.05 8.537L18.585 5H14V3h8v8h-2V6.414l-3.537 3.537a7.5 7.5 0 1 1-1.414-1.414zM10.5 20a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/men-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/men-line.svg",
"repo_id": "owncloud",
"token_count": 172
} | 702 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<g>
<path d="M3 5H21V7H3V5ZM3 9H21V11H3V9ZM3 17H21V19H3V17Z" />
<path d="M21 13H3V15H21V13Z" />
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/menu-line-condensed.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/menu-line-condensed.svg",
"repo_id": "owncloud",
"token_count": 132
} | 703 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4 4h4v2H4V4zm12 15h4v2h-4v-2zM2 9h5v2H2V9zm7 0h3v2H9V9zm5 0h6v2h-6V9zM4 14h6v2H4v-2zm8 0h3v2h-3v-2zm5 0h5v2h-5v-2zM10 4h12v2H10V4zM2 19h12v2H2v-2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/mist-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/mist-line.svg",
"repo_id": "owncloud",
"token_count": 217
} | 704 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M15.984 17.208L16 2h2v20a7.593 7.593 0 0 0-2.02-.5L8 6.302V21.5a7.335 7.335 0 0 0-2 .5V2h2l7.984 15.208z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/netflix-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/netflix-line.svg",
"repo_id": "owncloud",
"token_count": 155
} | 705 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M20 3c.552 0 1 .448 1 1v16c0 .552-.448 1-1 1H4c-.552 0-1-.448-1-1V4c0-.552.448-1 1-1h16zm-3 4H7v10h5V9.5h2.5V17H17V7z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/npmjs-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/npmjs-fill.svg",
"repo_id": "owncloud",
"token_count": 167
} | 706 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M8 5h11a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V11l4-6zm5-4h5a1 1 0 0 1 1 1v2h-7V2a1 1 0 0 1 1-1zM6 12v7h2v-7H6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/oil-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/oil-fill.svg",
"repo_id": "owncloud",
"token_count": 175
} | 707 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M17 21v-4H7v4H5v-5a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v5h-2zM7 3v4h10V3h2v5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V3h2zM2 9l4 3-4 3V9zm20 0v6l-4-3 4-3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/page-separator.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/page-separator.svg",
"repo_id": "owncloud",
"token_count": 193
} | 708 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M11 14h1.5a3.5 3.5 0 0 0 0-7H9v10h2v-3zM4 3h16a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm7 6h1.5a1.5 1.5 0 0 1 0 3H11V9z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/parking-box-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/parking-box-fill.svg",
"repo_id": "owncloud",
"token_count": 190
} | 709 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4.929 21.485l5.846-5.846a2 2 0 1 0-1.414-1.414l-5.846 5.846-1.06-1.06c2.827-3.3 3.888-6.954 5.302-13.082l6.364-.707 5.657 5.657-.707 6.364c-6.128 1.414-9.782 2.475-13.081 5.303l-1.061-1.06zM16.596 2.04l6.347 6.346a.5.5 0 0 1-.277.848l-1.474.23-5.656-5.656.212-1.485a.5.5 0 0 1 .848-.283z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/pen-nib-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/pen-nib-fill.svg",
"repo_id": "owncloud",
"token_count": 275
} | 710 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M22 18v2H2v-2h20zM2 3.5l8 5-8 5v-10zM22 11v2H12v-2h10zM4 7.108v2.784L6.226 8.5 4 7.108zM22 4v2H12V4h10z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/play-list-2-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/play-list-2-line.svg",
"repo_id": "owncloud",
"token_count": 162
} | 711 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21 6h-2V5H5v14h14v-1h2v2a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v2zM6 6h2v3H6V6zm9 10a4 4 0 1 0 0-8 4 4 0 0 0 0 8zm0 2a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-4a2 2 0 1 1 0-4 2 2 0 0 1 0 4z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/polaroid-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/polaroid-line.svg",
"repo_id": "owncloud",
"token_count": 227
} | 712 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M16 17v-1h-3v-3h3v2h2v2h-1v2h-2v2h-2v-3h2v-1h1zm5 4h-4v-2h2v-2h2v4zM3 3h8v8H3V3zm2 2v4h4V5H5zm8-2h8v8h-8V3zm2 2v4h4V5h-4zM3 13h8v8H3v-8zm2 2v4h4v-4H5zm13-2h3v2h-3v-2zM6 6h2v2H6V6zm0 10h2v2H6v-2zM16 6h2v2h-2V6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/qr-code-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/qr-code-line.svg",
"repo_id": "owncloud",
"token_count": 281
} | 713 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M6 3V1h2v2h13.008c.548 0 .992.445.992.993v16.014a1 1 0 0 1-.992.993H2.992A.993.993 0 0 1 2 20.007V3.993A1 1 0 0 1 2.992 3H6zm3 12a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm5-6v2h4V9h-4zm0 4v2h4v-2h-4z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/radio-2-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/radio-2-fill.svg",
"repo_id": "owncloud",
"token_count": 208
} | 714 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M18 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h12zm-3 13h-2v2h2v-2zm-4 0H9v2h2v-2zm2-9h-2v2H9v2h1.999L11 12h2l-.001-2H15V8h-2V6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/remote-control-2-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/remote-control-2-fill.svg",
"repo_id": "owncloud",
"token_count": 202
} | 715 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M11 17.035a.5.5 0 0 1-.788.409l-7.133-5.036a.5.5 0 0 1 0-.816l7.133-5.036a.5.5 0 0 1 .788.409v10.07zm1.079-4.627a.5.5 0 0 1 0-.816l7.133-5.036a.5.5 0 0 1 .788.409v10.07a.5.5 0 0 1-.788.409l-7.133-5.036z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/rewind-mini-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/rewind-mini-fill.svg",
"repo_id": "owncloud",
"token_count": 222
} | 716 |
<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="M17.812 6.503l-4.398 6.911-6.911 4.398A7.973 7.973 0 0 0 11 19.938V18h2v1.938a7.96 7.96 0 0 0 3.906-1.618l-1.37-1.37 1.414-1.414 1.37 1.37A7.96 7.96 0 0 0 19.938 13H18v-2h1.938a7.973 7.973 0 0 0-2.126-4.497zm-.315-.315A7.973 7.973 0 0 0 13 4.062V6h-2V4.062A7.96 7.96 0 0 0 7.094 5.68l1.37 1.37L7.05 8.464l-1.37-1.37A7.96 7.96 0 0 0 4.062 11H6v2H4.062a7.973 7.973 0 0 0 2.126 4.497l4.398-6.911 6.911-4.398zM12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/safari-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/safari-line.svg",
"repo_id": "owncloud",
"token_count": 397
} | 717 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M13 2v1.278l5 1.668 3.632-1.21.633 1.896-3.032 1.011 3.096 8.512C21.237 16.292 19.7 17 18 17c-1.701 0-3.237-.708-4.329-1.845l3.094-8.512L13 5.387V19H17v2H7v-2h4V5.387L7.232 6.643l3.096 8.512C9.237 16.292 7.7 17 6 17c-1.701 0-3.237-.708-4.329-1.845l3.094-8.512-3.03-1.01.633-1.898L6 4.945l5-1.667V2h2zm5 7.103l-1.958 5.386c.587.331 1.257.511 1.958.511.7 0 1.37-.18 1.958-.51L18 9.102zm-12 0l-1.958 5.386C4.629 14.82 5.299 15 6 15c.7 0 1.37-.18 1.958-.51L6 9.102z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/scales-3-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/scales-3-line.svg",
"repo_id": "owncloud",
"token_count": 381
} | 718 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M11.993 14.407l-1.552 1.552a4 4 0 1 1-1.418-1.41l1.555-1.556-4.185-4.185 1.415-1.415 4.185 4.185 4.189-4.189 1.414 1.414-4.19 4.19 1.562 1.56a4 4 0 1 1-1.414 1.414l-1.561-1.56zM7 20a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm10 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm2-7V5H5v8H3V4a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v9h-2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/screenshot-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/screenshot-line.svg",
"repo_id": "owncloud",
"token_count": 274
} | 719 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M3 13h6v-2H3V1.846a.5.5 0 0 1 .741-.438l18.462 10.154a.5.5 0 0 1 0 .876L3.741 22.592A.5.5 0 0 1 3 22.154V13z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/send-plane-2-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/send-plane-2-fill.svg",
"repo_id": "owncloud",
"token_count": 158
} | 720 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M13.576 17.271l-5.11-2.787a3.5 3.5 0 1 1 0-4.968l5.11-2.787a3.5 3.5 0 1 1 .958 1.755l-5.11 2.787a3.514 3.514 0 0 1 0 1.458l5.11 2.787a3.5 3.5 0 1 1-.958 1.755z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/share-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/share-fill.svg",
"repo_id": "owncloud",
"token_count": 189
} | 721 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 1l8.217 1.826a1 1 0 0 1 .783.976v9.987a6 6 0 0 1-2.672 4.992L12 23l-6.328-4.219A6 6 0 0 1 3 13.79V3.802a1 1 0 0 1 .783-.976L12 1zm0 2.049L5 4.604v9.185a4 4 0 0 0 1.781 3.328L12 20.597l5.219-3.48A4 4 0 0 0 19 13.79V4.604L12 3.05zM12 7a2 2 0 0 1 1.001 3.732L13 15h-2v-4.268A2 2 0 0 1 12 7z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/shield-keyhole-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/shield-keyhole-line.svg",
"repo_id": "owncloud",
"token_count": 264
} | 722 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 1a5 5 0 0 1 5 5v2h3a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h3V6a5 5 0 0 1 5-5zm5 10h-2v1a1 1 0 0 0 1.993.117L17 12v-1zm-8 0H7v1a1 1 0 0 0 1.993.117L9 12v-1zm3-8a3 3 0 0 0-2.995 2.824L9 6v2h6V6a3 3 0 0 0-2.824-2.995L12 3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/shopping-bag-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/shopping-bag-fill.svg",
"repo_id": "owncloud",
"token_count": 257
} | 723 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M2.808 1.393l17.677 17.678-1.414 1.414-3.683-3.683L12 21 .69 6.997c.914-.74 1.902-1.391 2.95-1.942L1.394 2.808l1.415-1.415zM12 3c4.284 0 8.22 1.497 11.31 3.996l-5.407 6.693L7.724 3.511C9.094 3.177 10.527 3 12 3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/signal-wifi-off-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/signal-wifi-off-fill.svg",
"repo_id": "owncloud",
"token_count": 215
} | 724 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M7.788 17.444A.5.5 0 0 1 7 17.035V6.965a.5.5 0 0 1 .788-.409l7.133 5.036a.5.5 0 0 1 0 .816l-7.133 5.036zM16 7a1 1 0 0 1 2 0v10a1 1 0 1 1-2 0V7z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/skip-forward-mini-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/skip-forward-mini-fill.svg",
"repo_id": "owncloud",
"token_count": 179
} | 725 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M8.17 3A3.001 3.001 0 0 1 11 1h2c1.306 0 2.417.835 2.83 2H21a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5.17zM10 9v6l5-3-5-3zm1-6a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/slideshow-4-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/slideshow-4-fill.svg",
"repo_id": "owncloud",
"token_count": 212
} | 726 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M2.88 18.054a35.897 35.897 0 0 1 8.531-16.32.8.8 0 0 1 1.178 0c.166.18.304.332.413.455a35.897 35.897 0 0 1 8.118 15.865c-2.141.451-4.34.747-6.584.874l-2.089 4.178a.5.5 0 0 1-.894 0l-2.089-4.178a44.019 44.019 0 0 1-6.584-.874zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/space-ship-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/space-ship-fill.svg",
"repo_id": "owncloud",
"token_count": 246
} | 727 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M9.536 13H7.329c-.412 1.166-1.523 2-2.829 2-1.657 0-3-1.343-3-3s1.343-3 3-3c1.306 0 2.418.835 2.83 2h2.206L13 5h3.17c.412-1.165 1.524-2 2.83-2 1.657 0 3 1.343 3 3s-1.343 3-3 3c-1.306 0-2.417-.834-2.829-2h-2.017l-2.886 4.999L14.155 17h2.016c.411-1.165 1.523-2 2.829-2 1.657 0 3 1.343 3 3s-1.343 3-3 3c-1.306 0-2.417-.834-2.829-2H13l-3.464-6zM19 17c-.552 0-1 .448-1 1s.448 1 1 1 1-.448 1-1-.448-1-1-1zM4.5 11c-.552 0-1 .448-1 1s.448 1 1 1 1-.448 1-1-.448-1-1-1zM19 5c-.552 0-1 .448-1 1s.448 1 1 1 1-.448 1-1-.448-1-1-1z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/stackshare-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/stackshare-line.svg",
"repo_id": "owncloud",
"token_count": 416
} | 728 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21.8 14.001a10.009 10.009 0 0 1-8.4 7.902v-2.025A8.01 8.01 0 0 0 19.748 14l2.052.001zm-17.548 0a8.01 8.01 0 0 0 6.247 5.858v2.03A10.01 10.01 0 0 1 2.2 14h2.052zM18 11v2h-3a2 2 0 0 0-1.995 1.85L13 15v3h-2v-3a2 2 0 0 0-1.85-1.995L9 13H6v-2h12zm-6-9c5.185 0 9.449 3.947 9.95 9h-2.012a8.001 8.001 0 0 0-15.876 0H2.049C2.551 5.947 6.815 2 12 2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/steering-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/steering-line.svg",
"repo_id": "owncloud",
"token_count": 304
} | 729 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4 5v14h16V5H4zM3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm4.05 4.121l1.414 1.415A4.984 4.984 0 0 0 7 12.07c0 1.38.56 2.63 1.464 3.536L7.05 17.02A6.978 6.978 0 0 1 5 12.07c0-1.933.784-3.683 2.05-4.95zm9.9 0a6.978 6.978 0 0 1 2.05 4.95 6.978 6.978 0 0 1-2.05 4.95l-1.414-1.414A4.984 4.984 0 0 0 17 12.07c0-1.38-.56-2.63-1.464-3.535L16.95 7.12zM12 13.071a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 2a3 3 0 1 1 0-6 3 3 0 0 1 0 6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/surround-sound-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/surround-sound-line.svg",
"repo_id": "owncloud",
"token_count": 369
} | 730 |
<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="M9 3a3 3 0 0 0 6 0h6a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-2.001L19 20a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1l-.001-8.001L3 12a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h6zm11 1.999h-3.417l-.017.041a5.002 5.002 0 0 1-4.35 2.955L12 8a5.001 5.001 0 0 1-4.566-2.96L7.416 5H4v5l2.999-.001V19H17l-.001-9L20 9.999v-5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/t-shirt-2-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/t-shirt-2-line.svg",
"repo_id": "owncloud",
"token_count": 278
} | 731 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M10.83 13A3 3 0 1 0 8 15h8a3 3 0 1 0-2.83-2h-2.34zM3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm13 10a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm-8 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/tape-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/tape-fill.svg",
"repo_id": "owncloud",
"token_count": 210
} | 732 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm9 12v2h6v-2h-6zm-3.586-3l-2.828 2.828L7 16.243 11.243 12 7 7.757 5.586 9.172 8.414 12z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/terminal-box-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/terminal-box-fill.svg",
"repo_id": "owncloud",
"token_count": 191
} | 733 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M9.4 16H3a2 2 0 0 1-2-2v-2.104a2 2 0 0 1 .15-.762L4.246 3.62A1 1 0 0 1 5.17 3H22a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-3.482a1 1 0 0 0-.817.423l-5.453 7.726a.5.5 0 0 1-.632.159L9.802 22.4a2.5 2.5 0 0 1-1.305-2.853L9.4 16zm7.6-2.588V5H5.84L3 11.896V14h6.4a2 2 0 0 1 1.938 2.493l-.903 3.548a.5.5 0 0 0 .261.571l.661.33 4.71-6.672c.25-.354.57-.644.933-.858zM19 13h2V5h-2v8z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/thumb-down-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/thumb-down-line.svg",
"repo_id": "owncloud",
"token_count": 326
} | 734 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M17.618 5.968l1.453-1.453 1.414 1.414-1.453 1.453a9 9 0 1 1-1.414-1.414zM12 20a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM11 8h2v6h-2V8zM8 1h8v2H8V1z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/timer-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/timer-line.svg",
"repo_id": "owncloud",
"token_count": 176
} | 735 |
<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="M20 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h16zm-1 14H5v4h14v-4zm-2 1v2h-2v-2h2zM12 2L8 6h3v5h2V6h3l-4-4z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/uninstall-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/uninstall-fill.svg",
"repo_id": "owncloud",
"token_count": 194
} | 736 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M20 22H4v-2a5 5 0 0 1 5-5h6a5 5 0 0 1 5 5v2zm-8-9a6 6 0 1 1 0-12 6 6 0 0 1 0 12z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/user-3-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/user-3-fill.svg",
"repo_id": "owncloud",
"token_count": 140
} | 737 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 14v8H4a8 8 0 0 1 8-8zm0-1c-3.315 0-6-2.685-6-6s2.685-6 6-6 6 2.685 6 6-2.685 6-6 6zm8.828 7.828L18 23.657l-2.828-2.829a4 4 0 1 1 5.656 0zM18 17a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/user-location-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/user-location-fill.svg",
"repo_id": "owncloud",
"token_count": 205
} | 738 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 14v8H4a8 8 0 0 1 8-8zm6 7.5l-2.939 1.545.561-3.272-2.377-2.318 3.286-.478L18 14l1.47 2.977 3.285.478-2.377 2.318.56 3.272L18 21.5zM12 13c-3.315 0-6-2.685-6-6s2.685-6 6-6 6 2.685 6 6-2.685 6-6 6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/user-star-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/user-star-fill.svg",
"repo_id": "owncloud",
"token_count": 215
} | 739 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M1 3h4l7 12 7-12h4L12 22 1 3zm8.667 0L12 7l2.333-4h4.035L12 14 5.632 3h4.035z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/vuejs-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/vuejs-fill.svg",
"repo_id": "owncloud",
"token_count": 138
} | 740 |
<template>
<span
class="oc-avatar-count"
:style="{ width: size + 'px', height: size + 'px', fontSize: fontSize }"
v-text="`+${count}`"
/>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
/**
* Count of avatars which weren't displayed.
*/
export default defineComponent({
name: 'OcAvatarCount',
status: 'ready',
release: '2.1.0',
props: {
/**
* Count of avatars
*/
count: {
type: Number,
required: true
},
/**
* Width and height of the element in pixels
*/
size: {
type: Number,
required: false,
default: 30
}
},
computed: {
fontSize() {
return Math.floor(this.size / 2.5) + 'px'
}
}
})
</script>
<style lang="scss">
.oc-avatar-count {
align-items: center;
background-color: var(--oc-color-swatch-passive-default);
border-radius: 50%;
color: var(--oc-color-text-inverse);
display: flex;
justify-content: center;
}
</style>
<docs>
```js
<oc-avatar-count :count="21" />
```
</docs>
| owncloud/web/packages/design-system/src/components/OcAvatarCount/OcAvatarCount.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcAvatarCount/OcAvatarCount.vue",
"repo_id": "owncloud",
"token_count": 439
} | 741 |
<template>
<component
:is="type"
v-bind="additionalAttributes"
:aria-label="ariaLabel"
:class="$_ocButton_buttonClass"
v-on="handlers"
>
<oc-spinner v-if="showSpinner" size="small" class="spinner" />
<!-- @slot Content of the button -->
<slot />
</component>
</template>
<script lang="ts">
import { defineComponent, PropType } from 'vue'
import { RouteLocationRaw } from 'vue-router'
import { getSizeClass } from '../../utils/sizeClasses'
export default defineComponent({
name: 'OcButton',
status: 'ready',
release: '1.0.0',
props: {
/**
* The html element used for the button.
* `button, a, router-link`
*/
type: {
type: String,
default: 'button',
validator: (value: any) => {
return ['button', 'a', 'router-link'].includes(value)
}
},
/**
* Disable the button
*/
disabled: {
type: Boolean,
default: false
},
/**
* The size of the button. Defaults to medium.
* `small, medium, large`
*/
size: {
type: String,
default: 'medium',
validator: (value: string) => {
return ['small', 'medium', 'large'].includes(value)
}
},
/**
* When setting the button’s type to a link, use this option to give a href.
*/
href: {
type: String,
default: null
},
/**
* When setting the button’s type to a link, use this option to give a give a target.
* `_blank, _self, _parent, _top`
*/
target: {
type: String,
default: null,
validator: (value: string) => {
return ['_blank', '_self', '_parent', '_top'].includes(value)
}
},
/**
* When setting the button’s type to a router-link, use this option to give a to.
*/
to: {
type: [String, Object] as PropType<RouteLocationRaw>,
default: null
},
/**
* The aria-label of the button. Only use this property if you want to overwrite the accessible content of the
* oc-button. Usually this is not needed.
*/
ariaLabel: {
type: String,
default: null
},
/**
* Set the button’s type ("submit", "button" or "reset").
*/
submit: {
type: String,
default: 'button',
validator: (value: string) => {
return ['null', 'button', 'submit', 'reset'].includes(value)
}
},
/**
* Style variation to give additional meaning.
* Defaults to `primary`.
* Can be `passive, primary, danger, success, warning, brand`.
*/
variation: {
type: String,
default: 'passive',
validator: (value: string) => {
return ['passive', 'primary', 'danger', 'success', 'warning', 'brand'].includes(value)
}
},
/**
* Style variation to give additional meaning.
* Defaults to `outline`.
* Can be `outline, filled, raw, raw-inverse` with following characteristics:
* - outline: transparent button with text- and border-color according to variation default-color
* - filled: button filled in variation default-color, text in variation contrast-color
* - raw: text-only button with text in variation default-color
* - raw-inverse: text-only button with text in variation contrast-color
*/
appearance: {
type: String,
default: 'outline',
validator: (value: string) => {
return ['filled', 'outline', 'raw', 'raw-inverse'].includes(value)
}
},
/**
* How to justify content within the button. Defaults to center.
* `left, center, right, space-around, space-between, space-evenly`
*/
justifyContent: {
type: String,
default: 'center',
validator: (value: string) => {
return [
'left',
'center',
'right',
'space-around',
'space-between',
'space-evenly'
].includes(value)
}
},
/**
* Distance between children of the button. Defaults to medium. Might be overruled by justify-content value.
* @values none, xsmall, small, medium, large, xlarge
*/
gapSize: {
type: String,
default: 'medium',
validator: (value: string) => {
return ['none', 'xsmall', 'small', 'medium', 'large', 'xlarge'].includes(value)
}
},
/**
* Show loading spinner
*/
showSpinner: {
type: Boolean,
default: false
}
},
emits: ['click'],
computed: {
$_ocButton_buttonClass() {
return [
'oc-button',
'oc-rounded',
`oc-button-${getSizeClass(this.size)}`,
`oc-button-justify-content-${this.justifyContent}`,
`oc-button-gap-${getSizeClass(this.gapSize)}`,
`oc-button-${this.variation}`,
`oc-button-${this.variation}-${this.appearance}`
]
},
additionalAttributes() {
return {
...(this.href && { href: this.href }),
...(this.target && { target: this.target }),
...(this.to && { to: this.to }),
...(this.type === 'button' && { type: this.submit }),
...(this.type === 'button' && { disabled: this.disabled })
}
},
handlers() {
return {
...(this.type === 'button' && { click: this.$_ocButton_onClick })
}
}
},
methods: {
$_ocButton_onClick(event) {
this.$emit('click', event)
}
}
})
</script>
<style lang="scss">
@mixin oc-button-gap($factor) {
gap: round(calc($oc-space-small * $factor / 2)) * 2;
}
@mixin oc-button-line-height($factor) {
line-height: $oc-size-icon-default * $factor;
}
@mixin oc-button-variation($color, $hover-color, $muted-color, $contrast-color) {
&:disabled {
background-color: $muted-color;
}
&:focus:not([disabled]),
&:hover:not([disabled]) {
background-color: $hover-color;
}
&-raw,
&-raw-inverse {
background-color: transparent;
border-style: none;
font-size: var(--oc-font-size-medium);
font-weight: normal;
min-height: 0;
padding: 0;
&:focus:not([disabled]),
&:hover:not([disabled]) {
background-color: transparent;
}
&:focus:not([disabled]):not(button),
&:hover:not([disabled]):not(button) {
text-decoration: underline;
}
&:disabled {
background-color: transparent;
color: $muted-color;
}
}
&-raw {
color: $color;
.oc-icon > svg {
fill: $color;
}
}
&-raw-inverse {
color: $contrast-color;
.oc-icon > svg {
fill: $contrast-color;
}
}
&-filled {
background-color: $color;
color: $contrast-color;
.oc-icon > svg {
fill: $contrast-color;
}
&:hover:not([disabled]),
&:focus:not([disabled]) {
color: $contrast-color;
background-color: $hover-color;
border-color: $hover-color;
.oc-icon > svg {
fill: $contrast-color;
}
}
}
&-outline {
outline: 1px solid $color;
outline-offset: -1px;
background-color: transparent;
color: $color;
.oc-icon > svg {
fill: $color;
}
&:disabled {
background-color: transparent;
color: $muted-color;
}
}
&-outline:hover:not([disabled]),
&-outline:focus:not([disabled]) {
color: $contrast-color;
background-color: $hover-color;
border-color: $hover-color;
.oc-icon > svg {
fill: $contrast-color;
}
}
}
.oc-button {
@include oc-button-line-height(1);
align-items: center;
border: 0;
box-sizing: border-box;
display: inline-flex;
font-weight: 400;
padding: 0.5rem 0.8rem;
text-align: left;
text-decoration: none;
.spinner {
margin-left: -0.5rem;
}
&-justify-content {
&-left {
justify-content: left;
}
&-center {
justify-content: center;
}
&-right {
justify-content: right;
}
&-space-between {
justify-content: space-between;
}
&-space-around {
justify-content: space-around;
}
&-space-evenly {
justify-content: space-evenly;
}
}
&-gap {
&-xs {
@include oc-button-gap(0.5);
}
&-s {
@include oc-button-gap(0.7);
}
&-m {
@include oc-button-gap(1);
}
&-l {
@include oc-button-gap(1.5);
}
&-xl {
@include oc-button-gap(2);
}
}
&:hover {
cursor: pointer;
}
&-s {
@include oc-button-line-height(0.7);
font-size: var(--oc-font-size-small);
min-height: 1.2rem;
}
&-m {
@include oc-button-line-height(1);
font-size: var(--oc-font-size-medium);
min-height: $global-control-height;
}
&-l {
@include oc-button-line-height(1.5);
font-size: var(--oc-font-size-xlarge);
min-height: 2rem;
}
&-passive {
@include oc-button-variation(
var(--oc-color-swatch-passive-default),
var(--oc-color-swatch-passive-hover),
var(--oc-color-swatch-passive-muted),
var(--oc-color-swatch-passive-contrast)
);
&-outline {
&:focus:not([disabled]),
&:hover:not([disabled]) {
color: var(--oc-color-swatch-passive-default);
background-color: var(--oc-color-swatch-passive-hover-outline);
border-color: var(--oc-color-swatch-passive-hover-outline);
.oc-icon > svg {
fill: var(--oc-color-swatch-passive-default);
}
}
}
}
&-brand {
@include oc-button-variation(
var(--oc-color-swatch-brand-default),
var(--oc-color-swatch-brand-hover),
var(--oc-color-swatch-brand-muted),
var(--oc-color-swatch-brand-contrast)
);
}
&-primary {
@include oc-button-variation(
var(--oc-color-swatch-primary-default),
var(--oc-color-swatch-primary-hover),
var(--oc-color-swatch-primary-muted),
var(--oc-color-swatch-primary-contrast)
);
&-filled {
@include oc-background-primary-gradient;
color: var(--oc-color-swatch-primary-contrast) !important;
span > svg {
fill: var(--oc-color-swatch-primary-contrast) !important;
}
}
}
&-success {
@include oc-button-variation(
var(--oc-color-swatch-success-default),
var(--oc-color-swatch-success-hover),
var(--oc-color-swatch-success-muted),
var(--oc-color-swatch-success-contrast)
);
}
&-warning {
@include oc-button-variation(
var(--oc-color-swatch-warning-default),
var(--oc-color-swatch-warning-hover),
var(--oc-color-swatch-warning-muted),
var(--oc-color-swatch-warning-contrast)
);
}
&-danger {
@include oc-button-variation(
var(--oc-color-swatch-danger-default),
var(--oc-color-swatch-danger-hover),
var(--oc-color-swatch-danger-muted),
var(--oc-color-swatch-danger-contrast)
);
}
&:disabled {
cursor: default;
opacity: 0.6;
}
&-group {
display: inline-flex;
flex-flow: row wrap;
outline: 1px solid var(--oc-color-swatch-passive-default);
outline-offset: -1px;
border-radius: 5px;
.oc-button {
border-radius: 0;
outline: 0;
&:first-of-type {
border-radius: 5px 0 0 5px;
}
&:last-of-type {
border-radius: 0 5px 5px 0;
}
&-default {
border-left: 0;
border-right: 0;
&:first-of-type {
// TODO: Implement color variations if button group should be used again
border-left: 1px solid var(--oc-color-swatch-primary-default);
}
&:last-of-type {
// TODO: Implement color variations if button group should be used again
border-right: 1px solid var(--oc-color-swatch-primary-default);
}
}
}
}
}
</style>
<docs>
Buttons are generally used for interface actions. Suitable for all-purpose use.
Defaults to appearance that has white background with blue border.
Filled appearance should be used only once per view for main call-to-action.
All buttons are built with a css grid which ensures that there will be a pre-defined gutter between all child items.
## Accessibility
### Distinction when to use a `<button>`, when to use an `<a>`
Regardless of the visual representation the following differentiation should be made if in doubt what to choose.
- an anchor/link changes the location, be it internally on the website, or to another resource/document/route.
- a button does change the state of the website, e.g.: adds, deletes, opens, ...
### Accessible name
The accessible name ([explainer for the term](https://developer.paciellogroup.com/blog/2017/04/what-is-an-accessible-name/)) of a button is derived from several sources. Right now, only two of them are relevant:
1. The value of the `aria-label` attribute
2. The text between the opening and closing tag, `<button>This text here</button>`
When an aria-label attribute exists, its value will override the button text. So in this case, the accessible name would be "foo": `<button aria-label="foo">Bar</button>`, although visual users will see "Bar". This difference between accessible name and visual name is a problem for a certain type of assistive technology ([explainer for the term](https://en.wikipedia.org/wiki/Assistive_technology)), this is why the [WCAG success criterion 2.5.3, "Label in name"](https://www.w3.org/TR/WCAG21/#label-in-name) exists. This difference should be avoided, if it can't, W3C recommends that the accessible name should start with visible label.
### Icon-only button
Every button has to have an accessible name. It cannot be provided by a text between the button tags (for example, because it is an icon button; see "Upload" example below), the accessible name has to be provided by `aria-label`.
## Examples
```js
<template>
<div>
<h3 class="oc-heading-divider">
Button variations
</h3>
<div>
<oc-button v-for="variation in variations" :variation="variation.title" :class="{ 'oc-background-brand': variation.title === 'inverse' }" class="oc-mr-s oc-mb-s">
{{ variation.title }}
</oc-button>
</div>
<h3 class="oc-heading-divider">
Button sizes
</h3>
<div class="oc-flex">
<oc-button size="large" class="oc-mr-s">Large</oc-button>
<oc-button class="oc-mr-s oc-align-self-center">Medium (default)</oc-button>
<oc-button size="small" class="oc-align-self-center">Small</oc-button>
</div>
<h3 class="oc-heading-divider">
Button with icons
</h3>
<div class="oc-flex">
<oc-button class="oc-mr-s">
<oc-icon name="home-2" />
Home
</oc-button>
<oc-button variation="primary" class="oc-mr-s">
Select
<oc-icon name="arrow-drop-down" fill-type="line" />
</oc-button>
<oc-button variation="primary" aria-label="Upload a file">
<oc-icon name="upload-cloud-2" fill-type="line" />
</oc-button>
</div>
<h3 class="oc-heading-divider">
Using buttons in a group
</h3>
<div class="oc-button-group">
<oc-button variation="primary" appearance="filled">Hello</oc-button>
<oc-button>
<oc-icon name="folder" />
Demo Button
</oc-button>
<oc-button variation="danger" appearance="filled">Delete</oc-button>
</div>
<h3 class="oc-heading-divider">
All available button combinations
</h3>
<oc-table-simple>
<oc-thead>
<oc-tr>
<oc-th>Variation & usage</oc-th>
<oc-th>Outline (default)</oc-th>
<oc-th>Filled</oc-th>
<oc-th>Raw</oc-th>
</oc-tr>
</oc-thead>
<oc-tbody>
<oc-tr v-for="variation in variations">
<oc-td>
{{ variation.description }}
</oc-td>
<oc-td v-for="appearance in appearances" :class="{ 'oc-background-brand': variation.title === 'inverse' }" class="oc-p-m">
<oc-button :variation="variation.title" :appearance="appearance" class="oc-mb-s">
{{ variation.title }}
<oc-icon name="home-2" />
</oc-button>
<oc-button :variation="variation.title" :appearance="appearance" disabled>
{{ variation.title }}
<oc-icon name="home-2" />
</oc-button>
</oc-td>
</oc-tr>
</oc-tbody>
</oc-table-simple>
</div>
</template>
<script>
export default {
computed: {
variations() {
return [
{
title: "passive",
description: "Default appearance of interactive elements (links and buttons)"
},
{
title: "primary",
description: "Used as a visual clue to the main action on each page"
},
{
title: "success",
description: "Useful as confirmations or to finish a multi-step process"
},
{
title: "warning",
description: "Used as a visual hint for certain actions, like publicly sharing a file or removing a share"
},
{
title: "danger",
description: "Use for triggering possible destructive and non-reversible actions, like permanently deleting a file"
}
]
},
appearances() {
return [
"outline",
"filled",
"raw",
"raw-inverse"
]
},
},
}
</script>
```
</docs>
| owncloud/web/packages/design-system/src/components/OcButton/OcButton.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcButton/OcButton.vue",
"repo_id": "owncloud",
"token_count": 7259
} | 742 |
<template>
<div :class="classes">
<slot />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
/**
* The Grid system allows you to arrange block elements in columns.
*/
export default defineComponent({
name: 'OcGrid',
status: 'ready',
release: '1.0.0',
props: {
/**
* The Grid component comes with a default gutter that is decreased automatically from a certain breakpoint usually on a smaller desktop viewport width. To apply a different gutter, add one of the following: small, medium, large
*/
gutter: {
type: String,
default: 'collapse',
validator: (value: string) => {
return ['small', 'medium', 'large', 'collapse'].includes(value)
}
},
/**
* Center elements along the cross axis.
*/
flex: {
type: [Boolean],
default: false
}
},
computed: {
classes() {
let c = []
c.push('oc-grid-' + this.gutter)
if (this.flex) {
c.push('oc-flex')
c.push('oc-flex-middle')
}
return c
}
}
})
</script>
<style lang="scss">
// Ported from UiKit until we change UI frameworks
// Name: Grid
// Description: Component to create responsive, fluid and nestable grids
//
// Component: `oc-grid`
//
// Modifiers: `oc-grid-small`
// `oc-grid-medium`
// `oc-grid-large`
// `oc-grid-collapse`
// `oc-grid-divider`
// `oc-grid-match`
// `oc-grid-stack`
// `oc-grid-margin`
// `oc-grid-margin-small`
// `oc-grid-margin-medium`
// `oc-grid-margin-large`
// `oc-grid-margin-collapse`
//
// Sub-modifier: `oc-grid-item-match`
//
// States: `oc-first-column`
//
// ========================================================================
// Variables
// ========================================================================
$grid-gutter-horizontal: 30px !default;
$grid-gutter-vertical: $grid-gutter-horizontal !default;
$grid-gutter-horizontal-l: 40px !default;
$grid-gutter-vertical-l: $grid-gutter-horizontal-l !default;
$grid-small-gutter-horizontal: 15px !default;
$grid-small-gutter-vertical: $grid-small-gutter-horizontal !default;
$grid-medium-gutter-horizontal: 30px !default;
$grid-medium-gutter-vertical: $grid-medium-gutter-horizontal !default;
$grid-large-gutter-horizontal: 40px !default;
$grid-large-gutter-vertical: $grid-large-gutter-horizontal !default;
$grid-large-gutter-horizontal-l: 70px !default;
$grid-large-gutter-vertical-l: $grid-large-gutter-horizontal-l !default;
$grid-divider-border-width: 1px !default;
$grid-divider-border: #e5e5e5 !default;
/* ========================================================================
Component: Grid
========================================================================== */
/*
* 1. Allow cells to wrap into the next line
* 2. Reset list
*/
.oc-grid {
display: flex;
/* 1 */
flex-wrap: wrap;
/* 2 */
margin: 0;
padding: 0;
list-style: none;
}
/*
* Grid cell
* Note: Space is allocated solely based on content dimensions, but shrinks: 0 1 auto
* Reset margin for e.g. paragraphs
*/
.oc-grid > * {
margin: 0;
}
/*
* Remove margin from the last-child
*/
.oc-grid > * > :last-child {
margin-bottom: 0;
}
/* Gutter
========================================================================== */
/*
* Default
*/
/* Horizontal */
.oc-grid {
margin-left: (-$grid-gutter-horizontal);
}
.oc-grid > * {
padding-left: $grid-gutter-horizontal;
}
/* Vertical */
.oc-grid + .oc-grid,
.oc-grid > .oc-grid-margin,
* + .oc-grid-margin {
margin-top: $grid-gutter-vertical;
}
/* Desktop and bigger */
@media (min-width: $oc-breakpoint-large-default) {
/* Horizontal */
.oc-grid {
margin-left: (-$grid-gutter-horizontal-l);
}
.oc-grid > * {
padding-left: $grid-gutter-horizontal-l;
}
/* Vertical */
.oc-grid + .oc-grid,
.oc-grid > .oc-grid-margin,
* + .oc-grid-margin {
margin-top: $grid-gutter-vertical-l;
}
}
/*
* Small
*/
/* Horizontal */
.oc-grid-small,
.oc-grid-column-small {
margin-left: (-$grid-small-gutter-horizontal);
}
.oc-grid-small > *,
.oc-grid-column-small > * {
padding-left: $grid-small-gutter-horizontal;
}
/* Vertical */
.oc-grid + .oc-grid-small,
.oc-grid + .oc-grid-row-small,
.oc-grid-small > .oc-grid-margin,
.oc-grid-row-small > .oc-grid-margin,
* + .oc-grid-margin-small {
margin-top: $grid-small-gutter-vertical;
}
/*
* Medium
*/
/* Horizontal */
.oc-grid-medium,
.oc-grid-column-medium {
margin-left: (-$grid-medium-gutter-horizontal);
}
.oc-grid-medium > *,
.oc-grid-column-medium > * {
padding-left: $grid-medium-gutter-horizontal;
}
/* Vertical */
.oc-grid + .oc-grid-medium,
.oc-grid + .oc-grid-row-medium,
.oc-grid-medium > .oc-grid-margin,
.oc-grid-row-medium > .oc-grid-margin,
* + .oc-grid-margin-medium {
margin-top: $grid-medium-gutter-vertical;
}
/*
* Large
*/
/* Horizontal */
.oc-grid-large,
.oc-grid-column-large {
margin-left: (-$grid-large-gutter-horizontal);
}
.oc-grid-large > *,
.oc-grid-column-large > * {
padding-left: $grid-large-gutter-horizontal;
}
/* Vertical */
.oc-grid + .oc-grid-large,
.oc-grid + .oc-grid-row-large,
.oc-grid-large > .oc-grid-margin,
.oc-grid-row-large > .oc-grid-margin,
* + .oc-grid-margin-large {
margin-top: $grid-large-gutter-vertical;
}
/* Desktop and bigger */
@media (min-width: $oc-breakpoint-large-default) {
/* Horizontal */
.oc-grid-large,
.oc-grid-column-large {
margin-left: (-$grid-large-gutter-horizontal-l);
}
.oc-grid-large > *,
.oc-grid-column-large > * {
padding-left: $grid-large-gutter-horizontal-l;
}
/* Vertical */
.oc-grid + .oc-grid-large,
.oc-grid + .oc-grid-row-large,
.oc-grid-large > .oc-grid-margin,
.oc-grid-row-large > .oc-grid-margin,
* + .oc-grid-margin-large {
margin-top: $grid-large-gutter-vertical-l;
}
}
/*
* Collapse
*/
/* Horizontal */
.oc-grid-collapse,
.oc-grid-column-collapse {
margin-left: 0;
}
.oc-grid-collapse > *,
.oc-grid-column-collapse > * {
padding-left: 0;
}
/* Vertical */
.oc-grid + .oc-grid-collapse,
.oc-grid + .oc-grid-row-collapse,
.oc-grid-collapse > .oc-grid-margin,
.oc-grid-row-collapse > .oc-grid-margin {
margin-top: 0;
}
/* Divider
========================================================================== */
.oc-grid-divider > * {
position: relative;
}
.oc-grid-divider > :not(.oc-first-column)::before {
content: '';
position: absolute;
top: 0;
bottom: 0;
border-left: $grid-divider-border-width solid $grid-divider-border;
}
/* Vertical */
.oc-grid-divider.oc-grid-stack > .oc-grid-margin::before {
content: '';
position: absolute;
left: 0;
right: 0;
border-top: $grid-divider-border-width solid $grid-divider-border;
}
/*
* Default
*/
/* Horizontal */
.oc-grid-divider {
margin-left: -($grid-gutter-horizontal * 2);
}
.oc-grid-divider > * {
padding-left: ($grid-gutter-horizontal * 2);
}
.oc-grid-divider > :not(.oc-first-column)::before {
left: $grid-gutter-horizontal;
}
/* Vertical */
.oc-grid-divider.oc-grid-stack > .oc-grid-margin {
margin-top: ($grid-gutter-vertical * 2);
}
.oc-grid-divider.oc-grid-stack > .oc-grid-margin::before {
top: (-$grid-gutter-vertical);
left: ($grid-gutter-horizontal * 2);
}
/* Desktop and bigger */
@media (min-width: $oc-breakpoint-large-default) {
/* Horizontal */
.oc-grid-divider {
margin-left: -($grid-gutter-horizontal-l * 2);
}
.oc-grid-divider > * {
padding-left: ($grid-gutter-horizontal-l * 2);
}
.oc-grid-divider > :not(.oc-first-column)::before {
left: $grid-gutter-horizontal-l;
}
/* Vertical */
.oc-grid-divider.oc-grid-stack > .oc-grid-margin {
margin-top: ($grid-gutter-vertical-l * 2);
}
.oc-grid-divider.oc-grid-stack > .oc-grid-margin::before {
top: (-$grid-gutter-vertical-l);
left: ($grid-gutter-horizontal-l * 2);
}
}
/*
* Small
*/
/* Horizontal */
.oc-grid-divider.oc-grid-small,
.oc-grid-divider.oc-grid-column-small {
margin-left: -($grid-small-gutter-horizontal * 2);
}
.oc-grid-divider.oc-grid-small > *,
.oc-grid-divider.oc-grid-column-small > * {
padding-left: ($grid-small-gutter-horizontal * 2);
}
.oc-grid-divider.oc-grid-small > :not(.oc-first-column)::before,
.oc-grid-divider.oc-grid-column-small > :not(.oc-first-column)::before {
left: $grid-small-gutter-horizontal;
}
/* Vertical */
.oc-grid-divider.oc-grid-small.oc-grid-stack > .oc-grid-margin,
.oc-grid-divider.oc-grid-row-small.oc-grid-stack > .oc-grid-margin {
margin-top: ($grid-small-gutter-vertical * 2);
}
.oc-grid-divider.oc-grid-small.oc-grid-stack > .oc-grid-margin::before {
top: (-$grid-small-gutter-vertical);
left: ($grid-small-gutter-horizontal * 2);
}
.oc-grid-divider.oc-grid-row-small.oc-grid-stack > .oc-grid-margin::before {
top: (-$grid-small-gutter-vertical);
}
.oc-grid-divider.oc-grid-column-small.oc-grid-stack > .oc-grid-margin::before {
left: ($grid-small-gutter-horizontal * 2);
}
/*
* Medium
*/
/* Horizontal */
.oc-grid-divider.oc-grid-medium,
.oc-grid-divider.oc-grid-column-medium {
margin-left: -($grid-medium-gutter-horizontal * 2);
}
.oc-grid-divider.oc-grid-medium > *,
.oc-grid-divider.oc-grid-column-medium > * {
padding-left: ($grid-medium-gutter-horizontal * 2);
}
.oc-grid-divider.oc-grid-medium > :not(.oc-first-column)::before,
.oc-grid-divider.oc-grid-column-medium > :not(.oc-first-column)::before {
left: $grid-medium-gutter-horizontal;
}
/* Vertical */
.oc-grid-divider.oc-grid-medium.oc-grid-stack > .oc-grid-margin,
.oc-grid-divider.oc-grid-row-medium.oc-grid-stack > .oc-grid-margin {
margin-top: ($grid-medium-gutter-vertical * 2);
}
.oc-grid-divider.oc-grid-medium.oc-grid-stack > .oc-grid-margin::before {
top: (-$grid-medium-gutter-vertical);
left: ($grid-medium-gutter-horizontal * 2);
}
.oc-grid-divider.oc-grid-row-medium.oc-grid-stack > .oc-grid-margin::before {
top: (-$grid-medium-gutter-vertical);
}
.oc-grid-divider.oc-grid-column-medium.oc-grid-stack > .oc-grid-margin::before {
left: ($grid-medium-gutter-horizontal * 2);
}
/*
* Large
*/
/* Horizontal */
.oc-grid-divider.oc-grid-large,
.oc-grid-divider.oc-grid-column-large {
margin-left: -($grid-large-gutter-horizontal * 2);
}
.oc-grid-divider.oc-grid-large > *,
.oc-grid-divider.oc-grid-column-large > * {
padding-left: ($grid-large-gutter-horizontal * 2);
}
.oc-grid-divider.oc-grid-large > :not(.oc-first-column)::before,
.oc-grid-divider.oc-grid-column-large > :not(.oc-first-column)::before {
left: $grid-large-gutter-horizontal;
}
/* Vertical */
.oc-grid-divider.oc-grid-large.oc-grid-stack > .oc-grid-margin,
.oc-grid-divider.oc-grid-row-large.oc-grid-stack > .oc-grid-margin {
margin-top: ($grid-large-gutter-vertical * 2);
}
.oc-grid-divider.oc-grid-large.oc-grid-stack > .oc-grid-margin::before {
top: (-$grid-large-gutter-vertical);
left: ($grid-large-gutter-horizontal * 2);
}
.oc-grid-divider.oc-grid-row-large.oc-grid-stack > .oc-grid-margin::before {
top: (-$grid-large-gutter-vertical);
}
.oc-grid-divider.oc-grid-column-large.oc-grid-stack > .oc-grid-margin::before {
left: ($grid-large-gutter-horizontal * 2);
}
/* Desktop and bigger */
@media (min-width: $oc-breakpoint-large-default) {
/* Horizontal */
.oc-grid-divider.oc-grid-large,
.oc-grid-divider.oc-grid-column-large {
margin-left: -($grid-large-gutter-horizontal-l * 2);
}
.oc-grid-divider.oc-grid-large > *,
.oc-grid-divider.oc-grid-column-large > * {
padding-left: ($grid-large-gutter-horizontal-l * 2);
}
.oc-grid-divider.oc-grid-large > :not(.oc-first-column)::before,
.oc-grid-divider.oc-grid-column-large > :not(.oc-first-column)::before {
left: $grid-large-gutter-horizontal-l;
}
/* Vertical */
.oc-grid-divider.oc-grid-large.oc-grid-stack > .oc-grid-margin,
.oc-grid-divider.oc-grid-row-large.oc-grid-stack > .oc-grid-margin {
margin-top: ($grid-large-gutter-vertical-l * 2);
}
.oc-grid-divider.oc-grid-large.oc-grid-stack > .oc-grid-margin::before {
top: (-$grid-large-gutter-vertical-l);
left: ($grid-large-gutter-horizontal-l * 2);
}
.oc-grid-divider.oc-grid-row-large.oc-grid-stack > .oc-grid-margin::before {
top: (-$grid-large-gutter-vertical-l);
}
.oc-grid-divider.oc-grid-column-large.oc-grid-stack > .oc-grid-margin::before {
left: ($grid-large-gutter-horizontal-l * 2);
}
}
/* Match child of a grid cell
========================================================================== */
/*
* Behave like a block element
* 1. Wrap into the next line
* 2. Take the full width, at least 100%. Only if no class from the Width component is set.
* 3. Expand width even if larger than 100%, e.g. because of negative margin (Needed for nested grids)
*/
.oc-grid-match > *,
.oc-grid-item-match {
display: flex;
/* 1 */
flex-wrap: wrap;
}
.oc-grid-match > * > :not([class*='oc-width']),
.oc-grid-item-match > :not([class*='oc-width']) {
/* 2 */
box-sizing: border-box;
width: 100%;
/* 3 */
flex: auto;
}
</style>
<docs>
```js
<h3 class="oc-heading-divider">
Simple boxes
</h3>
<oc-grid>
<div style="width: 80px; height: 80px; background-color: var(--oc-color-swatch-passive-default)" class="oc-height-small"></div>
<div style="width: 80px; height: 80px; background-color: var(--oc-color-swatch-success-default)" class="oc-height-small"></div>
<div style="width: 80px; height: 80px; background-color: var(--oc-color-swatch-warning-default)" class="oc-height-small"></div>
</oc-grid>
<h3 class="oc-heading-divider">
Simple boxes
</h3>
<oc-grid gutter="large">
<div class="oc-width-1-1 oc-width-large@l">
<div style="background-color: var(--oc-color-swatch-passive-default)" class="oc-p-m">
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
</div>
</div>
<div class="oc-width-expand">
<div style="background-color: var(--oc-color-swatch-passive-default)" class="oc-p-m">
<p>I'm matching my neightbors height in @l viewports</p>
</div>
</div>
</oc-grid>
<h3 class="oc-heading-divider">
An application bar
</h3>
<div style="background-color: var(--oc-color-background-muted)" class="oc-p-s">
<oc-grid flex gutter="small">
<div class="oc-width-expand">
<oc-breadcrumb :items="[{text:'First',to:{path:'first'}},{text:'Second'},{text:'Third'}]" />
</div>
<div class="oc-width-auto oc-visible@m">
<oc-search-bar />
</div>
<div class="oc-width-auto">
<div class="oc-button-group">
<oc-button text="Nothing">Nothing</oc-button>
<oc-button id="my_drop_1"><oc-icon name="list-settings" fill-type="line" /></oc-button>
</div>
</div>
</oc-grid>
<oc-drop toggle="#my_drop_1" mode="hover">
<div slot="special" class="oc-card">
<div class="oc-card-header">
<h3 class="oc-card-title">
Advanced
</h3>
</div>
<div class="oc-card-body">
<p>
I'm a slightly more advanced drop down
</p>
<oc-search-bar small class="oc-hidden@m" />
</div>
</div>
</oc-drop>
</div>
```
</docs>
| owncloud/web/packages/design-system/src/components/OcGrid/OcGrid.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcGrid/OcGrid.vue",
"repo_id": "owncloud",
"token_count": 6497
} | 743 |
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`OcModal > displays input 1`] = `
"<div class="oc-modal-background" aria-labelledby="oc-modal-title">
<focus-trap-stub active="true" escapedeactivates="true" returnfocusondeactivate="true" allowoutsideclick="true" clickoutsidedeactivates="false" initialfocus="[Function]" delayinitialfocus="true" preventscroll="false" setreturnfocus="false">
<div class="oc-modal oc-modal-passive" tabindex="0" role="dialog" aria-modal="true">
<div class="oc-modal-title">
<!--v-if-->
<h2 id="oc-modal-title" class="oc-text-truncate">Create new folder</h2>
</div>
<div class="oc-modal-body">
<!--v-if-->
<!--v-if-->
<oc-text-input-stub id="oc-textinput-1" type="text" modelvalue="New folder" clearbuttonenabled="false" clearbuttonaccessiblelabel="" disabled="false" label="Folder name" fixmessageline="true" readonly="false" passwordpolicy="[object Object]" class="oc-modal-body-input"></oc-text-input-stub>
</div>
<div class="oc-modal-body-actions oc-flex oc-flex-right">
<div class="oc-modal-body-actions-grid">
<oc-button-stub type="button" disabled="false" size="medium" submit="button" variation="passive" appearance="outline" justifycontent="center" gapsize="medium" showspinner="false" class="oc-modal-body-actions-cancel">Cancel</oc-button-stub>
<oc-button-stub type="button" disabled="false" size="medium" submit="button" variation="primary" appearance="filled" justifycontent="center" gapsize="medium" showspinner="false" class="oc-modal-body-actions-confirm oc-ml-s">Confirm</oc-button-stub>
</div>
</div>
</div>
</focus-trap-stub>
</div>"
`;
exports[`OcModal > hides icon if not specified 1`] = `
"<div class="oc-modal-background" aria-labelledby="oc-modal-title">
<focus-trap-stub active="true" escapedeactivates="true" returnfocusondeactivate="true" allowoutsideclick="true" clickoutsidedeactivates="false" initialfocus="[Function]" delayinitialfocus="true" preventscroll="false" setreturnfocus="false">
<div class="oc-modal oc-modal-passive" tabindex="0" role="dialog" aria-modal="true">
<div class="oc-modal-title">
<!--v-if-->
<h2 id="oc-modal-title" class="oc-text-truncate">Example title</h2>
</div>
<div class="oc-modal-body">
<p class="oc-modal-body-message oc-mt-rm oc-mb-rm">Example message</p>
<!--v-if-->
<!--v-if-->
</div>
<div class="oc-modal-body-actions oc-flex oc-flex-right">
<div class="oc-modal-body-actions-grid">
<oc-button-stub type="button" disabled="false" size="medium" submit="button" variation="passive" appearance="outline" justifycontent="center" gapsize="medium" showspinner="false" class="oc-modal-body-actions-cancel">Cancel</oc-button-stub>
<oc-button-stub type="button" disabled="false" size="medium" submit="button" variation="primary" appearance="filled" justifycontent="center" gapsize="medium" showspinner="false" class="oc-modal-body-actions-confirm oc-ml-s">Confirm</oc-button-stub>
</div>
</div>
</div>
</focus-trap-stub>
</div>"
`;
exports[`OcModal > matches snapshot 1`] = `
"<div class="oc-modal-background" aria-labelledby="oc-modal-title">
<focus-trap-stub active="true" escapedeactivates="true" returnfocusondeactivate="true" allowoutsideclick="true" clickoutsidedeactivates="false" initialfocus="[Function]" delayinitialfocus="true" preventscroll="false" setreturnfocus="false">
<div class="oc-modal oc-modal-passive" tabindex="0" role="dialog" aria-modal="true">
<div class="oc-modal-title">
<oc-icon-stub name="info" filltype="fill" accessiblelabel="" type="span" size="medium" variation="passive" color=""></oc-icon-stub>
<h2 id="oc-modal-title" class="oc-text-truncate">Example title</h2>
</div>
<div class="oc-modal-body">
<p class="oc-modal-body-message oc-mt-rm oc-mb-rm">Example message</p>
<!--v-if-->
<!--v-if-->
</div>
<div class="oc-modal-body-actions oc-flex oc-flex-right">
<div class="oc-modal-body-actions-grid">
<oc-button-stub type="button" disabled="false" size="medium" submit="button" variation="passive" appearance="outline" justifycontent="center" gapsize="medium" showspinner="false" class="oc-modal-body-actions-cancel">Cancel</oc-button-stub>
<oc-button-stub type="button" disabled="false" size="medium" submit="button" variation="primary" appearance="filled" justifycontent="center" gapsize="medium" showspinner="false" class="oc-modal-body-actions-confirm oc-ml-s">Confirm</oc-button-stub>
</div>
</div>
</div>
</focus-trap-stub>
</div>"
`;
exports[`OcModal > overrides props message with slot 1`] = `
"<div class="oc-modal-background" aria-labelledby="oc-modal-title">
<focus-trap-stub active="true" escapedeactivates="true" returnfocusondeactivate="true" allowoutsideclick="true" clickoutsidedeactivates="false" initialfocus="[Function]" delayinitialfocus="true" preventscroll="false" setreturnfocus="false">
<div class="oc-modal oc-modal-passive" tabindex="0" role="dialog" aria-modal="true">
<div class="oc-modal-title">
<!--v-if-->
<h2 id="oc-modal-title" class="oc-text-truncate">Example title</h2>
</div>
<div class="oc-modal-body">
<div class="oc-modal-body-message">
<p>Slot message</p>
</div>
</div>
<div class="oc-modal-body-actions oc-flex oc-flex-right">
<div class="oc-modal-body-actions-grid">
<oc-button-stub type="button" disabled="false" size="medium" submit="button" variation="passive" appearance="outline" justifycontent="center" gapsize="medium" showspinner="false" class="oc-modal-body-actions-cancel">Cancel</oc-button-stub>
<oc-button-stub type="button" disabled="false" size="medium" submit="button" variation="primary" appearance="filled" justifycontent="center" gapsize="medium" showspinner="false" class="oc-modal-body-actions-confirm oc-ml-s">Confirm</oc-button-stub>
</div>
</div>
</div>
</focus-trap-stub>
</div>"
`;
| owncloud/web/packages/design-system/src/components/OcModal/__snapshots__/OcModal.spec.ts.snap/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcModal/__snapshots__/OcModal.spec.ts.snap",
"repo_id": "owncloud",
"token_count": 2435
} | 744 |
<template>
<span class="oc-recipient">
<template v-if="recipient.hasAvatar">
<oc-spinner
v-if="recipient.isLoadingAvatar"
key="recipient-avatar-spinner"
size="small"
:aria-label="$gettext('Loading avatar')"
data-testid="recipient-avatar-spinner"
/>
<oc-avatar
v-else
:key="recipient.avatar || recipient.name"
data-testid="recipient-avatar"
class="oc-recipient-avatar"
:src="recipient.avatar"
:user-name="recipient.name"
:width="16.8"
/>
</template>
<oc-icon
v-else-if="recipient.icon && recipient.icon.name"
class="oc-recipient-icon"
size="small"
:name="recipient.icon.name"
:accessible-label="recipient.icon.label"
data-testid="recipient-icon"
/>
<p class="oc-recipient-name" data-testid="recipient-name" v-text="recipient.name" />
<!-- @slot Append content (actions, additional info, etc.) -->
<slot name="append" />
</span>
</template>
<script lang="ts">
import { defineComponent, PropType } from 'vue'
import OcAvatar from '../OcAvatar/OcAvatar.vue'
import OcIcon from '../OcIcon/OcIcon.vue'
import OcSpinner from '../OcSpinner/OcSpinner.vue'
import { Recipient } from './types'
export default defineComponent({
name: 'OcRecipient',
status: 'ready',
release: '8.2.0',
components: { OcAvatar, OcIcon, OcSpinner },
props: {
/**
* Recipient object containing name (required), icon and avatar
*/
recipient: {
type: Object as PropType<Recipient>,
required: true,
validator: (recipient: Recipient) => {
if (!Object.prototype.hasOwnProperty.call(recipient, 'name')) {
throw new Error('Recipient name is not defined')
}
if (typeof recipient.name !== 'string') {
throw new Error('Recipient name is not a string')
}
if (recipient.name.length < 1) {
throw new Error('Recipient name is empty')
}
if (Object.prototype.hasOwnProperty.call(recipient, 'icon')) {
if (!Object.prototype.hasOwnProperty.call(recipient.icon, 'name')) {
throw new Error('Recipient icon name is not defined')
}
if (typeof recipient.icon.name !== 'string') {
throw new Error('Recipient icon name is not a string')
}
if (recipient.icon.name.length < 1) {
throw new Error('Recipient icon name is empty')
}
if (!Object.prototype.hasOwnProperty.call(recipient.icon, 'label')) {
throw new Error('Recipient icon label is not defined')
}
if (typeof recipient.icon.label !== 'string') {
throw new Error('Recipient icon label is not a string')
}
if (recipient.icon.label.length < 1) {
throw new Error('Recipient icon label is empty')
}
}
return true
}
}
}
})
</script>
<style lang="scss">
.oc-recipient {
align-items: center;
background-color: var(--oc-color-background-default);
border: 1px solid var(--oc-color-input-border);
border-radius: 6px;
display: flex;
gap: var(--oc-space-xsmall);
justify-content: flex-start;
padding: var(--oc-space-xsmall);
width: auto;
&-icon > svg {
fill: var(--oc-color-text-default);
}
&-name {
color: var(--oc-color-text-default);
margin: 0;
padding: 0;
}
}
</style>
<docs>
```js
<div class="oc-flex oc-flex-column oc-flex-left oc-flex-top">
<oc-recipient :recipient="{ name: 'Alice', avatar: 'https://picsum.photos/24', hasAvatar: true, isAvatarLoading: false }" class="oc-mb-s" />
<oc-recipient :recipient="{ name: 'Alice', icon: { name: 'person', label: 'User' }, hasAvatar: false }" />
</div>
```
</docs>
| owncloud/web/packages/design-system/src/components/OcRecipient/OcRecipient.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcRecipient/OcRecipient.vue",
"repo_id": "owncloud",
"token_count": 1642
} | 745 |
import { shallowMount } from 'web-test-helpers'
import Tag from './OcTag.vue'
describe('OcTag', () => {
it('uses correct component when type is specified', () => {
const wrapper = shallowMount(Tag, {
props: {
type: 'button'
}
})
expect(wrapper.element.tagName.toLowerCase()).toMatch('button')
expect(wrapper.html()).toMatchSnapshot()
})
it('emits a click event', async () => {
const wrapper = shallowMount(Tag, {
props: {
type: 'a'
}
})
await wrapper.trigger('click')
expect(wrapper.emitted().click).toBeTruthy()
})
})
| owncloud/web/packages/design-system/src/components/OcTag/OcTag.spec.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcTag/OcTag.spec.ts",
"repo_id": "owncloud",
"token_count": 239
} | 746 |
<template>
<component :is="type" :class="cellClasses" @click="$emit('click', $event)">
<slot />
</component>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'OcTableCell',
status: 'ready',
release: '2.1.0',
props: {
type: {
type: String,
default: 'td',
required: false,
validator: (type: string) => ['td', 'th'].includes(type)
},
alignH: {
type: String,
default: 'left',
validator: (alignment: string) => ['left', 'center', 'right'].includes(alignment)
},
alignV: {
type: String,
default: 'middle',
validator: (alignment: string) => ['top', 'middle', 'bottom'].includes(alignment)
},
width: {
type: String,
default: 'auto',
validator: (width: string) => ['auto', 'shrink', 'expand'].includes(width)
},
wrap: {
type: String,
default: null,
validator: (wrap: string) => ['break', 'nowrap', 'truncate'].includes(wrap) || !wrap
}
},
emits: ['click'],
computed: {
cellClasses() {
const classes = [
'oc-table-cell',
`oc-table-cell-align-${this.alignH}`,
`oc-table-cell-align-${this.alignV}`,
`oc-table-cell-width-${this.width}`
]
if (this.wrap) {
classes.push(`oc-text-${this.wrap}`)
}
return classes
}
}
})
</script>
<style lang="scss">
.oc-table-cell {
/* padding is not configurable until we need it */
padding: 0 var(--oc-space-small);
position: relative;
&-align {
&-left {
text-align: left;
}
&-center {
text-align: center;
}
&-right {
text-align: right;
}
&-top {
vertical-align: top;
}
&-middle {
vertical-align: middle;
}
&-bottom {
vertical-align: bottom;
}
}
&-width {
&-shrink {
width: 1px;
}
&-expand {
min-width: 150px;
}
}
}
</style>
| owncloud/web/packages/design-system/src/components/_OcTableCell/_OcTableCell.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/_OcTableCell/_OcTableCell.vue",
"repo_id": "owncloud",
"token_count": 906
} | 747 |
/**
* Converts hex to rgb
* @param {string} hex: The hex color value (with or without #)
* @return {Array<number>|null} The converted rgb array
**/
export function hexToRgb(hex: string): Array<number> | null {
hex = hex.startsWith('#') ? hex : `#${hex}`
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
return result ? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)] : null
}
/**
* Converts rgb to hex
* @param {Array<number>} rgbArray: The rgb color
* @return {string} The converted hex value
**/
export function rgbToHex(rgbArray: Array<number>): string {
const [r, g, b] = rgbArray
const rHex = r.toString(16).padStart(2, '0')
const gHex = g.toString(16).padStart(2, '0')
const bHex = b.toString(16).padStart(2, '0')
return `#${rHex}${gHex}${bHex}`
}
function shadeValue(value: number, percent: number): string {
let a = (value * (100 + percent)) / 100
a = a < 255 ? a : 255
a = Math.round(a)
return a.toString(16).length == 1 ? '0' + a.toString(16) : a.toString(16)
}
/**
* Dim or brighten a hex color
* @param {string} rgb: The rgb color value
* @return {string} The brightened or dimmed hex color
**/
export function calculateShadeColor(rgb: Array<number>, percent: number): string {
const r = rgb[0]
const g = rgb[1]
const b = rgb[2]
return `#${shadeValue(r, percent)}${shadeValue(g, percent)}${shadeValue(b, percent)}`
}
/**
* Get the luminance of an rgb color
* @param {Array<number>} rgb: The rgb value as an array
* @return {Number} Returns value between 0 and 1, where 1 is white
**/
export function getLuminanace(rgb: Array<number>): number {
const mappedRgb = rgb.map((v) => {
const val = v / 255
return val <= 0.03928 ? val / 12.92 : ((val + 0.055) / 1.055) ** 2.4
})
return Number((0.2126 * mappedRgb[0] + 0.7152 * mappedRgb[1] + 0.0722 * mappedRgb[2]).toFixed(3))
}
/**
* Get the contrast ratio between two rgb colors
* @param {Array<number>} rgbColorA: The first rgb value as an array
* @param {Array<number>} rgbColorB: The second rgb value as an array
* @return {Number} Returns value between 1 and 21, where 1 is no contrast and 21 is max contrast
**/
export function getContrastRatio(rgbColorA: Array<number>, rgbColorB: Array<number>): number {
const lumA = getLuminanace(rgbColorA)
const lumB = getLuminanace(rgbColorB)
return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05)
}
/**
* Gives you a random hashed color for a string, e.g. if you give it 'owncloud' it will always return the same color
* @param {string} name: Can be any string
* @return {string} Returns a hex color
**/
export function generateHashedColorForString(name: string): string {
let hash = 0
for (let i = 0; i < name.length; i++) {
hash = name.charCodeAt(i) + ((hash << 5) - hash)
}
return `#${(hash & 0x00ffffff).toString(16).toUpperCase()}`
}
/**
* Adjusts a given color to match the contrast ratio of another color
* @param {Array<number>} targetColorRgb: color to adjust
* @param {Array<number>} associatedColorRgb: brightest reference color
* @param {Array<number>} desiredRatio: desired contrast ratio
* @return {string} Returns a rgb color array
**/
export function setDesiredContrastRatio(
targetColorRgb: Array<number>,
associatedColorRgb: Array<number>,
desiredRatio: number
): Array<number> {
const ratio = getContrastRatio(targetColorRgb, associatedColorRgb)
if (Math.abs(desiredRatio - ratio) <= 0.3) {
return targetColorRgb
}
if (ratio < desiredRatio) {
return setDesiredContrastRatio(
hexToRgb(calculateShadeColor(targetColorRgb, -1)),
associatedColorRgb,
desiredRatio
)
}
return setDesiredContrastRatio(
hexToRgb(calculateShadeColor(targetColorRgb, 1)),
associatedColorRgb,
desiredRatio
)
}
/**
* Convert a css rgb value like rgb(255, 255, 255) to a hex value like #FFFFFF
* works also with rgba()
* @param {string} cssRgb: color to adjust
* @return {string} Returns a hex color
**/
export function cssRgbToHex(cssRgb: string): string {
cssRgb = cssRgb.toLowerCase().replace(/\s/g, '')
const isRgba = cssRgb.includes('rgba(')
const values = cssRgb.match(isRgba ? /rgba?\(([^)]+)\)/ : /rgb?\(([^)]+)\)/)
if (!values) {
return '#000000'
}
const colorArray = values[1].split(',')
let alpha = ''
if (isRgba) {
alpha = Math.round(parseFloat(colorArray.pop()) * 255).toString(16)
if (alpha.length === 1) {
alpha = '0' + alpha
}
}
const hex = colorArray
.map((value) => {
const intValue = parseInt(value, 10)
const hexValue = intValue.toString(16)
return hexValue.length === 1 ? '0' + hexValue : hexValue
})
.join('')
if (isRgba) {
return `#${hex}${alpha}`
} else {
return `#${hex}`
}
}
/**
* Get the hex value of a css var()
* @param {string} variable: The css var name e.g. var(--color-primary) or --color-primary
* @return {string} Returns a hex color
**/
export function getHexFromCssVar(variable: string): string {
if (!variable) {
return ''
}
// if color is a hex value, return it
if (variable.startsWith('#')) {
return variable
}
const varName = variable.match(/var\(([^)]+)\)/)?.[1] || variable
const result = getComputedStyle(document.documentElement).getPropertyValue(varName)
// if css var is hex value, return it
if (result.startsWith('#')) {
return result
}
return cssRgbToHex(result)
}
| owncloud/web/packages/design-system/src/helpers/colors.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/helpers/colors.ts",
"repo_id": "owncloud",
"token_count": 2034
} | 748 |
// Ported from UiKit until we change UI frameworks
// Name: Height
// Description: Utilities for heights
//
// Component: `oc-height-*`
//
// ========================================================================
// Variables
// ========================================================================
$height-small-height: 150px !default;
$height-medium-height: 300px !default;
$height-large-height: 450px !default;
/* ========================================================================
Component: Height
========================================================================== */
[class*="oc-height"] { box-sizing: border-box; }
/*
* Only works if parent element has a height set
*/
.oc-height-1-1 { height: 100%; }
/*
* Useful to create image teasers
*/
.oc-height-viewport { min-height: 100vh; }
/*
* Pixel
* Useful for `overflow: auto`
*/
.oc-height-small { height: $height-small-height; }
.oc-height-medium { height: $height-medium-height; }
.oc-height-large { height: $height-large-height; }
.oc-height-max-small { max-height: $height-small-height; }
.oc-height-max-medium { max-height: $height-medium-height; }
.oc-height-max-large { max-height: $height-large-height; }
| owncloud/web/packages/design-system/src/styles/theme/oc-height.scss/0 | {
"file_path": "owncloud/web/packages/design-system/src/styles/theme/oc-height.scss",
"repo_id": "owncloud",
"token_count": 359
} | 749 |
---
space:
xsmall:
value: 4px
small:
value: 8px
medium:
value: 16px
large:
value: 24px
xlarge:
value: 48px
xxlarge:
value: 96px
| owncloud/web/packages/design-system/src/tokens/ods/space.yaml/0 | {
"file_path": "owncloud/web/packages/design-system/src/tokens/ods/space.yaml",
"repo_id": "owncloud",
"token_count": 80
} | 750 |
module.exports = {
printWidth: 100,
singleQuote: true,
semi: false,
trailingComma: 'none'
}
| owncloud/web/packages/prettier-config/index.js/0 | {
"file_path": "owncloud/web/packages/prettier-config/index.js",
"repo_id": "owncloud",
"token_count": 38
} | 751 |
<template>
<div class="oc-flex group-info oc-mb-l">
<avatar-image class="oc-mb-m" :width="80" :userid="_group.id" :user-name="_group.displayName" />
<span class="oc-text-muted group-info-display-name" v-text="_group.displayName"></span>
<span class="oc-text-muted" v-text="groupMembersText"></span>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, PropType, unref } from 'vue'
import { Group } from '@ownclouders/web-client/src/generated'
import { useGettext } from 'vue3-gettext'
export default defineComponent({
name: 'GroupInfoBox',
props: {
group: {
type: Object as PropType<Group>,
required: true
}
},
setup(props) {
const _group = computed<Group>(() => props.group)
const { $ngettext } = useGettext()
const groupMembersText = computed(() => {
return $ngettext(
'%{groupCount} member',
'%{groupCount} members',
unref(_group).members.length,
{
groupCount: unref(_group).members.length.toString()
}
)
})
return {
groupMembersText,
_group
}
}
})
</script>
<style lang="scss">
.gr-info {
align-items: center;
flex-direction: column;
}
.group-info-display-name {
font-size: 1.5rem;
}
</style>
| owncloud/web/packages/web-app-admin-settings/src/components/Groups/SideBar/GroupInfoBox.vue/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/components/Groups/SideBar/GroupInfoBox.vue",
"repo_id": "owncloud",
"token_count": 524
} | 752 |
<template>
<div class="oc-flex user-info oc-mb-l">
<avatar-image class="oc-mb-m" :width="80" :userid="user.id" :user-name="user.displayName" />
<span v-text="user.onPremisesSamAccountName"></span>
<span class="oc-text-muted user-info-display-name" v-text="user.displayName"></span>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'UserInfoBox',
props: {
user: {
type: Object,
required: true
}
}
})
</script>
<style lang="scss">
.user-info {
align-items: center;
flex-direction: column;
}
.user-info-display-name {
font-size: 1.5rem;
}
</style>
| owncloud/web/packages/web-app-admin-settings/src/components/Users/SideBar/UserInfoBox.vue/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/components/Users/SideBar/UserInfoBox.vue",
"repo_id": "owncloud",
"token_count": 264
} | 753 |
import { computed, toRaw } from 'vue'
import { useGettext } from 'vue3-gettext'
import {
QuotaModal,
useAbility,
useModals,
UserAction,
UserActionOptions,
useCapabilityStore
} from '@ownclouders/web-pkg'
import { SpaceResource } from '@ownclouders/web-client'
import { isPersonalSpaceResource } from '@ownclouders/web-client/src/helpers'
import { User } from '@ownclouders/web-client/src/generated'
export const useUserActionsEditQuota = () => {
const { dispatchModal } = useModals()
const capabilityStore = useCapabilityStore()
const { $gettext } = useGettext()
const ability = useAbility()
const getModalTitle = ({ resources }: { resources: User[] }) => {
if (resources.length === 1) {
return $gettext('Change quota for user "%{name}"', {
name: resources[0].displayName
})
}
return $gettext('Change quota for %{count} users', {
count: resources.length.toString()
})
}
const getUserDrives = ({ resources }: { resources: User[] }) => {
const selectedPersonalDrives: SpaceResource[] = []
resources.forEach((user) => {
const drive = toRaw(user.drive)
if (drive === undefined || drive.id === undefined) {
return
}
const spaceResource = {
id: drive.id,
name: user.displayName,
spaceQuota: drive.quota
} as SpaceResource
selectedPersonalDrives.push(spaceResource)
})
return selectedPersonalDrives
}
const handler = ({ resources }: UserActionOptions) => {
const usersWithoutDrive = resources.filter(
({ drive }) => !isPersonalSpaceResource(drive as SpaceResource)
)
dispatchModal({
title: getModalTitle({ resources }),
customComponent: QuotaModal,
customComponentAttrs: () => ({
spaces: getUserDrives({ resources }),
resourceType: 'user',
warningMessage: usersWithoutDrive.length
? $gettext('Quota will only be applied to users who logged in at least once.')
: '',
warningMessageContextualHelperData: usersWithoutDrive.length
? {
title: $gettext('Unaffected users'),
text: [...usersWithoutDrive]
.sort((u1, u2) => u1.displayName.localeCompare(u2.displayName))
.map((user) => user.displayName)
.join(', ')
}
: {}
})
})
}
const actions = computed((): UserAction[] => [
{
name: 'editQuota',
icon: 'cloud',
label: () => {
return $gettext('Edit quota')
},
handler,
isVisible: ({ resources }) => {
if (!resources || !resources.length) {
return false
}
if (capabilityStore.graphUsersReadOnlyAttributes.includes('drive.quota')) {
return false
}
if (!resources.some((r) => r.drive?.quota)) {
return false
}
return ability.can('set-quota-all', 'Drive')
},
componentType: 'button',
class: 'oc-users-actions-edit-quota-trigger'
}
])
return {
actions
}
}
| owncloud/web/packages/web-app-admin-settings/src/composables/actions/users/useUserActionsEditQuota.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/composables/actions/users/useUserActionsEditQuota.ts",
"repo_id": "owncloud",
"token_count": 1251
} | 754 |
import { ref } from 'vue'
import AppTemplate from '../../../src/components/AppTemplate.vue'
import {
defaultComponentMocks,
defaultPlugins,
RouteLocation,
shallowMount
} from 'web-test-helpers'
import { eventBus, SideBar } from '@ownclouders/web-pkg'
import { SideBarEventTopics } from '@ownclouders/web-pkg'
import { mock } from 'vitest-mock-extended'
import { OcBreadcrumb } from 'design-system/src/components'
const stubSelectors = {
ocBreadcrumb: 'oc-breadcrumb-stub',
appLoadingSpinner: 'app-loading-spinner-stub',
sideBar: 'side-bar-stub',
sideBarToggleButton: '#files-toggle-sidebar'
}
const elSelectors = {
adminSettingsWrapper: '#admin-settings-wrapper'
}
vi.mock('@ownclouders/web-pkg')
describe('AppTemplate', () => {
describe('loading is true', () => {
it('should show app loading spinner component', () => {
const { wrapper } = getWrapper({ props: { loading: true } })
expect(wrapper.find(stubSelectors.appLoadingSpinner).exists()).toBeTruthy()
})
it('should not show side bar component', () => {
const { wrapper } = getWrapper({ props: { loading: true } })
expect(wrapper.find(stubSelectors.sideBar).exists()).toBeFalsy()
})
it('should not show admin settings wrapper', () => {
const { wrapper } = getWrapper({ props: { loading: true } })
expect(wrapper.find(elSelectors.adminSettingsWrapper).exists()).toBeFalsy()
})
})
describe('loading is false', () => {
it('should not show app loading spinner component', () => {
const { wrapper } = getWrapper({ props: { loading: false } })
expect(wrapper.find(stubSelectors.appLoadingSpinner).exists()).toBeFalsy()
})
it('should show side bar component', () => {
const { wrapper } = getWrapper({ props: { loading: false } })
expect(wrapper.find(stubSelectors.sideBar).exists()).toBeTruthy()
})
it('should show admin settings wrapper', () => {
const { wrapper } = getWrapper({ props: { loading: false } })
expect(wrapper.find(elSelectors.adminSettingsWrapper).exists()).toBeTruthy()
})
})
describe('sideBar', () => {
it('should show when opened', () => {
const { wrapper } = getWrapper({ props: { isSideBarOpen: true } })
expect(wrapper.find(stubSelectors.sideBar).exists()).toBeTruthy()
})
it('should not show when closed', () => {
const { wrapper } = getWrapper({ props: { isSideBarOpen: false } })
expect(wrapper.find(stubSelectors.sideBar).exists()).toBeFalsy()
})
it('can be closed', () => {
const eventSpy = vi.spyOn(eventBus, 'publish')
const { wrapper } = getWrapper()
wrapper.findComponent<any>(stubSelectors.sideBar).vm.$emit('close')
expect(eventSpy).toHaveBeenCalledWith(SideBarEventTopics.close)
})
it('panel can be selected', () => {
const eventSpy = vi.spyOn(eventBus, 'publish')
const panelName = 'SomePanel'
const { wrapper } = getWrapper()
wrapper.findComponent<any>(stubSelectors.sideBar).vm.$emit('selectPanel', panelName)
expect(eventSpy).toHaveBeenCalledWith(SideBarEventTopics.setActivePanel, panelName)
})
})
describe('property propagation', () => {
describe('oc breadcrumb component', () => {
it('receives correct props', () => {
const { wrapper } = getWrapper({
props: { breadcrumbs: [{ text: 'Administration Settings' }, { text: 'Users' }] }
})
expect(
wrapper.findComponent<typeof OcBreadcrumb>(stubSelectors.ocBreadcrumb).props().items
).toEqual([{ text: 'Administration Settings' }, { text: 'Users' }])
})
it('does not show in mobile view', () => {
const { wrapper } = getWrapper({ isMobileWidth: true })
expect(wrapper.find(stubSelectors.ocBreadcrumb).exists()).toBeFalsy()
})
})
describe('side bar component', () => {
it('receives correct props', () => {
const { wrapper } = getWrapper({
props: {
sideBarActivePanel: 'DetailsPanel',
sideBarAvailablePanels: [{ app: 'DetailsPanel' }]
}
})
expect(
wrapper.findComponent<typeof SideBar>(stubSelectors.sideBar).props().activePanel
).toEqual('DetailsPanel')
expect(
wrapper.findComponent<typeof SideBar>(stubSelectors.sideBar).props().availablePanels
).toEqual([{ app: 'DetailsPanel' }])
})
})
})
})
function getWrapper({ props = {}, isMobileWidth = false } = {}) {
return {
wrapper: shallowMount(AppTemplate, {
props: {
loading: false,
breadcrumbs: [],
isSideBarOpen: true,
sideBarAvailablePanels: [],
sideBarActivePanel: '',
...props
},
global: {
plugins: [...defaultPlugins()],
provide: { isMobileWidth: ref(isMobileWidth) },
stubs: {
OcButton: false
},
mocks: {
...defaultComponentMocks({
currentRoute: mock<RouteLocation>({ query: { app: 'admin-settings' } })
})
}
}
})
}
}
| owncloud/web/packages/web-app-admin-settings/tests/unit/components/AppTemplate.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/components/AppTemplate.spec.ts",
"repo_id": "owncloud",
"token_count": 2027
} | 755 |
import { useGroupActionsEdit } from '../../../../../src/composables/actions/groups/useGroupActionsEdit'
import { mock } from 'vitest-mock-extended'
import { unref } from 'vue'
import { Group } from '@ownclouders/web-client/src/generated'
import { getComposableWrapper } from 'web-test-helpers'
describe('useGroupActionsEdit', () => {
describe('method "isVisible"', () => {
it.each([
{ resources: [mock<Group>({ groupTypes: [] })], isVisible: true },
{ resources: [], isVisible: false },
{
resources: [mock<Group>({ groupTypes: [] }), mock<Group>({ groupTypes: [] })],
isVisible: false
}
])('should only return true for one group', ({ resources, isVisible }) => {
getWrapper({
setup: ({ actions }) => {
expect(unref(actions)[0].isVisible({ resources })).toEqual(isVisible)
}
})
})
it('should return false for read-only groups', () => {
getWrapper({
setup: ({ actions }) => {
const resources = [mock<Group>({ groupTypes: ['ReadOnly'] })]
expect(unref(actions)[0].isVisible({ resources })).toBeFalsy()
}
})
})
})
})
function getWrapper({
setup
}: {
setup: (instance: ReturnType<typeof useGroupActionsEdit>) => void
}) {
return {
wrapper: getComposableWrapper(() => {
const instance = useGroupActionsEdit()
setup(instance)
})
}
}
| owncloud/web/packages/web-app-admin-settings/tests/unit/composables/actions/groups/useGroupActionsEdit.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/composables/actions/groups/useGroupActionsEdit.spec.ts",
"repo_id": "owncloud",
"token_count": 566
} | 756 |
[main]
host = https://www.transifex.com
[o:owncloud-org:p:owncloud-web:r:draw-io]
file_filter = locale/<lang>/LC_MESSAGES/app.po
minimum_perc = 0
source_file = template.pot
source_lang = en
type = PO
| owncloud/web/packages/web-app-draw-io/l10n/.tx/config/0 | {
"file_path": "owncloud/web/packages/web-app-draw-io/l10n/.tx/config",
"repo_id": "owncloud",
"token_count": 85
} | 757 |
import {
AppWrapperRoute,
defineWebApplication,
useCapabilityStore,
useAppsStore,
useClientService,
useRequest
} from '@ownclouders/web-pkg'
import translations from '../l10n/translations.json'
import App from './App.vue'
import { stringify } from 'qs'
import { Resource, SpaceResource } from '@ownclouders/web-client'
import { join } from 'path'
import { AppListSchema } from './schemas'
import { useGettext } from 'vue3-gettext'
const appInfo = {
name: 'External',
id: 'external'
}
const routes = [
{
name: 'apps',
path: '/:driveAliasAndItem(.*)?',
component: AppWrapperRoute(App, {
applicationId: appInfo.id
}),
meta: {
authContext: 'hybrid',
patchCleanPath: true
}
}
]
export default defineWebApplication({
setup() {
const capabilityStore = useCapabilityStore()
const appsStore = useAppsStore()
const { makeRequest } = useRequest()
const clientService = useClientService()
const { $gettext } = useGettext()
return {
appInfo,
routes,
translations,
ready: async () => {
if (!capabilityStore.filesAppProviders[0]?.enabled) {
return
}
const {
data: { 'mime-types': mimeTypes }
} = await clientService.httpUnAuthenticated.get(
capabilityStore.filesAppProviders[0].apps_url,
{
schema: AppListSchema
}
)
mimeTypes.forEach((mimeType) => {
mimeType.app_providers.forEach((provider) => {
appsStore.registerFileExtension({
appId: 'external',
data: {
extension: mimeType.ext,
label: $gettext('Open in %{app}', { app: provider.name }),
icon: provider.icon,
name: provider.name,
mimeType: mimeType.mime_type,
routeName: 'external-apps',
hasPriority: mimeType.default_application === provider.name,
...(mimeType.allow_creation && { newFileMenu: { menuTitle: () => mimeType.name } }),
createFileHandler: async ({
fileName,
space,
currentFolder
}: {
fileName: string
space: SpaceResource
currentFolder: Resource
}) => {
if (fileName === '') {
return
}
const query = stringify({
parent_container_id: currentFolder.fileId,
filename: fileName
})
const url = `${capabilityStore.filesAppProviders[0].new_url}?${query}`
const response = await makeRequest('POST', url)
if (response.status !== 200) {
throw new Error(`An error has occurred: ${response.status}`)
}
const path = join(currentFolder.path, fileName) || ''
return clientService.webdav.getFileInfo(space, { path })
}
}
})
})
})
}
}
}
})
| owncloud/web/packages/web-app-external/src/index.ts/0 | {
"file_path": "owncloud/web/packages/web-app-external/src/index.ts",
"repo_id": "owncloud",
"token_count": 1570
} | 758 |
<template>
<div
id="files-list-not-found-message"
class="oc-text-center oc-flex-middle oc-flex oc-flex-center oc-flex-column"
>
<oc-icon name="cloud" type="div" size="xxlarge" />
<div class="oc-text-muted oc-text-xlarge">
<span v-translate>Resource not found</span>
</div>
<div class="oc-text-muted">
<span v-translate>
We went looking everywhere, but were unable to find the selected resource.
</span>
</div>
<div class="oc-mt-s">
<oc-button
v-if="showSpacesButton"
id="space-not-found-button-go-spaces"
type="router-link"
appearance="raw"
:to="spacesRoute"
>
<span v-translate>Go to »Spaces Overview«</span>
</oc-button>
<oc-button
v-if="showHomeButton"
id="files-list-not-found-button-go-home"
type="router-link"
appearance="raw"
:to="homeRoute"
>
<span v-translate>Go to »Personal« page</span>
</oc-button>
<oc-button
v-if="showPublicLinkButton"
id="files-list-not-found-button-reload-link"
type="router-link"
appearance="raw"
:to="publicLinkRoute"
>
<span v-translate>Reload public link</span>
</oc-button>
</div>
</div>
</template>
<script lang="ts">
import {
createLocationPublic,
createLocationSpaces,
isLocationPublicActive,
isLocationSpacesActive
} from '@ownclouders/web-pkg'
import { useRouter } from '@ownclouders/web-pkg'
import { defineComponent, PropType } from 'vue'
import { SpaceResource } from '@ownclouders/web-client/src/helpers'
import { createFileRouteOptions } from '@ownclouders/web-pkg'
export default defineComponent({
name: 'NotFoundMessage',
props: {
space: {
type: Object as PropType<SpaceResource>,
required: false,
default: null
}
},
setup(props) {
const router = useRouter()
const isProjectSpace = props.space?.driveType === 'project'
return {
showPublicLinkButton: isLocationPublicActive(router, 'files-public-link'),
showHomeButton: isLocationSpacesActive(router, 'files-spaces-generic') && !isProjectSpace,
showSpacesButton: isLocationSpacesActive(router, 'files-spaces-generic') && isProjectSpace,
homeRoute: createLocationSpaces('files-spaces-generic', {
params: {
driveAliasAndItem: 'personal'
}
}),
publicLinkRoute: createLocationPublic(
'files-public-link',
createFileRouteOptions(props.space, {})
),
spacesRoute: createLocationSpaces('files-spaces-projects')
}
}
})
</script>
<style>
#files-list-not-found-message {
height: 75vh;
}
</style>
| owncloud/web/packages/web-app-files/src/components/FilesList/NotFoundMessage.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/FilesList/NotFoundMessage.vue",
"repo_id": "owncloud",
"token_count": 1151
} | 759 |
<template>
<div class="oc-flex oc-flex-middle oc-flex-nowrap">
<oc-datepicker
v-model="dateCurrent"
:min-date="dateMin"
:max-date="dateMax"
:locale="language.current"
:is-required="enforced"
class="files-recipient-expiration-datepicker oc-width-1-1"
data-testid="recipient-datepicker"
>
<template #default="{ togglePopover }">
<oc-button
class="files-collaborators-expiration-button oc-p-s action-menu-item"
data-testid="recipient-datepicker-btn"
appearance="raw"
gap-size="none"
:aria-label="
dateCurrent ? $gettext('Edit expiration date') : $gettext('Set expiration date')
"
@click="togglePopover"
>
<oc-icon name="calendar-event" fill-type="line" size="medium" variation="passive" />
<span
v-if="!dateCurrent"
key="no-expiration-date-label"
v-text="$gettext('Set expiration date')"
/>
<span
v-else
key="set-expiration-date-label"
v-text="$gettext('Expires %{expires}', { expires: dateExpire })"
/>
</oc-button>
</template>
</oc-datepicker>
<oc-button
v-if="!enforced && dateCurrent"
class="recipient-edit-expiration-btn-remove"
appearance="raw"
:aria-label="$gettext('Remove expiration date')"
@click="dateCurrent = null"
>
<oc-icon name="close" />
</oc-button>
</div>
</template>
<script lang="ts">
import { DateTime } from 'luxon'
import { computed, watch, defineComponent, customRef } from 'vue'
import { useCapabilityStore } from '@ownclouders/web-pkg'
import { ShareTypes } from '@ownclouders/web-client/src/helpers/share'
import { formatRelativeDateFromDateTime, getLocaleFromLanguage } from '@ownclouders/web-pkg'
import { useGettext } from 'vue3-gettext'
export default defineComponent({
name: 'DateCurrentpicker',
props: {
shareTypes: {
type: Array,
required: false,
default: () => []
}
},
emits: ['optionChange'],
setup(props, { emit }) {
const language = useGettext()
const capabilityStore = useCapabilityStore()
const optionsUser = computed(() => capabilityStore.sharingUserExpireDate)
const optionsGroup = computed(() => capabilityStore.sharingGroupExpireDate)
const enforced = computed(() => optionsUser.value?.enforced || optionsGroup.value?.enforced)
const dateMin = DateTime.now().setLocale(language.current).toJSDate()
const dateDefault = computed(() => {
const hasUserCollaborators = props.shareTypes.includes(ShareTypes.user.value)
const hasGroupCollaborators = props.shareTypes.includes(ShareTypes.group.value)
const userMaxExpirationDays = parseInt(optionsUser.value?.days)
const groupMaxExpirationDays = parseInt(optionsGroup.value?.days)
if (!(optionsUser.value?.enabled || optionsGroup.value?.enabled)) {
return null
}
let days = 0
if (
userMaxExpirationDays &&
hasUserCollaborators &&
groupMaxExpirationDays &&
hasGroupCollaborators
) {
days = Math.min(userMaxExpirationDays, groupMaxExpirationDays)
} else if (userMaxExpirationDays && hasUserCollaborators) {
days = userMaxExpirationDays
} else if (groupMaxExpirationDays && hasGroupCollaborators) {
days = groupMaxExpirationDays
}
if (!days) {
return null
}
return DateTime.now()
.setLocale(getLocaleFromLanguage(language.current))
.plus({ days })
.toJSDate()
})
const dateMax = computed(() => (enforced.value ? dateDefault.value : null))
const dateCurrent = customRef<Date>((track, trigger) => {
let date = null
return {
get() {
track()
return date || dateDefault.value
},
set(val) {
date = val
trigger()
}
}
})
const dateExpire = computed(() =>
formatRelativeDateFromDateTime(
DateTime.fromJSDate(dateCurrent.value).endOf('day'),
language.current
)
)
watch(dateCurrent, (val) => {
const dateCurrent = DateTime.fromJSDate(val)
.setLocale(getLocaleFromLanguage(language.current))
.endOf('day')
emit('optionChange', {
expirationDate: dateCurrent.isValid ? dateCurrent : null
})
})
watch(dateMax, (val) => {
if (!val || dateCurrent.value < val) {
return
}
dateCurrent.value = val
})
return {
language,
enforced,
dateCurrent,
dateMin,
dateMax,
dateExpire
}
}
})
</script>
<style lang="scss" scoped>
.recipient-edit-expiration-btn-remove {
vertical-align: middle;
}
</style>
| owncloud/web/packages/web-app-files/src/components/SideBar/Shares/Collaborators/InviteCollaborator/ExpirationDatepicker.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/SideBar/Shares/Collaborators/InviteCollaborator/ExpirationDatepicker.vue",
"repo_id": "owncloud",
"token_count": 2060
} | 760 |
<template>
<div
class="space-header oc-p-m"
:class="{ 'oc-flex': !imageExpanded && !isMobileWidth, 'space-header-squashed': isSideBarOpen }"
>
<div
class="space-header-image"
:class="{ 'space-header-image-expanded': imageExpanded || isMobileWidth }"
>
<img
v-if="imageContent"
class="oc-cursor-pointer"
alt=""
:src="imageContent"
@click="toggleImageExpanded"
/>
<div v-else class="space-header-image-default oc-flex oc-flex-middle oc-flex-center">
<oc-icon name="layout-grid" size="xxlarge" class="oc-px-m oc-py-m" />
</div>
</div>
<div class="space-header-infos">
<div class="oc-flex oc-mb-s oc-flex-middle oc-flex-between">
<div class="oc-flex oc-flex-middle space-header-infos-heading">
<h2 class="space-header-name">{{ space.name }}</h2>
<oc-button
:id="`space-context-btn`"
v-oc-tooltip="$gettext('Show context menu')"
:aria-label="$gettext('Show context menu')"
appearance="raw"
class="oc-ml-s"
>
<oc-icon name="more-2" />
</oc-button>
<oc-drop
:drop-id="`space-context-drop`"
:toggle="`#space-context-btn`"
mode="click"
close-on-click
:options="{ delayHide: 0 }"
padding-size="small"
position="right-start"
>
<space-context-actions :action-options="{ resources: [space] }" />
</oc-drop>
</div>
<oc-button
v-if="memberCount"
:aria-label="$gettext('Open context menu and show members')"
appearance="raw"
@click="openSideBarSharePanel"
>
<oc-icon name="group" fill-type="line" size="small" />
<span class="space-header-people-count oc-text-small" v-text="memberCountString"></span>
</oc-button>
</div>
<p v-if="space.description" class="oc-mt-rm oc-text-bold">{{ space.description }}</p>
<div ref="markdownContainerRef" class="markdown-container">
<text-editor
v-if="markdownContent"
:resource="markdownResource"
:current-content="markdownContent"
:is-read-only="true"
:application-config="{}"
/>
</div>
<div
v-if="showMarkdownCollapse && markdownContent"
class="markdown-collapse oc-text-center oc-mt-s"
>
<oc-button appearance="raw" @click="toggleMarkdownCollapsed">
<oc-icon :name="toggleMarkdownCollapsedIcon" />
<span>{{ toggleMarkdownCollapsedText }}</span>
</oc-button>
</div>
</div>
</div>
</template>
<script lang="ts">
import {
computed,
defineComponent,
inject,
onBeforeUnmount,
onMounted,
PropType,
Ref,
ref,
unref,
watch
} from 'vue'
import { SpaceResource } from '@ownclouders/web-client/src/helpers'
import {
useClientService,
usePreviewService,
ProcessorType,
useSpacesStore,
useResourcesStore,
TextEditor
} from '@ownclouders/web-pkg'
import { ImageDimension } from '@ownclouders/web-pkg'
import { VisibilityObserver } from '@ownclouders/web-pkg'
import SpaceContextActions from './SpaceContextActions.vue'
import { eventBus } from '@ownclouders/web-pkg'
import { SideBarEventTopics } from '@ownclouders/web-pkg'
import { useGettext } from 'vue3-gettext'
import { useTask } from 'vue-concurrency'
const visibilityObserver = new VisibilityObserver()
const markdownContainerCollapsedClass = 'collapsed'
export default defineComponent({
name: 'SpaceHeader',
components: {
SpaceContextActions,
TextEditor
},
props: {
space: {
type: Object as PropType<SpaceResource>,
required: true
},
isSideBarOpen: { type: Boolean, default: false }
},
setup(props) {
const language = useGettext()
const { $gettext, $ngettext } = language
const clientService = useClientService()
const { getFileContents, getFileInfo } = clientService.webdav
const previewService = usePreviewService()
const spacesStore = useSpacesStore()
const resourcesStore = useResourcesStore()
const markdownContainerRef = ref(null)
const markdownContent = ref('')
const markdownResource = ref(null)
const markdownCollapsed = ref(true)
const showMarkdownCollapse = ref(false)
const toggleMarkdownCollapsedIcon = computed(() => {
return unref(markdownCollapsed) ? 'add' : 'subtract'
})
const toggleMarkdownCollapsedText = computed(() => {
return unref(markdownCollapsed) ? $gettext('Show more') : $gettext('Show less')
})
const toggleMarkdownCollapsed = () => {
markdownCollapsed.value = !unref(markdownCollapsed)
unref(markdownContainerRef).classList.toggle(markdownContainerCollapsedClass)
}
const onMarkdownResize = () => {
if (!unref(markdownContainerRef)) {
return
}
unref(markdownContainerRef).classList.remove(markdownContainerCollapsedClass)
const markdownContainerHeight = unref(markdownContainerRef).offsetHeight
if (markdownContainerHeight < 150) {
showMarkdownCollapse.value = false
return
}
showMarkdownCollapse.value = true
if (unref(markdownCollapsed)) {
unref(markdownContainerRef).classList.add(markdownContainerCollapsedClass)
}
}
const markdownResizeObserver = new ResizeObserver(onMarkdownResize)
const observeMarkdownContainerResize = () => {
if (!markdownResizeObserver || !unref(markdownContainerRef)) {
return
}
markdownResizeObserver.unobserve(unref(markdownContainerRef))
markdownResizeObserver.observe(unref(markdownContainerRef))
}
const unobserveMarkdownContainerResize = () => {
if (!markdownResizeObserver || !unref(markdownContainerRef)) {
return
}
markdownResizeObserver.unobserve(unref(markdownContainerRef))
}
onMounted(observeMarkdownContainerResize)
onBeforeUnmount(() => {
visibilityObserver.disconnect()
unobserveMarkdownContainerResize()
})
watch(
computed(() => props.space.spaceReadmeData),
async (data: any) => {
if (!data) {
return
}
const fileContentsResponse = await getFileContents(props.space, {
path: `.space/${props.space.spaceReadmeData.name}`
})
const fileInfoResponse = await getFileInfo(props.space, {
path: `.space/${props.space.spaceReadmeData.name}`
})
unobserveMarkdownContainerResize()
markdownContent.value = fileContentsResponse.body
markdownResource.value = fileInfoResponse
if (unref(markdownContent)) {
observeMarkdownContainerResize()
}
},
{ deep: true, immediate: true }
)
const imageContent = ref(null)
const imageExpanded = ref(false)
const toggleImageExpanded = () => {
imageExpanded.value = !unref(imageExpanded)
}
const loadPreviewTask = useTask(function* (signal) {
const resource = yield getFileInfo(props.space, {
path: `.space/${props.space.spaceImageData.name}`
})
imageContent.value = yield previewService.loadPreview({
space: props.space,
resource,
dimensions: ImageDimension.Tile,
processor: ProcessorType.enum.fit
})
})
watch(
computed(() => props.space.spaceImageData),
async (data) => {
if (!data) {
return
}
await loadPreviewTask.perform()
},
{ deep: true, immediate: true }
)
const memberCount = computed(() => {
return spacesStore.spaceMembers.length
})
const memberCountString = computed(() => {
return $ngettext('%{count} member', '%{count} members', unref(memberCount), {
count: unref(memberCount).toString()
})
})
const openSideBarSharePanel = () => {
resourcesStore.setSelection([])
eventBus.publish(SideBarEventTopics.openWithPanel, 'space-share')
}
return {
isMobileWidth: inject<Ref<boolean>>('isMobileWidth'),
markdownContainerRef,
markdownContent,
markdownResource,
markdownCollapsed,
showMarkdownCollapse,
toggleMarkdownCollapsedIcon,
toggleMarkdownCollapsedText,
toggleMarkdownCollapsed,
imageContent,
imageExpanded,
toggleImageExpanded,
memberCount,
memberCountString,
openSideBarSharePanel,
loadPreviewTask
}
}
})
</script>
<style lang="scss">
.space-header {
&-squashed {
.space-header-image {
@media only screen and (max-width: 1200px) {
display: none;
}
}
}
&-image {
width: 280px;
min-width: 280px;
aspect-ratio: 16 / 9;
margin-right: var(--oc-space-large);
max-height: 158px;
&-default {
background-color: var(--oc-color-background-highlight);
height: 100%;
border-radius: 10px;
}
&-expanded {
width: 100%;
margin: 0;
max-height: 100%;
max-width: 100%;
}
img {
border-radius: 10px;
height: 100%;
width: 100%;
max-height: 100%;
object-fit: cover;
}
}
&-infos {
flex: 1;
&-heading {
max-width: 100%;
}
}
&-name {
font-size: 1.5rem;
word-break: break-all;
}
&-people-count {
white-space: nowrap;
}
.markdown-container.collapsed {
max-height: 100px;
overflow: hidden;
-webkit-mask-image: linear-gradient(180deg, #000 90%, transparent);
}
}
</style>
| owncloud/web/packages/web-app-files/src/components/Spaces/SpaceHeader.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/Spaces/SpaceHeader.vue",
"repo_id": "owncloud",
"token_count": 4099
} | 761 |
import { omit } from 'lodash-es'
import { ContextualHelperData } from 'design-system/src/helpers'
import { ConfigStore } from '@ownclouders/web-pkg'
// just a dummy function to trick gettext tools
function $gettext(msg) {
return msg
}
interface ContextualHelperOptions {
configStore: ConfigStore
}
export const shareInviteCollaboratorHelp = (options: ContextualHelperOptions) =>
filterContextHelper(
{
title: $gettext('Share with people'),
text: $gettext(
'Use the input field to search for users and groups. Select them to share the item.'
),
list: [
{ text: $gettext('Subfolders'), headline: true },
{
text: $gettext(
'If you share a folder, all of its contents and subfolders will be shared as well.'
)
},
{ text: $gettext('Notification'), headline: true },
{
text: $gettext(
'People you share resources with will be notified via email or in-app notification.'
)
},
{ text: $gettext('Incognito'), headline: true },
{
text: $gettext('People you share resources with can not see who else has access.')
},
{ text: $gettext('“via folder”'), headline: true },
{
text: $gettext(
'The “via folder” is shown next to a share, if access has already been given via a parent folder. Click on the “via folder” to edit the share on its parent folder.'
)
}
],
readMoreLink: 'https://doc.owncloud.com/go?to=webui-users-sharing'
},
options
)
export const shareInviteCollaboratorHelpCern = (options: ContextualHelperOptions) =>
filterContextHelper(
{
title: '',
list: [
{ text: $gettext('Search for service or secondary Account'), headline: true },
{
text: $gettext(
'To search for service or secondary accounts prefix the username with "a:" (like "a:doe") and for guest accounts prefix the username with "l:" (like "l:doe").'
)
}
]
},
options
)
export const shareSpaceAddMemberHelp = (options: ContextualHelperOptions) =>
filterContextHelper(
{
title: $gettext('Add members to this Space'),
text: $gettext('Enter a name to add people or groups as members to this Space.'),
list: [
{ text: $gettext('Member capabilities'), headline: true },
{
text: $gettext(
'Members are able to see who has access to this space and access all files in this space. Read or write permissions can be set by assigning a role.'
)
},
{ text: $gettext('Space manager capabilities'), headline: true },
{
text: $gettext(
'Members with the Manager role are able to edit all properties and content of a Space, such as adding or removing members, sharing subfolders with non-members, or creating links to share.'
)
}
],
readMoreLink: 'https://doc.owncloud.com/go?to=webui-users-sharing'
},
options
)
export const shareViaLinkHelp = (options: ContextualHelperOptions) =>
filterContextHelper(
{
title: $gettext('Choose how access is granted'),
list: [
{
text: $gettext('Only invited people can access'),
headline: true
},
{
text: $gettext(
'Account and login is required. Only people from the list "Invited people" can access.'
)
},
{
text: $gettext('Everyone with the link'),
headline: true
},
{
text: $gettext(
'No login required. Everyone with the link can access. If you share this link with people from the list "Invited people", they need to login so that their individual assigned permissions can take effect. If they are not logged-in, the permissions of the link take effect.'
)
}
],
readMoreLink: 'https://doc.owncloud.com/go?to=webui-users-sharing'
},
options
)
export const shareViaIndirectLinkHelp = (options: ContextualHelperOptions) =>
filterContextHelper(
{
title: $gettext('What are indirect links?'),
text: $gettext('Indirect links are links giving access by a parent folder.'),
list: [
{
text: $gettext('How to edit indirect links'),
headline: true
},
{
text: $gettext(
'Indirect links can only be edited in their parent folder. Click on the folder icon below the link to navgate to the parent folder.'
)
}
],
readMoreLink: 'https://doc.owncloud.com/go?to=webui-users-sharing'
},
options
)
const filterContextHelper = (
data: ContextualHelperData,
options?: ContextualHelperOptions
): ContextualHelperData => {
if (options.configStore.options.contextHelpersReadMore === false) {
return omit(data, 'readMoreLink')
}
return data
}
export const tagsHelper = (options: ContextualHelperOptions) =>
filterContextHelper(
{
title: $gettext('Who can view tags?'),
list: [
{
text: $gettext(
'Everyone who can view the file can view its tags. Likewise, everyone who can edit the file can edit its tags.'
)
}
]
},
options
)
| owncloud/web/packages/web-app-files/src/helpers/contextualHelpers.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/helpers/contextualHelpers.ts",
"repo_id": "owncloud",
"token_count": 2113
} | 762 |
import { FolderLoader, FolderLoaderTask, TaskContext } from '../folder'
import { Router } from 'vue-router'
import { useTask } from 'vue-concurrency'
import { buildResource } from '@ownclouders/web-client/src/helpers'
import { isLocationCommonActive } from '@ownclouders/web-pkg'
export class FolderLoaderFavorites implements FolderLoader {
public isEnabled(): boolean {
return true
}
public isActive(router: Router): boolean {
return isLocationCommonActive(router, 'files-common-favorites')
}
public getTask(context: TaskContext): FolderLoaderTask {
const { resourcesStore, clientService } = context
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return useTask(function* (signal1, signal2) {
resourcesStore.clearResourceList()
resourcesStore.setAncestorMetaData({})
let resources = yield clientService.webdav.listFavoriteFiles()
resources = resources.map(buildResource)
resourcesStore.initResourceList({ currentFolder: null, resources })
resourcesStore.loadIndicators('/')
})
}
}
| owncloud/web/packages/web-app-files/src/services/folder/loaderFavorites.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/services/folder/loaderFavorites.ts",
"repo_id": "owncloud",
"token_count": 342
} | 763 |
<template>
<div class="oc-flex oc-width-1-1" :class="{ 'space-frontpage': isSpaceFrontpage }">
<whitespace-context-menu ref="whitespaceContextMenu" :space="space" />
<files-view-wrapper>
<app-bar
ref="appBarRef"
:breadcrumbs="breadcrumbs"
:breadcrumbs-context-actions-items="[currentFolder]"
:has-bulk-actions="displayFullAppBar"
:show-actions-on-selection="displayFullAppBar"
:has-view-options="displayFullAppBar"
:is-side-bar-open="isSideBarOpen"
:space="space"
:view-modes="viewModes"
@item-dropped="fileDropped"
>
<template #actions="{ limitedScreenSpace }">
<oc-button
v-if="isEmbedModeEnabled"
key="new-folder-btn"
v-oc-tooltip="limitedScreenSpace ? $gettext('New folder') : ''"
data-testid="btn-new-folder"
:aria-label="$gettext('New folder')"
appearance="filled"
variation="primary"
:disabled="!canUpload"
@click="createNewFolderAction"
>
<oc-icon name="add" />
<span v-if="!limitedScreenSpace" v-text="$gettext('New folder')" />
</oc-button>
<create-and-upload
v-else
key="create-and-upload-actions"
data-testid="actions-create-and-upload"
:space="space"
:item="item"
:item-id="itemId"
:limited-screen-space="limitedScreenSpace"
/>
</template>
</app-bar>
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<not-found-message v-if="folderNotFound" :space="space" class="files-not-found" />
<template v-else>
<space-header
v-if="hasSpaceHeader"
:space="space"
:is-side-bar-open="isSideBarOpen"
class="oc-px-m oc-mt-m"
/>
<no-content-message
v-if="isCurrentFolderEmpty"
id="files-space-empty"
class="files-empty"
icon="folder"
>
<template #message>
<span v-text="$gettext('No resources found')" />
</template>
<template #callToAction>
<span v-if="canUpload" class="file-empty-upload-hint" v-text="uploadHint" />
</template>
</no-content-message>
<template v-else>
<resource-details
v-if="displayResourceAsSingleResource"
:single-resource="paginatedResources[0]"
:space="space"
/>
<component
:is="folderView.component"
v-else
v-model:selectedIds="selectedResourcesIds"
:resources="paginatedResources"
:view-mode="viewMode"
:target-route-callback="resourceTargetRouteCallback"
:space="space"
:are-thumbnails-displayed="displayThumbnails"
:drag-drop="true"
:sort-by="sortBy"
:sort-dir="sortDir"
:header-position="fileListHeaderY /* table */"
:sort-fields="sortFields /* tiles */"
:view-size="viewSize /* tiles */"
:style="folderViewStyle"
v-bind="folderView.componentAttrs?.()"
@file-dropped="fileDropped"
@file-click="triggerDefaultAction"
@row-mounted="rowMounted"
@sort="handleSort"
>
<template #contextMenu="{ resource }">
<context-actions
v-if="isResourceInSelection(resource)"
:action-options="{ space, 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"
:size="totalResourcesSize"
/>
</template>
<template #quickActions="{ resource }">
<quick-actions
:class="resource.preview"
class="oc-visible@s"
:space="space"
:item="resource"
/>
</template>
</component>
</template>
</template>
</template>
</files-view-wrapper>
<file-side-bar :is-open="isSideBarOpen" :active-panel="sideBarActivePanel" :space="space" />
</div>
</template>
<script lang="ts">
import { debounce, omit, last } from 'lodash-es'
import { basename } from 'path'
import { computed, defineComponent, PropType, onBeforeUnmount, onMounted, unref, ref } from 'vue'
import { RouteLocationNamedRaw } from 'vue-router'
import { useGettext } from 'vue3-gettext'
import { Resource } from '@ownclouders/web-client'
import {
isPersonalSpaceResource,
isProjectSpaceResource,
isPublicSpaceResource,
isShareSpaceResource,
SpaceResource
} from '@ownclouders/web-client/src/helpers'
import {
FolderViewExtension,
ProcessorType,
ResourceTransfer,
TransferType,
useConfigStore,
useEmbedMode,
useExtensionRegistry,
useFileActions,
useFileActionsCreateNewFolder,
useResourcesStore,
useUserStore
} from '@ownclouders/web-pkg'
import {
AppBar,
AppLoadingSpinner,
ContextActions,
FileSideBar,
NoContentMessage,
Pagination,
ResourceTable,
CreateTargetRouteOptions,
FolderViewModeConstants,
VisibilityObserver,
createFileRouteOptions,
createLocationPublic,
createLocationSpaces,
displayPositionedDropdown,
useBreadcrumbsFromPath,
useClientService,
useDocumentTitle,
useOpenWithDefaultApp,
useKeyboardActions,
useRoute,
useRouteQuery
} from '@ownclouders/web-pkg'
import CreateAndUpload from '../../components/AppBar/CreateAndUpload.vue'
import FilesViewWrapper from '../../components/FilesViewWrapper.vue'
import ListInfo from '../../components/FilesList/ListInfo.vue'
import NotFoundMessage from '../../components/FilesList/NotFoundMessage.vue'
import QuickActions from '../../components/FilesList/QuickActions.vue'
import ResourceDetails from '../../components/FilesList/ResourceDetails.vue'
import { ResourceTiles } from '@ownclouders/web-pkg'
import SpaceHeader from '../../components/Spaces/SpaceHeader.vue'
import WhitespaceContextMenu from 'web-app-files/src/components/Spaces/WhitespaceContextMenu.vue'
import { eventBus } from '@ownclouders/web-pkg'
import { useResourcesViewDefaults } from '../../composables'
import { FolderLoaderOptions } from '../../services/folder'
import { BreadcrumbItem } from 'design-system/src/components/OcBreadcrumb/types'
import { v4 as uuidv4 } from 'uuid'
import {
useKeyboardTableMouseActions,
useKeyboardTableNavigation,
useKeyboardTableSpaceActions
} from 'web-app-files/src/composables/keyboardActions'
import { storeToRefs } from 'pinia'
import { ComponentPublicInstance } from 'vue'
const visibilityObserver = new VisibilityObserver()
export default defineComponent({
name: 'GenericSpace',
components: {
AppBar,
AppLoadingSpinner,
ContextActions,
CreateAndUpload,
FileSideBar,
FilesViewWrapper,
ListInfo,
NoContentMessage,
NotFoundMessage,
Pagination,
QuickActions,
ResourceDetails,
ResourceTable,
ResourceTiles,
SpaceHeader,
WhitespaceContextMenu
},
props: {
space: {
type: Object as PropType<SpaceResource>,
required: false,
default: null
},
item: {
type: String,
required: false,
default: null
},
itemId: {
type: [String, Number],
required: false,
default: null
}
},
setup(props) {
const userStore = useUserStore()
const { $gettext, $ngettext } = useGettext()
const openWithDefaultAppQuery = useRouteQuery('openWithDefaultApp')
const clientService = useClientService()
const { breadcrumbsFromPath, concatBreadcrumbs } = useBreadcrumbsFromPath()
const { openWithDefaultApp } = useOpenWithDefaultApp()
const { actions: createNewFolder } = useFileActionsCreateNewFolder({ space: props.space })
const { isEnabled: isEmbedModeEnabled } = useEmbedMode()
const configStore = useConfigStore()
const { options: configOptions } = storeToRefs(configStore)
const resourcesStore = useResourcesStore()
const { removeResources, resetSelection, updateResourceField } = resourcesStore
const { currentFolder, totalResourcesCount, totalResourcesSize } = storeToRefs(resourcesStore)
let loadResourcesEventToken: string
const canUpload = computed(() => {
return unref(currentFolder)?.canUpload({ user: userStore.user })
})
const extensionRegistry = useExtensionRegistry()
const viewModes = computed(() => {
return [
...extensionRegistry
.requestExtensions<FolderViewExtension>('folderView', ['resource'])
.map((e) => e.folderView)
]
})
const resourceTargetRouteCallback = ({
path,
fileId
}: CreateTargetRouteOptions): RouteLocationNamedRaw => {
const { params, query } = createFileRouteOptions(props.space, { path, fileId })
if (isPublicSpaceResource(props.space)) {
return createLocationPublic('files-public-link', { params, query })
}
return createLocationSpaces('files-spaces-generic', { params, query })
}
const hasSpaceHeader = computed(() => {
// for now the space header is only available in the root of a project space.
return props.space.driveType === 'project' && props.item === '/'
})
const folderNotFound = computed(() => unref(currentFolder) === null)
const isCurrentFolderEmpty = computed(
() => unref(resourcesViewDefaults.paginatedResources).length < 1
)
const titleSegments = computed(() => {
const segments = [props.space.name]
if (props.item !== '/') {
segments.unshift(basename(props.item))
}
return segments
})
useDocumentTitle({ titleSegments })
const route = useRoute()
const breadcrumbs = computed(() => {
const space = props.space
const rootBreadcrumbItems: BreadcrumbItem[] = []
if (isProjectSpaceResource(space)) {
rootBreadcrumbItems.push({
id: uuidv4(),
text: $gettext('Spaces'),
to: createLocationSpaces('files-spaces-projects'),
isStaticNav: true
})
} else if (isShareSpaceResource(space)) {
rootBreadcrumbItems.push(
{
id: uuidv4(),
text: $gettext('Shares'),
to: { path: '/files/shares' },
isStaticNav: true
},
{
id: uuidv4(),
text: $gettext('Shared with me'),
to: { path: '/files/shares/with-me' },
isStaticNav: true
}
)
}
let spaceBreadcrumbItem: BreadcrumbItem
let { params, query } = createFileRouteOptions(space, { fileId: space.fileId })
query = omit({ ...unref(route).query, ...query }, 'page')
if (isPersonalSpaceResource(space)) {
spaceBreadcrumbItem = {
id: uuidv4(),
text: space.name,
...(space.isOwner(userStore.user) && {
to: createLocationSpaces('files-spaces-generic', {
params,
query
})
})
}
} else if (isShareSpaceResource(space)) {
spaceBreadcrumbItem = {
id: uuidv4(),
allowContextActions: true,
text: space.name,
to: createLocationSpaces('files-spaces-generic', {
params,
query: omit(query, 'fileId')
})
}
} else if (isPublicSpaceResource(space)) {
spaceBreadcrumbItem = {
id: uuidv4(),
text: $gettext('Public link'),
to: createLocationPublic('files-public-link', {
params,
query
}),
isStaticNav: true
}
} else {
spaceBreadcrumbItem = {
id: uuidv4(),
allowContextActions: !unref(hasSpaceHeader),
text: space.name,
to: createLocationSpaces('files-spaces-generic', {
params,
query
})
}
}
return concatBreadcrumbs(
...rootBreadcrumbItems,
spaceBreadcrumbItem,
// FIXME: needs file ids for each parent folder path
...breadcrumbsFromPath({ route: unref(route), space, resourcePath: props.item })
)
})
const focusAndAnnounceBreadcrumb = (sameRoute) => {
const breadcrumbEl = document.getElementById('files-breadcrumb')
if (!breadcrumbEl) {
return
}
const activeBreadcrumb = last(breadcrumbEl.children[0].children)
const activeBreadcrumbItem = activeBreadcrumb.getElementsByTagName('button')[0]
if (!activeBreadcrumbItem) {
return
}
const totalFilesCount = unref(totalResourcesCount)
const itemCount = totalFilesCount.files + totalFilesCount.folders
const announcement = $ngettext(
'This folder contains %{ amount } item.',
'This folder contains %{ amount } items.',
itemCount,
{ amount: itemCount.toString() }
)
const translatedHint = itemCount > 0 ? announcement : $gettext('This folder has no content.')
document.querySelectorAll('.oc-breadcrumb-sr').forEach((el) => el.remove())
const invisibleHint = document.createElement('p')
invisibleHint.className = 'oc-invisible-sr oc-breadcrumb-sr'
invisibleHint.innerHTML = translatedHint
activeBreadcrumb.append(invisibleHint)
if (sameRoute) {
activeBreadcrumbItem.focus()
}
}
const resourcesViewDefaults = useResourcesViewDefaults<Resource, any, any[]>()
const folderView = computed(() => {
const viewMode = unref(resourcesViewDefaults.viewMode)
return unref(viewModes).find((v) => v.name === viewMode)
})
const appBarRef = ref<ComponentPublicInstance | null>()
const folderViewStyle = computed(() => {
return {
...(unref(folderView)?.isScrollable === false && {
height: `calc(100% - ${unref(appBarRef)?.$el.getBoundingClientRect().height}px)`
})
}
})
const keyActions = useKeyboardActions()
useKeyboardTableNavigation(
keyActions,
resourcesViewDefaults.paginatedResources,
resourcesViewDefaults.viewMode
)
useKeyboardTableMouseActions(keyActions, resourcesViewDefaults.viewMode)
useKeyboardTableSpaceActions(keyActions, props.space)
const performLoaderTask = async (
sameRoute: boolean,
path?: string,
fileId?: string | number
) => {
if (resourcesViewDefaults.loadResourcesTask.isRunning) {
return
}
const options: FolderLoaderOptions = { loadShares: !isPublicSpaceResource(props.space) }
await resourcesViewDefaults.loadResourcesTask.perform(
props.space,
path || props.item,
fileId || props.itemId,
options
)
resourcesViewDefaults.scrollToResourceFromRoute(
[unref(currentFolder), ...unref(resourcesViewDefaults.paginatedResources)],
'files-app-bar'
)
resourcesViewDefaults.refreshFileListHeaderPosition()
focusAndAnnounceBreadcrumb(sameRoute)
if (unref(openWithDefaultAppQuery) === 'true') {
openWithDefaultApp({
space: props.space,
resource: unref(resourcesViewDefaults.selectedResources)[0]
})
}
}
onMounted(() => {
performLoaderTask(false)
loadResourcesEventToken = eventBus.subscribe(
'app.files.list.load',
(path?: string, fileId?: string | number) => {
performLoaderTask(true, path, fileId)
}
)
const filesViewWrapper = document.getElementsByClassName('files-view-wrapper')[0]
filesViewWrapper?.addEventListener('contextmenu', (event) => {
const { target } = event
if ((target as HTMLElement).closest('.has-item-context-menu')) {
return
}
event.preventDefault()
const newEvent = new MouseEvent('contextmenu', event)
showContextMenu(newEvent)
})
})
onBeforeUnmount(() => {
visibilityObserver.disconnect()
eventBus.unsubscribe('app.files.list.load', loadResourcesEventToken)
})
const whitespaceContextMenu = ref(null)
const showContextMenu = (event) => {
resourcesStore.resetSelection()
displayPositionedDropdown(
unref(whitespaceContextMenu).$el._tippy,
event,
unref(whitespaceContextMenu)
)
}
const createNewFolderAction = computed(() => unref(createNewFolder)[0].handler)
return {
...useFileActions(),
...resourcesViewDefaults,
configOptions,
canUpload,
breadcrumbs,
folderNotFound,
hasSpaceHeader,
isCurrentFolderEmpty,
resourceTargetRouteCallback,
performLoaderTask,
FolderViewModeConstants,
viewModes,
appBarRef,
folderView,
folderViewStyle,
uploadHint: $gettext(
'Drag files and folders here or use the "New" or "Upload" buttons to add files'
),
whitespaceContextMenu,
clientService,
createNewFolderAction,
isEmbedModeEnabled,
currentFolder,
totalResourcesCount,
totalResourcesSize,
removeResources,
resetSelection,
updateResourceField
}
},
computed: {
displayFullAppBar() {
return !this.displayResourceAsSingleResource
},
displayResourceAsSingleResource() {
if (this.paginatedResources.length !== 1) {
return false
}
if (this.paginatedResources[0].isFolder) {
return false
}
if (isPublicSpaceResource(this.space) && !this.currentFolder?.fileId) {
return true
}
if (this.configOptions.runningOnEos) {
if (
!this.currentFolder.fileId ||
this.currentFolder.path === this.paginatedResources[0].path
) {
return true
}
}
return false
},
displayThumbnails() {
return !this.configOptions.disablePreviews
},
isSpaceFrontpage() {
return isProjectSpaceResource(this.space) && this.item === '/'
}
},
watch: {
item: {
handler: function () {
this.performLoaderTask(true)
}
},
space: {
handler: function () {
this.performLoaderTask(true)
}
}
},
methods: {
async fileDropped(fileTarget) {
const selected = [...this.selectedResources]
let targetFolder = null
if (typeof fileTarget === 'string') {
targetFolder = this.paginatedResources.find((e) => e.id === fileTarget)
const isTargetSelected = selected.some((e) => e.id === fileTarget)
if (isTargetSelected) {
return
}
} else if (fileTarget instanceof Object) {
const spaceRootRoutePath = this.$router.resolve(
createLocationSpaces('files-spaces-generic', {
params: {
driveAliasAndItem: this.space.driveAlias
}
})
).path
const splitIndex = fileTarget.path.indexOf(spaceRootRoutePath) + spaceRootRoutePath.length
const path = decodeURIComponent(fileTarget.path.slice(splitIndex, fileTarget.path.length))
try {
targetFolder = await this.clientService.webdav.getFileInfo(this.space, { path })
} catch (e) {
console.error(e)
return
}
}
if (!targetFolder) {
return
}
if (targetFolder.type !== 'folder') {
return
}
const copyMove = new ResourceTransfer(
this.space,
selected,
this.space,
targetFolder,
computed(() => this.currentFolder),
this.$clientService,
this.$loadingService,
this.$gettext,
this.$ngettext
)
const movedResources = await copyMove.perform(TransferType.MOVE)
this.removeResources(movedResources)
this.resetSelection()
},
rowMounted(resource: Resource, component, dimensions) {
if (!this.displayThumbnails) {
return
}
const loadPreview = async () => {
const processor =
this.viewMode === FolderViewModeConstants.name.tiles
? ProcessorType.enum.fit
: ProcessorType.enum.thumbnail
const preview = await this.$previewService.loadPreview(
{
space: this.space,
resource,
processor,
dimensions
},
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/spaces/GenericSpace.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/views/spaces/GenericSpace.vue",
"repo_id": "owncloud",
"token_count": 9289
} | 764 |
import RecipientContainer from 'web-app-files/src/components/SideBar/Shares/Collaborators/InviteCollaborator/RecipientContainer.vue'
import { CollaboratorAutoCompleteItem, ShareTypes } from '@ownclouders/web-client/src/helpers/share'
import { defaultPlugins, mount } from 'web-test-helpers'
import { CapabilityStore } from '@ownclouders/web-pkg'
vi.mock('web-app-files/src/helpers/user/avatarUrl', () => ({
avatarUrl: vi.fn().mockReturnValue('avatarUrl')
}))
const getRecipient = (shareType: number = ShareTypes.user.value): CollaboratorAutoCompleteItem => ({
displayName: 'Albert Einstein',
id: 'einstein',
shareType
})
describe('InviteCollaborator RecipientContainer', () => {
describe('renders a recipient with a deselect button', () => {
it.each(ShareTypes.authenticated)('different recipients for different shareTypes', (type) => {
const recipient = getRecipient(type.value)
const { wrapper } = getMountedWrapper(recipient)
expect(wrapper.html()).toMatchSnapshot()
})
})
it('displays an avatar image if capability is present', async () => {
const recipient = getRecipient()
const { wrapper } = getMountedWrapper(recipient, true)
await wrapper.vm.$nextTick()
expect(wrapper.html()).toMatchSnapshot()
})
it('emits an event if deselect button is clicked', async () => {
const recipient = getRecipient()
const { wrapper } = getMountedWrapper(recipient, true)
const spyOnDeselect = (wrapper.vm.deselect as any).mockImplementation()
const button = wrapper.find('.files-share-invite-recipient-btn-remove')
await button.trigger('click')
expect(spyOnDeselect).toHaveBeenCalledTimes(1)
})
})
function getMountedWrapper(recipient, avatarsEnabled = false) {
const capabilities = {
files_sharing: {
user: {
profile_picture: avatarsEnabled,
expire_date: { enabled: true, days: '10' }
}
}
} satisfies Partial<CapabilityStore['capabilities']>
return {
wrapper: mount(RecipientContainer, {
props: {
recipient,
deselect: vi.fn()
},
global: {
plugins: [...defaultPlugins({ piniaOptions: { capabilityState: { capabilities } } })],
stubs: {
OcIcon: true
}
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/components/SideBar/Shares/Collaborators/InviteCollaborator/RecipientContainer.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/components/SideBar/Shares/Collaborators/InviteCollaborator/RecipientContainer.spec.ts",
"repo_id": "owncloud",
"token_count": 809
} | 765 |
import SpaceContextActions from '../../../../src/components/Spaces/SpaceContextActions.vue'
import { buildSpace } from '@ownclouders/web-client/src/helpers'
import { defaultComponentMocks, defaultPlugins, mount, RouteLocation } from 'web-test-helpers'
import { mock } from 'vitest-mock-extended'
import { Drive } from '@ownclouders/web-client/src/generated'
const spaceMock = mock<Drive>({
id: '1',
root: { permissions: [{ roles: ['manager'], grantedToIdentities: [{ user: { id: '1' } }] }] },
driveType: 'project',
special: null
})
describe('SpaceContextActions', () => {
describe('action handlers', () => {
it('renders actions that are always available: "Members", "Edit Quota", "Details"', () => {
const { wrapper } = getWrapper(buildSpace(spaceMock))
expect(
wrapper.findAll('[data-testid="action-label"]').some((el) => el.text() === 'Members')
).toBeDefined()
expect(
wrapper.findAll('[data-testid="action-label"]').some((el) => el.text() === 'Edit quota')
).toBeDefined()
expect(
wrapper.findAll('[data-testid="action-label"]').some((el) => el.text() === 'Details')
).toBeDefined()
})
})
})
function getWrapper(space) {
const mocks = defaultComponentMocks({ currentRoute: mock<RouteLocation>({ path: '/files' }) })
mocks.$previewService.getSupportedMimeTypes.mockReturnValue([])
return {
wrapper: mount(SpaceContextActions, {
props: {
actionOptions: {
resources: [space]
}
},
global: {
mocks,
provide: mocks,
plugins: [
...defaultPlugins({
abilities: [{ action: 'set-quota-all', subject: 'Drive' }]
})
]
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/components/Spaces/SpaceContextActions.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/components/Spaces/SpaceContextActions.spec.ts",
"repo_id": "owncloud",
"token_count": 696
} | 766 |
import DriveResolver from '../../../../src/views/spaces/DriveResolver.vue'
import { queryItemAsString, useDriveResolver, useRouteParam } from '@ownclouders/web-pkg'
import { computed, ref } from 'vue'
import { mock, mockDeep } from 'vitest-mock-extended'
import { ClientService } from '@ownclouders/web-pkg'
import { useGetMatchingSpace } from '@ownclouders/web-pkg'
import { locationPublicUpload } from '@ownclouders/web-pkg'
import { PublicSpaceResource, Resource, SpaceResource } from '@ownclouders/web-client/src/helpers'
import { SharePermissionBit } from '@ownclouders/web-client/src/helpers/share'
import {
defaultPlugins,
mount,
defaultComponentMocks,
defaultStubs,
RouteLocation,
useGetMatchingSpaceMock
} from 'web-test-helpers'
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
useGetMatchingSpace: vi.fn(),
useDriveResolver: vi.fn(),
useRouteParam: vi.fn(),
queryItemAsString: vi.fn()
}))
describe('DriveResolver view', () => {
it('renders the "drive-redirect"-component when no space is given', async () => {
const { wrapper } = getMountedWrapper()
await wrapper.vm.$nextTick()
expect(wrapper.find('drive-redirect-stub').exists()).toBeTruthy()
})
it('renders the "generic-trash"-component when on a trash route', async () => {
const { wrapper } = getMountedWrapper({
space: mockDeep<SpaceResource>({ driveType: 'project' }),
currentRouteName: 'files-trash-generic'
})
await wrapper.vm.$nextTick()
expect(wrapper.find('generic-trash-stub').exists()).toBeTruthy()
})
it('renders the "generic-space"-component when a space is given', async () => {
const { wrapper } = getMountedWrapper({
space: mockDeep<SpaceResource>({ driveType: 'project' })
})
await wrapper.vm.$nextTick()
expect(wrapper.find('generic-space-stub').exists()).toBeTruthy()
})
it('redirects to the public drop page in a public context with "upload-only"-permissions', async () => {
const space = { id: '1', getDriveAliasAndItem: vi.fn(), driveType: 'public' }
const clientService = mockDeep<ClientService>()
clientService.webdav.getFileInfo.mockResolvedValue(
mockDeep<PublicSpaceResource>({ publicLinkPermission: SharePermissionBit.Create })
)
const { wrapper, mocks } = getMountedWrapper({
space,
mocks: { $clientService: clientService }
})
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
expect(mocks.$router.push).toHaveBeenCalledWith({
name: locationPublicUpload.name,
params: { token: space.id }
})
})
it('redirects to personal space if user has access to the resource via their personal space', async () => {
const space = { id: '1', getDriveAliasAndItem: vi.fn(), driveType: 'public' }
const internalSpace = { id: '1', getDriveAliasAndItem: vi.fn(), driveType: 'personal' }
const clientService = mockDeep<ClientService>()
clientService.webdav.getPathForFileId.mockResolvedValue('/path')
clientService.webdav.getFileInfo.mockResolvedValue(mock<Resource>())
const { wrapper, mocks } = getMountedWrapper({
space,
internalSpace,
mocks: { $clientService: clientService },
userContextReady: true
})
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
expect(mocks.$router.push).toHaveBeenCalledWith(
expect.objectContaining({ name: 'files-spaces-generic' })
)
})
it('redirects to private link if user has access to the resource via a share', async () => {
const space = { id: '1', getDriveAliasAndItem: vi.fn(), driveType: 'public' }
const clientService = mockDeep<ClientService>()
clientService.webdav.getPathForFileId.mockResolvedValue('/path')
const { wrapper, mocks } = getMountedWrapper({
space,
mocks: { $clientService: clientService },
userContextReady: true
})
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
expect(mocks.$router.push).toHaveBeenCalledWith(
expect.objectContaining({
name: 'resolvePrivateLink'
})
)
})
it('redirects to private link if no drive alias but a fileId is given', async () => {
const { wrapper, mocks } = getMountedWrapper({ driveAliasAndItem: '' })
await wrapper.vm.$nextTick()
expect(mocks.$router.push).toHaveBeenCalledWith(
expect.objectContaining({
name: 'resolvePrivateLink'
})
)
})
})
function getMountedWrapper({
mocks = {},
space = undefined,
internalSpace = undefined,
currentRouteName = 'files-spaces-generic',
userContextReady = false,
driveAliasAndItem = 'personal/einstein/file',
fileId = '1'
} = {}) {
vi.mocked(useRouteParam).mockReturnValue(ref(driveAliasAndItem))
vi.mocked(queryItemAsString).mockReturnValue(fileId)
vi.mocked(useDriveResolver).mockImplementation(() => ({
space,
item: ref('/'),
itemId: computed(() => 'id'),
loading: ref(false)
}))
vi.mocked(useGetMatchingSpace).mockImplementation(() =>
useGetMatchingSpaceMock({
getInternalSpace: () => internalSpace
})
)
const defaultMocks = {
...defaultComponentMocks({
currentRoute: mock<RouteLocation>({
name: currentRouteName,
params: { driveAliasAndItem: '/' }
})
}),
...(mocks && mocks)
}
return {
mocks: defaultMocks,
wrapper: mount(DriveResolver, {
global: {
plugins: [
...defaultPlugins({
piniaOptions: { authState: { userContextReady: userContextReady } }
})
],
mocks: defaultMocks,
provide: defaultMocks,
stubs: { ...defaultStubs, 'app-banner': true }
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/views/spaces/DriveResolver.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/views/spaces/DriveResolver.spec.ts",
"repo_id": "owncloud",
"token_count": 2205
} | 767 |
import {
FileActionOptions,
useClientService,
useConfigStore,
useMessages,
useWindowOpen
} from '@ownclouders/web-pkg'
import { useGettext } from 'vue3-gettext'
import { computed } from 'vue'
import { Extension } from '@ownclouders/web-pkg'
import { OCM_PROVIDER_ID } from '@ownclouders/web-client/src/helpers'
export const extensions = () => {
const { showErrorMessage } = useMessages()
const clientService = useClientService()
const configStore = useConfigStore()
const { $gettext } = useGettext()
const { openUrl } = useWindowOpen()
const handler = async ({ resources }: FileActionOptions) => {
const resource = resources[0]
try {
const params = new URLSearchParams()
params.append('file', resource.id.toString())
const { data } = await clientService.httpAuthenticated.post(
'/sciencemesh/open-in-app',
params
)
if (data.app_url) {
openUrl(data.app_url)
} else {
showErrorMessage({
title: $gettext('An error occurred'),
desc: $gettext("Couldn't open remotely")
})
}
} catch (error) {
console.log(error)
showErrorMessage({
title: $gettext('An error occurred'),
desc: $gettext("Couldn't open remotely"),
errors: [error]
})
}
}
return computed(
() =>
[
{
id: 'com.github.owncloud.web.open-file-remote',
type: 'action',
scopes: ['resource', 'resource.context-menu'],
action: {
name: 'open-file-remote',
icon: 'remote-control',
handler,
label: () => $gettext('Open remotely'),
isVisible: ({ resources }: FileActionOptions) => {
return (
configStore.options.ocm.openRemotely &&
resources[0]?.storageId?.startsWith(OCM_PROVIDER_ID)
)
},
componentType: 'button',
class: 'oc-files-actions-open-file-remote'
}
}
] satisfies Extension[]
)
}
| owncloud/web/packages/web-app-ocm/src/extensions.ts/0 | {
"file_path": "owncloud/web/packages/web-app-ocm/src/extensions.ts",
"repo_id": "owncloud",
"token_count": 914
} | 768 |
<template>
<app-banner :file-id="fileId"></app-banner>
<main
id="preview"
ref="preview"
class="oc-width-1-1"
tabindex="-1"
@keydown.left="prev"
@keydown.right="next"
@keydown.esc="closeApp"
>
<h1 class="oc-invisible-sr" v-text="pageTitle" />
<app-top-bar
v-if="!isFileContentError"
:resource="activeFilteredFile"
:main-actions="fileActions"
@close="closeApp"
/>
<div class="oc-flex oc-width-1-1 oc-height-1-1">
<div
v-if="isFolderLoading || isFileContentLoading"
class="oc-width-1-1"
:class="{ 'preview-sidebar-open': isSideBarOpen }"
>
<div class="oc-position-center">
<oc-spinner :aria-label="$gettext('Loading media file')" size="xlarge" />
</div>
</div>
<oc-icon
v-else-if="isFileContentError"
name="file-damage"
variation="danger"
size="xlarge"
class="oc-position-center"
:class="{ 'preview-sidebar-open': isSideBarOpen }"
:accessible-label="$gettext('Failed to load media file')"
/>
<div
v-else
class="oc-flex oc-width-1-1 oc-height-1-1"
:class="{ 'preview-sidebar-open': isSideBarOpen }"
>
<div class="stage" :class="{ lightbox: isFullScreenModeActivated }">
<div v-show="activeMediaFileCached" class="stage_media">
<media-image
v-if="activeMediaFileCached.isImage"
:file="activeMediaFileCached"
:current-image-rotation="currentImageRotation"
:current-image-zoom="currentImageZoom"
:current-image-position-x="currentImagePositionX"
:current-image-position-y="currentImagePositionY"
@pan-zoom-change="onPanZoomChanged"
/>
<media-video
v-else-if="activeMediaFileCached.isVideo"
:file="activeMediaFileCached"
:is-auto-play-enabled="isAutoPlayEnabled"
/>
<media-audio
v-else-if="activeMediaFileCached.isAudio"
:file="activeMediaFileCached"
:is-auto-play-enabled="isAutoPlayEnabled"
/>
</div>
<media-controls
class="stage_controls"
:files="filteredFiles"
:active-index="activeIndex"
:is-full-screen-mode-activated="isFullScreenModeActivated"
:is-folder-loading="isFolderLoading"
:is-image="activeMediaFileCached?.isImage"
:current-image-rotation="currentImageRotation"
:current-image-zoom="currentImageZoom"
@set-rotation="currentImageRotation = $event"
@set-zoom="currentImageZoom = $event"
@reset-image="resetImage"
@toggle-full-screen="toggleFullscreenMode"
@toggle-previous="prev"
@toggle-next="next"
/>
</div>
</div>
<file-side-bar :is-open="isSideBarOpen" :active-panel="sideBarActivePanel" :space="space" />
</div>
</main>
</template>
<script lang="ts">
import { computed, defineComponent, ref, unref } from 'vue'
import { RouteLocationRaw } from 'vue-router'
import { Resource } from '@ownclouders/web-client/src'
import {
AppTopBar,
FileSideBar,
ProcessorType,
useAppsStore,
useSelectedResources,
useSideBar
} from '@ownclouders/web-pkg'
import {
queryItemAsString,
sortHelper,
useAppDefaults,
useRoute,
useRouteQuery,
useRouter
} from '@ownclouders/web-pkg'
import { Action, ActionOptions } from '@ownclouders/web-pkg'
import { useDownloadFile } from '@ownclouders/web-pkg'
import { createFileRouteOptions } from '@ownclouders/web-pkg'
import MediaControls from './components/MediaControls.vue'
import MediaAudio from './components/Sources/MediaAudio.vue'
import MediaImage from './components/Sources/MediaImage.vue'
import MediaVideo from './components/Sources/MediaVideo.vue'
import { CachedFile } from './helpers/types'
import AppBanner from '@ownclouders/web-pkg/src/components/AppBanner.vue'
import { watch } from 'vue'
import { getCurrentInstance } from 'vue'
import { getMimeTypes } from './mimeTypes'
import { PanzoomEventDetail } from '@panzoom/panzoom'
export const appId = 'preview'
export default defineComponent({
name: 'Preview',
components: {
AppBanner,
AppTopBar,
FileSideBar,
MediaControls,
MediaAudio,
MediaImage,
MediaVideo
},
setup() {
const router = useRouter()
const route = useRoute()
const appsStore = useAppsStore()
const appDefaults = useAppDefaults({ applicationId: 'preview' })
const contextRouteQuery = useRouteQuery('contextRouteQuery')
const { downloadFile } = useDownloadFile()
const activeIndex = ref()
const cachedFiles = ref<CachedFile[]>([])
const folderLoaded = ref(false)
const isFileContentError = ref(false)
const isAutoPlayEnabled = ref(true)
const toPreloadImageIds = ref([])
const currentImageZoom = ref(1)
const currentImageRotation = ref(0)
const currentImagePositionX = ref(0)
const currentImagePositionY = ref(0)
const preloadImageCount = ref(10)
const mimeTypes = computed(() => {
return getMimeTypes(appsStore.externalAppConfig[appId]?.mimeTypes)
})
const sortBy = computed(() => {
if (!unref(contextRouteQuery)) {
return 'name'
}
return unref(contextRouteQuery)['sort-by'] ?? 'name'
})
const sortDir = computed(() => {
if (!unref(contextRouteQuery)) {
return 'desc'
}
return unref(contextRouteQuery)['sort-dir'] ?? 'asc'
})
const { activeFiles, currentFileContext, closed } = appDefaults
const fileId = computed(() => unref(unref(currentFileContext).itemId))
const space = computed(() => unref(unref(currentFileContext).space))
const isFullScreenModeActivated = ref(false)
const toggleFullscreenMode = () => {
const activateFullscreen = !unref(isFullScreenModeActivated)
isFullScreenModeActivated.value = activateFullscreen
if (activateFullscreen) {
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen()
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen()
}
}
}
const onPanZoomChanged = ({ detail }: { detail: PanzoomEventDetail }) => {
currentImagePositionX.value = detail.x
currentImagePositionY.value = detail.y
}
const resetImage = () => {
currentImageZoom.value = 1
currentImageRotation.value = 0
currentImagePositionX.value = 0
currentImagePositionY.value = 0
}
const filteredFiles = computed<Resource[]>(() => {
if (!unref(activeFiles)) {
return []
}
const files = unref(activeFiles).filter((file) => {
return unref(mimeTypes).includes(file.mimeType?.toLowerCase())
})
return sortHelper(files, [{ name: unref(sortBy) }], unref(sortBy), unref(sortDir))
})
const activeFilteredFile = computed(() => {
return unref(filteredFiles)[unref(activeIndex)]
})
const activeMediaFileCached = computed(() => {
return unref(cachedFiles).find((i) => i.id === unref(activeFilteredFile)?.id)
})
const updateLocalHistory = () => {
// this is a rare edge case when browsing quickly through a lot of files
// we workaround context being null, when useDriveResolver is in loading state
if (!unref(currentFileContext)) {
return
}
const { params, query } = createFileRouteOptions(
unref(unref(currentFileContext).space),
unref(activeFilteredFile)
)
router.replace({
...unref(route),
params: { ...unref(route).params, ...params },
query: { ...unref(route).query, ...query }
})
}
const isFileContentLoading = ref(true)
const triggerActiveFileDownload = () => {
if (unref(isFileContentLoading)) {
return
}
downloadFile(unref(space), unref(activeFilteredFile))
}
const fileActions: Action<ActionOptions>[] = [
{
name: 'download-file',
isVisible: () => true,
componentType: 'button',
icon: 'file-download',
id: 'preview-download',
label: () => 'Download',
handler: () => {
triggerActiveFileDownload()
}
}
]
const instance = getCurrentInstance()
watch(
currentFileContext,
async () => {
if (!unref(currentFileContext) || unref(closed)) {
return
}
if (!unref(folderLoaded)) {
await appDefaults.loadFolderForFileContext(unref(currentFileContext))
folderLoaded.value = true
}
;(instance.proxy as any).setActiveFile(unref(unref(currentFileContext).driveAliasAndItem))
},
{ immediate: true }
)
const { selectedResources } = useSelectedResources()
watch(activeFilteredFile, (file) => {
selectedResources.value = [file]
})
return {
...useSideBar(),
...appDefaults,
activeFilteredFile,
activeIndex,
activeMediaFileCached,
cachedFiles,
filteredFiles,
fileActions,
isFileContentLoading,
isFullScreenModeActivated,
toggleFullscreenMode,
updateLocalHistory,
fileId,
space,
resetImage,
isFileContentError,
isAutoPlayEnabled,
toPreloadImageIds,
currentImageZoom,
currentImageRotation,
currentImagePositionX,
currentImagePositionY,
onPanZoomChanged,
preloadImageCount
}
},
computed: {
pageTitle() {
return this.$gettext('Preview for %{currentMediumName}', {
currentMediumName: this.activeFilteredFile?.name
})
},
thumbDimensions() {
switch (true) {
case window.innerWidth <= 1024:
return 1024
case window.innerWidth <= 1280:
return 1280
case window.innerWidth <= 1920:
return 1920
case window.innerWidth <= 2160:
return 2160
default:
return 3840
}
},
isActiveFileTypeImage() {
return !this.isActiveFileTypeAudio && !this.isActiveFileTypeVideo
},
isActiveFileTypeAudio() {
return this.isFileTypeAudio(this.activeFilteredFile)
},
isActiveFileTypeVideo() {
return this.isFileTypeVideo(this.activeFilteredFile)
}
},
watch: {
activeIndex(newValue, oldValue) {
if (newValue !== oldValue) {
this.loadMedium()
this.preloadImages()
}
if (oldValue !== null) {
this.isAutoPlayEnabled = false
}
this.currentImageZoom = 1
this.currentImageRotation = 0
}
},
mounted() {
// keep a local history for this component
window.addEventListener('popstate', this.handleLocalHistoryEvent)
document.addEventListener('fullscreenchange', this.handleFullScreenChangeEvent)
;(this.$refs.preview as HTMLElement).focus()
},
beforeUnmount() {
window.removeEventListener('popstate', this.handleLocalHistoryEvent)
document.removeEventListener('fullscreenchange', this.handleFullScreenChangeEvent)
this.cachedFiles.forEach((medium) => {
this.revokeUrl(medium.url)
})
},
methods: {
setActiveFile(driveAliasAndItem: string) {
for (let i = 0; i < this.filteredFiles.length; i++) {
if (
unref(this.currentFileContext.space)?.getDriveAliasAndItem(this.filteredFiles[i]) ===
driveAliasAndItem
) {
this.activeIndex = i
return
}
}
this.isFileContentLoading = false
this.isFileContentError = true
},
// react to PopStateEvent ()
handleLocalHistoryEvent() {
const result = this.$router.resolve(document.location as unknown as RouteLocationRaw)
this.setActiveFile(queryItemAsString(result.params.driveAliasAndItem))
},
handleFullScreenChangeEvent() {
if (document.fullscreenElement === null) {
this.isFullScreenModeActivated = false
}
},
loadMedium() {
if (this.activeMediaFileCached) {
return
}
this.loadActiveFileIntoCache()
},
async loadActiveFileIntoCache() {
this.isFileContentLoading = true
try {
const loadRawFile = !this.isActiveFileTypeImage
let mediaUrl
if (loadRawFile) {
mediaUrl = await this.getUrlForResource(
unref(this.currentFileContext.space),
this.activeFilteredFile
)
} else {
mediaUrl = await this.loadPreview(this.activeFilteredFile)
}
this.addPreviewToCache(this.activeFilteredFile, mediaUrl)
this.isFileContentLoading = false
this.isFileContentError = false
} catch (e) {
this.isFileContentLoading = false
this.isFileContentError = true
console.error(e)
}
},
next() {
if (this.isFileContentLoading) {
return
}
this.isFileContentError = false
if (this.activeIndex + 1 >= this.filteredFiles.length) {
this.activeIndex = 0
this.updateLocalHistory()
return
}
this.activeIndex++
this.updateLocalHistory()
},
prev() {
if (this.isFileContentLoading) {
return
}
this.isFileContentError = false
if (this.activeIndex === 0) {
this.activeIndex = this.filteredFiles.length - 1
this.updateLocalHistory()
return
}
this.activeIndex--
this.updateLocalHistory()
},
isFileTypeImage(file) {
return !this.isFileTypeAudio(file) && !this.isFileTypeVideo(file)
},
isFileTypeAudio(file) {
return file.mimeType.toLowerCase().startsWith('audio')
},
isFileTypeVideo(file) {
return file.mimeType.toLowerCase().startsWith('video')
},
addPreviewToCache(file, url) {
this.cachedFiles.push({
id: file.id,
name: file.name,
url,
ext: file.extension,
mimeType: file.mimeType,
isVideo: this.isFileTypeVideo(file),
isImage: this.isFileTypeImage(file),
isAudio: this.isFileTypeAudio(file)
})
},
loadPreview(file) {
return this.$previewService.loadPreview({
space: unref(this.currentFileContext.space),
resource: file,
dimensions: [this.thumbDimensions, this.thumbDimensions] as [number, number],
processor: ProcessorType.enum.fit
})
},
preloadImages() {
const loadPreviewAsync = (file) => {
this.toPreloadImageIds.push(file.id)
this.loadPreview(file)
.then((mediaUrl) => {
this.addPreviewToCache(file, mediaUrl)
})
.catch((e) => {
console.error(e)
this.toPreloadImageIds = this.toPreloadImageIds.filter((fileId) => fileId !== file.id)
})
}
const preloadFile = (preloadFileIndex) => {
let cycleIndex =
(((this.activeIndex + preloadFileIndex) % this.filteredFiles.length) +
this.filteredFiles.length) %
this.filteredFiles.length
const file = this.filteredFiles[cycleIndex]
if (!this.isFileTypeImage(file) || this.toPreloadImageIds.includes(file.id)) {
return
}
loadPreviewAsync(file)
}
for (
let followingFileIndex = 1;
followingFileIndex <= this.preloadImageCount;
followingFileIndex++
) {
preloadFile(followingFileIndex)
}
for (
let previousFileIndex = -1;
previousFileIndex >= this.preloadImageCount * -1;
previousFileIndex--
) {
preloadFile(previousFileIndex)
}
}
}
})
</script>
<style lang="scss" scoped>
.stage {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
text-align: center;
&_media {
flex-grow: 1;
overflow: hidden;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
&_controls {
height: auto;
margin: 10px auto;
}
}
@media (max-width: $oc-breakpoint-medium-default) {
.preview-sidebar-open {
display: none;
}
}
</style>
| owncloud/web/packages/web-app-preview/src/App.vue/0 | {
"file_path": "owncloud/web/packages/web-app-preview/src/App.vue",
"repo_id": "owncloud",
"token_count": 7006
} | 769 |
import SearchBar from './portals/SearchBar.vue'
import App from './App.vue'
import List from './views/List.vue'
import { Component } from 'vue'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import translations from '../l10n/translations.json'
// just a dummy function to trick gettext tools
const $gettext = (msg) => {
return msg
}
export default {
appInfo: {
name: $gettext('Search'),
id: 'search',
icon: 'folder'
},
routes: [
{
name: 'search',
path: '/',
component: App,
children: [
{
name: 'provider-list',
path: 'list/:page?',
component: List,
meta: {
authContext: 'user',
contextQueryItems: ['term', 'provider']
}
}
]
}
],
translations,
mounted({
portal
}: {
portal: {
open: (toApp: string, toPortal: string, order: number, components: Component[]) => void
}
}): void {
portal.open('runtime', 'header', 1, [SearchBar])
}
}
| owncloud/web/packages/web-app-search/src/index.ts/0 | {
"file_path": "owncloud/web/packages/web-app-search/src/index.ts",
"repo_id": "owncloud",
"token_count": 459
} | 770 |
export interface OwnCloudServer {
rel: string
href: string
titles?: Record<string, string>
}
| owncloud/web/packages/web-app-webfinger/src/discovery/types.ts/0 | {
"file_path": "owncloud/web/packages/web-app-webfinger/src/discovery/types.ts",
"repo_id": "owncloud",
"token_count": 29
} | 771 |
/* tslint:disable */
/* eslint-disable */
/**
* Libre Graph API
* Libre Graph is a free API for cloud collaboration inspired by the MS Graph API.
*
* The version of the OpenAPI document: v1.0.4
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
baseOptions?: any;
formDataCtor?: new () => any;
}
export class Configuration {
/**
* parameter for apiKey security
* @param name security name
* @memberof Configuration
*/
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
password?: string;
/**
* parameter for oauth2 security
* @param name security name
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
* @type {string}
* @memberof Configuration
*/
basePath?: string;
/**
* base options for axios calls
*
* @type {any}
* @memberof Configuration
*/
baseOptions?: any;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
constructor(param: ConfigurationParameters = {}) {
this.apiKey = param.apiKey;
this.username = param.username;
this.password = param.password;
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
}
| owncloud/web/packages/web-client/src/generated/configuration.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/generated/configuration.ts",
"repo_id": "owncloud",
"token_count": 1175
} | 772 |
import { SharePermissionBit } from './constants'
// dummy to trick gettext string extraction into recognizing strings
const $gettext = (str) => {
return str
}
export class SharePermission {
private readonly _key: string
private readonly _bit: number
private readonly _label: string
constructor(key: string, bit: number, label: string) {
this._key = key
this._bit = bit
this._label = label
}
get key(): string {
return this._key
}
get bit(): number {
return this._bit
}
get label(): string {
return this._label
}
public enabled(bitmask: number): boolean {
return (bitmask & this.bit) > 0
}
}
export abstract class SharePermissions {
static readonly internal = new SharePermission(
'internal',
SharePermissionBit.Internal,
$gettext('Internal')
)
static readonly read = new SharePermission('read', SharePermissionBit.Read, $gettext('View'))
static readonly update = new SharePermission(
'update',
SharePermissionBit.Update,
$gettext('Edit')
)
static readonly create = new SharePermission(
'create',
SharePermissionBit.Create,
$gettext('Create')
)
static readonly delete = new SharePermission(
'delete',
SharePermissionBit.Delete,
$gettext('Delete')
)
static readonly share = new SharePermission('share', SharePermissionBit.Share, $gettext('Share'))
static readonly denied = new SharePermission('denied', 64, $gettext('Deny'))
static permissionsToBitmask(permissions: SharePermission[]): number {
return (permissions || []).reduce((b: number, p: SharePermission) => b | p.bit, 0)
}
static bitmaskToPermissions(bitmask: number): SharePermission[] {
return [this.read, this.update, this.create, this.delete, this.share].reduce(
(a: SharePermission[], p: SharePermission) => {
if (p.enabled(bitmask)) {
a.push(p)
}
return a
},
[]
)
}
}
| owncloud/web/packages/web-client/src/helpers/share/permission.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/helpers/share/permission.ts",
"repo_id": "owncloud",
"token_count": 675
} | 773 |
import { unref } from 'vue'
import { Resource, SpaceResource, buildWebDavSpacesTrashPath } from '../helpers'
import { WebDavOptions } from './types'
import { DAV, buildAuthHeader } from './client'
import { urlJoin } from '../utils'
interface ClearTrashBinOptions {
id?: Resource['id']
}
export const ClearTrashBinFactory = (dav: DAV, { accessToken }: WebDavOptions) => {
return {
clearTrashBin(space: SpaceResource, { id }: ClearTrashBinOptions = {}) {
let path = buildWebDavSpacesTrashPath(space.id.toString())
if (id) {
path = urlJoin(path, id)
}
const headers = buildAuthHeader(unref(accessToken), space)
return dav.delete(path, { headers })
}
}
}
| owncloud/web/packages/web-client/src/webdav/clearTrashBin.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/webdav/clearTrashBin.ts",
"repo_id": "owncloud",
"token_count": 264
} | 774 |
import { urlJoin } from '../utils'
import { WebDavOptions } from './types'
import { DAV, buildAuthHeader } from './client'
import { unref } from 'vue'
import { DavProperties } from './constants'
export const ListFavoriteFilesFactory = (dav: DAV, { accessToken, user }: WebDavOptions) => {
return {
listFavoriteFiles({ davProperties = DavProperties.Default } = {}) {
const headers = buildAuthHeader(unref(accessToken))
return dav.report(urlJoin('files', unref(user).onPremisesSamAccountName), {
headers,
properties: davProperties,
filterRules: { favorite: 1 }
})
}
}
}
| owncloud/web/packages/web-client/src/webdav/listFavoriteFiles.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/webdav/listFavoriteFiles.ts",
"repo_id": "owncloud",
"token_count": 225
} | 775 |
<template>
<div id="files-app-bar" ref="filesAppBar" :class="{ 'files-app-bar-squashed': isSideBarOpen }">
<oc-hidden-announcer :announcement="selectedResourcesAnnouncement" level="polite" />
<div class="files-topbar oc-py-s">
<h1 class="oc-invisible-sr" v-text="pageTitle" />
<div
class="oc-flex oc-flex-middle files-app-bar-controls"
:class="{
'oc-flex-between': breadcrumbs.length || hasSharesNavigation,
'oc-flex-right': !breadcrumbs.length && !hasSharesNavigation
}"
>
<oc-breadcrumb
v-if="showBreadcrumb"
id="files-breadcrumb"
data-testid="files-breadcrumbs"
class="oc-flex oc-flex-middle"
context-menu-padding="small"
:show-context-actions="showContextActions"
:items="breadcrumbs"
:max-width="breadcrumbMaxWidth"
:truncation-offset="breadcrumbTruncationOffset"
@item-dropped-breadcrumb="fileDroppedBreadcrumb"
>
<template #contextMenu>
<context-actions
:action-options="{ space, resources: breadcrumbsContextActionsItems.filter(Boolean) }"
/>
</template>
</oc-breadcrumb>
<portal-target v-if="showMobileNav" name="app.runtime.mobile.nav" />
<slot v-if="hasSharesNavigation" name="navigation" />
<div v-if="hasViewOptions" id="files-app-bar-controls-right" class="oc-flex">
<view-options
:view-modes="viewModes"
:has-hidden-files="hasHiddenFiles"
:has-file-extensions="hasFileExtensions"
:has-pagination="hasPagination"
per-page-storage-prefix="files"
:view-mode-default="viewModeDefault"
/>
</div>
</div>
<div class="files-app-bar-actions oc-mt-xs">
<div class="oc-flex-1 oc-flex oc-flex-start oc-flex-middle">
<slot name="actions" :limited-screen-space="limitedScreenSpace" />
<batch-actions
v-if="showBatchActions"
:actions="batchActions"
:action-options="{ space, resources: selectedResources }"
:limited-screen-space="limitedScreenSpace"
/>
</div>
</div>
<slot name="content" />
</div>
</div>
</template>
<script lang="ts">
import last from 'lodash-es/last'
import { computed, defineComponent, inject, PropType, ref, Ref, unref, useSlots } from 'vue'
import { Resource } from '@ownclouders/web-client'
import {
isPersonalSpaceResource,
isProjectSpaceResource,
isShareSpaceResource,
SpaceResource
} from '@ownclouders/web-client/src/helpers'
import BatchActions from '../BatchActions.vue'
import ContextActions from '../FilesList/ContextActions.vue'
import ViewOptions from '../ViewOptions.vue'
import { isLocationCommonActive, isLocationTrashActive } from '../../router'
import { FolderView } from '../../ui/types'
import {
useFileActionsEnableSync,
useFileActionsCopy,
useFileActionsDisableSync,
useFileActionsDelete,
useFileActionsDownloadArchive,
useFileActionsDownloadFile,
useFileActionsEmptyTrashBin,
useFileActionsMove,
useFileActionsRestore,
useSpaceActionsDuplicate
} from '../../composables/actions'
import {
useAbility,
useFileActionsToggleHideShare,
useResourcesStore,
useRouteMeta,
useSpacesStore,
FolderViewModeConstants
} from '../../composables'
import { BreadcrumbItem } from 'design-system/src/components/OcBreadcrumb/types'
import { useActiveLocation } from '../../composables'
import { helpers } from 'design-system'
import { useGettext } from 'vue3-gettext'
import {
FileAction,
useSpaceActionsDelete,
useSpaceActionsDisable,
useSpaceActionsEditQuota,
useSpaceActionsRestore
} from '../../composables'
import { storeToRefs } from 'pinia'
const { EVENT_ITEM_DROPPED } = helpers
export default defineComponent({
components: {
BatchActions,
ContextActions,
ViewOptions
},
props: {
viewModeDefault: {
type: String,
required: false,
default: () => FolderViewModeConstants.name.table
},
breadcrumbs: {
type: Array as PropType<BreadcrumbItem[]>,
default: () => []
},
breadcrumbsContextActionsItems: {
type: Array as PropType<Resource[]>,
default: () => []
},
viewModes: {
type: Array as PropType<FolderView[]>,
default: () => []
},
hasBulkActions: { type: Boolean, default: false },
hasViewOptions: { type: Boolean, default: true },
hasHiddenFiles: { type: Boolean, default: true },
hasFileExtensions: { type: Boolean, default: true },
hasPagination: { type: Boolean, default: true },
showActionsOnSelection: { type: Boolean, default: false },
isSideBarOpen: { type: Boolean, default: false },
space: {
type: Object as PropType<SpaceResource>,
required: false,
default: null
}
},
setup(props, { emit }) {
const spacesStore = useSpacesStore()
const { $gettext } = useGettext()
const { can } = useAbility()
const resourcesStore = useResourcesStore()
const { selectedResources } = storeToRefs(resourcesStore)
const { actions: enableSyncActions } = useFileActionsEnableSync()
const { actions: hideShareActions } = useFileActionsToggleHideShare()
const { actions: copyActions } = useFileActionsCopy()
const { actions: duplicateActions } = useSpaceActionsDuplicate()
const { actions: disableSyncActions } = useFileActionsDisableSync()
const { actions: deleteActions } = useFileActionsDelete()
const { actions: downloadArchiveActions } = useFileActionsDownloadArchive()
const { actions: downloadFileActions } = useFileActionsDownloadFile()
const { actions: emptyTrashBinActions } = useFileActionsEmptyTrashBin()
const { actions: moveActions } = useFileActionsMove()
const { actions: restoreActions } = useFileActionsRestore()
const { actions: deleteSpaceActions } = useSpaceActionsDelete()
const { actions: disableSpaceActions } = useSpaceActionsDisable()
const { actions: editSpaceQuotaActions } = useSpaceActionsEditQuota()
const { actions: restoreSpaceActions } = useSpaceActionsRestore()
const breadcrumbMaxWidth = ref<number>(0)
const isSearchLocation = useActiveLocation(isLocationCommonActive, 'files-common-search')
const hasSharesNavigation = computed(
() => useSlots().hasOwnProperty('navigation') && can('create-all', 'Share')
)
const batchActions = computed(() => {
let actions = [
...unref(hideShareActions),
...unref(enableSyncActions),
...unref(disableSyncActions),
...unref(downloadArchiveActions),
...unref(downloadFileActions),
...unref(moveActions),
...unref(copyActions),
...unref(emptyTrashBinActions),
...unref(deleteActions),
...unref(restoreActions)
]
/**
* We show mixed results in search result page, including resources like files and folders but also spaces.
* Space actions shouldn't be possible in that context.
**/
if (!isSearchLocation.value) {
actions = [
...actions,
...unref(duplicateActions),
...unref(editSpaceQuotaActions),
...unref(restoreSpaceActions),
...unref(deleteSpaceActions),
...unref(disableSpaceActions)
] as FileAction[]
}
return actions.filter((item) =>
item.isVisible({ space: props.space, resources: resourcesStore.selectedResources })
)
})
const spaces = computed(() =>
spacesStore.spaces.filter((s) => isPersonalSpaceResource(s) || isProjectSpaceResource(s))
)
const isMobileWidth = inject<Ref<boolean>>('isMobileWidth')
const isTrashLocation = useActiveLocation(isLocationTrashActive, 'files-trash-generic')
const showBreadcrumb = computed(() => {
if (!unref(isMobileWidth) && props.breadcrumbs.length) {
return true
}
if (unref(isTrashLocation) && unref(spaces).length === 1) {
return false
}
return props.breadcrumbs.length > 1
})
const showMobileNav = computed(() => {
if (unref(isTrashLocation) && unref(spaces).length === 1) {
return props.breadcrumbs.length <= 2
}
return props.breadcrumbs.length <= 1
})
const breadcrumbTruncationOffset = computed(() => {
if (!props.space) {
return 2
}
return isProjectSpaceResource(unref(props.space)) || isShareSpaceResource(unref(props.space))
? 3
: 2
})
const fileDroppedBreadcrumb = (data) => {
emit(EVENT_ITEM_DROPPED, data)
}
const routeMetaTitle = useRouteMeta('title')
const pageTitle = computed(() => {
if (unref(routeMetaTitle)) {
return $gettext(unref(routeMetaTitle))
}
return props.space?.name || ''
})
return {
hasSharesNavigation,
batchActions,
showBreadcrumb,
showMobileNav,
breadcrumbMaxWidth,
breadcrumbTruncationOffset,
fileDroppedBreadcrumb,
pageTitle,
selectedResources
}
},
data: function () {
return {
resizeObserver: new ResizeObserver(this.onResize as ResizeObserverCallback),
limitedScreenSpace: false
}
},
computed: {
showContextActions() {
return last<BreadcrumbItem>(this.breadcrumbs).allowContextActions
},
showBatchActions() {
return (
this.hasBulkActions &&
(this.selectedResources.length >= 1 ||
isLocationTrashActive(this.$router, 'files-trash-generic'))
)
},
selectedResourcesAnnouncement() {
if (this.selectedResources.length === 0) {
return this.$gettext('No items selected.')
}
return this.$ngettext(
'%{ amount } item selected. Actions are available above the table.',
'%{ amount } items selected. Actions are available above the table.',
this.selectedResources.length,
{
amount: this.selectedResources.length.toString()
}
)
}
},
mounted() {
this.resizeObserver.observe(this.$refs.filesAppBar as HTMLElement)
window.addEventListener('resize', this.onResize)
},
beforeUnmount() {
this.resizeObserver.unobserve(this.$refs.filesAppBar as HTMLElement)
window.removeEventListener('resize', this.onResize)
},
methods: {
onResize() {
const totalContentWidth =
document.getElementById('web-content-main')?.getBoundingClientRect().width || 0
const leftSidebarWidth =
document.getElementById('web-nav-sidebar')?.getBoundingClientRect().width || 0
const rightSidebarWidth =
document.getElementById('app-sidebar')?.getBoundingClientRect().width || 0
const rightControlsWidth = document.getElementById('files-app-bar-controls-right')
?.clientWidth
this.breadcrumbMaxWidth =
totalContentWidth - leftSidebarWidth - rightSidebarWidth - rightControlsWidth
this.limitedScreenSpace = this.isSideBarOpen
? window.innerWidth <= 1280
: window.innerWidth <= 1000
}
}
})
</script>
<style lang="scss" scoped>
#files-app-bar {
background-color: var(--oc-color-background-default);
border-top-right-radius: 15px;
box-sizing: border-box;
z-index: 2;
position: sticky;
padding: 0 var(--oc-space-medium);
top: 0;
.files-app-bar-controls {
min-height: 52px;
@media (max-width: $oc-breakpoint-xsmall-max) {
justify-content: space-between;
}
}
.files-app-bar-actions {
align-items: center;
display: flex;
gap: var(--oc-space-small);
justify-content: flex-end;
min-height: 3rem;
}
#files-breadcrumb {
min-height: 2rem;
}
}
</style>
| owncloud/web/packages/web-pkg/src/components/AppBar/AppBar.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/AppBar/AppBar.vue",
"repo_id": "owncloud",
"token_count": 4702
} | 776 |
<template>
<oc-text-input
id="create-shortcut-modal-url-input"
v-model="inputUrl"
:label="$gettext('Shortcut to a webpage or file')"
@keydown.up="onKeyUpDrop"
@keydown.down="onKeyDownDrop"
@keydown.esc="onKeyEscDrop"
@keydown.enter="onKeyEnterDrop"
@input="onInputUrlInput"
@click="onClickUrlInput"
/>
<oc-drop
ref="dropRef"
class="oc-pt-s"
padding-size="remove"
drop-id="create-shortcut-modal-contextmenu"
mode="manual"
position="bottom-start"
:close-on-click="true"
@hide-drop="onHideDrop"
@show-drop="onShowDrop"
>
<oc-list>
<li
class="oc-p-xs selectable-item selectable-item-url"
:class="{
active: isDropItemActive(0)
}"
>
<oc-button
class="oc-width-1-1"
appearance="raw"
justify-content="left"
@click="dropItemUrlClicked"
>
<oc-icon name="external-link" />
<span v-text="dropItemUrl" />
</oc-button>
</li>
<li v-if="searchTask.isRunning" class="oc-p-xs oc-flex oc-flex-center">
<oc-spinner />
</li>
<template v-if="searchResult?.values?.length">
<li class="create-shortcut-modal-search-separator oc-text-muted oc-text-small oc-pl-xs">
<span v-text="$gettext('Link to a file')" />
</li>
<li
v-for="(value, index) in searchResult.values"
:key="index"
class="oc-p-xs selectable-item"
:class="{
active: isDropItemActive(index + 1)
}"
>
<oc-button
class="oc-width-1-1"
appearance="raw"
justify-content="left"
@click="dropItemResourceClicked(value)"
>
<resource-preview :search-result="value" :is-clickable="false" />
</oc-button>
</li>
</template>
</oc-list>
</oc-drop>
<div class="oc-flex oc-width-1-1 oc-mt-m">
<oc-text-input
v-model="inputFilename"
class="oc-width-1-1"
:label="$gettext('Shortcut name')"
:error-message="inputFileNameErrorMessage"
:fix-message-line="true"
/>
<span class="oc-ml-s oc-flex oc-flex-bottom create-shortcut-modal-url-extension">.url</span>
</div>
</template>
<script lang="ts">
import {
defineComponent,
PropType,
ref,
unref,
computed,
nextTick,
Ref,
watch,
onMounted
} from 'vue'
import { SpaceResource } from '@ownclouders/web-client'
import {
Modal,
useClientService,
useFolderLink,
useMessages,
useResourcesStore,
useRouter,
useSearch
} from '../composables'
import { urlJoin } from '@ownclouders/web-client/src/utils'
import { useGettext } from 'vue3-gettext'
import DOMPurify from 'dompurify'
import Mark from 'mark.js'
import { OcDrop } from '@ownclouders/design-system/src/components'
import { resolveFileNameDuplicate } from '../helpers'
import { useTask } from 'vue-concurrency'
import { debounce } from 'lodash-es'
import ResourcePreview from './Search/ResourcePreview.vue'
import { SearchResult, SearchResultValue } from './Search'
import { isLocationPublicActive } from '../router'
import { storeToRefs } from 'pinia'
const SEARCH_LIMIT = 7
const SEARCH_DEBOUNCE_TIME = 200
export default defineComponent({
name: 'CreateShortcutModal',
components: { ResourcePreview },
props: {
modal: { type: Object as PropType<Modal>, required: true },
space: {
type: Object as PropType<SpaceResource>,
required: true
}
},
emits: ['update:confirmDisabled'],
setup(props, { emit, expose }) {
const clientService = useClientService()
const { $gettext } = useGettext()
const { showMessage, showErrorMessage } = useMessages()
const router = useRouter()
const { search } = useSearch()
const {
getPathPrefix,
getParentFolderName,
getParentFolderLink,
getParentFolderLinkIconAdditionalAttributes,
getFolderLink
} = useFolderLink()
const resourcesStore = useResourcesStore()
const { resources, currentFolder } = storeToRefs(resourcesStore)
const dropRef = ref(null)
const inputUrl = ref('')
const inputFilename = ref('')
const searchResult: Ref<SearchResult> = ref(null)
const activeDropItemIndex = ref(null)
const isDropOpen = ref(false)
let markInstance = null
const dropItemUrl = computed(() => {
let url = unref(inputUrl).trim()
if (isMaybeUrl(url)) {
return url
}
return `https://${url}`
})
const fileAlreadyExists = computed(
() => !!unref(resources).find((file) => file.name === `${unref(inputFilename)}.url`)
)
const confirmButtonDisabled = computed(
() => unref(fileAlreadyExists) || !unref(inputFilename) || !unref(inputUrl)
)
watch(
confirmButtonDisabled,
() => {
emit('update:confirmDisabled', unref(confirmButtonDisabled))
},
{ immediate: true }
)
const inputFileNameErrorMessage = computed(() => {
if (unref(fileAlreadyExists)) {
return $gettext('%{name} already exists', { name: `${unref(inputFilename)}.url` })
}
return ''
})
const searchTask = useTask(function* (signal, searchTerm: string) {
searchResult.value = null
searchTerm = `name:"*${searchTerm}*" NOT name:"*.url"`
try {
searchResult.value = yield search(searchTerm, SEARCH_LIMIT)
} catch (e) {
// Don't show user facing error, as the core functionality does work without an intact search
}
})
const debouncedSearch = debounce(() => {
searchTask.perform(unref(inputUrl))
}, SEARCH_DEBOUNCE_TIME)
const isMaybeUrl = (input: string) => {
const urlPrefixes = ['http://', 'https://']
return urlPrefixes.some((prefix) => prefix.startsWith(input) || input.startsWith(prefix))
}
const dropItemUrlClicked = () => {
searchResult.value = null
inputUrl.value = unref(dropItemUrl)
try {
let filename = new URL(unref(dropItemUrl)).host
if (unref(resources).some((f) => f.name === `${filename}.url`)) {
filename = resolveFileNameDuplicate(`${filename}.url`, 'url', unref(resources)).slice(
0,
-4
)
}
inputFilename.value = filename
} catch (_) {}
}
const dropItemResourceClicked = (item: SearchResultValue) => {
searchResult.value = null
const webURL = new URL(window.location.href)
let filename = item.data.name
inputUrl.value = `${webURL.origin}/f/${item.id}`
if (unref(resources).some((f) => f.name === `${filename}.url`)) {
filename = resolveFileNameDuplicate(`${filename}.url`, 'url', unref(resources)).slice(0, -4)
}
inputFilename.value = filename
}
const isDropItemActive = (index) => {
return unref(activeDropItemIndex) === index
}
const findNextDropItemIndex = (previous = false) => {
const elements = Array.from(document.querySelectorAll('li.selectable-item'))
let index =
unref(activeDropItemIndex) !== null
? unref(activeDropItemIndex)
: previous
? elements.length
: -1
const increment = previous ? -1 : 1
do {
index += increment
if (index < 0 || index > elements.length - 1) {
return null
}
} while (elements[index].classList.contains('disabled'))
return index
}
const onKeyUpDrop = () => {
activeDropItemIndex.value = findNextDropItemIndex(true)
}
const onKeyDownDrop = () => {
activeDropItemIndex.value = findNextDropItemIndex(false)
}
const onKeyEscDrop = (e: Event) => {
if (!unref(isDropOpen)) {
return
}
e.stopPropagation()
;(unref(dropRef) as InstanceType<typeof OcDrop>).hide()
}
const onKeyEnterDrop = (e: Event) => {
if (!unref(isDropOpen)) {
return
}
e.stopPropagation()
if (unref(activeDropItemIndex) === null) {
return
}
if (unref(activeDropItemIndex) === 0) {
dropItemUrlClicked()
} else {
dropItemResourceClicked(unref(searchResult)?.values?.[unref(activeDropItemIndex) - 1])
}
;(unref(dropRef) as InstanceType<typeof OcDrop>).hide()
}
const onHideDrop = () => {
isDropOpen.value = false
activeDropItemIndex.value = null
}
const onShowDrop = () => {
isDropOpen.value = true
activeDropItemIndex.value = 0
}
const onClickUrlInput = () => {
const showDrop = inputUrl.value.trim().length
if (showDrop) {
;(unref(dropRef) as InstanceType<typeof OcDrop>).show()
}
}
const onInputUrlInput = async () => {
await nextTick()
const hideDrop = !inputUrl.value.trim().length
if (hideDrop) {
;(unref(dropRef) as InstanceType<typeof OcDrop>).hide()
return
}
;(unref(dropRef) as InstanceType<typeof OcDrop>).show()
if (!isLocationPublicActive(router, 'files-public-link')) {
debouncedSearch()
}
}
const onConfirm = async () => {
try {
// Omit possible xss code
const sanitizedUrl = DOMPurify.sanitize(unref(inputUrl), { USE_PROFILES: { html: true } })
const content = `[InternetShortcut]\nURL=${sanitizedUrl}`
const path = urlJoin(unref(currentFolder).path, `${unref(inputFilename)}.url`)
const resource = await clientService.webdav.putFileContents(props.space, {
path,
content
})
resourcesStore.upsertResource(resource)
showMessage({ title: $gettext('Shortcut was created successfully') })
} catch (e) {
console.error(e)
showErrorMessage({
title: $gettext('Failed to create shortcut'),
errors: [e]
})
}
}
onMounted(async () => {
await nextTick()
markInstance = new Mark(unref(dropRef)?.$refs?.drop)
})
watch(
searchResult,
async () => {
await nextTick()
if (!unref(isDropOpen) || !markInstance) {
return
}
markInstance.unmark()
markInstance.mark(unref(inputUrl), {
element: 'span',
className: 'mark-highlight',
exclude: ['.selectable-item-url *', '.create-shortcut-modal-search-separator *']
})
},
{ deep: true }
)
watch(activeDropItemIndex, () => {
if (!unref(isDropOpen) || typeof unref(dropRef)?.$el?.scrollTo !== 'function') {
return
}
const elements = unref(dropRef).$el.querySelectorAll('.selectable-item')
unref(dropRef).$el.scrollTo(
0,
unref(activeDropItemIndex) === null
? 0
: elements[unref(activeDropItemIndex)].getBoundingClientRect().y -
elements[unref(activeDropItemIndex)].getBoundingClientRect().height
)
})
expose({ onConfirm })
return {
inputUrl,
inputFilename,
dropRef,
dropItemUrl,
searchResult,
confirmButtonDisabled,
inputFileNameErrorMessage,
searchTask,
dropItemUrlClicked,
dropItemResourceClicked,
getPathPrefix,
getFolderLink,
getParentFolderLink,
getParentFolderName,
getParentFolderLinkIconAdditionalAttributes,
onKeyEnterDrop,
onKeyDownDrop,
onKeyUpDrop,
onKeyEscDrop,
onHideDrop,
onShowDrop,
onInputUrlInput,
onClickUrlInput,
isDropItemActive,
// unit tests
onConfirm
}
}
})
</script>
<style lang="scss">
.create-shortcut-modal {
&-url-extension {
margin-bottom: calc(var(--oc-space-xsmall) + 1.3125rem);
}
&-search-separator:hover {
background: none !important;
}
}
#create-shortcut-modal-contextmenu {
width: 458px;
.oc-resource-name {
text-decoration: none !important;
}
li:hover,
li.active {
background-color: var(--oc-color-background-highlight);
}
}
</style>
| owncloud/web/packages/web-pkg/src/components/CreateShortcutModal.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/CreateShortcutModal.vue",
"repo_id": "owncloud",
"token_count": 5229
} | 777 |
<template>
<div class="item-filter oc-flex" :class="`item-filter-${filterName}`">
<oc-filter-chip
:is-toggle="true"
:filter-label="filterLabel"
:is-toggle-active="filterActive"
@toggle-filter="toggleFilter"
@clear-filter="toggleFilter"
/>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref, unref } from 'vue'
import omit from 'lodash-es/omit'
import { useRoute, useRouteQuery, useRouter, queryItemAsString } from '../composables'
export default defineComponent({
name: 'ItemFilterToggle',
props: {
filterLabel: {
type: String,
required: true
},
filterName: {
type: String,
required: true
}
},
emits: ['toggleFilter'],
setup: function (props, { emit }) {
const router = useRouter()
const currentRoute = useRoute()
const filterActive = ref<boolean>(false)
const queryParam = `q_${props.filterName}`
const currentRouteQuery = useRouteQuery(queryParam)
const setRouteQuery = () => {
return router.push({
query: {
...omit(unref(currentRoute).query, [queryParam]),
...(unref(filterActive) && { [queryParam]: 'true' })
}
})
}
const toggleFilter = async () => {
filterActive.value = !unref(filterActive)
await setRouteQuery()
emit('toggleFilter', unref(filterActive))
}
onMounted(() => {
const queryStr = queryItemAsString(unref(currentRouteQuery))
if (queryStr === 'true') {
filterActive.value = true
}
})
return {
queryParam,
filterActive,
toggleFilter
}
}
})
</script>
| owncloud/web/packages/web-pkg/src/components/ItemFilterToggle.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/ItemFilterToggle.vue",
"repo_id": "owncloud",
"token_count": 670
} | 778 |
<template>
<InnerSideBar
v-if="isOpen"
ref="sidebar"
class="files-side-bar"
tabindex="-1"
:is-open="isOpen"
:active-panel="activePanel"
:available-panels="availablePanels"
:panel-context="panelContext"
:loading="isLoading"
v-bind="$attrs"
data-custom-key-bindings-disabled="true"
@before-unmount="destroySideBar"
@mounted="focusSideBar"
@file-changed="focusSideBar"
@select-panel="setActiveSideBarPanel"
@close="closeSideBar"
>
<template #header>
<file-info
v-if="isFileHeaderVisible"
class="sidebar-panel__file_info"
:is-sub-panel-active="!!activePanel"
/>
<space-info v-else-if="isSpaceHeaderVisible" class="sidebar-panel__space_info" />
</template>
</InnerSideBar>
</template>
<script lang="ts">
import { computed, defineComponent, PropType, provide, readonly, ref, unref, watch } from 'vue'
import PQueue from 'p-queue'
import { SideBarPanelContext, SideBar as InnerSideBar } from '../SideBar'
import { SpaceInfo } from './Spaces'
import { FileInfo } from './Files'
import {
isLocationCommonActive,
isLocationPublicActive,
isLocationSharesActive,
isLocationSpacesActive,
isLocationTrashActive
} from '../../router'
import {
SidebarPanelExtension,
SideBarEventTopics,
useClientService,
useEventBus,
useRouter,
useActiveLocation,
useExtensionRegistry,
useSelectedResources,
useSpacesStore,
useSharesStore,
useResourcesStore,
useUserStore,
useConfigStore
} from '../../composables'
import {
isProjectSpaceResource,
SpaceResource,
Resource,
CollaboratorShare,
LinkShare,
ShareRole,
getGraphItemId,
call
} from '@ownclouders/web-client/src/helpers'
import { storeToRefs } from 'pinia'
import { useTask } from 'vue-concurrency'
import {
buildCollaboratorShare,
buildLinkShare
} from '@ownclouders/web-client/src/helpers/share/functionsNG'
import { Permission } from '@ownclouders/web-client/src/generated'
export default defineComponent({
name: 'FileSideBar',
components: { FileInfo, SpaceInfo, InnerSideBar },
props: {
isOpen: {
type: Boolean,
required: true
},
activePanel: {
type: String,
required: false,
default: null
},
space: {
type: Object as PropType<SpaceResource>,
required: false,
default: null
}
},
setup(props) {
const router = useRouter()
const clientService = useClientService()
const extensionRegistry = useExtensionRegistry()
const eventBus = useEventBus()
const spacesStore = useSpacesStore()
const sharesStore = useSharesStore()
const userStore = useUserStore()
const configStore = useConfigStore()
const resourcesStore = useResourcesStore()
const { currentFolder } = storeToRefs(resourcesStore)
const loadedResource = ref<Resource>()
const isLoading = ref(false)
const availableShareRoles = ref<ShareRole[]>([])
const { selectedResources } = useSelectedResources()
const panelContext = computed<SideBarPanelContext<SpaceResource, Resource, Resource>>(() => {
if (unref(selectedResources).length === 0) {
return {
root: props.space,
parent: null,
items: unref(currentFolder)?.id ? [unref(currentFolder)] : []
}
}
return {
root: props.space,
parent: unref(currentFolder),
items: unref(selectedResources)
}
})
const isSharedWithMeLocation = useActiveLocation(isLocationSharesActive, 'files-shares-with-me')
const isSharedWithOthersLocation = useActiveLocation(
isLocationSharesActive,
'files-shares-with-others'
)
const isSharedViaLinkLocation = useActiveLocation(
isLocationSharesActive,
'files-shares-via-link'
)
const isProjectsLocation = isLocationSpacesActive(router, 'files-spaces-projects')
const isFavoritesLocation = useActiveLocation(isLocationCommonActive, 'files-common-favorites')
const isSearchLocation = useActiveLocation(isLocationCommonActive, 'files-common-search')
const isPublicFilesLocation = useActiveLocation(isLocationPublicActive, 'files-public-link')
const isTrashLocation = useActiveLocation(isLocationTrashActive, 'files-trash-generic')
const closeSideBar = () => {
eventBus.publish(SideBarEventTopics.close)
}
const setActiveSideBarPanel = (panelName) => {
eventBus.publish(SideBarEventTopics.setActivePanel, panelName)
}
const focusSideBar = (component, event) => {
component.focus({
from: document.activeElement,
to: component.sidebar?.$el,
revert: event === 'beforeUnmount'
})
}
const destroySideBar = (component, event) => {
focusSideBar(component, event)
eventBus.publish(SideBarEventTopics.close)
}
const isFileHeaderVisible = computed(() => {
return (
unref(panelContext).items?.length === 1 &&
!isProjectSpaceResource(unref(panelContext).items[0])
)
})
const isSpaceHeaderVisible = computed(() => {
return (
unref(panelContext).items?.length === 1 &&
isProjectSpaceResource(unref(panelContext).items[0])
)
})
const isShareLocation = computed(() => {
return (
unref(isSharedWithMeLocation) ||
unref(isSharedWithOthersLocation) ||
unref(isSharedViaLinkLocation)
)
})
const isFlatFileList = computed(() => {
return unref(isShareLocation) || unref(isSearchLocation) || unref(isFavoritesLocation)
})
const availablePanels = computed(() =>
extensionRegistry
.requestExtensions<SidebarPanelExtension<SpaceResource, Resource, Resource>>(
'sidebarPanel',
['resource']
)
.map((e) => e.panel)
)
const loadSharesTask = useTask(function* (signal, resource: Resource) {
sharesStore.setLoading(true)
sharesStore.removeOrphanedShares()
const { collaboratorShares: collaboratorCache, linkShares: linkCache } = sharesStore
const resourceId = getGraphItemId(resource)
const { data } = yield* call(
clientService.graphAuthenticated.permissions.listPermissions(props.space.id, resourceId)
)
let availableRoles =
sharesStore.graphRoles.filter(
(r) =>
data['@libre.graph.permissions.roles.allowedValues']?.map(({ id }) => id).includes(r.id)
) || []
// FIXME server bug, remove when https://github.com/owncloud/ocis/issues/8331 is resolved
if (resource.isFolder) {
availableRoles = availableRoles.filter(
({ id }) => id !== '2d00ce52-1fc2-4dbc-8b95-a73b73395f5a'
)
} else {
availableRoles = availableRoles.filter(
({ id }) =>
id !== 'fb6c3e19-e378-47e5-b277-9732f9de6e21' &&
id !== '1c996275-f1c9-4e71-abdf-a42f6495e960'
)
}
availableShareRoles.value = availableRoles
const permissions = data.value || []
const loadedCollaboratorShares: CollaboratorShare[] = []
const loadedLinkShares: LinkShare[] = []
const buildShares = ({
p,
resourceId,
indirect = false
}: {
p: Permission[]
resourceId: string
indirect?: boolean
}) => {
p.forEach((graphPermission) => {
if (!!graphPermission.link) {
loadedLinkShares.push(
buildLinkShare({ graphPermission, user: userStore.user, resourceId, indirect })
)
return
}
loadedCollaboratorShares.push(
buildCollaboratorShare({
graphPermission,
graphRoles: sharesStore.graphRoles,
resourceId,
spaceId: getGraphItemId(props.space),
user: userStore.user,
indirect
})
)
})
}
// load direct shares
buildShares({ p: permissions, resourceId })
// use cache for indirect shares
const useCache = !unref(isFlatFileList) && !unref(isProjectsLocation)
if (useCache) {
collaboratorCache.forEach((share) => {
if (loadedCollaboratorShares.some((s) => s.id === share.id)) {
return
}
loadedCollaboratorShares.push({ ...share, indirect: true })
})
linkCache.forEach((share) => {
if (loadedLinkShares.some((s) => s.id === share.id)) {
return
}
loadedLinkShares.push({ ...share, indirect: true })
})
}
// load uncached indirect shares
const ancestorDataWithoutRoot = resourcesStore.ancestorMetaData
if (Object.keys(resourcesStore.ancestorMetaData).includes('/')) {
// filter out space roots because they don't have shares
// (expect for project spaces, but they are loaded separately)
delete ancestorDataWithoutRoot['/']
}
const chachedIds = [...collaboratorCache, ...linkCache].map(({ resourceId }) => resourceId)
const ancestorIds = Object.values(ancestorDataWithoutRoot)
.map(({ id }) => id)
.filter((id) => id !== resourceId && !chachedIds.includes(id))
const queue = new PQueue({
concurrency: configStore.options.concurrentRequests.shares.list
})
const promises = ancestorIds.map((id) => {
return queue.add(() =>
clientService.graphAuthenticated.permissions
.listPermissions(props.space.id, id)
.then((value) => {
const data = value.data
const permissions = ((data as any).value || []) as Permission[]
buildShares({ p: permissions, resourceId: id, indirect: true })
})
)
})
yield Promise.allSettled(promises)
sharesStore.setCollaboratorShares(loadedCollaboratorShares)
sharesStore.setLinkShares(loadedLinkShares)
if (isProjectSpaceResource(resource)) {
// FIXME: do we need this?
spacesStore.setSpaceMembers(sharesStore.collaboratorShares)
}
sharesStore.setLoading(false)
}).restartable()
watch(
() => [...unref(panelContext).items, props.isOpen],
async () => {
if (!props.isOpen) {
sharesStore.pruneShares()
loadedResource.value = null
return
}
if (unref(panelContext).items?.length !== 1) {
// don't load additional metadata for empty or multi-select contexts
return
}
const resource = unref(panelContext).items[0]
if (unref(loadedResource)?.id === resource.id) {
// current resource is already loaded
return
}
isLoading.value = true
if (!unref(isPublicFilesLocation) && !unref(isTrashLocation)) {
try {
if (loadSharesTask.isRunning) {
loadSharesTask.cancelAll()
}
loadSharesTask.perform(resource)
} catch (e) {
console.error(e)
}
}
if (!unref(isShareLocation)) {
loadedResource.value = resource
isLoading.value = false
return
}
// shared resources look different, hence we need to fetch the actual resource here
try {
let fullResource = await clientService.webdav.getFileInfo(props.space, {
path: resource.path
})
// make sure props from the share (=resource) are available on the full resource as well
fullResource = { ...fullResource, ...resource }
loadedResource.value = fullResource
} catch (error) {
loadedResource.value = resource
console.error(error)
}
isLoading.value = false
},
{ deep: true, immediate: true }
)
provide('resource', readonly(loadedResource))
provide(
'space',
computed(() => props.space)
)
provide(
'activePanel',
computed(() => props.activePanel)
)
provide('availableShareRoles', readonly(availableShareRoles))
return {
loadedResource,
setActiveSideBarPanel,
closeSideBar,
destroySideBar,
focusSideBar,
panelContext,
availablePanels,
isLoading,
isFileHeaderVisible,
isSpaceHeaderVisible
}
}
})
</script>
<style lang="scss">
.files-side-bar {
z-index: 3;
.sidebar-panel {
&__file_info {
background-color: var(--oc-color-background-default);
padding: var(--oc-space-small) var(--oc-space-small) 0 var(--oc-space-small);
}
}
._clipboard-success-animation {
animation-name: _clipboard-success-animation;
animation-duration: 0.8s;
animation-timing-function: ease-out;
animation-fill-mode: both;
}
}
@keyframes _clipboard-success-animation {
0% {
opacity: 1;
}
50% {
opacity: 0.9;
}
100% {
opacity: 0;
}
}
</style>
| owncloud/web/packages/web-pkg/src/components/SideBar/FileSideBar.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/SideBar/FileSideBar.vue",
"repo_id": "owncloud",
"token_count": 5341
} | 779 |
<template>
<div id="text-editor-container" ref="toastUiEditorRef" :data-markdown-mode="isMarkdown" />
</template>
<script lang="ts">
import { computed, defineComponent, unref, PropType, ref, onMounted } from 'vue'
import { Resource } from '@ownclouders/web-client/src/helpers/resource/types'
import '@toast-ui/editor/dist/toastui-editor.css'
import '@toast-ui/editor/dist/theme/toastui-editor-dark.css'
import '@toast-ui/editor/dist/i18n/cs-cz'
import '@toast-ui/editor/dist/i18n/de-de'
import '@toast-ui/editor/dist/i18n/es-es'
import '@toast-ui/editor/dist/i18n/fr-fr'
import '@toast-ui/editor/dist/i18n/it-it'
import '@toast-ui/editor/dist/i18n/nl-nl'
import '@toast-ui/editor/dist/i18n/ko-kr'
import '@toast-ui/editor/dist/i18n/sv-se'
import '@toast-ui/editor/dist/i18n/tr-tr'
import '@toast-ui/editor/dist/i18n/zh-cn'
import { Editor, EditorCore, EditorOptions } from '@toast-ui/editor'
import 'prismjs/themes/prism.css'
import '@toast-ui/editor-plugin-code-syntax-highlight/dist/toastui-editor-plugin-code-syntax-highlight.css'
import codeSyntaxHighlight from '@toast-ui/editor-plugin-code-syntax-highlight/dist/toastui-editor-plugin-code-syntax-highlight-all.js'
import { useGettext } from 'vue3-gettext'
import { useThemeStore } from '../composables'
import { AppConfigObject } from '../apps'
export default defineComponent({
name: 'TextEditor',
props: {
applicationConfig: { type: Object as PropType<AppConfigObject>, required: true },
currentContent: {
type: String,
required: true
},
isReadOnly: { type: Boolean, required: false, default: false },
resource: { type: Object as PropType<Resource>, required: true }
},
emits: ['update:currentContent'],
setup(props, { emit }) {
const { current: currentLanguage } = useGettext()
const themeStore = useThemeStore()
const toastUiEditorRef = ref()
// Should not be a ref, otherwise functions like setMarkdown won't work
let toastUiEditor: EditorCore = null
const config = computed(() => {
// TODO: Remove typecasting once vue-tsc has figured it out
const { showPreviewOnlyMd = true } = props.applicationConfig as AppConfigObject
return { showPreviewOnlyMd }
})
const isMarkdown = computed(() => {
return (
['md', 'markdown'].includes(props.resource?.extension) || !unref(config).showPreviewOnlyMd
)
})
onMounted(() => {
let config: EditorOptions = {
el: unref(toastUiEditorRef),
usageStatistics: false, // sends hostname to google analytics DISABLE
initialValue: props.currentContent,
useCommandShortcut: false,
hideModeSwitch: true,
language: currentLanguage,
height: '100%',
plugins: [codeSyntaxHighlight],
viewer: props.isReadOnly,
events: {
change: () => {
emit('update:currentContent', toastUiEditor.getMarkdown())
}
},
...(themeStore.currentTheme.isDark && { theme: 'dark' })
}
if (!unref(isMarkdown)) {
config = {
...config,
toolbarItems: [],
initialEditType: 'wysiwyg'
}
}
toastUiEditor = Editor.factory(config) as EditorCore
})
return {
toastUiEditorRef,
isMarkdown
}
}
})
</script>
<style lang="scss">
.toastui-editor-tabs {
// Fix tab with for long i18n text
.tab-item {
width: auto;
padding-left: var(--oc-space-small);
padding-right: var(--oc-space-small);
}
}
</style>
| owncloud/web/packages/web-pkg/src/components/TextEditor.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/TextEditor.vue",
"repo_id": "owncloud",
"token_count": 1420
} | 780 |
import {
isLocationCommonActive,
isLocationPublicActive,
isLocationSharesActive,
isLocationSpacesActive
} from '../../../router'
import { useIsFilesAppActive } from '../helpers'
import path from 'path'
import first from 'lodash-es/first'
import {
isIncomingShareResource,
isProjectSpaceResource,
isPublicSpaceResource,
Resource
} from '@ownclouders/web-client/src/helpers'
import { computed, unref } from 'vue'
import { useLoadingService } from '../../loadingService'
import { useRouter } from '../../router'
import { FileAction, FileActionOptions } from '../types'
import { useGettext } from 'vue3-gettext'
import { useArchiverService } from '../../archiverService'
import { formatFileSize } from '../../../helpers/filesize'
import { useAuthStore, useMessages } from '../../piniaStores'
export const useFileActionsDownloadArchive = () => {
const { showErrorMessage } = useMessages()
const router = useRouter()
const loadingService = useLoadingService()
const archiverService = useArchiverService()
const { $ngettext, $gettext, current } = useGettext()
const authStore = useAuthStore()
const isFilesAppActive = useIsFilesAppActive()
const handler = ({ space, resources }: FileActionOptions) => {
if (resources.length > 1) {
// the handler can be triggered successfully if project spaces are selected along with other files.
// but we must filter out the project spaces in such a case (only the other selected files are allowed for download).
resources = resources.filter((r) => r.canDownload() && !isProjectSpaceResource(r))
}
const fileOptions = unref(archiverService.fileIdsSupported)
? {
fileIds: resources.map((resource) => resource.fileId)
}
: {
dir: path.dirname(first<Resource>(resources).path) || '/',
files: resources.map((resource) => resource.name)
}
return archiverService
.triggerDownload({
...fileOptions,
...(space &&
isPublicSpaceResource(space) && {
publicToken: space.id as string,
publicLinkPassword: authStore.publicLinkPassword
})
})
.catch((e) => {
console.error(e)
showErrorMessage({
title: $ngettext(
'Failed to download the selected folder.', // on single selection only available for folders
'Failed to download the selected files.', // on multi selection available for files+folders
resources.length
),
errors: [e]
})
})
}
const areArchiverLimitsExceeded = (resources: Resource[]) => {
const archiverCapabilities = unref(archiverService.capability)
if (!archiverCapabilities) {
return
}
const selectedFilesSize = resources.reduce(
(accumulator, currentValue) => accumulator + parseInt(`${currentValue.size}`),
0
)
return selectedFilesSize > parseInt(archiverCapabilities.max_size)
}
const actions = computed((): FileAction[] => {
return [
{
name: 'download-archive',
icon: 'inbox-archive',
handler: async (args) => {
await loadingService.addTask(() => handler(args))
},
label: () => $gettext('Download'),
disabledTooltip: ({ resources }) => {
return areArchiverLimitsExceeded(resources)
? $gettext('The selection exceeds the allowed archive size (max. %{maxSize})', {
maxSize: formatFileSize(unref(archiverService.capability).max_size, current)
})
: ''
},
isDisabled: ({ resources }) => areArchiverLimitsExceeded(resources),
isVisible: ({ resources }) => {
if (
unref(isFilesAppActive) &&
!isLocationSpacesActive(router, 'files-spaces-generic') &&
!isLocationPublicActive(router, 'files-public-link') &&
!isLocationCommonActive(router, 'files-common-favorites') &&
!isLocationCommonActive(router, 'files-common-search') &&
!isLocationSharesActive(router, 'files-shares-with-me') &&
!isLocationSharesActive(router, 'files-shares-with-others') &&
!isLocationSharesActive(router, 'files-shares-via-link') &&
!isLocationCommonActive(router, 'files-common-search')
) {
return false
}
if (!unref(archiverService.available)) {
return false
}
if (resources.length === 0) {
return false
}
if (resources.length === 1 && !resources[0].isFolder) {
return false
}
if (resources.length > 1 && resources.every((r) => isProjectSpaceResource(r))) {
return false
}
if (isProjectSpaceResource(resources[0]) && resources[0].disabled) {
return false
}
if (isIncomingShareResource(resources[0]) && !resources[0].syncEnabled) {
return false
}
if (
!unref(archiverService.fileIdsSupported) &&
isLocationCommonActive(router, 'files-common-favorites')
) {
return false
}
const downloadDisabled = resources.some((resource) => {
return !resource.canDownload()
})
return !downloadDisabled
},
componentType: 'button',
class: 'oc-files-actions-download-archive-trigger'
}
]
})
return {
actions
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsDownloadArchive.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsDownloadArchive.ts",
"repo_id": "owncloud",
"token_count": 2235
} | 781 |
import PQueue from 'p-queue'
import { isLocationSharesActive } from '../../../router'
import { useClientService } from '../../clientService'
import { useLoadingService } from '../../loadingService'
import { useRouter } from '../../router'
import { computed } from 'vue'
import { useGettext } from 'vue3-gettext'
import { FileAction, FileActionOptions } from '../../actions'
import { useMessages, useConfigStore, useResourcesStore } from '../../piniaStores'
import { IncomingShareResource } from '@ownclouders/web-client/src/helpers'
import { urlJoin } from '@ownclouders/web-client/src/utils'
export const useFileActionsToggleHideShare = () => {
const { showMessage, showErrorMessage } = useMessages()
const router = useRouter()
const { $gettext } = useGettext()
const clientService = useClientService()
const loadingService = useLoadingService()
const configStore = useConfigStore()
const { updateResourceField, resetSelection } = useResourcesStore()
const handler = async ({ resources }: FileActionOptions<IncomingShareResource>) => {
const errors = []
const triggerPromises = []
const triggerQueue = new PQueue({
concurrency: configStore.options.concurrentRequests.resourceBatchActions
})
const hidden = !resources[0].hidden
resources.forEach((resource) => {
triggerPromises.push(
triggerQueue.add(async () => {
try {
// FIXME: use graph endpoint as soon as it's available: https://github.com/owncloud/ocis/issues/8654
await clientService.httpAuthenticated.put(
urlJoin('ocs/v2.php/apps/files_sharing/api/v1/shares/pending', resource.shareId),
null,
{
params: { hidden: hidden ? 'true' : 'false', format: 'json' },
headers: { 'Ocs-Apirequest': true }
}
)
updateResourceField<IncomingShareResource, any>({
id: resource.id,
field: 'hidden',
value: hidden
})
} catch (error) {
console.error(error)
errors.push(error)
}
})
)
})
await Promise.all(triggerPromises)
if (errors.length === 0) {
resetSelection()
showMessage({
title: hidden
? $gettext('The share was hidden successfully')
: $gettext('The share was unhidden successfully')
})
return
}
showErrorMessage({
title: hidden
? $gettext('Failed to hide the share')
: $gettext('Failed to unhide share share'),
errors
})
}
const actions = computed((): FileAction<IncomingShareResource>[] => [
{
name: 'toggle-hide-share',
icon: 'eye-off', // FIXME: change icon based on hidden status
handler: (args) => loadingService.addTask(() => handler(args)),
label: ({ resources }) => (resources[0].hidden ? $gettext('Unhide') : $gettext('Hide')),
isVisible: ({ resources }) => {
if (resources.length === 0) {
return false
}
return isLocationSharesActive(router, 'files-shares-with-me')
},
componentType: 'button',
class: 'oc-files-actions-hide-share-trigger'
}
])
return {
actions
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsToggleHideShare.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsToggleHideShare.ts",
"repo_id": "owncloud",
"token_count": 1293
} | 782 |
import { SpaceResource } from '@ownclouders/web-client'
import { computed } from 'vue'
import { SpaceAction, SpaceActionOptions } from '../types'
import { useClientService } from '../../clientService'
import { useLoadingService } from '../../loadingService'
import { useGettext } from 'vue3-gettext'
import { useMessages, useModals, useSpacesStore, useUserStore } from '../../piniaStores'
import { useCreateSpace } from '../../spaces'
import { buildSpace } from '@ownclouders/web-client/src/helpers'
import { eventBus } from '../../../services'
import { Drive } from '@ownclouders/web-client/src/generated'
import { blobToArrayBuffer, canvasToBlob } from '../../../helpers'
import EmojiPickerModal from '../../../components/Modals/EmojiPickerModal.vue'
export const useSpaceActionsSetIcon = () => {
const userStore = useUserStore()
const { showMessage, showErrorMessage } = useMessages()
const { $gettext } = useGettext()
const clientService = useClientService()
const loadingService = useLoadingService()
const { createDefaultMetaFolder } = useCreateSpace()
const spacesStore = useSpacesStore()
const { dispatchModal } = useModals()
const handler = ({ resources }: SpaceActionOptions) => {
if (resources.length !== 1) {
return
}
dispatchModal({
elementClass: 'oc-width-auto',
title: $gettext('Set icon for %{space}', { space: resources[0].name }),
hideConfirmButton: true,
customComponent: EmojiPickerModal,
focusTrapInitial: 'em-emoji-picker',
onConfirm: (emoji: string) => setIconSpace(resources[0], emoji)
})
}
const generateEmojiImage = async (emoji: string): Promise<ArrayBuffer | string> => {
const canvas = document.createElement('canvas')
const context = canvas.getContext('2d')
const aspectRatio = 16 / 9,
width = 720,
height = width / aspectRatio
canvas.width = width
canvas.height = height
const textSize = 0.4 * width
context.font = `${textSize}px sans-serif`
context.textBaseline = 'middle'
context.textAlign = 'center'
// FIXME: This offset center the emoji vertical, try to do it programmatically
const heightOffset = 15
context.fillText(emoji, canvas.width / 2, canvas.height / 2 + heightOffset)
const blob = await canvasToBlob(canvas)
return blobToArrayBuffer(blob)
}
const setIconSpace = async (space: SpaceResource, emoji: string) => {
const graphClient = clientService.graphAuthenticated
const content = await generateEmojiImage(emoji)
try {
await clientService.webdav.getFileInfo(space, { path: '.space' })
} catch (_) {
spacesStore.updateSpaceField({
id: space.id,
field: 'spaceReadmeData',
value: (await createDefaultMetaFolder(space)).spaceReadmeData
})
}
return loadingService.addTask(async () => {
const headers = {
'Content-Type': 'application/offset+octet-stream'
}
try {
const { fileId } = await clientService.webdav.putFileContents(space, {
path: `/.space/emoji.png`,
content,
headers,
overwrite: true
})
const { data } = await graphClient.drives.updateDrive(
space.id.toString(),
{
special: [
{
specialFolder: {
name: 'image'
},
id: fileId
}
]
} as Drive,
{}
)
spacesStore.updateSpaceField({
id: space.id.toString(),
field: 'spaceImageData',
value: data.special.find((special) => special.specialFolder.name === 'image')
})
showMessage({ title: $gettext('Space icon was set successfully') })
eventBus.publish('app.files.spaces.uploaded-image', buildSpace(data))
} catch (error) {
console.error(error)
showErrorMessage({
title: $gettext('Failed to set space icon'),
errors: [error]
})
}
})
}
const actions = computed((): SpaceAction[] => [
{
name: 'set-space-icon',
icon: 'emoji-sticker',
handler,
label: () => {
return $gettext('Set icon')
},
isVisible: ({ resources }) => {
if (resources.length !== 1) {
return false
}
return resources[0].canEditImage({ user: userStore.user })
},
componentType: 'button',
class: 'oc-files-actions-set-space-icon-trigger'
}
])
return {
actions,
setIconSpace
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsSetIcon.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsSetIcon.ts",
"repo_id": "owncloud",
"token_count": 1822
} | 783 |
export * from './useArchiverService'
| owncloud/web/packages/web-pkg/src/composables/archiverService/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/archiverService/index.ts",
"repo_id": "owncloud",
"token_count": 11
} | 784 |
export * from './useEmbedMode'
| owncloud/web/packages/web-pkg/src/composables/embedMode/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/embedMode/index.ts",
"repo_id": "owncloud",
"token_count": 11
} | 785 |
export * from './useLoadingService'
| owncloud/web/packages/web-pkg/src/composables/loadingService/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/loadingService/index.ts",
"repo_id": "owncloud",
"token_count": 10
} | 786 |
import { Action } from '../actions'
import { SearchProvider, SideBarPanel } from '../../components'
import { defineStore } from 'pinia'
import { Ref, unref } from 'vue'
import { AppNavigationItem } from '../../apps'
import { Item } from '@ownclouders/web-client/src/helpers'
import { useConfigStore } from './config'
import { FolderView } from '../../ui'
import { StringUnionOrAnyString } from '../../utils/types'
export type ExtensionType = StringUnionOrAnyString<
'action' | 'search' | 'sidebarNav' | 'sidebarPanel' | 'folderView'
>
export type ExtensionScope = StringUnionOrAnyString<'resource' | 'user' | 'group'>
export type BaseExtension = {
id: string
type: ExtensionType
scopes?: ExtensionScope[]
}
export interface ActionExtension extends BaseExtension {
type: 'action'
action: Action
}
export interface SearchExtension extends BaseExtension {
type: 'search'
searchProvider: SearchProvider
}
export interface SidebarNavExtension extends BaseExtension {
type: 'sidebarNav'
navItem: AppNavigationItem
}
export interface SidebarPanelExtension<R extends Item, P extends Item, T extends Item>
extends BaseExtension {
type: 'sidebarPanel'
panel: SideBarPanel<R, P, T>
}
export interface FolderViewExtension extends BaseExtension {
type: 'folderView'
folderView: FolderView
}
export type Extension =
| ActionExtension
| SearchExtension
| SidebarNavExtension
| SidebarPanelExtension<Item, Item, Item>
| FolderViewExtension
export const useExtensionRegistry = () => {
const configStore = useConfigStore()
return defineStore('extensionRegistry', {
state: () => ({ extensions: [] as Ref<Extension[]>[] }),
actions: {
registerExtensions(extensions: Ref<Extension[]>) {
this.extensions.push(extensions)
}
},
getters: {
requestExtensions:
(state) =>
<ExtensionType extends Extension>(type: string, scopes?: ExtensionScope[]) => {
return state.extensions
.map((e) =>
unref(e).filter(
(e) =>
e.type === type &&
!configStore.options.disabledExtensions.includes(e.id) &&
(!scopes || e.scopes?.some((s) => scopes.includes(s)))
)
)
.flat() as ExtensionType[]
}
}
})()
}
export type ExtensionRegistry = ReturnType<typeof useExtensionRegistry>
| owncloud/web/packages/web-pkg/src/composables/piniaStores/extensionRegistry.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/piniaStores/extensionRegistry.ts",
"repo_id": "owncloud",
"token_count": 873
} | 787 |
export * from './useGetResourceContext'
export * from './useLoadFileInfoById'
| owncloud/web/packages/web-pkg/src/composables/resources/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/resources/index.ts",
"repo_id": "owncloud",
"token_count": 23
} | 788 |
import { computed, unref } from 'vue'
import { Resource } from '@ownclouders/web-client/src'
import { queryItemAsString } from '../appDefaults/useAppNavigation'
import { eventBus } from '../../services'
import { useRouteQuery } from '../router'
import { SideBarEventTopics } from '../sideBar'
import { useResourcesStore } from '../piniaStores'
import { isIncomingShareResource } from '@ownclouders/web-client/src/helpers'
export interface ScrollToResult {
scrollToResource(
resourceId: Resource['id'],
options?: { forceScroll?: boolean; topbarElement: string }
): void
scrollToResourceFromRoute(resources: Resource[], topbarElement: string): void
}
export const useScrollTo = (): ScrollToResult => {
const scrollToQuery = useRouteQuery('scrollTo')
const detailsQuery = useRouteQuery('details')
const resourcesStore = useResourcesStore()
const scrollTo = computed(() => {
return queryItemAsString(unref(scrollToQuery))
})
const details = computed(() => {
return queryItemAsString(unref(detailsQuery))
})
const scrollToResource = (
resourceId: Resource['id'],
options = { forceScroll: false, topbarElement: null }
) => {
const resourceElement = document.querySelectorAll(
`[data-item-id='${resourceId}']`
)[0] as HTMLElement
if (!resourceElement) {
eventBus.publish('app.files.navigate.page', {
resourceId,
forceScroll: options.forceScroll,
topbarElement: options.topbarElement
})
return
}
// files-app-bar, admin-settings-app-bar
const topbarElement = document.getElementById(options.topbarElement)
// topbar height + th height + height of one row = offset needed when scrolling top
const topOffset = topbarElement.offsetHeight + resourceElement.offsetHeight * 2
if (
resourceElement.getBoundingClientRect().bottom > window.innerHeight ||
resourceElement.getBoundingClientRect().top < topOffset ||
options.forceScroll
) {
resourceElement.scrollIntoView({ behavior: 'smooth', block: 'center' })
}
}
eventBus.subscribe(
'app.files.navigate.scrollTo',
(data: { resourceId: string; forceScroll: boolean; topbarElement: string }) =>
scrollToResource(data.resourceId, {
forceScroll: data.forceScroll,
topbarElement: data.topbarElement
})
)
const scrollToResourceFromRoute = (resources: Resource[], topbarElement: null) => {
if (!unref(scrollTo) || !resources.length) {
return
}
const resource = unref(resources).find((r) => {
if (isIncomingShareResource(r)) {
return r.shareId === unref(scrollTo)
}
return r.id === unref(scrollTo)
})
if (resource && resource.processing !== true) {
resourcesStore.setSelection([resource.id])
scrollToResource(resource.id, { forceScroll: true, topbarElement })
if (unref(details)) {
eventBus.publish(SideBarEventTopics.openWithPanel, unref(details))
}
}
}
return {
scrollToResource,
scrollToResourceFromRoute
}
}
| owncloud/web/packages/web-pkg/src/composables/scrollTo/useScrollTo.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/scrollTo/useScrollTo.ts",
"repo_id": "owncloud",
"token_count": 1063
} | 789 |
export * from './useSpaceHelpers'
export * from './useGetMatchingSpace'
export * from './useCreateSpace'
| owncloud/web/packages/web-pkg/src/composables/spaces/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/spaces/index.ts",
"repo_id": "owncloud",
"token_count": 33
} | 790 |
export { default as Cache } from './cache'
| owncloud/web/packages/web-pkg/src/helpers/cache/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/helpers/cache/index.ts",
"repo_id": "owncloud",
"token_count": 12
} | 791 |
import { Resource } from '@ownclouders/web-client'
import { basename, join } from 'path'
import { SpaceResource } from '@ownclouders/web-client/src/helpers'
import {
ConflictDialog,
FileConflict,
ResolveStrategy,
TransferType,
isResourceBeeingMovedToSameLocation,
resolveFileNameDuplicate
} from '.'
import { ClientService, LoadingService, LoadingTaskCallbackArguments } from '../../../services'
import { useMessages } from '../../../composables'
import { Ref, unref } from 'vue'
export class ResourceTransfer extends ConflictDialog {
constructor(
private sourceSpace: SpaceResource,
private resourcesToMove: Resource[],
private targetSpace: SpaceResource,
private targetFolder: Resource,
private currentFolder: Ref<Resource>,
private clientService: ClientService,
private loadingService: LoadingService,
$gettext: (
msgid: string,
parameters?: {
[key: string]: string
},
disableHtmlEscaping?: boolean
) => string,
$ngettext: (
msgid: string,
plural: string,
n: number,
parameters?: {
[key: string]: string
},
disableHtmlEscaping?: boolean
) => string
) {
super($gettext, $ngettext)
}
hasRecursion(): boolean {
if (this.sourceSpace.id !== this.targetSpace.id) {
return false
}
return this.resourcesToMove.some(
(resource: Resource) => this.targetFolder.path === resource.path
)
}
showRecursionErrorMessage() {
const count = this.resourcesToMove.length
const title = this.$ngettext(
"You can't paste the selected file at this location because you can't paste an item into itself.",
"You can't paste the selected files at this location because you can't paste an item into itself.",
count
)
const messageStore = useMessages()
messageStore.showErrorMessage({ title })
}
showResultMessage(errors, movedResources: Array<Resource>, transferType: TransferType) {
if (errors.length === 0) {
const count = movedResources.length
if (count === 0) {
return
}
const title =
transferType === TransferType.COPY
? this.$ngettext(
'%{count} item was copied successfully',
'%{count} items were copied successfully',
count,
{ count: count.toString() },
true
)
: this.$ngettext(
'%{count} item was moved successfully',
'%{count} items were moved successfully',
count,
{ count: count.toString() },
true
)
const messageStore = useMessages()
messageStore.showMessage({ title, status: 'success' })
return
}
let title =
transferType === TransferType.COPY
? this.$gettext('Failed to copy %{count} resources', { count: errors.length }, true)
: this.$gettext('Failed to move %{count} resources', { count: errors.length }, true)
if (errors.length === 1) {
title =
transferType === TransferType.COPY
? this.$gettext('Failed to copy "%{name}"', { name: errors[0]?.resourceName }, true)
: this.$gettext('Failed to move "%{name}"', { name: errors[0]?.resourceName }, true)
}
const messageStore = useMessages()
messageStore.showErrorMessage({ title, errors })
}
async perform(transferType: TransferType): Promise<Resource[]> {
if (this.hasRecursion()) {
this.showRecursionErrorMessage()
return []
}
if (this.sourceSpace.id !== this.targetSpace.id && transferType === TransferType.MOVE) {
const doCopyInsteadOfMove = await this.resolveDoCopyInsteadOfMoveForSpaces()
if (!doCopyInsteadOfMove) {
return []
}
transferType = TransferType.COPY
}
const targetFolderResources = (
await this.clientService.webdav.listFiles(this.targetSpace, this.targetFolder)
).children
const resolvedConflicts = await this.resolveAllConflicts(
this.resourcesToMove,
this.targetFolder,
targetFolderResources
)
return this.loadingService.addTask(
({ setProgress }) => {
return this.moveResources(resolvedConflicts, targetFolderResources, transferType, {
setProgress
})
},
{ indeterminate: transferType === TransferType.COPY }
)
}
// This is for an edge case if a user moves a subfolder with the same name as the parent folder into the parent of the parent folder (which is not possible because of the backend)
public isOverwritingParentFolder(
resource: Resource,
targetFolder: Resource,
targetFolderResources: Resource[]
) {
if (resource.type !== 'folder') {
return false
}
if (targetFolder.path === unref(this.currentFolder)?.path) {
return false
}
const folderName = basename(resource.path)
const newPath = join(targetFolder.path, folderName)
return targetFolderResources.some((resource) => resource.path === newPath)
}
private async moveResources(
resolvedConflicts: FileConflict[],
targetFolderResources: Resource[],
transferType: TransferType,
{ setProgress }: LoadingTaskCallbackArguments
) {
const movedResources: Resource[] = []
const errors = []
for (const [i, resourceToMove] of this.resourcesToMove.entries()) {
// shallow copy of resources to prevent modifying existing rows
const resource = { ...resourceToMove }
const hasConflict = resolvedConflicts.some((e) => e.resource.id === resource.id)
let targetName = resource.name
let overwriteTarget = false
if (hasConflict) {
const resolveStrategy = resolvedConflicts.find((e) => e.resource.id === resource.id)
?.strategy
if (resolveStrategy === ResolveStrategy.SKIP) {
continue
}
if (resolveStrategy === ResolveStrategy.REPLACE) {
if (this.isOverwritingParentFolder(resource, this.targetFolder, targetFolderResources)) {
errors.push({ resourceName: resource.name })
continue
}
overwriteTarget = true
}
if (resolveStrategy === ResolveStrategy.KEEP_BOTH) {
targetName = resolveFileNameDuplicate(resource.name, resource.extension, [
...movedResources,
...targetFolderResources
])
resource.name = targetName
}
}
try {
if (
isResourceBeeingMovedToSameLocation(
this.sourceSpace,
resource,
this.targetSpace,
this.targetFolder
) &&
overwriteTarget
) {
continue
}
if (transferType === TransferType.COPY) {
await this.clientService.webdav.copyFiles(
this.sourceSpace,
resource,
this.targetSpace,
{ path: join(this.targetFolder.path, targetName) },
{ overwrite: overwriteTarget }
)
resource.id = undefined
resource.fileId = undefined
} else if (transferType === TransferType.MOVE) {
await this.clientService.webdav.moveFiles(
this.sourceSpace,
resource,
this.targetSpace,
{ path: join(this.targetFolder.path, targetName) },
{ overwrite: overwriteTarget }
)
}
resource.path = join(this.targetFolder.path, resource.name)
resource.webDavPath = join(this.targetFolder.webDavPath, resource.name)
movedResources.push(resource)
} catch (error) {
console.error(error)
error.resourceName = resource.name
errors.push(error)
} finally {
setProgress({ total: this.resourcesToMove.length, current: i + 1 })
}
}
this.showResultMessage(errors, movedResources, transferType)
return movedResources
}
}
| owncloud/web/packages/web-pkg/src/helpers/resource/conflictHandling/transfer.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/helpers/resource/conflictHandling/transfer.ts",
"repo_id": "owncloud",
"token_count": 3125
} | 792 |
export * from './resourceTable'
export * from './resourceTiles'
| owncloud/web/packages/web-pkg/src/helpers/ui/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/helpers/ui/index.ts",
"repo_id": "owncloud",
"token_count": 19
} | 793 |
import { Router, RouteLocationNamedRaw } from 'vue-router'
import merge from 'lodash-es/merge'
import { unref } from 'vue'
export interface ActiveRouteDirectorFunc<T extends string> {
(router: Router, ...comparatives: T[]): boolean
}
/**
* helper function to find out if comparative route location is active or not.
* it uses vue router resolve to do so.
*
* @param router
* @param comparatives
*/
export const isLocationActive = (
router: Router,
...comparatives: [RouteLocationNamedRaw, ...RouteLocationNamedRaw[]]
): boolean => {
// FIXME: router.resolve cleans the path. we don't need it, if we can rely on
// router.currentRoute to not have slashs encoded for paths
const { href: currentHref } = router.resolve(unref(router.currentRoute))
return comparatives
.map((comparative) => {
const { href: comparativeHref } = router.resolve({
...comparative
// ...(comparative.name && { name: resolveRouteName(comparative.name) })
})
/**
* Href might be '/' or '#/' if router is not able to resolve the proper path.
* This happens if the we don't pass a param which is defined in the route configuration, for example:
* path: user/:id
*
* This implies that the comparative route is not active
**/
if (comparativeHref === '/' || comparativeHref === '#/') {
return false
}
return currentHref.startsWith(comparativeHref)
})
.some(Boolean)
}
/**
* wraps isLocationActive to be used as a closure,
* the resulting closure then can be used to check a location against the defined set of director locations
*
* @param defaultComparatives
*/
export const isLocationActiveDirector = <T extends string>(
...defaultComparatives: [RouteLocationNamedRaw, ...RouteLocationNamedRaw[]]
): ActiveRouteDirectorFunc<T> => {
return (router: Router, ...comparatives: T[]): boolean => {
if (!comparatives.length) {
return isLocationActive(router, ...defaultComparatives)
}
const [first, ...rest] = comparatives.map((name) => {
const match = defaultComparatives.find((c) => c.name === name)
if (!match) {
throw new Error(`unknown comparative '${name}'`)
}
return match
})
return isLocationActive(router, first, ...rest)
}
}
/**
* just a dummy function to trick gettext tools
*
* @param msg
*/
export function $gettext(msg: string): string {
return msg
}
/**
* create a location with attached default values
*
* @param name
* @param locations
*/
export const createLocation = (
name: string,
...locations: RouteLocationNamedRaw[]
): RouteLocationNamedRaw =>
merge(
{},
{
name
},
...locations.map((location) => ({
...(location.params && { params: location.params }),
...(location.query && { query: location.query })
}))
)
| owncloud/web/packages/web-pkg/src/router/utils.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/router/utils.ts",
"repo_id": "owncloud",
"token_count": 974
} | 794 |
export interface UppyResource {
id?: string
source: string
name: string
isFolder: boolean
type: string
size: number
data: Blob
isRemote: boolean
meta: {
// IMPORTANT: must only contain primitive types, complex types won't be serialized properly!
name?: string
mtime?: number
// current space & folder
spaceId: string
spaceName: string
driveAlias: string
driveType: string
currentFolder: string // current folder path during upload initiation
currentFolderId?: string
fileId?: string
// upload data
uppyId?: string
relativeFolder: string
relativePath: string
tusEndpoint: string
uploadId: string
topLevelFolderId?: string
// route data
routeName?: string
routeDriveAliasAndItem?: string
routeShareId?: string
}
tus?: {
endpoint: string
}
xhrUpload?: {
endpoint: string
}
}
| owncloud/web/packages/web-pkg/src/services/uppy/types.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/services/uppy/types.ts",
"repo_id": "owncloud",
"token_count": 300
} | 795 |
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`The external app error screen component > displays an icon and a paragraph 1`] = `
"<div class="oc-text-center oc-flex oc-flex-center oc-flex-middle oc-height-1-1">
<oc-icon-stub name="error-warning" filltype="line" accessiblelabel="" type="span" size="xxlarge" variation="passive" color=""></oc-icon-stub>
<p class="oc-text-xlarge">Error when loading the application</p>
</div>"
`;
| owncloud/web/packages/web-pkg/tests/unit/components/AppTemplates/__snapshots__/ErrorScreen.spec.ts.snap/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/components/AppTemplates/__snapshots__/ErrorScreen.spec.ts.snap",
"repo_id": "owncloud",
"token_count": 158
} | 796 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.