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 fill-rule="nonzero" d="M11 2v5H8l4 4 4-4h-3V2h7a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h7zm8 14H5v4h14v-4zm-2 1v2h-2v-2h2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/install-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/install-fill.svg",
"repo_id": "owncloud",
"token_count": 188
} | 751 |
<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="M22 20a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v16zm-11-5H4v4h7v-4zm9-4h-7v8h7v-8zm-9-6H4v8h7V5zm9 0h-7v4h7V5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/layout-masonry-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/layout-masonry-line.svg",
"repo_id": "owncloud",
"token_count": 200
} | 752 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M7.941 18c-.297-1.273-1.637-2.314-2.187-3a8 8 0 1 1 12.49.002c-.55.685-1.888 1.726-2.185 2.998H7.94zM16 20v1a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-1h8zm-3-9.995V6l-4.5 6.005H11v4l4.5-6H13z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/lightbulb-flash-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/lightbulb-flash-fill.svg",
"repo_id": "owncloud",
"token_count": 215
} | 753 |
<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="M6.94 5a2 2 0 1 1-4-.002 2 2 0 0 1 4 .002zM7 8.48H3V21h4V8.48zm6.32 0H9.34V21h3.94v-6.57c0-3.66 4.77-4 4.77 0V21H22v-7.93c0-6.17-7.06-5.94-8.72-2.91l.04-1.68z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/linkedin-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/linkedin-fill.svg",
"repo_id": "owncloud",
"token_count": 209
} | 754 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M18.364 5.636L16.95 7.05A7 7 0 1 0 19 12h2a9 9 0 1 1-2.636-6.364z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/loader-4-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/loader-4-fill.svg",
"repo_id": "owncloud",
"token_count": 129
} | 755 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M10 11H2.05C2.55 5.947 6.814 2 12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10c-5.185 0-9.449-3.947-9.95-9H10v3l5-4-5-4v3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/login-circle-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/login-circle-fill.svg",
"repo_id": "owncloud",
"token_count": 166
} | 756 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M15 3c.552 0 1 .448 1 1v2h4c.552 0 1 .448 1 1v12h2v2H1v-2h2V7c0-.552.448-1 1-1h4V4c0-.552.448-1 1-1h6zm-5 5H8v11h2V8zm6 0h-2v11h2V8zm-2-3h-4v1h4V5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/luggage-deposit-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/luggage-deposit-fill.svg",
"repo_id": "owncloud",
"token_count": 198
} | 757 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M22 12.803A6 6 0 0 0 13.803 21H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v8.803zm-9.94-1.12L5.648 6.238 4.353 7.762l7.72 6.555 7.581-6.56-1.308-1.513-6.285 5.439zM20 18h3l-4 4-4-4h3v-4h2v4z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/mail-download-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/mail-download-fill.svg",
"repo_id": "owncloud",
"token_count": 216
} | 758 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M18.803 8.493A5.023 5.023 0 0 0 22 8.9V20a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h13.1c-.066.323-.1.658-.1 1a4.98 4.98 0 0 0 1.193 3.241l-5.132 4.442-6.414-5.445-1.294 1.524 7.72 6.555 6.73-5.824zM21 7a3 3 0 1 1 0-6 3 3 0 0 1 0 6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/mail-unread-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/mail-unread-fill.svg",
"repo_id": "owncloud",
"token_count": 234
} | 759 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M18.364 17.364L12 23.728l-6.364-6.364a9 9 0 1 1 12.728 0zM11 10H8v2h3v3h2v-3h3v-2h-3V7h-2v3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/map-pin-add-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/map-pin-add-fill.svg",
"repo_id": "owncloud",
"token_count": 152
} | 760 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 6.654a6.786 6.786 0 0 1 2.596 5.344A6.786 6.786 0 0 1 12 17.34a6.786 6.786 0 0 1-2.596-5.343A6.786 6.786 0 0 1 12 6.654zm-.87-.582A7.783 7.783 0 0 0 8.4 12a7.783 7.783 0 0 0 2.728 5.926 6.798 6.798 0 1 1 .003-11.854zm1.742 11.854A7.783 7.783 0 0 0 15.6 12a7.783 7.783 0 0 0-2.73-5.928 6.798 6.798 0 1 1 .003 11.854z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/mastercard-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/mastercard-fill.svg",
"repo_id": "owncloud",
"token_count": 267
} | 761 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M21 18v2H3v-2h18zM17.404 3.904L22 8.5l-4.596 4.596-1.414-1.414L19.172 8.5 15.99 5.318l1.414-1.414zM12 11v2H3v-2h9zm0-7v2H3V4h9z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/menu-unfold-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/menu-unfold-line.svg",
"repo_id": "owncloud",
"token_count": 178
} | 762 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 3a3 3 0 0 0-3 3v4a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zm0-2a5 5 0 0 1 5 5v4a5 5 0 0 1-10 0V6a5 5 0 0 1 5-5zM3.055 11H5.07a7.002 7.002 0 0 0 13.858 0h2.016A9.004 9.004 0 0 1 13 18.945V23h-2v-4.055A9.004 9.004 0 0 1 3.055 11z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/mic-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/mic-line.svg",
"repo_id": "owncloud",
"token_count": 226
} | 763 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm1-9v-1h3v-2h-2.586l2.122-2.121-1.415-1.415L12 8.586 9.879 6.464 8.464 7.88 10.586 10H8v2h3v1H8v2h3v2h2v-2h3v-2h-3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/money-cny-circle-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/money-cny-circle-fill.svg",
"repo_id": "owncloud",
"token_count": 210
} | 764 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M8.67 5.007a7 7 0 0 1 7.55-3.901 4.5 4.5 0 0 0 5.674 5.674c.07.396.106.804.106 1.22a6.969 6.969 0 0 1-.865 3.373A5.5 5.5 0 0 1 17.5 21H9a8 8 0 0 1-.33-15.993zm2.177.207a8.016 8.016 0 0 1 5.61 4.885 5.529 5.529 0 0 1 2.96.245c.226-.425.393-.885.488-1.37a6.502 6.502 0 0 1-5.878-5.88 5.003 5.003 0 0 0-3.18 2.12z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/moon-cloudy-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/moon-cloudy-fill.svg",
"repo_id": "owncloud",
"token_count": 269
} | 765 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M2 3.993A1 1 0 0 1 2.992 3h18.016c.548 0 .992.445.992.993v16.014a1 1 0 0 1-.992.993H2.992A.993.993 0 0 1 2 20.007V3.993zm8.622 4.422a.4.4 0 0 0-.622.332v6.506a.4.4 0 0 0 .622.332l4.879-3.252a.4.4 0 0 0 0-.666l-4.88-3.252z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/movie-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/movie-fill.svg",
"repo_id": "owncloud",
"token_count": 222
} | 766 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M10 2c.552 0 1 .448 1 1v4c0 .552-.448 1-1 1H8v2h5V9c0-.552.448-1 1-1h6c.552 0 1 .448 1 1v4c0 .552-.448 1-1 1h-6c-.552 0-1-.448-1-1v-1H8v6h5v-1c0-.552.448-1 1-1h6c.552 0 1 .448 1 1v4c0 .552-.448 1-1 1h-6c-.552 0-1-.448-1-1v-1H7c-.552 0-1-.448-1-1V8H4c-.552 0-1-.448-1-1V3c0-.552.448-1 1-1h6zm9 16h-4v2h4v-2zm0-8h-4v2h4v-2zM9 4H5v2h4V4z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/node-tree.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/node-tree.svg",
"repo_id": "owncloud",
"token_count": 320
} | 767 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 12a5 5 0 1 1 0-10 5 5 0 0 1 0 10zm6 5v5h-2v-5c0-4.451 2.644-8.285 6.447-10.016l.828 1.82A9.002 9.002 0 0 0 18 17zM8 17v5H6v-5A9.002 9.002 0 0 0 .725 8.805l.828-1.821A11.002 11.002 0 0 1 8 17z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/open-arm-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/open-arm-fill.svg",
"repo_id": "owncloud",
"token_count": 206
} | 768 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4 3h16a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm2 9h6a1 1 0 0 1 1 1v3h1v6h-4v-6h1v-2H5a1 1 0 0 1-1-1v-2h2v1zm11.732 1.732l1.768-1.768 1.768 1.768a2.5 2.5 0 1 1-3.536 0z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/paint-brush-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/paint-brush-fill.svg",
"repo_id": "owncloud",
"token_count": 225
} | 769 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M6 3h7a6 6 0 1 1 0 12H8v6H6V3zm2 2v8h5a4 4 0 1 0 0-8H8z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/parking-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/parking-line.svg",
"repo_id": "owncloud",
"token_count": 129
} | 770 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M15.728 9.686l-1.414-1.414L5 17.586V19h1.414l9.314-9.314zm1.414-1.414l1.414-1.414-1.414-1.414-1.414 1.414 1.414 1.414zM7.242 21H3v-4.243L16.435 3.322a1 1 0 0 1 1.414 0l2.829 2.829a1 1 0 0 1 0 1.414L7.243 21z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/pencil-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/pencil-line.svg",
"repo_id": "owncloud",
"token_count": 216
} | 771 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M2 18h10v2H2v-2zm0-7h14v2H2v-2zm0-7h20v2H2V4zm17 11.17V9h5v2h-3v7a3 3 0 1 1-2-2.83z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/play-list-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/play-list-fill.svg",
"repo_id": "owncloud",
"token_count": 157
} | 772 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M3 7l8.445-5.63a1 1 0 0 1 1.11 0L21 7v14a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7zm9 4a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm-4 5v2h8v-2H8zm0-3v2h8v-2H8z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/price-tag-2-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/price-tag-2-fill.svg",
"repo_id": "owncloud",
"token_count": 186
} | 773 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M11.112 12a4.502 4.502 0 0 0 8.776 0H22v8a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-8h9.112zM5 16h2v2H5v-2zm10.5-2.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zM11.112 10H2V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v6h-2.112a4.502 4.502 0 0 0-8.776 0z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/projector-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/projector-fill.svg",
"repo_id": "owncloud",
"token_count": 237
} | 774 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21 15v5.007a.994.994 0 0 1-.993.993H3.993A.994.994 0 0 1 3 20.007V15h18zM2 11h20v2H2v-2zm19-2H3V3.993C3 3.445 3.445 3 3.993 3h16.014c.548 0 .993.445.993.993V9z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/qr-scan-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/qr-scan-fill.svg",
"repo_id": "owncloud",
"token_count": 183
} | 775 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm0-3a5 5 0 1 1 0-10 5 5 0 0 1 0 10z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/radio-button-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/radio-button-line.svg",
"repo_id": "owncloud",
"token_count": 167
} | 776 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M14.173 9.763A9.98 9.98 0 0 0 19 7.141V4H5v3.141a9.98 9.98 0 0 0 4.827 2.622 2.5 2.5 0 0 1 4.346 0zm.208 2a2.501 2.501 0 0 1-4.762 0A11.94 11.94 0 0 1 5 9.749V20h14V9.748a11.94 11.94 0 0 1-4.619 2.016zM4 2h16a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/red-packet-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/red-packet-line.svg",
"repo_id": "owncloud",
"token_count": 258
} | 777 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M17 12a1 1 0 0 1 1 1v9h-2v-8H8v8H6v-9a1 1 0 0 1 1-1h10zm-5 4v2h-2v-2h2zm0-10a6 6 0 0 1 5.368 3.316l-1.79.895a4 4 0 0 0-7.157 0l-1.789-.895A6 6 0 0 1 12 6zm0-4a10 10 0 0 1 8.946 5.527l-1.789.895A8 8 0 0 0 12 4a8 8 0 0 0-7.157 4.422l-1.79-.895A10 10 0 0 1 12 2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/remote-control-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/remote-control-line.svg",
"repo_id": "owncloud",
"token_count": 259
} | 778 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4 15V8.5a4.5 4.5 0 0 1 9 0v7a2.5 2.5 0 1 0 5 0V8.83a3.001 3.001 0 1 1 2 0v6.67a4.5 4.5 0 1 1-9 0v-7a2.5 2.5 0 0 0-5 0V15h3l-4 5-4-5h3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/route-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/route-fill.svg",
"repo_id": "owncloud",
"token_count": 185
} | 779 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M18 20H6v2H4v-2H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1h-1v2h-2v-2zm-7-6.126V17h2v-3.126A4.002 4.002 0 0 0 12 6a4 4 0 0 0-1 7.874zM12 12a2 2 0 1 1 0-4 2 2 0 0 1 0 4z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/safe-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/safe-fill.svg",
"repo_id": "owncloud",
"token_count": 217
} | 780 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4.257 5.671l2.137 2.137a7 7 0 1 0 1.414-1.414L5.67 4.257A9.959 9.959 0 0 1 12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12c0-2.401.846-4.605 2.257-6.329zm3.571 3.572L12 13.414 13.414 12 9.243 7.828a5 5 0 1 1-1.414 1.414z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/scan-2-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/scan-2-fill.svg",
"repo_id": "owncloud",
"token_count": 221
} | 781 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M7 2h12a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-8.58a1 1 0 0 1 .292-.706l1.562-1.568A.5.5 0 0 0 6 9.793V3a1 1 0 0 1 1-1zm8 2v4h2V4h-2zm-3 0v4h2V4h-2zM9 4v4h2V4H9z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/sd-card-mini-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/sd-card-mini-fill.svg",
"repo_id": "owncloud",
"token_count": 210
} | 782 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M1.923 9.37c-.51-.205-.504-.51.034-.689l19.086-6.362c.529-.176.832.12.684.638l-5.454 19.086c-.15.529-.475.553-.717.07L11 13 1.923 9.37zm4.89-.2l5.636 2.255 3.04 6.082 3.546-12.41L6.812 9.17z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/send-plane-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/send-plane-line.svg",
"repo_id": "owncloud",
"token_count": 204
} | 783 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M9 3v2H4v14h16v-9h2v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h6zm7 2V1l7 6h-9a2 2 0 0 0-2 2v6h-2V9a4 4 0 0 1 4-4h2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/share-forward-box-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/share-forward-box-fill.svg",
"repo_id": "owncloud",
"token_count": 180
} | 784 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path fill-rule="nonzero" d="M15.366 3.438L18.577 9H22v2h-1.167l-.757 9.083a1 1 0 0 1-.996.917H4.92a1 1 0 0 1-.996-.917L3.166 11H2V9h3.422l3.212-5.562 1.732 1L7.732 9h8.535l-2.633-4.562 1.732-1zM18.826 11H5.173l.667 8h12.319l.667-8zM13 13v4h-2v-4h2zm-4 0v4H7v-4h2zm8 0v4h-2v-4h2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/shopping-basket-2-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/shopping-basket-2-line.svg",
"repo_id": "owncloud",
"token_count": 267
} | 785 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M6 4v16h12V7.828L14.172 4H6zM5 2h10l4.707 4.707a1 1 0 0 1 .293.707V21a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1zm8 8v8h-2v-6H8v-2h5zm-5 3h2v2H8v-2zm6 0h2v2h-2v-2zm0-3h2v2h-2v-2zm-6 6h2v2H8v-2zm6 0h2v2h-2v-2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/sim-card-2-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/sim-card-2-line.svg",
"repo_id": "owncloud",
"token_count": 255
} | 786 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path fill-rule="nonzero" d="M12 2c5.523 0 10 4.477 10 10v3.764a2 2 0 0 1-1.106 1.789L18 19v1a3 3 0 0 1-2.824 2.995L14.95 23a2.5 2.5 0 0 0 .044-.33L15 22.5V22a2 2 0 0 0-1.85-1.995L13 20h-2a2 2 0 0 0-1.995 1.85L9 22v.5c0 .171.017.339.05.5H9a3 3 0 0 1-3-3v-1l-2.894-1.447A2 2 0 0 1 2 15.763V12C2 6.477 6.477 2 12 2zm0 2a8 8 0 0 0-7.996 7.75L4 12v3.764l4 2v1.591l.075-.084a3.992 3.992 0 0 1 2.723-1.266L11 18l2.073.001.223.01c.999.074 1.89.51 2.55 1.177l.154.167v-1.591l4-2V12a8 8 0 0 0-8-8zm-4 7a2 2 0 1 1 0 4 2 2 0 0 1 0-4zm8 0a2 2 0 1 1 0 4 2 2 0 0 1 0-4z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/skull-2-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/skull-2-line.svg",
"repo_id": "owncloud",
"token_count": 426
} | 787 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M13 21v2h-2v-2H3a1 1 0 0 1-1-1V6h20v14a1 1 0 0 1-1 1h-8zm-9-2h16V8H4v11zm9-9h5v2h-5v-2zm0 4h5v2h-5v-2zm-4-4v3h3a3 3 0 1 1-3-3zM2 3h20v2H2V3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/slideshow-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/slideshow-line.svg",
"repo_id": "owncloud",
"token_count": 205
} | 788 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4.788 17.444A.5.5 0 0 1 4 17.035V6.965a.5.5 0 0 1 .788-.409l7.133 5.036a.5.5 0 0 1 0 .816l-7.133 5.036zM13 6.965a.5.5 0 0 1 .788-.409l7.133 5.036a.5.5 0 0 1 0 .816l-7.133 5.036a.5.5 0 0 1-.788-.409V6.965z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/speed-mini-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/speed-mini-fill.svg",
"repo_id": "owncloud",
"token_count": 219
} | 789 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21 16l-5.003 5H3.998A.996.996 0 0 1 3 20.007V3.993C3 3.445 3.445 3 3.993 3h16.014c.548 0 .993.447.993.999V16z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/sticky-note-2-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/sticky-note-2-fill.svg",
"repo_id": "owncloud",
"token_count": 149
} | 790 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21 11.646V21a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-9.354A3.985 3.985 0 0 1 2 9V3a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v6c0 1.014-.378 1.94-1 2.646zM14 9a1 1 0 0 1 2 0 2 2 0 1 0 4 0V4H4v5a2 2 0 1 0 4 0 1 1 0 1 1 2 0 2 2 0 1 0 4 0z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/store-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/store-fill.svg",
"repo_id": "owncloud",
"token_count": 219
} | 791 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M15 3c.552 0 1 .448 1 1v2h5c.552 0 1 .448 1 1v13c0 .552-.448 1-1 1H3c-.552 0-1-.448-1-1V7c0-.552.448-1 1-1h5V4c0-.552.448-1 1-1h6zM8 8H6v11h2V8zm10 0h-2v11h2V8zm-4-3h-4v1h4V5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/suitcase-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/suitcase-fill.svg",
"repo_id": "owncloud",
"token_count": 210
} | 792 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M14.515 5l2.606-2.607a1 1 0 0 1 1.415 0l4.242 4.243a1 1 0 0 1 0 1.414L19 11.828V21a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-9.172L1.222 8.05a1 1 0 0 1 0-1.414l4.242-4.243a1 1 0 0 1 1.415 0L9.485 5h5.03z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/t-shirt-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/t-shirt-fill.svg",
"repo_id": "owncloud",
"token_count": 208
} | 793 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M16.988 18l1.216-1.58a1.5 1.5 0 0 0-1.189-2.415H15v-3.976a1.5 1.5 0 0 0-2.69-.914l-6.365 8.281A8.002 8.002 0 0 1 9 2a8.003 8.003 0 0 1 7.458 5.099A5.5 5.5 0 1 1 17.5 18h-.512zM13 16.005h3l-5 6.5v-4.5H8l5-6.505v4.505z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/thunderstorms-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/thunderstorms-fill.svg",
"repo_id": "owncloud",
"token_count": 231
} | 794 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M8 5h8a7 7 0 0 1 0 14H8A7 7 0 0 1 8 5zm8 10a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/toggle-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/toggle-fill.svg",
"repo_id": "owncloud",
"token_count": 132
} | 795 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M7.537 9.95L4.66 7.076 2.186 9.55.772 8.136l6.364-6.364L8.55 3.186 6.075 5.661l2.876 2.876A7.5 7.5 0 1 1 7.537 9.95z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/travesti-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/travesti-fill.svg",
"repo_id": "owncloud",
"token_count": 161
} | 796 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21 3v11.74l-4.696 4.695h-3.913l-2.437 2.348H6.913v-2.348H3V6.13L4.227 3H21zm-1.565 1.565H6.13v11.74h3.13v2.347l2.349-2.348h4.695l3.13-3.13V4.565zm-3.13 3.13v4.696h-1.566V7.696h1.565zm-3.914 0v4.696h-1.565V7.696h1.565z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/twitch-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/twitch-fill.svg",
"repo_id": "owncloud",
"token_count": 242
} | 797 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M10 10v4h4v-4h7v11H3V10h7zm-2 2H5v7h14v-7h-3l-.001 4H8v-4zm8-9v6H8V3h8zm-2 2h-4v2h4V5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/unsplash-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/unsplash-line.svg",
"repo_id": "owncloud",
"token_count": 162
} | 798 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M5 20h14v2H5v-2zm7-2a8 8 0 1 1 0-16 8 8 0 0 1 0 16zm0-2a6 6 0 1 0 0-12 6 6 0 0 0 0 12z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/user-4-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/user-4-line.svg",
"repo_id": "owncloud",
"token_count": 143
} | 799 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M14 14.252v2.09A6 6 0 0 0 6 22l-2-.001a8 8 0 0 1 10-7.748zM12 13c-3.315 0-6-2.685-6-6s2.685-6 6-6 6 2.685 6 6-2.685 6-6 6zm0-2c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm8 6h3v2h-3v3.5L15 18l5-4.5V17z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/user-received-2-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/user-received-2-line.svg",
"repo_id": "owncloud",
"token_count": 234
} | 800 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M5 15v4h4v2H3v-6h2zm16 0v6h-6v-2h4v-4h2zm-8-9v12h-2V6h2zM9 9v6H7V9h2zm8 0v6h-2V9h2zM9 3v2H5v4H3V3h6zm12 0v6h-2V5h-4V3h6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/voice-recognition-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/voice-recognition-line.svg",
"repo_id": "owncloud",
"token_count": 198
} | 801 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M21 2.5v19l-18-2v-15l18-2zm-2 10.499L12 13v5.487l7 .778V13zm-14 4.71l5 .556V13l-5-.001v4.71zM19 11V4.735l-7 .777V11l7-.001zm-9-5.265L5 6.29V11L10 11V5.734z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/windows-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/windows-line.svg",
"repo_id": "owncloud",
"token_count": 193
} | 802 |
<template>
<div class="oc-contextual-helper">
<oc-button :id="buttonId" appearance="raw">
<oc-icon name="question" fill-type="line" size="small" />
</oc-button>
<oc-info-drop :drop-id="dropId" :toggle="toggleId" v-bind="$props as any" />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import uniqueId from '../../utils/uniqueId'
import OcButton from '../OcButton/OcButton.vue'
import OcIcon from '../OcIcon/OcIcon.vue'
import OcInfoDrop from '../OcInfoDrop/OcInfoDrop.vue'
export default defineComponent({
name: 'OcContextualHelper',
status: 'unreleased',
components: { OcButton, OcIcon, OcInfoDrop },
props: {
/**
* Title
*/
title: {
type: String,
required: false,
default: ''
},
/**
* Text at the beginning
*/
text: {
type: String,
required: false,
default: ''
},
/**
* List element
*/
list: {
type: Array,
required: false,
default: () => []
},
/**
* Text at the end
*/
endText: {
type: String,
required: false,
default: ''
},
/**
* Read more link at the end
*/
readMoreLink: {
type: String,
required: false,
default: ''
}
},
computed: {
dropId() {
return uniqueId('oc-contextual-helper-')
},
buttonId() {
return `${this.dropId}-button`
},
toggleId() {
return `#${this.buttonId}`
}
}
})
</script>
<style lang="scss">
.oc-contextual-helper {
display: inline-block;
.oc-button {
vertical-align: middle;
}
}
</style>
<docs>
## Examples
A simple example, using only text.
```js
<template>
<div>
<oc-contextual-helper v-bind="helperContent"/>
</div>
</template>
<script>
export default {
computed: {
helperContent() {
return {
text: "Invite persons or groups to access this file or folder.",
}
}
},
}
</script>
```
An example using Title, Text, List, End-Text and Read-More-Link properties.
```js
<template>
<div>
<oc-contextual-helper v-bind="helperContent"/>
</div>
</template>
<script>
export default {
computed: {
helperContent() {
return {
title: 'Choose how access is granted ',
text: "Share a file or folder by link",
list: [
{text: "Only invited people can access", headline: true},
{text: "Only people from the list \"Invited people\" can access. If there is no list, no people are invited yet."},
{text: "Everyone with the link", headline: true },
{text: "Everyone with the link can access. Note: If you share this link with people from the list \"Invited people\", they need to login-in so that their individual assigned permissions can take effect. If they are not logged-in, the permissions of the link take effect." }
],
endText: "Invited persons can not see who else has access",
readMoreLink: "https://owncloud.design"
}
}
},
}
</script>
```
</docs>
| owncloud/web/packages/design-system/src/components/OcContextualHelper/OcContextualHelper.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcContextualHelper/OcContextualHelper.vue",
"repo_id": "owncloud",
"token_count": 1241
} | 803 |
import { mount } from 'web-test-helpers'
import OcIcon from './OcIcon.vue'
import { glob } from 'glob'
import path from 'path'
describe('OcIcon', () => {
test('render and update', async () => {
const icons = glob.sync(path.resolve(__dirname, '..', 'assets', 'icons', '*.svg')).map((p) => ({
name: path.basename(p, '.svg'),
path: path.relative(__dirname, p)
}))
const wrapper = mount(OcIcon)
await wrapper.vm.$nextTick()
const inlineSvg = wrapper.findComponent({ name: 'inline-svg' })
for (const icon of icons) {
await wrapper.setProps({ name: icon.name })
await inlineSvg.emitted('unloaded')
await inlineSvg.emitted('loaded')
expect(wrapper.find('text').text()).toBe(icon.name)
}
})
})
| owncloud/web/packages/design-system/src/components/OcIcon/OcIcon.spec.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcIcon/OcIcon.spec.ts",
"repo_id": "owncloud",
"token_count": 301
} | 804 |
import OcNotifications from './OcNotifications.vue'
import { shallowMount } from 'web-test-helpers'
describe('OcNotifications', () => {
function getWrapper(options = {}) {
return shallowMount(OcNotifications, options)
}
describe('position prop', () => {
it('should not allow values other than top-left, top-center, top-right', () => {
expect(OcNotifications.props.position.validator('invalid')).toBeFalsy()
})
it.each(['top-left', 'top-center', 'top-right'])(
'should set provided position as class for wrapper',
(position) => {
const wrapper = getWrapper({
props: { position: position }
})
expect(wrapper.attributes('class')).toContain(`oc-notification-${position}`)
}
)
})
it('should render provided slot html', () => {
const wrapper = getWrapper({
slots: {
default:
"<oc-notification-message title='test notification title' message='Testing is good.'/>"
},
global: {
renderStubDefaultSlot: true,
stubs: {
OcNotificationMessage: true
}
}
})
const slotEl = wrapper.find('oc-notification-message-stub')
expect(slotEl.exists()).toBeTruthy()
expect(slotEl.attributes('title')).toBe('test notification title')
expect(slotEl.attributes('message')).toBe('Testing is good.')
})
})
| owncloud/web/packages/design-system/src/components/OcNotifications/OcNotifications.spec.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcNotifications/OcNotifications.spec.ts",
"repo_id": "owncloud",
"token_count": 534
} | 805 |
<template>
<oc-grid
flex
:role="isFilter ? undefined : 'search'"
class="oc-search oc-flex-middle"
:class="{ 'oc-search-small': small }"
>
<div class="oc-width-expand oc-position-relative">
<input
ref="searchInput"
:class="inputClass"
:aria-label="label"
:value="searchQuery"
:disabled="loading"
:placeholder="placeholder"
@input="onType(($event.target as HTMLInputElement).value)"
@keydown.enter="onSearch"
@keyup="$emit('keyup', $event)"
/>
<slot name="locationFilter" />
<oc-button
v-if="icon"
v-oc-tooltip="$gettext('Search')"
:aria-label="$gettext('Search')"
class="oc-position-small oc-position-center-right oc-mt-rm"
appearance="raw"
@click.prevent.stop="$emit('advancedSearch', $event)"
>
<oc-icon v-show="!loading" :name="icon" size="small" fill-type="line" variation="passive" />
<oc-spinner
v-show="loading"
:size="spinnerSize"
:aria-label="loadingAccessibleLabelValue"
/>
</oc-button>
</div>
<div class="oc-search-button-wrapper" :class="{ 'oc-invisible-sr': buttonHidden }">
<oc-button
class="oc-search-button"
variation="primary"
appearance="filled"
:size="small ? 'small' : 'medium'"
:disabled="loading || searchQuery.length < 1"
@click="onSearch"
>
{{ buttonLabel }}
</oc-button>
</div>
<oc-button
v-if="showCancelButton"
:variation="cancelButtonVariation"
:appearance="cancelButtonAppearance"
class="oc-ml-m"
@click="onCancel"
>
<span v-text="$gettext('Cancel')" />
</oc-button>
</oc-grid>
</template>
<script lang="ts">
import { computed, defineComponent, ref, useSlots, watch } from 'vue'
import OcButton from '../OcButton/OcButton.vue'
import OcGrid from '../OcGrid/OcGrid.vue'
import OcIcon from '../OcIcon/OcIcon.vue'
import OcSpinner from '../OcSpinner/OcSpinner.vue'
/**
* The search bar is an input element used for searching server side resources or to filter local results.
*
* ## Accessibility
*
* ### Landmark role=search
* Given there is only one instance of `<oc-search-bar>` per page/route, this component should communicate its purpose, being the main site search, to screen readers ([explainer of landmark roles](https://www.washington.edu/accessibility/web/landmarks/)). If the component serves as a filter form, it is advised to disable the landmark role via `isFilter="true"`.
*
* ### Making sure a submit button exits
*
* Both a search and filter form does need a submit button, regardless if the button is visually perceivable or not. If a "buttonless" look is desired, use `button-hidden="true"`, which renders the button visually hidden.
*
* The `aria-label` of the loading spinner can be set via `customLoadingAccessibleLabel`. If not set, it will default to "Loading results".
*/
export default defineComponent({
name: 'OcSearchBar',
status: 'ready',
release: '1.0.0',
components: {
OcButton,
OcGrid,
OcIcon,
OcSpinner
},
props: {
/**
* Set the search query
*/
value: {
type: String,
required: false,
default: null
},
/**
* The icon to be displayed
*/
icon: {
type: String,
required: false,
default: 'search'
},
/**
* Informative placeholder about the data to be entered
*/
placeholder: {
type: String,
required: false,
default: ''
},
/**
* Informative label about the data to be entered
*/
label: {
type: String,
required: true,
default: ''
},
/**
* Indicator if the search bar should be of smaller size
*/
small: {
type: Boolean,
default: false
},
/**
* Determine the button text
*/
buttonLabel: {
type: [String],
required: false,
default: 'Search'
},
/**
* Determine the button visibility
*/
buttonHidden: {
type: [Boolean],
required: false,
default: false
},
/**
* If set to true the search event is triggered on each entered character
*/
typeAhead: {
type: Boolean,
required: false,
default: false
},
/**
* automatically trim whitespaces around search term
*/
trimQuery: {
type: Boolean,
required: false,
default: true
},
/**
* If set to true data is loaded and the user cannot enter further data
*/
loading: {
type: Boolean,
required: false,
default: false
},
/**
* If set to true the search landmark role is removed since it's not the page's main search function anymore
*/
isFilter: {
type: Boolean,
required: false,
default: false
},
/**
* The aria-label for the loading spinner
*/
loadingAccessibleLabel: {
type: String,
required: false,
default: ''
},
/**
* Show a "cancel" button next to the search bar.
*/
showCancelButton: {
type: Boolean,
required: false,
default: false
},
/**
* Variation of the cancel button
*/
cancelButtonVariation: {
type: String,
required: false,
default: 'primary',
validator: (value: string) => {
return ['passive', 'primary', 'danger', 'success', 'warning', 'brand'].includes(value)
}
},
/**
* Appearance of the cancel button
*/
cancelButtonAppearance: {
type: String,
required: false,
default: 'raw',
validator: (value: string) => {
return ['outline', 'filled', 'raw', 'raw-inverse'].includes(value)
}
},
/**
* Handler function for when the cancel button is clicked.
*/
cancelHandler: {
type: Function,
required: false,
default: () => {}
}
},
emits: ['advancedSearch', 'clear', 'input', 'keyup', 'search'],
setup(props) {
const slots = useSlots()
const query = ref<string>('')
watch(
() => props.value,
() => {
if (!props.value) {
query.value = ''
}
}
)
const inputIconRightPadding = computed(() => {
if (slots.locationFilter?.().length > 0) {
return '125px'
}
return '48px'
})
return { query, inputIconRightPadding }
},
computed: {
searchQuery() {
// please don't treat empty string the same as null...
return this.value === null ? this.query : this.value
},
spinnerSize() {
if (this.small) {
return 'xsmall'
}
return 'medium'
},
inputClass() {
const classes = ['oc-search-input', 'oc-input']
!this.buttonHidden && classes.push('oc-search-input-button')
return classes
},
loadingAccessibleLabelValue() {
return this.loadingAccessibleLabel || this.$gettext('Loading results')
}
},
methods: {
focusSearchInput() {
;(this.$refs.searchInput as HTMLElement).focus()
},
onSearch() {
/**
* Search event on filter or search user input
* @event search
* @type {event}
*/
this.$emit('search', this.query)
},
onType(query) {
this.query = this.trimQuery ? query.trim() : query
/**
* Input event to support model directive
* @event Input
* @type {event}
*/
this.$emit('input', query)
if (this.typeAhead) this.onSearch(query)
},
onCancel() {
this.query = ''
this.onType('')
this.onSearch()
this.cancelHandler()
}
}
})
</script>
<style lang="scss">
.oc-search {
min-width: $form-width-medium;
&-button {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
// Prevent double borders
// from input and button
transform: translateX(-1px);
z-index: 0;
}
&-icon {
align-items: center;
bottom: 0;
color: var(--oc-color-text-muted);
display: inline-flex;
justify-content: center;
left: 0;
position: absolute;
top: 0;
width: 40px;
}
&-input {
border-radius: 25px !important;
border: none;
padding: var(--oc-space-medium);
color: var(--oc-color-input-text-muted) !important;
&:focus {
background-color: var(--oc-color-input-bg);
border-color: var(--oc-color-input-text-default);
color: var(--oc-color-input-text-default);
background-image: none;
}
&::-ms-clear,
&::-ms-reveal {
display: none;
}
}
&-input-icon {
padding-left: var(--oc-space-xlarge) !important;
padding-right: v-bind(inputIconRightPadding) !important;
}
&-input-button {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
&-clear {
right: var(--oc-space-large) !important;
}
&-small {
.oc-search-input {
height: 30px;
line-height: 28px;
padding-left: var(--oc-space-xlarge);
}
.oc-icon {
&,
svg {
height: 18px;
width: 18px;
}
}
}
}
</style>
<docs>
```js
<template>
<div>
<section>
<h3 class="oc-heading-divider">
Search examples
</h3>
<oc-search-bar label="Search files" placeholder="Search files" @search="onSearch" @clear="onClear" />
<div v-if="searchQuery" class="oc-m">Search query: {{ searchQuery }}</div>
<div class="oc-my-m">
<oc-search-bar label="Loading..." placeholder="Loading ..." loadingAccessibleLabel="Custom loading aria label" :loading="true" />
</div>
<div class="oc-my-m">
<oc-search-bar small label="Small searchbar" placeholder="Small searchbar" :loading="true" />
</div>
</section>
<section>
<h3 class="oc-heading-divider">
Search example with visually hidden button
</h3>
<div class="oc-mb">
<oc-search-bar label="Search files" placeholder="Search files" @search="onSearch" @clear="onClear" :button-hidden="true" />
</div>
</section>
<section>
<h3 class="oc-heading-divider">
Filter examples
</h3>
<oc-search-bar :isFilter="true" label="Search files" placeholder="Filter Files ..." :type-ahead="true" @search="onFilter" button="Filter" icon="" />
<div v-if="filterQuery" class="oc-m">Filter query: {{ filterQuery }}</div>
</section>
<section>
<h3 class="oc-heading-divider">
Search with cancel button
</h3>
<oc-search-bar label="Search files" placeholder="Enter search term" :type-ahead="true" :show-cancel-button="true" />
</section>
</div>
</template>
<script>
export default {
data: () => {
return {
filterQuery: '',
searchQuery: ''
}
},
methods: {
onFilter(val) {
this.filterQuery = val
},
onSearch(val) {
this.searchQuery = val
},
onClear () {
alert('Query has been cleared')
}
}
}
</script>
```
</docs>
| owncloud/web/packages/design-system/src/components/OcSearchBar/OcSearchBar.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcSearchBar/OcSearchBar.vue",
"repo_id": "owncloud",
"token_count": 4698
} | 806 |
import { shallowMount, mount, defaultPlugins } from 'web-test-helpers'
import OcTextInput from './OcTextInput.vue'
import { PasswordPolicy } from '../../helpers'
import { mock } from 'vitest-mock-extended'
const defaultProps = {
label: 'label'
}
Object.assign(navigator, {
clipboard: {
writeText: vi.fn(),
readText: vi.fn()
}
})
// @vitest-environment jsdom
describe('OcTextInput', () => {
function getShallowWrapper(props = {}) {
return shallowMount(OcTextInput, {
props: {
...defaultProps,
...props
},
global: { plugins: [...defaultPlugins()] }
})
}
function getMountedWrapper(
options: { props?: Record<string, unknown>; attachTo?: HTMLElement } = { props: {} },
passwordPolicy = { active: false, pass: false }
) {
const passwordPolicyMock = mock<PasswordPolicy>()
passwordPolicyMock.missing.mockReturnValueOnce({
rules: [
{
code: 'minLength',
message: 'At least %{param1} characters',
format: ['8'],
verified: passwordPolicy.pass
}
]
})
passwordPolicyMock.check.mockReturnValueOnce(passwordPolicy.pass)
if (passwordPolicy.active) {
options.props = { ...(options.props || {}), passwordPolicy: passwordPolicyMock }
}
return mount(OcTextInput, {
...options,
global: {
plugins: [...defaultPlugins()]
}
})
}
const selectors = {
textInputMessage: '.oc-text-input-message span',
clearInputButton: '.oc-text-input-btn-clear',
inputField: '.oc-text-input',
infoIcon: '.oc-text-input-message .oc-icon',
showPasswordToggleBtn: '.oc-text-input-show-password-toggle',
copyPasswordBtn: '.oc-text-input-copy-password-button',
generatePasswordBtn: '.oc-text-input-generate-password-button'
}
describe('id prop', () => {
const wrapper = getShallowWrapper({ id: 'test-input-id', descriptionMessage: 'hello' })
it('should set provided id to the input', () => {
expect(wrapper.find('input').attributes().id).toBe('test-input-id')
})
it('should set label target for provided id', () => {
expect(wrapper.find('label').attributes().for).toBe('test-input-id')
})
it('should set message id according to provided id', () => {
expect(wrapper.find(selectors.textInputMessage).attributes().id).toBe('test-input-id-message')
})
})
describe('label prop', () => {
it('should set provided label to the input', () => {
const wrapper = getShallowWrapper()
expect(wrapper.find('label').text()).toBe('label')
})
})
describe('password input field', () => {
describe('copy password button', () => {
it('should not exist if type is not "password" or no value entered', () => {
const wrapper = getMountedWrapper()
expect(wrapper.find(selectors.copyPasswordBtn).exists()).toBeFalsy()
const wrapper2 = getMountedWrapper({ props: { type: 'password' } })
expect(wrapper2.find(selectors.copyPasswordBtn).exists()).toBeFalsy()
})
it('should not exist if the input is disabled', () => {
const wrapper = getMountedWrapper({ props: { type: 'password', disabled: true } })
expect(wrapper.find(selectors.copyPasswordBtn).exists()).toBeFalsy()
})
it('should exist if type is "password" and value entered', async () => {
const wrapper = getMountedWrapper({ props: { type: 'password' } })
await wrapper.find(selectors.inputField).setValue('password')
expect(wrapper.find(selectors.copyPasswordBtn).exists()).toBeTruthy()
})
it('should copy password to clipboard if clicked', async () => {
const wrapper = getMountedWrapper({ props: { type: 'password' } })
await wrapper.find(selectors.inputField).setValue('password')
await wrapper.find(selectors.copyPasswordBtn).trigger('click')
expect(navigator.clipboard.writeText).toHaveBeenCalledWith('password')
})
})
describe('show hide password toggle button', () => {
it('should not exist if type is not "password" or no value entered', () => {
const wrapper = getMountedWrapper()
expect(wrapper.find(selectors.showPasswordToggleBtn).exists()).toBeFalsy()
const wrapper2 = getMountedWrapper({ props: { type: 'password' } })
expect(wrapper2.find(selectors.showPasswordToggleBtn).exists()).toBeFalsy()
})
it('should not exist if the input is disabled', () => {
const wrapper = getMountedWrapper({ props: { type: 'password', disabled: true } })
expect(wrapper.find(selectors.showPasswordToggleBtn).exists()).toBeFalsy()
})
it('should exist if type is "password" and value entered', async () => {
const wrapper = getMountedWrapper({ props: { type: 'password' } })
await wrapper.find(selectors.inputField).setValue('password')
expect(wrapper.find(selectors.showPasswordToggleBtn).exists()).toBeTruthy()
})
it('should show password plaintext/veiled if clicked', async () => {
const wrapper = getMountedWrapper({ props: { type: 'password' } })
await wrapper.find(selectors.inputField).setValue('password')
await wrapper.find(selectors.showPasswordToggleBtn).trigger('click')
expect(wrapper.find(selectors.inputField).attributes().type).toBe('text')
await wrapper.find(selectors.showPasswordToggleBtn).trigger('click')
expect(wrapper.find(selectors.inputField).attributes().type).toBe('password')
})
})
describe('generate password button', () => {
it('should not exist if type is not "password" or prop "generatePasswordMethod" is not provided', () => {
const wrapper = getMountedWrapper()
expect(wrapper.find(selectors.generatePasswordBtn).exists()).toBeFalsy()
const wrapper2 = getMountedWrapper({ props: { type: 'password' } })
expect(wrapper2.find(selectors.generatePasswordBtn).exists()).toBeFalsy()
})
it('should not exist if the input is disabled', () => {
const wrapper = getMountedWrapper({ props: { type: 'password', disabled: true } })
expect(wrapper.find(selectors.generatePasswordBtn).exists()).toBeFalsy()
})
it('should exist if type is "password" and prop "generatePasswordMethod" is provided', () => {
const wrapper = getMountedWrapper({
props: { generatePasswordMethod: vi.fn(), type: 'password' }
})
expect(wrapper.find(selectors.generatePasswordBtn).exists()).toBeTruthy()
})
it('should fill input with generated password if clicked', async () => {
const wrapper = getMountedWrapper({
props: { generatePasswordMethod: vi.fn(() => 'PAssword12#!'), type: 'password' }
})
await wrapper.find(selectors.generatePasswordBtn).trigger('click')
expect((wrapper.find(selectors.inputField).element as HTMLInputElement).value).toEqual(
'PAssword12#!'
)
})
})
describe('password policy', () => {
it('should emit "passwordChallengeFailed" if password does not match criteria', async () => {
const wrapper = getMountedWrapper(
{
props: { type: 'password' }
},
{ active: true, pass: false }
)
await wrapper.find(selectors.inputField).setValue('pass')
expect(wrapper.emitted('passwordChallengeCompleted')).toBeFalsy()
})
it('should emit "passwordChallengeCompleted" if password matches criteria', async () => {
const wrapper = getMountedWrapper(
{
props: { type: 'password' }
},
{ active: true, pass: true }
)
await wrapper.find(selectors.inputField).setValue('password123')
expect(wrapper.emitted('passwordChallengeCompleted')).toBeTruthy()
})
it('displays error state if password does not match criteria', async () => {
const wrapper = getMountedWrapper(
{
props: { type: 'password' }
},
{ active: true, pass: false }
)
await wrapper.find(selectors.inputField).setValue('pass')
expect(wrapper.html()).toMatchSnapshot()
})
it('displays success state if password matches criteria', async () => {
const wrapper = getMountedWrapper(
{
props: { type: 'password' }
},
{ active: true, pass: true }
)
await wrapper.find(selectors.inputField).setValue('password123')
expect(wrapper.html()).toMatchSnapshot()
})
})
})
describe('when a description message is provided', () => {
const wrapper = getShallowWrapper({ descriptionMessage: 'You should pass.' })
it('should add the description class to the input message', () => {
expect(wrapper.find(selectors.textInputMessage).attributes().class).toContain(
'oc-text-input-description'
)
})
it('should show the description message as the input message text', () => {
expect(wrapper.find(selectors.textInputMessage).text()).toBe('You should pass.')
})
const mountedWrapper = getMountedWrapper({ props: { descriptionMessage: 'You should pass.' } })
it('should show an info icon', () => {
expect(mountedWrapper.find(selectors.infoIcon).exists()).toBe(true)
})
})
describe('when a warning message is provided', () => {
const wrapper = getShallowWrapper({ warningMessage: 'You may pass.' })
it('should add the warning class to the input', () => {
expect(wrapper.find('input').attributes().class).toContain('oc-text-input-warning')
})
it('should add the warning class to the input message', () => {
expect(wrapper.find(selectors.textInputMessage).attributes().class).toContain(
'oc-text-input-warning'
)
})
it('should show the warning message as the input message text', () => {
expect(wrapper.find(selectors.textInputMessage).text()).toBe('You may pass.')
})
})
describe('when an error message is provided', () => {
const wrapper = getShallowWrapper({ errorMessage: 'You shall not pass.' })
it('should add the error class to the input', () => {
expect(wrapper.find('input').attributes().class).toContain('oc-text-input-danger')
})
it('should add the error class to the input message', () => {
expect(wrapper.find(selectors.textInputMessage).attributes().class).toContain(
'oc-text-input-danger'
)
})
it('should show the error message as the input message text', () => {
expect(wrapper.find(selectors.textInputMessage).text()).toBe('You shall not pass.')
})
it('should set the input aria-invalid attribute to true', () => {
expect(wrapper.find('input').attributes('aria-invalid')).toBe('true')
})
})
describe('message priority', () => {
it('should give error message top priority', () => {
const wrapper = getShallowWrapper({
errorMessage: 'You shall not pass.',
warningMessage: 'You may pass.',
descriptionMessage: 'Your should pass.'
})
const messageEl = wrapper.find('.oc-text-input-message span')
expect(messageEl.attributes().class).toBe(
'oc-text-input-description oc-text-input-warning oc-text-input-danger'
)
expect(messageEl.text()).toBe('You shall not pass.')
})
it('should give waring message priority over description message', () => {
const wrapper = getShallowWrapper({
warningMessage: 'You may pass.',
descriptionMessage: 'Your should pass.'
})
const messageEl = wrapper.find(selectors.textInputMessage)
expect(messageEl.attributes().class).toBe('oc-text-input-description oc-text-input-warning')
expect(messageEl.text()).toBe('You may pass.')
})
})
describe('type prop', () => {
it('should only allow text, number, email and password as type', () => {
expect(OcTextInput.props.type.validator('binary')).toBeFalsy()
})
it.each(['text', 'number', 'email', 'password'])(
'should set the provided type for the input',
(type) => {
const wrapper = getMountedWrapper({ props: { type: type } })
expect(wrapper.find('input').attributes('type')).toBe(type)
}
)
})
describe('input events', () => {
it('should emit an input event on typing', async () => {
const wrapper = getShallowWrapper()
expect(wrapper.emitted().input).toBeFalsy()
await wrapper.find('input').setValue('a')
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
expect(wrapper.emitted('update:modelValue')[0][0]).toBe('a')
})
})
describe('clear-button accessible label prop', () => {
it('should set the aria label attribute if provided', () => {
const wrapper = getShallowWrapper({
clearButtonEnabled: true,
modelValue: 'non-empty-value',
clearButtonAccessibleLabel: 'test label'
})
expect(wrapper.find(selectors.clearInputButton).attributes().arialabel).toBe('test label')
})
})
describe('clear input', () => {
it('has no clear button when it is disabled', () => {
const wrapper = getShallowWrapper({
modelValue: 'non-empty-value',
clearButtonEnabled: true,
disabled: true
})
expect(wrapper.find(selectors.clearInputButton).exists()).toBeFalsy()
})
it('has clear button when it is enabled but the input is an empty string but not null', () => {
const wrapper = getShallowWrapper({
clearButtonEnabled: true,
modelValue: ''
})
expect(wrapper.find(selectors.clearInputButton).exists()).toBeTruthy()
})
it('has no clear button when it is enabled but the input is null', () => {
const wrapper = getShallowWrapper({
clearButtonEnabled: true,
modelValue: null
})
expect(wrapper.find(selectors.clearInputButton).exists()).toBeFalsy()
})
it('has a clear button when it is enabled and the input contains content', () => {
const wrapper = getShallowWrapper({
clearButtonEnabled: true,
modelValue: 'non-empty-value'
})
const btn = wrapper.find(selectors.clearInputButton)
expect(btn.exists()).toBeTruthy()
})
it('clears the content on click', async () => {
const wrapper = getMountedWrapper({
props: {
...defaultProps,
clearButtonEnabled: true,
modelValue: 'non-empty-value'
},
attachTo: document.body
})
const btn = wrapper.find(selectors.clearInputButton)
const input = wrapper.find(selectors.inputField)
await btn.trigger('click')
// value as data is supposed to be `null`
expect(wrapper.emitted('update:modelValue')[0][0]).toEqual(null)
// value in DOM would be the empty string if two way binding was used
// by just passing in the value it should remain unchanged
expect((input.element as HTMLInputElement).value).toEqual('non-empty-value')
expect(document.activeElement.id).toBe(input.element.id)
})
})
})
| owncloud/web/packages/design-system/src/components/OcTextInput/OcTextInput.spec.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcTextInput/OcTextInput.spec.ts",
"repo_id": "owncloud",
"token_count": 5697
} | 807 |
<template>
<oc-table-cell
type="th"
:align-h="alignH"
:align-v="alignV"
:width="width"
:wrap="wrap"
class="oc-th"
@click="$emit('click', $event)"
>
<slot />
</oc-table-cell>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import OcTableCell from '../_OcTableCell/_OcTableCell.vue'
export default defineComponent({
name: 'OcTh',
status: 'ready',
release: '2.1.0',
components: { OcTableCell },
props: {
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: 'nowrap',
validator: (wrap: string) => ['break', 'nowrap', 'truncate'].includes(wrap)
}
},
emits: ['click']
})
</script>
<style lang="scss">
.oc-th {
color: var(--oc-color-text-muted);
font-weight: inherit;
&[aria-sort] {
cursor: pointer;
}
}
</style>
| owncloud/web/packages/design-system/src/components/_OcTableCellHead/_OcTableCellHead.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/_OcTableCellHead/_OcTableCellHead.vue",
"repo_id": "owncloud",
"token_count": 541
} | 808 |
export interface ContextualHelperDataListItem {
text: string
headline?: boolean
}
export interface ContextualHelperData {
title: string
text?: string
list?: ContextualHelperDataListItem[]
readMoreLink?: string
}
export interface ContextualHelper {
isEnabled: boolean
data: ContextualHelperData
}
export interface PasswordPolicy {
rules: unknown[]
check(password: string): boolean
missing(password: string): {
rules: {
code: string
message: string
format: (number | string)[]
verified: boolean
}[]
}
}
| owncloud/web/packages/design-system/src/helpers/types.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/helpers/types.ts",
"repo_id": "owncloud",
"token_count": 173
} | 809 |
$directives: ("m": "margin");
@each $directiveKey, $directiveValue in $directives {
.-oc-#{$directiveKey} {
#{$directiveValue}: calc(-1 * $oc-space-medium) !important;
@each $directionKey, $directionValues in $directions {
&#{$directionKey} {
@each $direction in $directionValues {
#{$directiveValue}-#{$direction}: calc(-1 * $oc-space-medium) !important;
@each $sizeKey, $sizeValue in $sizes {
&-#{$sizeKey} {
#{$directiveValue}-#{$direction}: calc(-1 * $sizeValue) !important;
}
}
}
}
}
@each $sizeKey, $sizeValue in $sizes {
&-#{$sizeKey} {
#{$directiveValue}: calc(-1 * $sizeValue) !important;
}
}
}
}
| owncloud/web/packages/design-system/src/styles/theme/oc-spacing-negative.scss/0 | {
"file_path": "owncloud/web/packages/design-system/src/styles/theme/oc-spacing-negative.scss",
"repo_id": "owncloud",
"token_count": 358
} | 810 |
/**
* Share type
*/
export const shareType = {
user: 0,
group: 1,
link: 3,
guest: 4,
remote: 6
}
| owncloud/web/packages/design-system/src/utils/shareType.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/utils/shareType.ts",
"repo_id": "owncloud",
"token_count": 46
} | 811 |
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext",
/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "es2020",
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"lib": [
"ESNext",
"es2020",
"dom"
],
/* Specify library files to be included in the compilation. */
//"allowJs": true,
/* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
"downlevelIteration": true,
/* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
"isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false,
/* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
"moduleResolution": "node",
/* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
"types": ["vitest/globals"],
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true,
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
"experimentalDecorators": true,
/* Enables experimental support for ES7 decorators. */
//"emitDecoratorMetadata": true,
/* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true,
/* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true,
/* Disallow inconsistently-cased references to the same file. */
"resolveJsonModule": true
},
"exclude": [
"node_modules"
],
"vueCompilerOptions": {
"target": 3
}
}
| owncloud/web/packages/tsconfig/tsconfig.json/0 | {
"file_path": "owncloud/web/packages/tsconfig/tsconfig.json",
"repo_id": "owncloud",
"token_count": 2519
} | 812 |
<template>
<div>
<context-action-menu :menu-sections="menuSections" :action-options="{ resources: items }" />
</div>
</template>
<script lang="ts">
import { computed, defineComponent, PropType, unref } from 'vue'
import { SpaceResource } from '@ownclouders/web-client'
import { ContextActionMenu } from '@ownclouders/web-pkg'
import {
useSpaceActionsDelete,
useSpaceActionsDisable,
useSpaceActionsEditDescription,
useSpaceActionsEditQuota,
useSpaceActionsRename,
useSpaceActionsRestore,
useActionsShowDetails
} from '@ownclouders/web-pkg'
export default defineComponent({
name: 'ContextActions',
components: { ContextActionMenu },
props: {
items: {
type: Array as PropType<SpaceResource[]>,
required: true
}
},
setup(props) {
const filterParams = computed(() => ({ resources: props.items }))
const { actions: deleteActions } = useSpaceActionsDelete()
const { actions: disableActions } = useSpaceActionsDisable()
const { actions: editQuotaActions } = useSpaceActionsEditQuota()
const { actions: editDescriptionActions } = useSpaceActionsEditDescription()
const { actions: renameActions } = useSpaceActionsRename()
const { actions: restoreActions } = useSpaceActionsRestore()
const { actions: showDetailsActions } = useActionsShowDetails()
const menuItemsPrimaryActions = computed(() =>
[...unref(renameActions), ...unref(editDescriptionActions)].filter((item) =>
item.isVisible(unref(filterParams))
)
)
const menuItemsSecondaryActions = computed(() =>
[
...unref(editQuotaActions),
...unref(disableActions),
...unref(restoreActions),
...unref(deleteActions)
].filter((item) => item.isVisible(unref(filterParams)))
)
const menuItemsSidebar = computed(() =>
[...unref(showDetailsActions)].filter((item) => item.isVisible(unref(filterParams)))
)
const menuSections = computed(() => {
const sections = []
if (unref(menuItemsPrimaryActions).length) {
sections.push({
name: 'primaryActions',
items: unref(menuItemsPrimaryActions)
})
}
if (unref(menuItemsSecondaryActions).length) {
sections.push({
name: 'secondaryActions',
items: unref(menuItemsSecondaryActions)
})
}
if (unref(menuItemsSidebar).length) {
sections.push({
name: 'sidebar',
items: unref(menuItemsSidebar)
})
}
return sections
})
return {
menuSections
}
}
})
</script>
| owncloud/web/packages/web-app-admin-settings/src/components/Spaces/ContextActions.vue/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/components/Spaces/ContextActions.vue",
"repo_id": "owncloud",
"token_count": 1007
} | 813 |
import { useGettext } from 'vue3-gettext'
import { computed } from 'vue'
import { useAbility, useClientService, useMessages, useRouter } from '@ownclouders/web-pkg'
import { Action } from '@ownclouders/web-pkg'
export const useGeneralActionsResetLogo = () => {
const { showMessage, showErrorMessage } = useMessages()
const { $gettext } = useGettext()
const ability = useAbility()
const clientService = useClientService()
const router = useRouter()
const handler = async () => {
try {
const httpClient = clientService.httpAuthenticated
await httpClient.delete('/branding/logo')
showMessage({ title: $gettext('Logo was reset successfully. Reloading page...') })
setTimeout(() => {
router.go(0)
}, 1000)
} catch (e) {
console.error(e)
showErrorMessage({
title: $gettext('Failed to reset logo'),
errors: [e]
})
}
}
const actions = computed((): Action[] => [
{
name: 'reset-logo',
icon: 'restart',
label: () => {
return $gettext('Reset logo')
},
isVisible: () => {
return ability.can('update-all', 'Logo')
},
handler,
componentType: 'button',
class: 'oc-general-actions-reset-logo-trigger'
}
])
return {
actions
}
}
| owncloud/web/packages/web-app-admin-settings/src/composables/actions/general/useGeneralActionsResetLogo.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/composables/actions/general/useGeneralActionsResetLogo.ts",
"repo_id": "owncloud",
"token_count": 518
} | 814 |
export * from './useKeyboardTableNavigation'
export * from './useKeyboardTableMouseActions'
| owncloud/web/packages/web-app-admin-settings/src/composables/keyboardActions/index.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/composables/keyboardActions/index.ts",
"repo_id": "owncloud",
"token_count": 27
} | 815 |
import GroupsList from '../../../../src/components/Groups/GroupsList.vue'
import { defaultComponentMocks, defaultPlugins, mount, shallowMount } from 'web-test-helpers'
import { displayPositionedDropdown, eventBus, queryItemAsString } from '@ownclouders/web-pkg'
import { SideBarEventTopics } from '@ownclouders/web-pkg'
import { useGroupSettingsStore } from '../../../../src/composables'
const getGroupMocks = () => [
{ id: '1', members: [] },
{ id: '2', members: [] }
]
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
queryItemAsString: vi.fn(),
displayPositionedDropdown: vi.fn()
}))
describe('GroupsList', () => {
describe('method "orderBy"', () => {
it('should return an ascending ordered list while desc is set to false', () => {
const { wrapper } = getWrapper()
expect(
wrapper.vm.orderBy(
[{ displayName: 'users' }, { displayName: 'admins' }],
'displayName',
false
)
).toEqual([{ displayName: 'admins' }, { displayName: 'users' }])
})
it('should return an descending ordered list while desc is set to true', () => {
const { wrapper } = getWrapper()
expect(
wrapper.vm.orderBy(
[{ displayName: 'admins' }, { displayName: 'users' }],
'displayName',
true
)
).toEqual([{ displayName: 'users' }, { displayName: 'admins' }])
})
})
describe('method "filter"', () => {
it('should return a list containing record admins if search term is "ad"', () => {
const { wrapper } = getWrapper()
expect(
wrapper.vm.filter([{ displayName: 'users' }, { displayName: 'admins' }], 'ad')
).toEqual([{ displayName: 'admins' }])
})
it('should return an an empty list if search term does not match any entry', () => {
const { wrapper } = getWrapper()
expect(
wrapper.vm.filter([{ displayName: 'admins' }, { displayName: 'users' }], 'ownClouders')
).toEqual([])
})
})
it('should show the context menu on right click', async () => {
const groups = getGroupMocks()
const spyDisplayPositionedDropdown = vi.mocked(displayPositionedDropdown)
const { wrapper } = getWrapper({ mountType: mount, groups })
await wrapper.find(`[data-item-id="${groups[0].id}"]`).trigger('contextmenu')
expect(spyDisplayPositionedDropdown).toHaveBeenCalledTimes(1)
})
it('should show the context menu on context menu button click', async () => {
const groups = getGroupMocks()
const spyDisplayPositionedDropdown = vi.mocked(displayPositionedDropdown)
const { wrapper } = getWrapper({ mountType: mount, groups })
await wrapper.find('.groups-table-btn-action-dropdown').trigger('click')
expect(spyDisplayPositionedDropdown).toHaveBeenCalledTimes(1)
})
it('should show the group details on details button click', async () => {
const groups = getGroupMocks()
const eventBusSpy = vi.spyOn(eventBus, 'publish')
const { wrapper } = getWrapper({ mountType: mount, groups })
await wrapper.find('.groups-table-btn-details').trigger('click')
expect(eventBusSpy).toHaveBeenCalledWith(SideBarEventTopics.open)
})
describe('toggle selection', () => {
describe('selectGroups method', () => {
it('selects all groups', () => {
const groups = getGroupMocks()
const { wrapper } = getWrapper({ mountType: shallowMount, groups })
wrapper.vm.selectGroups(groups)
const { setSelectedGroups } = useGroupSettingsStore()
expect(setSelectedGroups).toHaveBeenCalledWith(groups)
})
})
describe('selectGroup method', () => {
it('selects a group', () => {
const groups = getGroupMocks()
const { wrapper } = getWrapper({ mountType: shallowMount, groups: [groups[0]] })
wrapper.vm.selectGroup(groups[0])
const { addSelectedGroup } = useGroupSettingsStore()
expect(addSelectedGroup).toHaveBeenCalledWith(groups[0])
})
it('de-selects a selected group', () => {
const groups = getGroupMocks()
const { wrapper } = getWrapper({
mountType: shallowMount,
groups: [groups[0]],
selectedGroups: [groups[0]]
})
wrapper.vm.selectGroup(groups[0])
const { setSelectedGroups } = useGroupSettingsStore()
expect(setSelectedGroups).toHaveBeenCalledWith([])
})
})
describe('unselectAllGroups method', () => {
it('de-selects all selected groups', () => {
const groups = getGroupMocks()
const { wrapper } = getWrapper({
mountType: shallowMount,
groups: [groups[0]],
selectedGroups: [groups[0]]
})
wrapper.vm.unselectAllGroups()
const { setSelectedGroups } = useGroupSettingsStore()
expect(setSelectedGroups).toHaveBeenCalledWith([])
})
})
})
})
function getWrapper({ mountType = shallowMount, groups = [], selectedGroups = [] } = {}) {
vi.mocked(queryItemAsString).mockImplementationOnce(() => '1')
vi.mocked(queryItemAsString).mockImplementationOnce(() => '100')
const mocks = defaultComponentMocks()
return {
wrapper: mountType(GroupsList, {
props: {
headerPosition: 0
},
global: {
plugins: [
...defaultPlugins({
piniaOptions: {
groupSettingsStore: { groups, selectedGroups }
}
})
],
mocks,
provide: mocks,
stubs: {
OcCheckbox: true
}
}
})
}
}
| owncloud/web/packages/web-app-admin-settings/tests/unit/components/Groups/GroupsList.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/components/Groups/GroupsList.spec.ts",
"repo_id": "owncloud",
"token_count": 2195
} | 816 |
import GroupSelect from '../../../../src/components/Users/GroupSelect.vue'
import { defaultPlugins, shallowMount } from 'web-test-helpers'
import { mock } from 'vitest-mock-extended'
import { Group } from '@ownclouders/web-client/src/generated'
const groupMock = mock<Group>({ id: '1', groupTypes: [] })
describe('GroupSelect', () => {
it('renders the select input', () => {
const { wrapper } = getWrapper()
expect(wrapper.html()).toMatchSnapshot()
})
it('correctly maps the read-only state', () => {
const groupMock = mock<Group>({ id: '1', groupTypes: ['ReadOnly'] })
const { wrapper } = getWrapper(groupMock)
expect(wrapper.vm.selectedOptions[0].readonly).toBeTruthy()
})
it('emits "selectedOptionChange" on update', () => {
const group = mock<Group>({ id: '2', groupTypes: [] })
const { wrapper } = getWrapper()
wrapper.vm.onUpdate(group)
expect(wrapper.emitted().selectedOptionChange).toBeTruthy()
expect(wrapper.vm.selectedOptions).toEqual(group)
})
})
function getWrapper(group = groupMock) {
return {
wrapper: shallowMount(GroupSelect, {
props: {
selectedGroups: [group],
groupOptions: [group]
},
global: {
plugins: [...defaultPlugins()]
}
})
}
}
| owncloud/web/packages/web-app-admin-settings/tests/unit/components/Users/GroupSelect.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/components/Users/GroupSelect.spec.ts",
"repo_id": "owncloud",
"token_count": 471
} | 817 |
import { useUserActionsDelete } from '../../../../../src/composables/actions/users/useUserActionsDelete'
import { mock } from 'vitest-mock-extended'
import { unref } from 'vue'
import { User } from '@ownclouders/web-client/src/generated'
import { useCapabilityStore } from '@ownclouders/web-pkg'
import { defaultComponentMocks, getComposableWrapper, writable } from 'web-test-helpers'
import { useUserSettingsStore } from '../../../../../src/composables/stores/userSettings'
describe('useUserActionsDelete', () => {
describe('method "isVisible"', () => {
it.each([
{ resources: [], disabledViaCapability: false, isVisible: false },
{ resources: [mock<User>()], disabledViaCapability: false, isVisible: true },
{ resources: [mock<User>(), mock<User>()], disabledViaCapability: false, isVisible: true },
{ resources: [mock<User>(), mock<User>()], disabledViaCapability: true, isVisible: false }
])(
'should only return true if 1 or more users are selected and not disabled via capability',
({ resources, disabledViaCapability, isVisible }) => {
getWrapper({
setup: ({ actions }) => {
const capabilityStore = useCapabilityStore()
writable(capabilityStore).graphUsersDeleteDisabled = !!disabledViaCapability
expect(unref(actions)[0].isVisible({ resources })).toEqual(isVisible)
}
})
}
)
})
describe('method "deleteUsers"', () => {
it('should successfully delete all given users and reload the users list', () => {
getWrapper({
setup: async ({ deleteUsers }, { clientService }) => {
const user = mock<User>({ id: '1' })
await deleteUsers([user])
expect(clientService.graphAuthenticated.users.deleteUser).toHaveBeenCalledWith(user.id)
const { removeUsers } = useUserSettingsStore()
expect(removeUsers).toHaveBeenCalled()
}
})
})
it('should handle errors', () => {
vi.spyOn(console, 'error').mockImplementation(() => undefined)
getWrapper({
setup: async ({ deleteUsers }, { clientService }) => {
clientService.graphAuthenticated.users.deleteUser.mockRejectedValue({})
const user = mock<User>({ id: '1' })
await deleteUsers([user])
expect(clientService.graphAuthenticated.users.deleteUser).toHaveBeenCalledWith(user.id)
const { removeUsers } = useUserSettingsStore()
expect(removeUsers).toHaveBeenCalled()
}
})
})
})
})
function getWrapper({
setup
}: {
setup: (
instance: ReturnType<typeof useUserActionsDelete>,
{
clientService
}: {
clientService: ReturnType<typeof defaultComponentMocks>['$clientService']
}
) => void
}) {
const mocks = defaultComponentMocks()
return {
wrapper: getComposableWrapper(
() => {
const instance = useUserActionsDelete()
setup(instance, { clientService: mocks.$clientService })
},
{ mocks, provide: mocks }
)
}
}
| owncloud/web/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsDelete.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/composables/actions/users/useUserActionsDelete.spec.ts",
"repo_id": "owncloud",
"token_count": 1162
} | 818 |
<template>
<iframe
id="drawio-editor"
ref="drawIoEditor"
:src="iframeSource"
:title="$gettext('Draw.io editor')"
/>
</template>
<script lang="ts">
import qs from 'qs'
import {
defineComponent,
unref,
PropType,
computed,
onMounted,
onBeforeUnmount,
VNodeRef,
ref,
watch,
nextTick
} from 'vue'
import { Resource } from '@ownclouders/web-client/src'
import { AppConfigObject } from '@ownclouders/web-pkg'
export default defineComponent({
name: 'DrawIoEditor',
props: {
resource: {
type: Object as PropType<Resource>,
required: true
},
applicationConfig: {
type: Object as PropType<AppConfigObject>,
required: true
},
currentContent: {
type: String,
required: true
},
isReadOnly: {
type: Boolean,
required: true
},
isDirty: {
type: Boolean,
required: true
}
},
emits: ['update:currentContent', 'save', 'close'],
setup(props, { emit }) {
const drawIoEditor: VNodeRef = ref()
const config = computed(() => {
const { url = 'https://embed.diagrams.net', theme = 'minimal' } =
props.applicationConfig as any
return { url, theme }
})
const urlHost = computed(() => {
const url = new URL(unref(config).url)
const urlHost = `${url.protocol}//${url.hostname}`
return url.port ? `${urlHost}:${url.port}` : urlHost
})
const iframeSource = computed(() => {
const query = qs.stringify({
embed: 1,
chrome: props.isReadOnly ? 0 : 1,
picker: 0,
stealth: 1,
spin: 1,
proto: 'json',
ui: unref(config).theme
})
return `${unref(config).url}?${query}`
})
const loadCurrentContent = () => {
postMessage({
action: 'load',
xml: props.currentContent,
autosave: true
})
}
watch(
() => props.isDirty,
() => {
postMessage({
action: 'status',
modified: props.isDirty
})
}
)
watch(
() => props.resource,
() => {
loadCurrentContent()
}
)
const postMessage = (
payload:
| { action: string; xml: string; autosave?: boolean }
| { action: 'status'; modified: boolean }
) => {
try {
if (!unref(drawIoEditor)) {
return
}
return (unref(drawIoEditor) as HTMLIFrameElement).contentWindow.postMessage(
JSON.stringify(payload),
unref(urlHost)
)
} catch (e) {
console.error(e)
}
}
const handleMessage = async (event) => {
if (event.data.length > 0) {
if (event.origin !== unref(config).url) {
return
}
await nextTick()
const payload = JSON.parse(event.data)
switch (payload?.event) {
case 'init':
loadCurrentContent()
break
case 'autosave':
emit('update:currentContent', payload.xml)
break
case 'save':
emit('save')
break
case 'exit':
emit('close')
break
}
}
}
onMounted(() => {
window.addEventListener('message', handleMessage)
})
onBeforeUnmount(() => {
window.removeEventListener('message', handleMessage)
})
return {
config,
drawIoEditor,
iframeSource
}
}
})
</script>
<style scoped>
#drawio-editor {
width: 100%;
height: 100%;
border: none;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
| owncloud/web/packages/web-app-draw-io/src/App.vue/0 | {
"file_path": "owncloud/web/packages/web-app-draw-io/src/App.vue",
"repo_id": "owncloud",
"token_count": 1674
} | 819 |
import { mock } from 'vitest-mock-extended'
import { defaultPlugins, shallowMount } from 'web-test-helpers'
import { useRequest, useRouteQuery } from '@ownclouders/web-pkg'
import { ref } from 'vue'
import { Resource } from '@ownclouders/web-client'
import App from '../../src/App.vue'
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
useRequest: vi.fn(),
useRouteQuery: vi.fn()
}))
const appUrl = 'https://example.test/d12ab86/loe009157-MzBw'
const providerSuccessResponsePost = {
app_url: appUrl,
method: 'POST',
form_parameters: {
access_token: 'asdfsadfsadf',
access_token_ttl: '123456'
}
}
const providerSuccessResponseGet = {
app_url: appUrl,
method: 'GET'
}
describe('The app provider extension', () => {
beforeEach(() => {
vi.spyOn(console, 'error').mockImplementation(() => undefined)
})
it('should fail for unauthenticated users', async () => {
const makeRequest = vi.fn().mockResolvedValue({
ok: true,
status: 401,
message: 'Login Required'
})
const { wrapper } = createShallowMountWrapper(makeRequest)
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
expect(wrapper.html()).toMatchSnapshot()
})
it('should be able to load an iFrame via get', async () => {
const makeRequest = vi.fn().mockResolvedValue({
ok: true,
status: 200,
data: providerSuccessResponseGet
})
const { wrapper } = createShallowMountWrapper(makeRequest)
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
expect(wrapper.html()).toMatchSnapshot()
})
it('should be able to load an iFrame via post', async () => {
const makeRequest = vi.fn().mockResolvedValue({
ok: true,
status: 200,
data: providerSuccessResponsePost
})
const { wrapper } = createShallowMountWrapper(makeRequest)
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
expect(wrapper.html()).toMatchSnapshot()
})
})
function createShallowMountWrapper(makeRequest = vi.fn().mockResolvedValue({ status: 200 })) {
vi.mocked(useRequest).mockImplementation(() => ({
makeRequest
}))
vi.mocked(useRouteQuery).mockImplementation(() => ref('example-app'))
const capabilities = {
files: {
app_providers: [{ apps_url: '/app/list', enabled: true, open_url: '/app/open' }]
}
}
return {
wrapper: shallowMount(App, {
props: {
space: null,
resource: mock<Resource>(),
isReadOnly: false
},
global: {
plugins: [
...defaultPlugins({
piniaOptions: {
capabilityState: { capabilities },
configState: { options: { editor: { openAsPreview: true } } }
}
})
]
}
})
}
}
| owncloud/web/packages/web-app-external/tests/unit/app.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-external/tests/unit/app.spec.ts",
"repo_id": "owncloud",
"token_count": 1133
} | 820 |
<template>
<div class="files-view-wrapper oc-width-expand">
<div id="files-view" v-bind="$attrs">
<slot />
</div>
</div>
<portal v-if="isEmbedModeEnabled" to="app.runtime.footer">
<embed-actions />
</portal>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { useEmbedMode } from '@ownclouders/web-pkg'
import EmbedActions from './EmbedActions/EmbedActions.vue'
export default defineComponent({
components: { EmbedActions },
inheritAttrs: false,
setup() {
const { isEnabled: isEmbedModeEnabled } = useEmbedMode()
return { isEmbedModeEnabled }
}
})
</script>
<style lang="scss" scoped>
.files-view-wrapper {
height: 100%;
position: relative;
overflow-y: auto;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: max-content max-content 1fr;
gap: 0 0;
grid-template-areas:
'header'
'upload'
'main';
&:focus {
outline: none;
}
}
#files-view {
grid-area: main;
z-index: 0;
outline: none;
}
</style>
| owncloud/web/packages/web-app-files/src/components/FilesViewWrapper.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/FilesViewWrapper.vue",
"repo_id": "owncloud",
"token_count": 404
} | 821 |
<template>
<div
:data-testid="`collaborator-${isAnyUserShareType ? 'user' : 'group'}-item-${
share.sharedWith.displayName
}`"
class="files-collaborators-collaborator oc-py-xs"
>
<div class="oc-width-1-1 oc-flex oc-flex-middle files-collaborators-collaborator-details">
<div class="oc-width-2-3 oc-flex oc-flex-middle">
<div>
<template v-if="isShareDenied">
<oc-avatar-item
:width="36"
icon-size="medium"
icon="stop"
:name="$gettext('Access denied')"
class="files-collaborators-collaborator-indicator"
/>
</template>
<template v-else>
<avatar-image
v-if="isAnyUserShareType"
:userid="share.sharedWith.id"
:user-name="share.sharedWith.displayName"
:width="36"
class="files-collaborators-collaborator-indicator"
/>
<oc-avatar-item
v-else
:width="36"
icon-size="medium"
:icon="shareTypeIcon"
:name="shareTypeKey"
class="files-collaborators-collaborator-indicator"
/>
</template>
</div>
<div class="oc-pl-s oc-text-truncate">
<div v-oc-tooltip="shareDisplayNameTooltip" class="oc-text-truncate">
<span
aria-hidden="true"
class="files-collaborators-collaborator-name"
v-text="shareDisplayName"
/>
<span class="oc-invisible-sr" v-text="screenreaderShareDisplayName" />
</div>
<div>
<div
v-if="isShareDenied"
v-oc-tooltip="shareDeniedTooltip"
class="oc-flex oc-flex-nowrap oc-flex-middle"
v-text="$gettext('Access denied')"
/>
<template v-else>
<div v-if="modifiable" class="oc-flex oc-flex-nowrap oc-flex-middle">
<role-dropdown
:dom-selector="shareDomSelector"
:existing-role="share.role"
:is-locked="isLocked"
class="files-collaborators-collaborator-role"
mode="edit"
@option-change="shareRoleChanged"
/>
</div>
<div v-else-if="share.role">
<span
v-oc-tooltip="$gettext(share.role.description)"
class="oc-mr-xs"
v-text="$gettext(share.role.displayName)"
/>
</div>
</template>
</div>
</div>
</div>
<div class="oc-flex oc-flex-middle oc-width-1-3 files-collaborators-collaborator-navigation">
<div
v-if="sharedParentRoute && !isShareDenied"
class="oc-resource-indicators oc-text-truncate"
>
<router-link
v-oc-tooltip="$gettext('Navigate to parent folder')"
class="parent-folder oc-text-truncate"
:to="sharedParentRoute"
>
<span class="text" v-text="$gettext('via')" />
<oc-icon name="folder-2" size="small" fill-type="line" class="oc-px-xs" />
<span class="text oc-text-truncate" v-text="sharedParentDir" />
</router-link>
</div>
<span v-if="hasExpirationDate">
<oc-icon
v-oc-tooltip="expirationDate"
class="files-collaborators-collaborator-expiration"
data-testid="recipient-info-expiration-date"
:aria-label="expirationDate"
name="calendar-event"
fill-type="line"
/>
<span class="oc-invisible-sr" v-text="screenreaderShareExpiration" />
</span>
<edit-dropdown
:id="`edit-drop-down-${editDropDownToggleId}`"
class="files-collaborators-collaborator-edit"
data-testid="collaborator-edit"
:expiration-date="share.expirationDateTime ? share.expirationDateTime : null"
:share-category="shareCategory"
:can-edit-or-delete="modifiable"
:is-share-denied="isShareDenied"
:is-locked="isLocked"
:deniable="deniable"
@expiration-date-changed="shareExpirationChanged"
@remove-share="removeShare"
@set-deny-share="setDenyShare"
@show-access-details="showAccessDetails"
@notify-share="showNotifyShareModal"
/>
<oc-info-drop
ref="accessDetailsDrop"
class="share-access-details-drop"
v-bind="isAnySpaceShareType ? accessDetailsPropsSpace : accessDetailsProps"
mode="manual"
:target="`#edit-drop-down-${editDropDownToggleId}`"
/>
</div>
</div>
</div>
</template>
<script lang="ts">
import { storeToRefs } from 'pinia'
import { DateTime } from 'luxon'
import EditDropdown from './EditDropdown.vue'
import RoleDropdown from './RoleDropdown.vue'
import { CollaboratorShare, ShareRole, ShareTypes } from '@ownclouders/web-client/src/helpers/share'
import {
queryItemAsString,
useMessages,
useModals,
useSpacesStore,
useUserStore,
useSharesStore
} from '@ownclouders/web-pkg'
import { Resource, extractDomSelector } from '@ownclouders/web-client/src/helpers/resource'
import { computed, defineComponent, inject, PropType, Ref } from 'vue'
import * as uuid from 'uuid'
import { formatDateFromDateTime, formatRelativeDateFromDateTime } from '@ownclouders/web-pkg'
import { useClientService } from '@ownclouders/web-pkg'
import { OcInfoDrop, OcDrop } from 'design-system/src/components'
import { RouteLocationNamedRaw } from 'vue-router'
import { useGettext } from 'vue3-gettext'
import { SpaceResource } from '@ownclouders/web-client'
import { buildSpace, isProjectSpaceResource } from '@ownclouders/web-client/src/helpers'
export default defineComponent({
name: 'ListItem',
components: {
EditDropdown,
RoleDropdown
},
props: {
share: {
type: Object as PropType<CollaboratorShare>,
required: true
},
isShareDenied: {
type: Boolean,
default: false
},
modifiable: {
type: Boolean,
default: false
},
sharedParentRoute: {
type: Object as PropType<RouteLocationNamedRaw>,
default: null
},
resourceName: {
type: String,
default: ''
},
deniable: {
type: Boolean,
default: false
},
isLocked: {
type: Boolean,
default: false
}
},
emits: ['onDelete', 'onSetDeny'],
setup(props, { emit }) {
const { showMessage, showErrorMessage } = useMessages()
const userStore = useUserStore()
const clientService = useClientService()
const { $gettext } = useGettext()
const { dispatchModal } = useModals()
const { updateShare } = useSharesStore()
const { upsertSpace, upsertSpaceMember } = useSpacesStore()
const { user } = storeToRefs(userStore)
const sharedParentDir = computed(() => {
return queryItemAsString(props.sharedParentRoute?.params?.driveAliasAndItem)
.split('/')
.pop()
})
const setDenyShare = (value) => {
emit('onSetDeny', { share: props.share, value })
}
const showNotifyShareModal = () => {
dispatchModal({
variation: 'warning',
icon: 'mail-send',
title: $gettext('Send a reminder'),
confirmText: $gettext('Send'),
message: $gettext('Are you sure you want to send a reminder about this share?'),
onConfirm: notifyShare
})
}
const notifyShare = async () => {
// FIXME: cern code
// const response = await clientService.owncloudSdk.shares.notifyShare(props.share.id)
}
return {
resource: inject<Ref<Resource>>('resource'),
space: inject<Ref<SpaceResource>>('space'),
updateShare,
user,
clientService,
sharedParentDir,
setDenyShare,
showNotifyShareModal,
showMessage,
showErrorMessage,
upsertSpace,
upsertSpaceMember
}
},
computed: {
shareType() {
return ShareTypes.getByValue(this.share.shareType)
},
shareTypeIcon() {
return this.shareType.icon
},
shareTypeKey() {
return this.shareType.key
},
shareDomSelector() {
if (!this.share.id) {
return undefined
}
return extractDomSelector(this.share.id)
},
isAnyUserShareType() {
return [ShareTypes.user, ShareTypes.spaceUser].includes(this.shareType)
},
isAnySpaceShareType() {
return [ShareTypes.spaceUser, ShareTypes.spaceGroup].includes(this.shareType)
},
shareTypeText() {
return this.$gettext(this.shareType.label)
},
shareCategory() {
return ShareTypes.isIndividual(this.shareType) ? 'user' : 'group'
},
shareDeniedTooltip() {
return this.$gettext('%{shareType} cannot access %{resourceName}', {
shareType: this.shareTypeText,
resourceName: this.resourceName
})
},
shareDisplayName() {
if (this.user.id === this.share.sharedWith.id) {
return this.$gettext('%{collaboratorName} (me)', {
collaboratorName: this.share.sharedWith.displayName
})
}
return this.share.sharedWith.displayName
},
shareDisplayNameTooltip() {
return this.shareDisplayName
},
screenreaderShareDisplayName() {
const context = {
displayName: this.share.sharedWith.displayName
}
return this.$gettext('Share receiver name: %{ displayName }', context)
},
screenreaderShareExpiration() {
return this.$gettext('Share expires %{ expiryDateRelative } (%{ expiryDate })', {
expiryDateRelative: this.expirationDateRelative,
expiryDate: this.expirationDate
})
},
hasExpirationDate() {
return !!this.share.expirationDateTime
},
expirationDate() {
return formatDateFromDateTime(
DateTime.fromISO(this.share.expirationDateTime).endOf('day'),
this.$language.current
)
},
expirationDateRelative() {
return formatRelativeDateFromDateTime(
DateTime.fromISO(this.share.expirationDateTime).endOf('day'),
this.$language.current
)
},
editDropDownToggleId() {
return uuid.v4()
},
shareDate() {
return ''
// FIXME
// return formatDateFromDateTime(
// DateTime.fromSeconds(parseInt(this.share.permission.)),
// this.$language.current
// )
},
shareOwnerDisplayName() {
return this.share.sharedBy.displayName
},
accessDetailsPropsSpace() {
const list = []
list.push({ text: this.$gettext('Name'), headline: true }, { text: this.shareDisplayName })
list.push({ text: this.$gettext('Type'), headline: true }, { text: this.shareTypeText })
return {
title: this.$gettext('Access details'),
list
}
},
accessDetailsProps() {
const list = []
list.push({ text: this.$gettext('Name'), headline: true }, { text: this.shareDisplayName })
list.push({ text: this.$gettext('Type'), headline: true }, { text: this.shareTypeText })
list.push(
{ text: this.$gettext('Access expires'), headline: true },
{ text: this.hasExpirationDate ? this.expirationDate : this.$gettext('no') }
)
list.push({ text: this.$gettext('Shared on'), headline: true }, { text: this.shareDate })
list.push(
{ text: this.$gettext('Invited by'), headline: true },
{ text: this.shareOwnerDisplayName }
)
return {
title: this.$gettext('Access details'),
list
}
}
},
methods: {
removeShare() {
this.$emit('onDelete', this.share)
},
showAccessDetails() {
;(
(this.$refs.accessDetailsDrop as InstanceType<typeof OcInfoDrop>).$refs
.drop as InstanceType<typeof OcDrop>
).show()
},
async shareRoleChanged(role: ShareRole) {
const expirationDateTime = this.share.expirationDateTime
try {
await this.saveShareChanges({ role, expirationDateTime })
} catch (e) {
console.error(e)
this.showErrorMessage({
title: this.$gettext('Failed to apply new permissions'),
errors: [e]
})
}
},
async shareExpirationChanged({ expirationDateTime }) {
const role = this.share.role
try {
await this.saveShareChanges({ role, expirationDateTime })
} catch (e) {
console.error(e)
this.showErrorMessage({
title: this.$gettext('Failed to apply expiration date'),
errors: [e]
})
}
},
async saveShareChanges({
role,
expirationDateTime
}: {
role: ShareRole
expirationDateTime?: string
}) {
try {
const share = await this.updateShare({
clientService: this.$clientService,
space: this.space,
resource: this.resource,
collaboratorShare: this.share,
options: { roles: [role.id], expirationDateTime }
})
if (isProjectSpaceResource(this.resource)) {
const client = this.clientService.graphAuthenticated
const graphResponse = await client.drives.getDrive(this.resource.id)
this.upsertSpace(buildSpace(graphResponse.data))
this.upsertSpaceMember({ member: share })
}
this.showMessage({ title: this.$gettext('Share successfully changed') })
} catch (e) {
console.error(e)
this.showErrorMessage({
title: this.$gettext('Error while editing the share.'),
errors: [e]
})
}
}
}
})
</script>
<style lang="scss" scoped>
.sharee-avatar {
min-width: 36px;
}
.share-access-details-drop {
dl {
display: grid;
grid-template-columns: max-content auto;
}
dt {
grid-column-start: 1;
}
dd {
grid-column-start: 2;
margin-left: var(--oc-space-medium);
}
}
.files-collaborators-collaborator-expiration {
margin-top: 5px;
}
.files-collaborators-collaborator-navigation {
justify-content: end;
}
.files-collaborators-collaborator-role {
max-width: 100%;
}
</style>
| owncloud/web/packages/web-app-files/src/components/SideBar/Shares/Collaborators/ListItem.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/SideBar/Shares/Collaborators/ListItem.vue",
"repo_id": "owncloud",
"token_count": 6447
} | 822 |
export * from './useSpaceActionsUploadImage'
| owncloud/web/packages/web-app-files/src/composables/actions/spaces/index.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/composables/actions/spaces/index.ts",
"repo_id": "owncloud",
"token_count": 13
} | 823 |
export * from './actions'
| owncloud/web/packages/web-app-files/src/helpers/resource/index.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/helpers/resource/index.ts",
"repo_id": "owncloud",
"token_count": 8
} | 824 |
<template>
<div class="oc-flex">
<files-view-wrapper>
<app-bar
:breadcrumbs="breadcrumbs"
:has-view-options="false"
:has-hidden-files="false"
:has-file-extensions="false"
:has-pagination="false"
/>
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<no-content-message v-if="!spaces.length" icon="delete-bin-5">
<template #message>
<span v-text="$gettext('You don\'t have access to any trashbins')"></span>
</template>
</no-content-message>
<template v-else>
<div
class="trash-bin-filters oc-flex oc-flex-right oc-flex-wrap oc-flex-bottom oc-mx-m oc-mb-m"
>
<oc-text-input
id="spaces-filter"
v-model="filterTerm"
:label="$gettext('Search')"
autocomplete="off"
/>
</div>
<oc-table
ref="tableRef"
class="spaces-table"
:sort-by="sortBy"
:sort-dir="sortDir"
:fields="fields"
:data="displaySpaces"
:header-position="fileListHeaderY"
:sticky="true"
:hover="true"
@sort="handleSort"
>
<template #icon="{ item }">
<oc-icon v-if="isPersonalSpaceResource(item)" class="oc-pl-m" name="folder" />
<oc-icon v-else class="oc-pl-m" name="layout-grid" />
</template>
<template #name="{ item }">
<oc-button
class="oc-display-block"
appearance="raw"
v-bind="getSpaceAttributes(item)"
>
{{ getSpaceName(item) }}
</oc-button>
</template>
<template #footer>
<div class="oc-text-nowrap oc-text-center oc-width-1-1 oc-my-s">
<p class="oc-text-muted">{{ footerTextTotal }}</p>
<p v-if="filterTerm" class="oc-text-muted">{{ footerTextFilter }}</p>
</div>
</template>
</oc-table>
</template>
</template>
</files-view-wrapper>
<file-side-bar :is-open="isSideBarOpen" :active-panel="sideBarActivePanel" />
</div>
</template>
<script lang="ts">
import { computed, defineComponent, nextTick, onMounted, ref, unref, watch } from 'vue'
import Mark from 'mark.js'
import Fuse from 'fuse.js'
import { useGettext } from 'vue3-gettext'
import { useTask } from 'vue-concurrency'
import {
defaultFuseOptions,
FileSideBar,
useClientService,
useResourcesStore,
useRouter,
useSideBar,
useSpacesStore,
useUserStore
} from '@ownclouders/web-pkg'
import { createLocationTrash } from '@ownclouders/web-pkg'
import { createFileRouteOptions } from '@ownclouders/web-pkg'
import { AppBar } from '@ownclouders/web-pkg'
import FilesViewWrapper from 'web-app-files/src/components/FilesViewWrapper.vue'
import {
isPersonalSpaceResource,
isProjectSpaceResource,
SpaceResource
} from '@ownclouders/web-client/src/helpers'
import { AppLoadingSpinner } from '@ownclouders/web-pkg'
import { NoContentMessage } from '@ownclouders/web-pkg'
import { FieldType } from 'design-system/src/components/OcTable/OcTable.vue'
import { useFileListHeaderPosition } from '@ownclouders/web-pkg'
export default defineComponent({
name: 'TrashOverview',
components: { FileSideBar, FilesViewWrapper, AppBar, AppLoadingSpinner, NoContentMessage },
setup() {
const userStore = useUserStore()
const spacesStore = useSpacesStore()
const router = useRouter()
const { $gettext } = useGettext()
const clientService = useClientService()
const { y: fileListHeaderY } = useFileListHeaderPosition()
const resourcesStore = useResourcesStore()
const sortBy = ref('name')
const sortDir = ref('asc')
const filterTerm = ref('')
const markInstance = ref(undefined)
const tableRef = ref(undefined)
const spaces = computed(() =>
spacesStore.spaces.filter(
(s: SpaceResource) =>
(isPersonalSpaceResource(s) && s.isOwner(userStore.user)) || isProjectSpaceResource(s)
)
)
const loadResourcesTask = useTask(function* () {
resourcesStore.clearResourceList()
yield spacesStore.reloadProjectSpaces({ graphClient: clientService.graphAuthenticated })
resourcesStore.initResourceList({ currentFolder: null, resources: unref(spaces) })
})
const areResourcesLoading = computed(() => {
return loadResourcesTask.isRunning || !loadResourcesTask.last
})
const footerTextTotal = computed(() => {
return $gettext('%{spaceCount} trashes in total', {
spaceCount: unref(spaces).length.toString()
})
})
const footerTextFilter = computed(() => {
return $gettext('%{spaceCount} matching trashes', {
spaceCount: unref(displaySpaces).length.toString()
})
})
const breadcrumbs = computed(() => [
{ text: $gettext('Deleted files'), onClick: () => loadResourcesTask.perform() }
])
const sort = (list: SpaceResource[], propName: string, desc: boolean) => {
return [...list].sort((s1, s2) => {
if (isPersonalSpaceResource(s1)) {
return -1
}
if (isPersonalSpaceResource(s2)) {
return +1
}
const a = s1[propName]
const b = s2[propName]
return desc ? b.localeCompare(a) : a.localeCompare(b)
})
}
const displaySpaces = computed(() =>
sort(filter(unref(spaces), unref(filterTerm)), unref(sortBy), unref(sortDir) === 'desc')
)
const handleSort = (event) => {
sortBy.value = event.sortBy
sortDir.value = event.sortDir
}
const filter = (spaces: SpaceResource[], filterTerm: string) => {
if (!(filterTerm || '').trim()) {
return spaces
}
const searchEngine = new Fuse(spaces, { ...defaultFuseOptions, keys: ['name'] })
return searchEngine.search(filterTerm).map((r) => r.item)
}
const fields = computed((): FieldType[] => [
{
name: 'icon',
title: '',
type: 'slot',
width: 'shrink'
},
{
name: 'name',
title: $gettext('Name'),
type: 'slot',
sortable: true
}
])
const getSpaceName = (space: SpaceResource) => {
if (isPersonalSpaceResource(space)) {
return $gettext('Personal')
}
if (space.disabled === true) {
return $gettext('%{spaceName} (disabled)', { spaceName: space.name })
}
return space.name
}
const getSpaceAttributes = (space: SpaceResource) => {
if (isProjectSpaceResource(space) && space.disabled === true) {
return {
disabled: true
}
}
return {
type: 'router-link',
to: getTrashLink(space)
}
}
const getTrashLink = (space: SpaceResource) => {
return createLocationTrash('files-trash-generic', {
...createFileRouteOptions(space, { fileId: space.fileId })
})
}
onMounted(async () => {
if (unref(spaces).length === 1 && !isProjectSpaceResource(unref(spaces)[0])) {
return router.push(getTrashLink(unref(spaces).pop()))
}
await loadResourcesTask.perform()
await nextTick()
markInstance.value = new Mark(unref(tableRef)?.$el)
})
watch(filterTerm, () => {
const instance = unref(markInstance)
if (!instance) {
return
}
instance.unmark()
instance.mark(unref(filterTerm), {
element: 'span',
className: 'mark-highlight',
exclude: ['th *', 'tfoot *']
})
})
return {
sortBy,
sortDir,
filterTerm,
footerTextTotal,
footerTextFilter,
fields,
tableRef,
spaces,
filter,
handleSort,
displaySpaces,
breadcrumbs,
getSpaceName,
getTrashLink,
getSpaceAttributes,
loadResourcesTask,
areResourcesLoading,
isPersonalSpaceResource,
fileListHeaderY,
...useSideBar()
}
}
})
</script>
<style lang="scss">
#spaces-filter {
width: 16rem;
}
</style>
| owncloud/web/packages/web-app-files/src/views/trash/Overview.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/views/trash/Overview.vue",
"repo_id": "owncloud",
"token_count": 3658
} | 825 |
import NotFoundMessage from '../../../../src/components/FilesList/NotFoundMessage.vue'
import { createLocationPublic, createLocationSpaces } from '@ownclouders/web-pkg'
import { PublicSpaceResource, SpaceResource, Resource } from '@ownclouders/web-client/src/helpers'
import { MockProxy, mock } from 'vitest-mock-extended'
import { join } from 'path'
import { defaultComponentMocks, defaultPlugins, shallowMount } from 'web-test-helpers'
import { OcButton } from 'design-system/src/components'
const selectors = {
homeButton: '#files-list-not-found-button-go-home',
reloadLinkButton: '#files-list-not-found-button-reload-link'
}
const spacesLocation = createLocationSpaces('files-spaces-generic')
const publicLocation = createLocationPublic('files-public-link')
describe('NotFoundMessage', () => {
describe('when user on personal route', () => {
let space: MockProxy<SpaceResource>
beforeEach(() => {
space = mock<SpaceResource>({
driveType: 'personal'
})
})
it('should show home button', () => {
const { wrapper } = getWrapper(space, spacesLocation)
const homeButton = wrapper.find(selectors.homeButton)
expect(homeButton.exists()).toBeTruthy()
expect(homeButton.find('span')).toBeTruthy()
expect(homeButton.find('span').text()).toBe('Go to »Personal« page')
})
it('should not show reload public link button', () => {
const { wrapper } = getWrapper(space, spacesLocation)
const reloadLinkButton = wrapper.find(selectors.reloadLinkButton)
expect(reloadLinkButton.exists()).toBeFalsy()
})
it('should have property route to personal space', () => {
const { wrapper } = getWrapper(space, spacesLocation)
const homeButton = wrapper.findComponent<typeof OcButton>(selectors.homeButton)
expect(homeButton.props().to.name).toBe(spacesLocation.name)
expect(homeButton.props().to.params.driveAliasAndItem).toBe('personal')
})
})
describe('when user on public link route', () => {
let space: MockProxy<PublicSpaceResource>
beforeEach(() => {
space = mock<PublicSpaceResource>({
driveType: 'public'
})
space.getDriveAliasAndItem.mockImplementation((resource) =>
join('public/1234', resource.path)
)
})
it('should show reload link button', () => {
const { wrapper } = getWrapper(space, publicLocation)
const reloadLinkButton = wrapper.find(selectors.reloadLinkButton)
expect(reloadLinkButton.exists()).toBeTruthy()
expect(reloadLinkButton.find('span')).toBeTruthy()
expect(reloadLinkButton.find('span').text()).toBe('Reload public link')
})
it('should not show home button', () => {
const { wrapper } = getWrapper(space, publicLocation)
const homeButton = wrapper.find(selectors.homeButton)
expect(homeButton.exists()).toBeFalsy()
})
it('should have property route to files public list', () => {
const { wrapper } = getWrapper(space, publicLocation)
const reloadLinkButton = wrapper.findComponent<typeof OcButton>(selectors.reloadLinkButton)
expect(reloadLinkButton.props().to.name).toBe(publicLocation.name)
expect(reloadLinkButton.props().to.params.driveAliasAndItem).toBe(
space.getDriveAliasAndItem({ path: '' } as Resource)
)
})
})
})
function getWrapper(space, route) {
const mocks = defaultComponentMocks({ currentRoute: route })
return {
wrapper: shallowMount(NotFoundMessage, {
props: { space },
global: {
renderStubDefaultSlot: true,
mocks,
provide: mocks,
plugins: [...defaultPlugins()]
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/components/FilesList/NotFoundMessage.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/components/FilesList/NotFoundMessage.spec.ts",
"repo_id": "owncloud",
"token_count": 1313
} | 826 |
import RoleDropdown from 'web-app-files/src/components/SideBar/Shares/Collaborators/RoleDropdown.vue'
import { ShareRole } from '@ownclouders/web-client/src/helpers/share'
import { defaultPlugins, mount, shallowMount } from 'web-test-helpers'
import { mock } from 'vitest-mock-extended'
import { Resource } from '@ownclouders/web-client'
const selectors = {
recipientRoleBtn: '.files-recipient-role-select-btn',
roleButton: '.files-recipient-role-drop-btn'
}
describe('RoleDropdown', () => {
it('renders a button with invite text if no existing role given', () => {
const { wrapper } = getWrapper({ mountType: shallowMount })
expect(wrapper.find(selectors.recipientRoleBtn).exists()).toBeTruthy()
expect(wrapper.find(`${selectors.recipientRoleBtn} span`).text()).toEqual('Can view')
})
it('renders a button with existing role if given', () => {
const { wrapper } = getWrapper({
mountType: shallowMount,
existingRole: mock<ShareRole>({ label: 'Can edit' })
})
expect(wrapper.find(selectors.recipientRoleBtn).exists()).toBeTruthy()
expect(wrapper.find(`${selectors.recipientRoleBtn} span`).text()).toEqual('Can edit')
})
it('does not render a button if only one role is available', () => {
const { wrapper } = getWrapper({
mountType: shallowMount,
availableShareRoles: [mock<ShareRole>({ displayName: 'Viewer', description: '', label: '' })]
})
expect(wrapper.find(selectors.recipientRoleBtn).exists()).toBeFalsy()
})
it('emits "optionChange"-event on role click', async () => {
const { wrapper } = getWrapper()
;(wrapper.vm.$refs.rolesDrop as any).tippy = { hide: vi.fn() }
await wrapper.find(selectors.roleButton).trigger('click')
expect(wrapper.emitted('optionChange')).toBeTruthy()
})
})
function getWrapper({
mountType = mount,
existingRole = null,
availableShareRoles = [
mock<ShareRole>({ displayName: 'Viewer', description: '', label: 'Can view' }),
mock<ShareRole>({ displayName: 'Editor', description: '', label: 'Can edit' })
]
} = {}) {
return {
wrapper: mountType(RoleDropdown, {
props: {
existingRole
},
global: {
plugins: [
...defaultPlugins({
piniaOptions: { userState: { user: { onPremisesSamAccountName: 'name' } } }
})
],
renderStubDefaultSlot: true,
provide: {
resource: mock<Resource>(),
availableShareRoles
}
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/components/SideBar/Shares/Collaborators/RoleDropdown.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/components/SideBar/Shares/Collaborators/RoleDropdown.spec.ts",
"repo_id": "owncloud",
"token_count": 943
} | 827 |
import { useSpaceActionsUploadImage } from 'web-app-files/src/composables/actions/spaces/useSpaceActionsUploadImage'
import { mock } from 'vitest-mock-extended'
import {
defaultComponentMocks,
RouteLocation,
getComposableWrapper,
mockAxiosResolve
} from 'web-test-helpers'
import { unref, VNodeRef } from 'vue'
import { eventBus, useMessages } from '@ownclouders/web-pkg'
import { Resource, SpaceResource } from '@ownclouders/web-client/src'
import { Drive } from '@ownclouders/web-client/src/generated'
describe('uploadImage', () => {
describe('method "uploadImageSpace"', () => {
it('should show message on success', () => {
getWrapper({
setup: async ({ uploadImageSpace }, { clientService }) => {
const busStub = vi.spyOn(eventBus, 'publish')
const driveMock = mock<Drive>({ special: [{ specialFolder: { name: 'image' } }] })
clientService.graphAuthenticated.drives.updateDrive.mockResolvedValue(
mockAxiosResolve(driveMock)
)
clientService.webdav.putFileContents.mockResolvedValue(
mock<Resource>({
fileId:
'YTE0ODkwNGItNTZhNy00NTQ4LTk2N2MtZjcwZjhhYTY0Y2FjOmQ4YzMzMmRiLWUxNWUtNDRjMy05NGM2LTViYjQ2MGMwMWJhMw=='
})
)
await uploadImageSpace({
currentTarget: {
files: [
{
name: 'image.png',
lastModifiedDate: new Date(),
type: 'image/png',
arrayBuffer: () => new ArrayBuffer(0)
}
]
}
})
expect(busStub).toHaveBeenCalledWith('app.files.spaces.uploaded-image', expect.anything())
const { showMessage } = useMessages()
expect(showMessage).toHaveBeenCalledTimes(1)
}
})
})
it('should show showErrorMessage on error', () => {
vi.spyOn(console, 'error').mockImplementation(() => undefined)
getWrapper({
setup: async ({ uploadImageSpace }, { clientService }) => {
clientService.webdav.putFileContents.mockRejectedValue(new Error(''))
await uploadImageSpace({
currentTarget: {
files: [
{
name: 'image.png',
lastModifiedDate: new Date(),
type: 'image/png',
arrayBuffer: () => new ArrayBuffer(0)
}
]
}
})
const { showErrorMessage } = useMessages()
expect(showErrorMessage).toHaveBeenCalledTimes(1)
}
})
})
})
})
function getWrapper({
setup
}: {
setup: (
instance: ReturnType<typeof useSpaceActionsUploadImage>,
{
spaceImageInput
}: {
spaceImageInput: VNodeRef
clientService: ReturnType<typeof defaultComponentMocks>['$clientService']
}
) => void
}) {
const mocks = {
...defaultComponentMocks({
currentRoute: mock<RouteLocation>({ name: 'files-spaces-generic' })
})
}
mocks.$previewService.isMimetypeSupported.mockReturnValue(true)
return {
wrapper: getComposableWrapper(
() => {
const spaceImageInput = mock<VNodeRef>()
const instance = useSpaceActionsUploadImage({ spaceImageInput })
unref(instance.actions)[0].handler({
resources: [
mock<SpaceResource>({
id: '1fe58d8b-aa69-4c22-baf7-97dd57479f22'
})
]
})
setup(instance, { spaceImageInput, clientService: mocks.$clientService })
},
{
mocks,
provide: mocks
}
)
}
}
| owncloud/web/packages/web-app-files/tests/unit/composables/actions/spaces/useSpaceActionsUploadImage.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/composables/actions/spaces/useSpaceActionsUploadImage.spec.ts",
"repo_id": "owncloud",
"token_count": 1744
} | 828 |
import Projects from '../../../../src/views/spaces/Projects.vue'
import { mock } from 'vitest-mock-extended'
import { h, nextTick, ref } from 'vue'
import { queryItemAsString, useFileActionsDelete, useExtensionRegistry } from '@ownclouders/web-pkg'
import {
defaultPlugins,
mount,
defaultComponentMocks,
defaultStubs,
RouteLocation
} from 'web-test-helpers'
import { useExtensionRegistryMock } from 'web-test-helpers/src/mocks/useExtensionRegistryMock'
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
displayPositionedDropdown: vi.fn(),
queryItemAsString: vi.fn(),
appDefaults: vi.fn(),
useExtensionRegistry: vi.fn(),
useRouteQueryPersisted: vi.fn().mockImplementation(() => ref('resource-table')),
useFileActions: vi.fn(),
useFileActionsDelete: vi.fn(() => mock<ReturnType<typeof useFileActionsDelete>>())
}))
const spacesResources = [
{
id: '1',
name: 'Some space',
driveType: 'project',
description: 'desc',
path: '',
type: 'space',
isFolder: true,
getDriveAliasAndItem: () => '1'
},
{
id: '2',
name: 'Some other space',
driveType: 'project',
description: 'desc',
path: '',
type: 'space',
isFolder: true,
getDriveAliasAndItem: () => '2'
}
]
describe('Projects view', () => {
it('appBar always present', () => {
const { wrapper } = getMountedWrapper()
expect(wrapper.find('app-bar-stub').exists()).toBeTruthy()
})
it('sideBar always present', () => {
const { wrapper } = getMountedWrapper()
expect(wrapper.find('file-side-bar-stub').exists()).toBeTruthy()
})
describe('different files view states', () => {
it('shows the loading spinner during loading', () => {
const { wrapper } = getMountedWrapper()
expect(wrapper.find('oc-spinner-stub').exists()).toBeTruthy()
})
it('shows the no-content-message after loading', async () => {
const { wrapper } = getMountedWrapper()
await wrapper.vm.loadResourcesTask.last
expect(wrapper.find('oc-spinner-stub').exists()).toBeFalsy()
expect(wrapper.find('.no-content-message').exists()).toBeTruthy()
})
it('lists all available project spaces', async () => {
const spaces = spacesResources
const { wrapper } = getMountedWrapper({ spaces })
await wrapper.vm.loadResourcesTask.last
// "space" is undefined for "space-context-actions", seems to be a bug because it's definitely not
// {{ space }} -> undefined, {{ space.id }} -> "1"
expect(wrapper.html()).toMatchSnapshot()
expect(wrapper.find('.no-content-message').exists()).toBeFalsy()
expect(wrapper.find('.spaces-list').exists()).toBeTruthy()
})
it('shows only filtered spaces if filter applied', async () => {
const { wrapper } = getMountedWrapper({ spaces: spacesResources })
wrapper.vm.filterTerm = 'Some other space'
await nextTick()
expect(wrapper.vm.items).toEqual([spacesResources[1]])
})
})
it('should display the "Create Space"-button when permission given', () => {
const { wrapper } = getMountedWrapper({
abilities: [{ action: 'create-all', subject: 'Drive' }],
stubAppBar: false
})
expect(wrapper.find('create-space-stub').exists()).toBeTruthy()
})
})
function getMountedWrapper({ mocks = {}, spaces = [], abilities = [], stubAppBar = true } = {}) {
vi.mocked(queryItemAsString).mockImplementationOnce(() => '1')
vi.mocked(queryItemAsString).mockImplementationOnce(() => '100')
const extensions = [
{
id: 'com.github.owncloud.web.files.folder-view.resource-table',
type: 'folderView',
scopes: ['resource', 'space', 'favorite'],
folderView: {
name: 'resource-table',
label: 'Switch to default view',
icon: {
name: 'menu-line',
fillType: 'none'
},
component: h('div', { class: 'resource-table' })
}
}
]
vi.mocked(useExtensionRegistry).mockImplementation(() =>
useExtensionRegistryMock({
requestExtensions<ExtensionType>(type: string, scopes: string[]) {
return extensions as ExtensionType[]
}
})
)
const defaultMocks = {
...defaultComponentMocks({
currentRoute: mock<RouteLocation>({ name: 'files-spaces-projects' })
}),
...(mocks && mocks)
}
return {
mocks: defaultMocks,
wrapper: mount(Projects, {
global: {
plugins: [...defaultPlugins({ abilities, piniaOptions: { spacesState: { spaces } } })],
mocks: defaultMocks,
provide: defaultMocks,
stubs: {
...defaultStubs,
'space-context-actions': true,
'app-bar': stubAppBar,
CreateSpace: true
}
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/views/spaces/Projects.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/views/spaces/Projects.spec.ts",
"repo_id": "owncloud",
"token_count": 1845
} | 829 |
import { z } from 'zod'
// Invite
export const inviteSchema = z.object({
token: z.string(),
expiration: z.number().optional(),
description: z.string().optional(),
invite_link: z.string().optional()
})
export type InviteSchema = z.infer<typeof inviteSchema>
export const inviteListSchema = z.array(inviteSchema)
export type InviteListSchema = z.infer<typeof inviteListSchema>
// Provider
export const providerSchema = z.object({
domain: z.string(),
full_name: z.string()
})
export type ProviderSchema = z.infer<typeof providerSchema>
export const providerListSchema = z.array(providerSchema)
export type ProviderListSchema = z.infer<typeof providerListSchema>
| owncloud/web/packages/web-app-ocm/src/schemas.ts/0 | {
"file_path": "owncloud/web/packages/web-app-ocm/src/schemas.ts",
"repo_id": "owncloud",
"token_count": 217
} | 830 |
<template>
<img
ref="img"
:key="`media-image-${file.id}`"
:src="file.url"
:alt="file.name"
:data-id="file.id"
:style="`transform: rotate(${currentImageRotation}deg)`"
/>
</template>
<script lang="ts">
import { CachedFile } from '../../helpers/types'
import { defineComponent, PropType, onMounted, ref, watch, unref, nextTick } from 'vue'
import type { PanzoomObject } from '@panzoom/panzoom'
import Panzoom from '@panzoom/panzoom'
export default defineComponent({
name: 'MediaImage',
props: {
file: {
type: Object as PropType<CachedFile>,
required: true
},
currentImageZoom: {
type: Number,
required: true
},
currentImageRotation: {
type: Number,
required: true
},
currentImagePositionX: {
type: Number,
required: true
},
currentImagePositionY: {
type: Number,
required: true
}
},
emits: ['panZoomChange'],
setup(props, { emit }) {
const img = ref<HTMLElement | null>()
const panzoom = ref<PanzoomObject>()
const onPanZoomChange = (event) => {
emit('panZoomChange', event)
}
const initPanzoom = async () => {
if (unref(panzoom)) {
;(unref(img) as unknown as HTMLElement).removeEventListener(
'panzoomchange',
onPanZoomChange
)
unref(panzoom)?.destroy()
}
// wait for next tick until image is rendered
await nextTick()
panzoom.value = Panzoom(unref(img), {
animate: false,
duration: 300,
overflow: 'auto',
maxScale: 10,
setTransform: (_, { scale, x, y }) => {
let h: number
let v: number
switch (props.currentImageRotation) {
case -270:
case 90:
h = y
v = 0 - x
break
case -180:
case 180:
h = 0 - x
v = 0 - y
break
case -90:
case 270:
h = 0 - y
v = x
break
default:
h = x
v = y
}
unref(panzoom).setStyle(
'transform',
`rotate(${props.currentImageRotation}deg) scale(${scale}) translate(${h}px, ${v}px)`
)
}
})
;(unref(img) as unknown as HTMLElement).addEventListener('panzoomchange', onPanZoomChange)
}
watch(img, initPanzoom)
onMounted(initPanzoom)
watch([() => props.currentImageZoom, () => props.currentImageRotation], () => {
unref(panzoom).zoom(props.currentImageZoom)
})
watch([() => props.currentImagePositionX, () => props.currentImagePositionY], () => {
unref(panzoom).pan(props.currentImagePositionX, props.currentImagePositionY)
})
return {
img
}
}
})
</script>
<style lang="scss" scoped>
img {
max-width: 80%;
max-height: 80%;
cursor: move;
}
</style>
| owncloud/web/packages/web-app-preview/src/components/Sources/MediaImage.vue/0 | {
"file_path": "owncloud/web/packages/web-app-preview/src/components/Sources/MediaImage.vue",
"repo_id": "owncloud",
"token_count": 1435
} | 831 |
import SearchBar from '../../../src/portals/SearchBar.vue'
import flushPromises from 'flush-promises'
import { mock } from 'vitest-mock-extended'
import { ref } from 'vue'
import { defineComponent } from 'vue'
import {
defaultPlugins,
mount,
defaultComponentMocks,
RouteLocation,
nextTicks
} from 'web-test-helpers'
import { useAvailableProviders } from '../../../src/composables'
const component = defineComponent({
emits: ['click', 'keyup'],
setup(props, ctx) {
const onClick = (event) => {
ctx.emit('click', event)
}
return { onClick }
},
template: '<div @click="onClick"></div>'
})
const providerFiles = {
id: 'files',
displayName: 'Files',
available: true,
previewSearch: {
available: true,
search: vi.fn(),
component
},
listSearch: {}
}
const providerContacts = {
id: 'contacts',
displayName: 'Contacts',
available: true,
previewSearch: {
available: true,
search: vi.fn(),
component
}
}
const selectors = {
search: '#files-global-search',
noResults: '#no-results',
searchInput: 'input',
searchInputClear: '.oc-search-clear',
providerListItem: '.provider',
providerDisplayName: '.provider .display-name',
providerMoreResultsLink: '.provider .more-results',
optionsHidden: '.tippy-box[data-state="hidden"]',
optionsVisible: '.tippy-box[data-state="visible"]'
}
vi.mock('lodash-es', () => ({ debounce: (fn) => fn }))
vi.mock('../../../src/composables/useAvailableProviders')
beforeEach(() => {
providerFiles.previewSearch.search.mockImplementation(() => {
return {
values: [
{ id: 'f1', data: 'albert.txt' },
{ id: 'f2', data: 'marie.txt' }
]
}
})
providerContacts.previewSearch.search.mockImplementation(() => {
return {
values: [
{ id: 'c1', data: 'albert' },
{ id: 'c2', data: 'marie' }
]
}
})
})
let wrapper
afterEach(() => {
wrapper.unmount()
})
describe('Search Bar portal component', () => {
vi.spyOn(console, 'warn').mockImplementation(undefined)
test('does not render a search field if no availableProviders given', () => {
wrapper = getMountedWrapper({ providers: [] }).wrapper
expect(wrapper.find(selectors.search).exists()).toBeFalsy()
})
test('does not render a search field if no user given', () => {
wrapper = getMountedWrapper({ userContextReady: false }).wrapper
expect(wrapper.find(selectors.search).exists()).toBeFalsy()
})
test('updates the search term on input', () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('alice')
expect(wrapper.vm.term).toBe('alice')
})
test('shows message if no results are available', async () => {
wrapper = getMountedWrapper().wrapper
providerFiles.previewSearch.search.mockImplementationOnce(() => {
return {
values: []
}
})
providerContacts.previewSearch.search.mockImplementationOnce(() => {
return {
values: []
}
})
wrapper.find(selectors.searchInput).setValue('nothing found')
await flushPromises()
expect(wrapper.find(selectors.noResults)).toBeTruthy()
})
test('displays all available providers', async () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('albert')
await nextTicks(3)
expect(wrapper.findAll(selectors.providerListItem).length).toEqual(2)
})
test('only displays provider list item if search results are attached', async () => {
wrapper = getMountedWrapper().wrapper
providerContacts.previewSearch.search.mockImplementation(() => {
return {
values: []
}
})
wrapper.find(selectors.searchInput).setValue('albert')
await nextTicks(3)
expect(wrapper.findAll(selectors.providerListItem).length).toEqual(1)
})
test('displays the provider name in the provider list item', async () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('albert')
await nextTicks(3)
const providerDisplayNameItems = wrapper.findAll(selectors.providerDisplayName)
expect(providerDisplayNameItems.at(0).text()).toEqual('Files')
expect(providerDisplayNameItems.at(1).text()).toEqual('Contacts')
})
test('The search provider only displays the more results link if a listSearch component is present', async () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('albert')
await nextTicks(3)
expect(wrapper.findAll(selectors.providerMoreResultsLink).length).toEqual(1)
})
test('hides options on preview item click', async () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('albert')
await nextTicks(3)
expect(wrapper.findAll(selectors.optionsVisible).length).toEqual(1)
wrapper.findAll('.preview-component').at(0).trigger('click')
expect(wrapper.findAll(selectors.optionsHidden).length).toEqual(1)
})
test('hides options on key press enter', async () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('albert')
await flushPromises()
expect(wrapper.findAll(selectors.optionsVisible).length).toEqual(1)
wrapper.find(selectors.searchInput).trigger('keyup.enter')
expect(wrapper.findAll(selectors.optionsHidden).length).toEqual(1)
})
test('hides options on key press escape', async () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('albert')
await flushPromises()
expect(wrapper.findAll(selectors.optionsVisible).length).toEqual(1)
wrapper.find(selectors.searchInput).trigger('keyup.esc')
expect(wrapper.findAll(selectors.optionsHidden).length).toEqual(1)
})
test('hides options if no search term is given', async () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('albert')
await flushPromises()
expect(wrapper.findAll(selectors.optionsVisible).length).toEqual(1)
wrapper.find(selectors.searchInput).setValue('')
expect(wrapper.findAll(selectors.optionsHidden).length).toEqual(1)
})
test('sets the search term according to route value on mount', async () => {
wrapper = getMountedWrapper({
mocks: {
$route: {
query: {
term: 'alice'
}
}
}
}).wrapper
await wrapper.vm.$nextTick()
expect(wrapper.vm.term).toBe('alice')
expect((wrapper.get('input').element as HTMLInputElement).value).toBe('alice')
})
test('sets active preview item via keyboard navigation', async () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('albert')
await flushPromises()
wrapper.find(selectors.searchInput).trigger('keyup.down')
wrapper.find(selectors.searchInput).trigger('keyup.down')
})
test('navigates to files-common-search route on key press enter if search term is given', async () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('albert')
const spyRouterPushStub = wrapper.vm.$router.push
await flushPromises()
wrapper.find(selectors.searchInput).trigger('keyup.enter')
expect(spyRouterPushStub).toHaveBeenCalledTimes(1)
expect(spyRouterPushStub).toHaveBeenCalledWith({
name: 'files-common-search',
query: expect.objectContaining({ term: 'albert', provider: 'files.sdk' })
})
})
test('does not navigate to the list view if no list provider given', async () => {
wrapper = getMountedWrapper({ providers: [providerContacts] }).wrapper
wrapper.find(selectors.searchInput).setValue('albert')
const spyRouterPushStub = wrapper.vm.$router.push
await flushPromises()
wrapper.find(selectors.searchInput).trigger('keyup.enter')
expect(spyRouterPushStub).not.toHaveBeenCalled()
})
})
function getMountedWrapper({
mocks = {},
userContextReady = true,
providers = [providerFiles, providerContacts]
} = {}) {
vi.mocked(useAvailableProviders).mockReturnValue(ref(providers))
const currentRoute = mock<RouteLocation>({
name: 'files-spaces-generic',
query: {
term: '',
provider: ''
}
})
const localMocks = {
...defaultComponentMocks({ currentRoute }),
...mocks
}
return {
wrapper: mount(SearchBar, {
attachTo: document.body,
global: {
plugins: [
...defaultPlugins({
piniaOptions: { authState: { userContextReady: userContextReady } }
})
],
mocks: localMocks,
provide: localMocks,
stubs: {
'router-link': true
}
}
})
}
}
| owncloud/web/packages/web-app-search/tests/unit/portals/SearchBar.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-search/tests/unit/portals/SearchBar.spec.ts",
"repo_id": "owncloud",
"token_count": 3175
} | 832 |
<template>
<main
class="webfinger-resolve oc-height-viewport oc-flex oc-flex-column oc-flex-center oc-flex-middle"
>
<h1 class="oc-invisible-sr" v-text="pageTitle" />
<div class="oc-card oc-card-body oc-text-center oc-width-large">
<template v-if="hasError">
<h2 key="webfinger-resolve-error">
<span v-text="$gettext('Sorry!')" />
</h2>
<p v-text="$gettext('Something went wrong.')" />
<p v-text="$gettext('We could not resolve the destination.')" />
</template>
<template v-else>
<h2 key="webfinger-resolve-loading">
<span v-text="$gettext('One moment please…')" />
</h2>
<p v-text="$gettext('You are being redirected.')" />
</template>
</div>
</main>
</template>
<script lang="ts">
import { computed, defineComponent, ref, unref, watch } from 'vue'
import {
useClientService,
useConfigStore,
useLoadingService,
useRoute,
useRouteMeta
} from '@ownclouders/web-pkg'
import { OwnCloudServer, WebfingerDiscovery } from 'web-app-webfinger/src/discovery'
import { useGettext } from 'vue3-gettext'
import { useAuthService } from '@ownclouders/web-pkg'
export default defineComponent({
name: 'WebfingerResolve',
setup() {
const configStore = useConfigStore()
const clientService = useClientService()
const loadingService = useLoadingService()
const authService = useAuthService()
const route = useRoute()
const { $gettext } = useGettext()
const title = useRouteMeta('title', '')
const pageTitle = computed(() => {
return $gettext(unref(title))
})
const ownCloudServers = ref<OwnCloudServer[]>([])
const hasError = ref(false)
const webfingerDiscovery = new WebfingerDiscovery(configStore.serverUrl, clientService)
loadingService.addTask(async () => {
try {
const servers = await webfingerDiscovery.discoverOwnCloudServers()
ownCloudServers.value = servers
if (servers.length === 0) {
hasError.value = true
}
} catch (e) {
console.error(e)
if (e.response?.status === 401) {
return authService.handleAuthError(unref(route))
}
hasError.value = true
}
})
watch(ownCloudServers, (instances) => {
if (instances.length === 0) {
return
}
// we can't deal with multi-instance results. just pick the first one for now.
window.location.href = ownCloudServers.value[0].href
})
return {
pageTitle,
ownCloudInstances: ownCloudServers,
hasError
}
}
})
</script>
<style lang="scss">
.webfinger-resolve {
.oc-card {
background: var(--oc-color-background-highlight);
border-radius: 15px;
&-body {
h2 {
margin-top: 0;
}
p {
font-size: var(--oc-font-size-large);
}
}
}
}
</style>
| owncloud/web/packages/web-app-webfinger/src/views/Resolve.vue/0 | {
"file_path": "owncloud/web/packages/web-app-webfinger/src/views/Resolve.vue",
"repo_id": "owncloud",
"token_count": 1200
} | 833 |
import { AxiosInstance, AxiosPromise, AxiosResponse } from 'axios'
import {
CollectionOfDrives,
CollectionOfGroup,
CollectionOfUser,
Configuration,
Drive,
DrivesApiFactory,
Group,
GroupApiFactory,
GroupsApiFactory,
MeChangepasswordApiFactory,
MeDrivesApi,
MeUserApiFactory,
User,
UserApiFactory,
UsersApiFactory,
TagsApiFactory,
CollectionOfTags,
TagAssignment,
TagUnassignment,
DrivesGetDrivesApi,
CollectionOfApplications,
ApplicationsApiFactory,
UserAppRoleAssignmentApiFactory,
AppRoleAssignment,
ExportPersonalDataRequest,
MeDriveApiFactory,
RoleManagementApiFactory,
UnifiedRoleDefinition,
CollectionOfDriveItems1,
DriveItemApiFactory,
DrivesRootApiFactory,
DriveItem,
DrivesPermissionsApiFactory,
Permission,
DriveItemCreateLink,
DriveItemInvite,
SharingLinkPassword,
CollectionOfPermissions,
CollectionOfPermissionsWithAllowedValues
} from './generated'
export interface Graph {
applications: {
listApplications: () => AxiosPromise<CollectionOfApplications>
}
tags: {
getTags: () => AxiosPromise<CollectionOfTags>
assignTags: (tagAssignment?: TagAssignment) => AxiosPromise<void>
unassignTags: (tagUnassignment?: TagUnassignment) => AxiosPromise<void>
}
drives: {
listMyDrives: (orderBy?: string, filter?: string) => Promise<AxiosResponse<CollectionOfDrives>>
listAllDrives: (orderBy?: string, filter?: string) => Promise<AxiosResponse<CollectionOfDrives>>
listSharedWithMe: () => AxiosPromise<CollectionOfDriveItems1>
listSharedByMe: () => AxiosPromise<CollectionOfDriveItems1>
getDrive: (id: string) => AxiosPromise<Drive>
createDrive: (drive: Drive, options: any) => AxiosPromise<Drive>
updateDrive: (id: string, drive: Drive, options: any) => AxiosPromise<Drive>
disableDrive: (id: string) => AxiosPromise<void>
deleteDrive: (id: string) => AxiosPromise<void>
deleteDriveItem: (driveId: string, itemId: string) => AxiosPromise<void>
createDriveItem: (driveId: string, driveItem: DriveItem) => AxiosPromise<DriveItem>
}
users: {
getUser: (userId: string) => AxiosPromise<User>
createUser: (user: User) => AxiosPromise<User>
getMe: () => AxiosPromise<User>
editMe: (user: User) => AxiosPromise<User>
changeOwnPassword: (currentPassword: string, newPassword: string) => AxiosPromise<void>
editUser: (userId: string, user: User) => AxiosPromise<User>
deleteUser: (userId: string) => AxiosPromise<void>
listUsers: (
orderBy?: string,
filter?: string,
expand?: Array<'drive' | 'drives' | 'memberOf' | 'appRoleAssignments'>,
search?: string
) => AxiosPromise<CollectionOfUser>
createUserAppRoleAssignment: (
userId: string,
appRoleAssignment: AppRoleAssignment
) => AxiosPromise<AppRoleAssignment>
exportPersonalData: (
userId: string,
exportPersonalDataRequest?: ExportPersonalDataRequest
) => AxiosPromise<void>
}
groups: {
listGroups: (
orderBy?: string,
expand?: Array<'members'>,
search?: string
) => AxiosPromise<CollectionOfGroup>
createGroup: (group: Group) => AxiosPromise<Group>
getGroup: (groupId: string) => AxiosPromise<Group>
editGroup: (groupId: string, group: Group) => AxiosPromise<void>
deleteGroup: (groupId: string) => AxiosPromise<void>
addMember: (groupId: string, userId: string, server: string) => AxiosPromise<void>
deleteMember: (groupId: string, userId: string) => AxiosPromise<void>
}
roleManagement: {
listPermissionRoleDefinitions: () => AxiosPromise<UnifiedRoleDefinition>
}
permissions: {
getPermission: (driveId: string, itemId: string, permId: string) => AxiosPromise<Permission>
listPermissions: (
driveId: string,
itemId: string
) => AxiosPromise<CollectionOfPermissionsWithAllowedValues>
createLink: (
driveId: string,
itemId: string,
driveItemCreateLink?: DriveItemCreateLink
) => AxiosPromise<Permission>
invite: (
driveId: string,
itemId: string,
driveItemInvite?: DriveItemInvite
) => AxiosPromise<CollectionOfPermissions>
deletePermission: (driveId: string, itemId: string, permId: string) => AxiosPromise<void>
updatePermission: (
driveId: string,
itemId: string,
permId: string,
permission: Permission
) => AxiosPromise<Permission>
setPermissionPassword: (
driveId: string,
itemId: string,
permId: string,
sharingLinkPassword: SharingLinkPassword
) => AxiosPromise<Permission>
}
}
export const graph = (baseURI: string, axiosClient: AxiosInstance): Graph => {
const url = new URL(baseURI)
url.pathname = [...url.pathname.split('/'), 'graph'].filter(Boolean).join('/')
const config = new Configuration({
basePath: url.href
})
const meDrivesApi = new MeDrivesApi(config, config.basePath, axiosClient)
const allDrivesApi = new DrivesGetDrivesApi(config, config.basePath, axiosClient)
const meUserApiFactory = MeUserApiFactory(config, config.basePath, axiosClient)
const meDriveApiFactory = MeDriveApiFactory(config, config.basePath, axiosClient)
const meChangepasswordApiFactory = MeChangepasswordApiFactory(
config,
config.basePath,
axiosClient
)
const applicationsApiFactory = ApplicationsApiFactory(config, config.basePath, axiosClient)
const userApiFactory = UserApiFactory(config, config.basePath, axiosClient)
const usersApiFactory = UsersApiFactory(config, config.basePath, axiosClient)
const userAppRoleAssignmentApiFactory = UserAppRoleAssignmentApiFactory(
config,
config.basePath,
axiosClient
)
const groupApiFactory = GroupApiFactory(config, config.basePath, axiosClient)
const groupsApiFactory = GroupsApiFactory(config, config.basePath, axiosClient)
const drivesApiFactory = DrivesApiFactory(config, config.basePath, axiosClient)
const tagsApiFactory = TagsApiFactory(config, config.basePath, axiosClient)
const roleManagementApiFactory = RoleManagementApiFactory(config, config.basePath, axiosClient)
const driveItemApiFactory = DriveItemApiFactory(config, config.basePath, axiosClient)
const drivesRootApiFactory = DrivesRootApiFactory(config, config.basePath, axiosClient)
const drivesPermissionsApiFactory = DrivesPermissionsApiFactory(
config,
config.basePath,
axiosClient
)
return <Graph>{
applications: {
listApplications: () => applicationsApiFactory.listApplications()
},
tags: {
getTags: () => tagsApiFactory.getTags(),
assignTags: (tagAssignment: TagAssignment) => tagsApiFactory.assignTags(tagAssignment),
unassignTags: (tagUnassignment: TagUnassignment) =>
tagsApiFactory.unassignTags(tagUnassignment)
},
drives: {
listMyDrives: (orderBy?: string, filter?: string) =>
meDrivesApi.listMyDrives(orderBy, filter),
listAllDrives: (orderBy?: string, filter?: string) =>
allDrivesApi.listAllDrives(orderBy, filter),
listSharedWithMe: () => meDriveApiFactory.listSharedWithMe(),
listSharedByMe: () => meDriveApiFactory.listSharedByMe(),
getDrive: (id: string) => drivesApiFactory.getDrive(id),
createDrive: (drive: Drive, options: any): AxiosPromise<Drive> =>
drivesApiFactory.createDrive(drive, options),
updateDrive: (id: string, drive: Drive, options: any): AxiosPromise<Drive> =>
drivesApiFactory.updateDrive(id, drive, options),
disableDrive: (id: string): AxiosPromise<void> => drivesApiFactory.deleteDrive(id, '', {}),
deleteDrive: (id: string): AxiosPromise<void> =>
drivesApiFactory.deleteDrive(id, '', {
headers: {
Purge: 'T'
}
}),
deleteDriveItem: (driveId: string, itemId: string) =>
driveItemApiFactory.deleteDriveItem(driveId, itemId),
createDriveItem: (driveId: string, driveItem: DriveItem) =>
drivesRootApiFactory.createDriveItem(driveId, driveItem)
},
users: {
getUser: (userId: string) =>
userApiFactory.getUser(
userId,
new Set<any>([]),
new Set<any>(['drive', 'memberOf', 'appRoleAssignments'])
),
createUser: (user: User) => usersApiFactory.createUser(user),
getMe: () => meUserApiFactory.getOwnUser(new Set<any>(['memberOf'])),
editMe: (user: User) => meUserApiFactory.updateOwnUser(user),
changeOwnPassword: (currentPassword, newPassword) =>
meChangepasswordApiFactory.changeOwnPassword({ currentPassword, newPassword }),
editUser: (userId: string, user: User) => userApiFactory.updateUser(userId, user),
deleteUser: (userId: string) => userApiFactory.deleteUser(userId),
listUsers: (
orderBy?: any,
filter?: string,
expand?: Array<'drive' | 'drives' | 'memberOf' | 'appRoleAssignments'>,
search: string = ''
) =>
usersApiFactory.listUsers(
search,
filter,
orderBy ? new Set<any>([orderBy]) : null,
null,
expand ? new Set<any>(expand) : null
),
createUserAppRoleAssignment: (userId: string, appRoleAssignment: AppRoleAssignment) =>
userAppRoleAssignmentApiFactory.userCreateAppRoleAssignments(userId, appRoleAssignment),
exportPersonalData: (userId: string, exportPersonalDataRequest?: ExportPersonalDataRequest) =>
userApiFactory.exportPersonalData(userId, exportPersonalDataRequest)
},
groups: {
createGroup: (group: Group) => groupsApiFactory.createGroup(group),
editGroup: (groupId: string, group: Group) => groupApiFactory.updateGroup(groupId, group),
getGroup: (groupId: string) =>
groupApiFactory.getGroup(groupId, new Set<any>([]), new Set<any>(['members'])),
deleteGroup: (groupId: string) => groupApiFactory.deleteGroup(groupId),
listGroups: (orderBy?: any, expand?: Array<'members'>, search: string = '') =>
groupsApiFactory.listGroups(
search,
orderBy ? new Set<any>([orderBy]) : null,
null,
expand ? new Set<any>(expand) : null
),
addMember: (groupId: string, userId: string, server: string) =>
groupApiFactory.addMember(groupId, { '@odata.id': `${server}graph/v1.0/users/${userId}` }),
deleteMember: (groupId: string, userId: string) =>
groupApiFactory.deleteMember(groupId, userId)
},
roleManagement: {
listPermissionRoleDefinitions: () => roleManagementApiFactory.listPermissionRoleDefinitions()
},
permissions: {
getPermission: (driveId: string, itemId: string, permId: string) =>
drivesPermissionsApiFactory.getPermission(driveId, itemId, permId),
listPermissions: (driveId: string, itemId: string) =>
drivesPermissionsApiFactory.listPermissions(driveId, itemId),
createLink: (driveId: string, itemId: string, driveItemCreateLink?: DriveItemCreateLink) =>
drivesPermissionsApiFactory.createLink(driveId, itemId, driveItemCreateLink),
invite: (driveId: string, itemId: string, driveItemInvite?: DriveItemInvite) =>
drivesPermissionsApiFactory.invite(driveId, itemId, driveItemInvite),
deletePermission: (driveId: string, itemId: string, permId: string) =>
drivesPermissionsApiFactory.deletePermission(driveId, itemId, permId),
updatePermission: (driveId: string, itemId: string, permId: string, permission: Permission) =>
drivesPermissionsApiFactory.updatePermission(driveId, itemId, permId, permission),
setPermissionPassword: (
driveId: string,
itemId: string,
permId: string,
sharingLinkPassword: SharingLinkPassword
) =>
drivesPermissionsApiFactory.setPermissionPassword(
driveId,
itemId,
permId,
sharingLinkPassword
)
}
}
}
| owncloud/web/packages/web-client/src/graph.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/graph.ts",
"repo_id": "owncloud",
"token_count": 4445
} | 834 |
import { User } from '../../generated'
import { extractDomSelector, extractNodeId, Resource, SpaceRole } from '../resource'
import {
PublicSpaceResource,
ShareSpaceResource,
SpaceResource,
SHARE_JAIL_ID,
OCM_PROVIDER_ID
} from './types'
import { DavProperty } from '../../webdav/constants'
import { buildWebDavPublicPath, buildWebDavOcmPath } from '../publicLink'
import { urlJoin } from '../../utils'
import { Drive, DriveItem } from '@ownclouders/web-client/src/generated'
export function buildWebDavSpacesPath(storageId: string | number, path?: string) {
return urlJoin('spaces', storageId, path, {
leadingSlash: true
})
}
export function buildWebDavSpacesTrashPath(storageId: string, path = '') {
return urlJoin('spaces', 'trash-bin', storageId, path, {
leadingSlash: true
})
}
export function getRelativeSpecialFolderSpacePath(space: SpaceResource, type: 'image' | 'readme') {
const typeMap = { image: 'spaceImageData', readme: 'spaceReadmeData' }
const webDavPathComponents = decodeURI(space[typeMap[type]].webDavUrl).split('/')
const idComponent = webDavPathComponents.find((c) => c.startsWith(space.id.toString()))
if (!idComponent) {
return ''
}
return webDavPathComponents.slice(webDavPathComponents.indexOf(idComponent) + 1).join('/')
}
export type PublicLinkType = 'ocm' | 'public-link'
export function buildPublicSpaceResource(
data: any & { publicLinkType: PublicLinkType }
): PublicSpaceResource {
const publicLinkPassword = data.publicLinkPassword
const fileId = data.props?.[DavProperty.FileId]
const publicLinkItemType = data.props?.[DavProperty.PublicLinkItemType]
const publicLinkPermission = data.props?.[DavProperty.PublicLinkPermission]
const publicLinkExpiration = data.props?.[DavProperty.PublicLinkExpiration]
const publicLinkShareDate = data.props?.[DavProperty.PublicLinkShareDate]
const publicLinkShareOwner = data.props?.[DavProperty.PublicLinkShareOwner]
let driveAlias
let webDavPath
if (data.publicLinkType === 'ocm') {
driveAlias = `ocm/${data.id}`
webDavPath = buildWebDavOcmPath(data.id)
} else {
driveAlias = `public/${data.id}`
webDavPath = buildWebDavPublicPath(data.id)
}
return Object.assign(
buildSpace({
...data,
driveType: 'public',
driveAlias,
webDavPath
}),
{
...(fileId && { fileId }),
...(publicLinkPassword && { publicLinkPassword }),
...(publicLinkItemType && { publicLinkItemType }),
...(publicLinkPermission && { publicLinkPermission: parseInt(publicLinkPermission) }),
...(publicLinkExpiration && { publicLinkExpiration }),
...(publicLinkShareDate && { publicLinkShareDate }),
...(publicLinkShareOwner && { publicLinkShareOwner })
}
)
}
export function buildShareSpaceResource({
driveAliasPrefix,
shareId,
shareName,
serverUrl
}: {
driveAliasPrefix: 'share' | 'ocm-share'
shareId: string | number
shareName: string
serverUrl: string
}): ShareSpaceResource {
let id
if (driveAliasPrefix === 'ocm-share') {
id = `${OCM_PROVIDER_ID}$${shareId}!${shareId}`
} else {
id = [SHARE_JAIL_ID, shareId].join('!')
}
const space = buildSpace({
id,
driveAlias: `${driveAliasPrefix}/${shareName}`,
driveType: 'share',
name: shareName,
shareId,
serverUrl
}) as ShareSpaceResource
space.rename = (newName: string) => {
space.driveAlias = `${driveAliasPrefix}/${newName}`
space.name = newName
}
return space
}
export function buildSpace(
data: Drive & {
path?: string
serverUrl?: string
shareId?: string | number
webDavPath?: string
webDavTrashPath?: string
}
): SpaceResource {
let spaceImageData: DriveItem, spaceReadmeData: DriveItem
let disabled = false
const spaceRoles: Resource['spaceRoles'] = { viewer: [], editor: [], manager: [] }
if (data.special) {
spaceImageData = data.special.find((el) => el.specialFolder.name === 'image')
spaceReadmeData = data.special.find((el) => el.specialFolder.name === 'readme')
if (spaceImageData) {
spaceImageData.webDavUrl = decodeURI(spaceImageData.webDavUrl)
}
if (spaceReadmeData) {
spaceReadmeData.webDavUrl = decodeURI(spaceReadmeData.webDavUrl)
}
}
if (data.root?.permissions) {
for (const permission of data.root.permissions) {
spaceRoles[permission.roles[0]].push(
...permission.grantedToIdentities.reduce((acc, info) => {
const kind = info.hasOwnProperty('group') ? 'group' : 'user'
const spaceRole: SpaceRole = {
kind,
id: info[kind].id,
displayName: info[kind].displayName,
isMember(u?: User): boolean {
if (!u) {
return false
}
switch (this.kind) {
case 'user':
return this.id == u.id
case 'group':
return u.memberOf.map((g) => g.id).includes(this.id)
default:
return false
}
}
}
return [...acc, spaceRole]
}, [])
)
}
if (data.root?.deleted) {
disabled = data.root.deleted?.state === 'trashed'
}
}
const webDavPath = urlJoin(data.webDavPath || buildWebDavSpacesPath(data.id), {
leadingSlash: true
})
const webDavUrl = urlJoin(data.serverUrl, 'remote.php/dav', webDavPath)
const webDavTrashPath = urlJoin(data.webDavTrashPath || buildWebDavSpacesTrashPath(data.id), {
leadingSlash: true
})
const webDavTrashUrl = urlJoin(data.serverUrl, 'remote.php/dav', webDavTrashPath)
const s = {
id: data.id,
fileId: data.id,
storageId: data.id,
mimeType: '',
name: data.name,
description: data.description,
extension: '',
path: '/',
webDavPath,
webDavTrashPath,
driveAlias: data.driveAlias,
driveType: data.driveType,
type: 'space',
isFolder: true,
mdate: data.lastModifiedDateTime,
size: data.quota?.used,
indicators: [],
tags: [],
permissions: '',
starred: false,
etag: '',
shareId: data.shareId?.toString(),
shareTypes: (function () {
return []
})(),
privateLink: '',
downloadURL: '',
owner: data.owner?.user,
disabled,
root: data.root,
spaceQuota: data.quota,
spaceRoles,
spaceImageData,
spaceReadmeData,
canUpload: function ({ user }: { user?: User } = {}): boolean {
return this.isManager(user) || this.isEditor(user)
},
canDownload: function () {
return true
},
canBeDeleted: function ({ user, ability }: { user?: User; ability?: any } = {}) {
return this.disabled && (ability?.can('delete-all', 'Drive') || this.isManager(user))
},
canRename: function ({ user, ability }: { user?: User; ability?: any } = {}) {
return ability?.can('update-all', 'Drive') || this.isManager(user)
},
canEditDescription: function ({ user, ability }: { user?: User; ability?: any } = {}) {
return ability?.can('update-all', 'Drive') || this.isManager(user)
},
canRestore: function ({ user, ability }: { user?: User; ability?: any } = {}) {
return this.disabled && (ability?.can('update-all', 'Drive') || this.isManager(user))
},
canDisable: function ({ user, ability }: { user?: User; ability?: any } = {}) {
return !this.disabled && (ability?.can('delete-all', 'Drive') || this.isManager(user))
},
canShare: function ({ user }: { user?: User } = {}) {
return this.isManager(user)
},
canEditImage: function ({ user }: { user?: User } = {}) {
return !this.disabled && (this.isManager(user) || this.isEditor(user))
},
canEditReadme: function ({ user }: { user?: User } = {}) {
return this.isManager(user) || this.isEditor(user)
},
canRemoveFromTrashbin: function ({ user }: { user?: User } = {}) {
return this.isManager(user)
},
canCreate: function () {
return true
},
canEditTags: function () {
return false
},
isMounted: function () {
return true
},
isReceivedShare: function () {
return false
},
isShareRoot: function () {
return ['share', 'mountpoint', 'public'].includes(data.driveType)
},
canDeny: () => false,
getDomSelector: () => extractDomSelector(data.id),
getDriveAliasAndItem({ path }: Resource): string {
return urlJoin(this.driveAlias, path, {
leadingSlash: false
})
},
getWebDavUrl({ path }: { path: string }): string {
return urlJoin(webDavUrl, path)
},
getWebDavTrashUrl({ path }: { path: string }): string {
return urlJoin(webDavTrashUrl, path)
},
isViewer(user: User): boolean {
return this.spaceRoles.viewer.map((r) => r.isMember(user)).some(Boolean)
},
isEditor(user: User): boolean {
return this.spaceRoles.editor.map((r) => r.isMember(user)).some(Boolean)
},
isManager(user: User): boolean {
return this.spaceRoles.manager.map((r) => r.isMember(user)).some(Boolean)
},
isMember(user: User): boolean {
return this.isViewer(user) || this.isEditor(user) || this.isManager(user)
},
isOwner({ id }: User): boolean {
return id === this.owner?.id
}
}
Object.defineProperty(s, 'nodeId', {
get() {
return extractNodeId(this.id)
}
})
return s
}
| owncloud/web/packages/web-client/src/helpers/space/functions.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/helpers/space/functions.ts",
"repo_id": "owncloud",
"token_count": 3735
} | 835 |
export * from './builders'
export * from './dav'
export * from './parsers'
| owncloud/web/packages/web-client/src/webdav/client/index.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/webdav/client/index.ts",
"repo_id": "owncloud",
"token_count": 27
} | 836 |
import { buildResource } from '../helpers/resource'
import { DavProperties, DavPropertyValue } from './constants'
import { urlJoin } from '../utils'
import { DAV, buildAuthHeader } from './client'
import { WebDavOptions } from './types'
import { unref } from 'vue'
import { ListFilesResult } from './listFiles'
export type ListFilesByIdOptions = {
depth?: number
davProperties?: DavPropertyValue[]
}
export const ListFilesByIdFactory = (dav: DAV, { accessToken }: WebDavOptions) => {
return {
async listFilesById(
{ fileId }: { fileId?: string },
{ depth = 1, davProperties }: ListFilesByIdOptions = {}
): Promise<ListFilesResult> {
const headers = buildAuthHeader(unref(accessToken), null)
const webDavPath = urlJoin('/spaces', fileId)
const webDavResources = await dav.propfind(webDavPath, {
depth,
headers,
properties: davProperties || DavProperties.Default
})
const resources = webDavResources.map(buildResource)
return { resource: resources[0], children: resources.slice(1) } as ListFilesResult
}
}
}
| owncloud/web/packages/web-client/src/webdav/listFilesById.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/webdav/listFilesById.ts",
"repo_id": "owncloud",
"token_count": 385
} | 837 |
{
"ignores": [
"web-pkg"
]
} | owncloud/web/packages/web-pkg/.depcheckrc/0 | {
"file_path": "owncloud/web/packages/web-pkg/.depcheckrc",
"repo_id": "owncloud",
"token_count": 22
} | 838 |
<template>
<main :id="applicationId" class="oc-height-1-1" @keydown.esc="closeApp">
<h1 class="oc-invisible-sr" v-text="pageTitle" />
<app-top-bar
v-if="!loading && !loadingError"
:main-actions="fileActions"
:resource="resource"
@close="closeApp"
/>
<loading-screen v-if="loading" />
<error-screen v-else-if="loadingError" :message="loadingError.message" />
<div
v-else
class="oc-flex oc-width-1-1 oc-height-1-1"
:class="{ 'app-sidebar-open': isSideBarOpen }"
>
<slot class="oc-height-1-1 oc-width-1-1" v-bind="slotAttrs" />
<file-side-bar :is-open="isSideBarOpen" :active-panel="sideBarActivePanel" :space="space" />
</div>
</main>
</template>
<script lang="ts">
import {
PropType,
Ref,
defineComponent,
onBeforeUnmount,
ref,
unref,
watch,
computed,
onMounted
} from 'vue'
import { DateTime } from 'luxon'
import { useTask } from 'vue-concurrency'
import { useGettext } from 'vue3-gettext'
import { onBeforeRouteLeave, useRouter } from 'vue-router'
import AppTopBar from '../AppTopBar.vue'
import ErrorScreen from './PartialViews/ErrorScreen.vue'
import LoadingScreen from './PartialViews/LoadingScreen.vue'
import { FileSideBar } from '../SideBar'
import {
UrlForResourceOptions,
queryItemAsString,
useAppDefaults,
useClientService,
useRoute,
useRouteParam,
useRouteQuery,
useSelectedResources,
useSideBar,
useModals,
useMessages,
useSpacesStore,
useAppsStore,
useConfigStore,
useResourcesStore,
FileContentOptions
} from '../../composables'
import {
Action,
ActionOptions,
ModifierKey,
Key,
useAppMeta,
useGetResourceContext,
useKeyboardActions
} from '../../composables'
import {
Resource,
SpaceResource,
isPersonalSpaceResource,
isProjectSpaceResource
} from '@ownclouders/web-client/src/helpers'
import { DavPermission } from '@ownclouders/web-client/src/webdav/constants'
import { HttpError } from '@ownclouders/web-client/src/errors'
import { dirname } from 'path'
export default defineComponent({
name: 'AppWrapper',
components: {
AppTopBar,
FileSideBar,
ErrorScreen,
LoadingScreen
},
props: {
// TODO: Add app-top-bar-actions array prop and pass to AppTopBar
applicationId: {
type: String,
required: true
},
urlForResourceOptions: {
type: Object as PropType<UrlForResourceOptions>,
default: () => null,
required: false
},
fileContentOptions: {
type: Object as PropType<FileContentOptions>,
default: () => null,
required: false
},
wrappedComponent: {
type: Object as PropType<ReturnType<typeof defineComponent>>,
default: null
},
importResourceWithExtension: {
type: Function as PropType<(Resource) => string>,
default: () => null
}
},
setup(props) {
const { $gettext } = useGettext()
const appsStore = useAppsStore()
const { showMessage, showErrorMessage } = useMessages()
const router = useRouter()
const currentRoute = useRoute()
const clientService = useClientService()
const { getResourceContext } = useGetResourceContext()
const { selectedResources } = useSelectedResources()
const { dispatchModal } = useModals()
const spacesStore = useSpacesStore()
const configStore = useConfigStore()
const resourcesStore = useResourcesStore()
const applicationName = ref('')
const resource: Ref<Resource> = ref()
const space: Ref<SpaceResource> = ref()
const currentETag = ref('')
const url = ref('')
const loading = ref(true)
const loadingError: Ref<Error> = ref()
const isReadOnly = ref(false)
const serverContent = ref()
const currentContent = ref()
const isEditor = computed(() => {
return Boolean(props.wrappedComponent.emits?.includes('update:currentContent'))
})
const hasProp = (name: string) => {
return Boolean(Object.keys(props.wrappedComponent.props).includes(name))
}
const isDirty = computed(() => {
return unref(currentContent) !== unref(serverContent)
})
const preventUnload = (e) => {
e.preventDefault()
e.returnValue = ''
}
watch(isDirty, (dirty) => {
// Prevent reload if there are changes
if (dirty) {
window.addEventListener('beforeunload', preventUnload)
} else {
window.removeEventListener('beforeunload', preventUnload)
}
})
const {
applicationConfig,
closeApp,
currentFileContext,
getFileContents,
getFileInfo,
getUrlForResource,
putFileContents,
replaceInvalidFileRoute,
revokeUrl
} = useAppDefaults({
applicationId: props.applicationId
})
const { applicationMeta } = useAppMeta({ applicationId: props.applicationId, appsStore })
const pageTitle = computed(() => {
const { name: appName } = unref(applicationMeta)
return $gettext(`%{appName} for %{fileName}`, {
appName: unref(applicationName) || $gettext(appName),
fileName: unref(unref(currentFileContext).fileName)
})
})
const driveAliasAndItem = useRouteParam('driveAliasAndItem')
const fileIdQueryItem = useRouteQuery('fileId')
const fileId = computed(() => {
return queryItemAsString(unref(fileIdQueryItem))
})
const addMissingDriveAliasAndItem = async () => {
const id = unref(fileId)
const { space, path } = await getResourceContext(id)
const driveAliasAndItem = space.getDriveAliasAndItem({ path } as Resource)
if (isPersonalSpaceResource(space)) {
return router.push({
params: {
...unref(currentRoute).params,
driveAliasAndItem
},
query: {
...unref(currentRoute).query,
fileId: id,
contextRouteName: 'files-spaces-generic',
contextRouteParams: { driveAliasAndItem: dirname(driveAliasAndItem) } as any
}
})
}
return router.push({
params: {
...unref(currentRoute).params,
driveAliasAndItem
},
query: {
...unref(currentRoute).query,
fileId: id,
shareId: space.shareId,
contextRouteName: path === '/' ? 'files-shares-with-me' : 'files-spaces-generic',
contextRouteParams: {
driveAliasAndItem: dirname(driveAliasAndItem)
} as any,
contextRouteQuery: {
shareId: space.shareId
} as any
}
})
}
const loadFileTask = useTask(function* () {
try {
if (!unref(driveAliasAndItem)) {
yield addMissingDriveAliasAndItem()
}
space.value = unref(unref(currentFileContext).space)
resource.value = yield getFileInfo(currentFileContext)
resourcesStore.initResourceList({ currentFolder: null, resources: [unref(resource)] })
selectedResources.value = [unref(resource)]
const newExtension = props.importResourceWithExtension(unref(resource))
if (newExtension) {
const timestamp = DateTime.local().toFormat('yyyyMMddHHmmss')
const targetPath = `${unref(resource).name}_${timestamp}.${newExtension}`
if (
!(yield clientService.webdav.copyFiles(unref(space), unref(resource), unref(space), {
path: targetPath
}))
) {
throw new Error($gettext('Importing failed'))
}
resource.value = { path: targetPath } as Resource
}
if (replaceInvalidFileRoute(currentFileContext, unref(resource))) {
return
}
isReadOnly.value = ![DavPermission.Updateable, DavPermission.FileUpdateable].some(
(p) => (unref(resource).permissions || '').indexOf(p) > -1
)
if (unref(hasProp('currentContent'))) {
const fileContentsResponse = yield getFileContents(
currentFileContext,
props.fileContentOptions
)
serverContent.value = currentContent.value = fileContentsResponse.body
currentETag.value = fileContentsResponse.headers['OC-ETag']
}
if (unref(hasProp('url'))) {
url.value = yield getUrlForResource(
unref(space),
unref(resource),
props.urlForResourceOptions
)
}
loading.value = false
} catch (e) {
console.error(e)
loadingError.value = e
loading.value = false
}
}).restartable()
watch(
currentFileContext,
() => {
loadFileTask.perform()
},
{ immediate: true }
)
onBeforeUnmount(() => {
if (unref(hasProp('url'))) {
revokeUrl(url.value)
}
})
const errorPopup = (error: HttpError) => {
console.error(error)
showErrorMessage({
title: $gettext('An error occurred'),
desc: error.message,
errors: [error]
})
}
const autosavePopup = () => {
showMessage({ title: $gettext('File autosaved') })
}
const saveFileTask = useTask(function* () {
const newContent = unref(currentContent)
try {
const putFileContentsResponse = yield putFileContents(currentFileContext, {
content: newContent,
previousEntityTag: unref(currentETag)
})
serverContent.value = newContent
currentETag.value = putFileContentsResponse.etag
resourcesStore.upsertResource(putFileContentsResponse)
} catch (e) {
switch (e.statusCode) {
case 401:
case 403:
errorPopup(
new HttpError($gettext("You're not authorized to save this file"), e.response)
)
break
case 409:
case 412:
errorPopup(
new HttpError(
$gettext(
'This file was updated outside this window. Please refresh the page (all changes will be lost).'
),
e.response
)
)
break
case 507:
const space = spacesStore.spaces.find(
(space) => space.id === unref(resource).storageId && isProjectSpaceResource(space)
)
if (space) {
errorPopup(
new HttpError(
$gettext('There is not enough quota on "%{spaceName}" to save this file', {
spaceName: space.name
}),
e.response
)
)
break
}
errorPopup(
new HttpError($gettext('There is not enough quota to save this file'), e.response)
)
break
default:
errorPopup(new HttpError('', e.response))
}
}
}).drop()
const save = async () => {
await saveFileTask.perform()
}
let autosaveIntervalId = null
onMounted(() => {
if (!unref(isEditor)) {
return
}
const editorOptions = configStore.options.editor
if (editorOptions.autosaveEnabled) {
autosaveIntervalId = setInterval(
async () => {
if (isDirty.value) {
await save()
autosavePopup()
}
},
(editorOptions.autosaveInterval || 120) * 1000
)
}
})
onBeforeUnmount(() => {
if (!unref(isEditor)) {
return
}
clearInterval(autosaveIntervalId)
autosaveIntervalId = null
})
const { bindKeyAction } = useKeyboardActions({ skipDisabledKeyBindingsCheck: true })
bindKeyAction({ modifier: ModifierKey.Ctrl, primary: Key.S }, () => {
if (!unref(isDirty)) {
return
}
save()
})
const fileActions = computed((): Action<ActionOptions>[] => [
{
name: 'save-file',
disabledTooltip: () => '',
isVisible: () => unref(isEditor),
isDisabled: () => isReadOnly.value || !isDirty.value,
componentType: 'button',
icon: 'save',
id: 'app-save-action',
label: () => 'Save',
handler: () => {
save()
}
}
])
onBeforeRouteLeave((_to, _from, next) => {
if (unref(isDirty)) {
dispatchModal({
variation: 'danger',
icon: 'warning',
title: $gettext('Unsaved changes'),
message: $gettext('Your changes were not saved. Do you want to save them?'),
cancelText: $gettext("Don't Save"),
confirmText: $gettext('Save'),
onCancel() {
next()
},
async onConfirm() {
await save()
next()
}
})
} else {
next()
}
})
const slotAttrs = computed(() => ({
url: unref(url),
space: unref(unref(currentFileContext).space),
resource: unref(resource),
isDirty: unref(isDirty),
isReadOnly: unref(isReadOnly),
applicationConfig: unref(applicationConfig),
currentFileContext: unref(currentFileContext),
currentContent: unref(currentContent),
'onUpdate:currentContent': (value) => {
currentContent.value = value
},
'onUpdate:applicationName': (value) => {
applicationName.value = value
},
onSave: save,
onClose: closeApp
}))
return {
...useSideBar(),
isEditor,
closeApp,
fileActions,
loading,
loadingError,
pageTitle,
resource,
space,
slotAttrs
}
}
})
</script>
<style lang="scss">
@media (max-width: $oc-breakpoint-medium-default) {
.app-sidebar-open > *:not(:last-child) {
display: none;
}
}
</style>
| owncloud/web/packages/web-pkg/src/components/AppTemplates/AppWrapper.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/AppTemplates/AppWrapper.vue",
"repo_id": "owncloud",
"token_count": 6076
} | 839 |
<template>
<oc-icon
:key="`resource-icon-${icon.name}`"
:name="icon.name"
:color="icon.color"
:size="size"
:class="['oc-resource-icon', iconTypeClass]"
/>
</template>
<script lang="ts">
import { computed, defineComponent, inject, PropType, unref } from 'vue'
import { Resource } from '@ownclouders/web-client'
import { AVAILABLE_SIZES } from 'design-system/src/helpers/constants'
import {
IconType,
createDefaultFileIconMapping,
ResourceIconMapping,
resourceIconMappingInjectionKey
} from '../../helpers/resource/icon'
const defaultFolderIcon: IconType = {
name: 'resource-type-folder',
color: 'var(--oc-color-icon-folder)'
}
const defaultSpaceIcon: IconType = {
name: 'layout-grid',
color: 'var(--oc-color-swatch-passive-default)'
}
const defaultFallbackIcon: IconType = {
name: 'resource-type-file',
color: 'var(--oc-color-text-default)'
}
const defaultFileIconMapping = createDefaultFileIconMapping()
export default defineComponent({
name: 'ResourceIcon',
props: {
/**
* The resource to be displayed
*/
resource: {
type: Object as PropType<Resource>,
required: true
},
/**
* The size of the icon. Defaults to small.
* `xsmall, small, medium, large, xlarge, xxlarge`
*/
size: {
type: String,
default: 'large',
validator: (value: string): boolean => {
return AVAILABLE_SIZES.some((e) => e === value)
}
}
},
setup(props) {
const iconMappingInjection = inject<ResourceIconMapping>(resourceIconMappingInjectionKey)
const isFolder = computed(() => {
// fallback is necessary since
// sometimes resources without a type
// but with `isFolder` are being passed
return props.resource.type === 'folder' || props.resource.isFolder
})
const isSpace = computed(() => {
return props.resource.type === 'space'
})
const extension = computed(() => {
return props.resource.extension?.toLowerCase()
})
const mimeType = computed(() => {
return props.resource.mimeType?.toLowerCase()
})
const icon = computed((): IconType => {
if (unref(isSpace)) {
return defaultSpaceIcon
}
if (unref(isFolder)) {
return defaultFolderIcon
}
const icon =
defaultFileIconMapping[unref(extension)] ||
iconMappingInjection?.mimeType[unref(mimeType)] ||
iconMappingInjection?.extension[unref(extension)]
return {
...defaultFallbackIcon,
...icon
}
})
const iconTypeClass = computed(() => {
if (unref(isSpace)) {
return 'oc-resource-icon-space'
}
if (unref(isFolder)) {
return 'oc-resource-icon-folder'
}
return 'oc-resource-icon-file'
})
return {
icon,
iconTypeClass
}
}
})
</script>
<style lang="scss">
.oc-resource-icon {
display: inline-flex;
align-items: center;
vertical-align: middle;
&-file svg {
height: 70%;
}
}
</style>
| owncloud/web/packages/web-pkg/src/components/FilesList/ResourceIcon.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/FilesList/ResourceIcon.vue",
"repo_id": "owncloud",
"token_count": 1204
} | 840 |
<template>
<oc-emoji-picker :theme="theme" @emoji-select="onEmojiSelect" />
</template>
<script lang="ts">
import { computed, defineComponent, PropType, unref } from 'vue'
import { Modal, useThemeStore } from '../../composables'
import { storeToRefs } from 'pinia'
export default defineComponent({
name: 'EmojiPickerModal',
components: {},
props: {
modal: { type: Object as PropType<Modal>, required: true }
},
emits: ['confirm'],
setup(props, { emit }) {
const themeStore = useThemeStore()
const { currentTheme } = storeToRefs(themeStore)
const theme = computed(() => {
return unref(currentTheme).isDark ? 'dark' : 'light'
})
const onEmojiSelect = (emoji: string) => {
emit('confirm', emoji)
}
return {
onEmojiSelect,
theme
}
}
})
</script>
| owncloud/web/packages/web-pkg/src/components/Modals/EmojiPickerModal.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/Modals/EmojiPickerModal.vue",
"repo_id": "owncloud",
"token_count": 316
} | 841 |
<template>
<div
id="app-sidebar"
data-testid="app-sidebar"
:class="{
'has-active-sub-panel': !!activeAvailablePanelName,
'oc-flex oc-flex-center oc-flex-middle': loading
}"
>
<oc-spinner v-if="loading" />
<template v-else>
<div
v-for="panel in panels"
:id="`sidebar-panel-${panel.name}`"
:key="`panel-${panel.name}`"
ref="panelContainer"
:data-testid="`sidebar-panel-${panel.name}`"
:tabindex="activePanelName === panel.name ? -1 : null"
class="sidebar-panel"
:class="{
'is-active-sub-panel': activeAvailablePanelName === panel.name,
'is-active-default-panel': panel.isRoot?.(panelContext) && activePanelName === panel.name,
'sidebar-panel-default': panel.isRoot?.(panelContext)
}"
>
<div
v-if="[activePanelName, oldPanelName].includes(panel.name)"
class="sidebar-panel__header header"
>
<oc-button
v-if="!panel.isRoot?.(panelContext)"
v-oc-tooltip="accessibleLabelBack"
class="header__back"
appearance="raw"
:aria-label="accessibleLabelBack"
@click="closePanel"
>
<oc-icon name="arrow-left-s" fill-type="line" />
</oc-button>
<h2 class="header__title oc-my-rm">
{{ panel.title(panelContext) }}
</h2>
<oc-button
appearance="raw"
class="header__close"
:aria-label="$gettext('Close file sidebar')"
@click="closeSidebar"
>
<oc-icon name="close" />
</oc-button>
</div>
<div>
<slot name="header" />
</div>
<div class="sidebar-panel__body" :class="[`sidebar-panel__body-${panel.name}`]">
<div
class="sidebar-panel__body-content"
:class="{ 'sidebar-panel__body-content-stretch': !panel.isRoot?.(panelContext) }"
>
<slot name="body">
<component
:is="panel.component"
v-bind="panel.componentAttrs?.(panelContext) || {}"
@scroll-to-element="scrollToElement"
/>
</slot>
</div>
<div
v-if="panel.isRoot?.(panelContext) && subPanels.length > 0"
class="sidebar-panel__navigation oc-mt-m"
>
<oc-button
v-for="panelSelect in subPanels"
:id="`sidebar-panel-${panelSelect.name}-select`"
:key="`panel-select-${panelSelect.name}`"
:data-testid="`sidebar-panel-${panelSelect.name}-select`"
appearance="raw"
@click="openPanel(panelSelect.name)"
>
<oc-icon :name="panelSelect.icon" :fill-type="panelSelect.iconFillType" />
{{ panelSelect.title(panelContext) }}
<oc-icon name="arrow-right-s" fill-type="line" />
</oc-button>
</div>
</div>
</div>
</template>
</div>
</template>
<script lang="ts">
import { VisibilityObserver } from '../../observer'
import { computed, defineComponent, PropType, unref } from 'vue'
import { SideBarPanel, SideBarPanelContext } from './types'
let visibilityObserver: VisibilityObserver
let hiddenObserver: VisibilityObserver
export default defineComponent({
props: {
isOpen: {
type: Boolean,
required: true
},
loading: {
type: Boolean,
required: true
},
availablePanels: {
type: Array as PropType<SideBarPanel<unknown, unknown, unknown>[]>,
required: true
},
panelContext: {
type: Object as PropType<SideBarPanelContext<unknown, unknown, unknown>>,
required: true
},
activePanel: {
type: String,
required: false,
default: ''
}
},
emits: ['close', 'selectPanel'],
setup(props) {
const panels = computed(() =>
props.availablePanels.filter((p) => p.isVisible(props.panelContext))
)
const subPanels = computed(() => unref(panels).filter((p) => !p.isRoot?.(props.panelContext)))
return {
panels,
subPanels
}
},
data() {
return {
focused: undefined,
oldPanelName: null,
selectedFile: {}
}
},
computed: {
activeAvailablePanelName() {
const panelName = this.activePanel?.split('#')[0]
if (!panelName) {
return null
}
if (!this.panels.map((p) => p.name).includes(panelName)) {
return null
}
return panelName
},
activePanelName() {
return this.activeAvailablePanelName || this.rootPanel?.name
},
rootPanel() {
return this.panels.find((panel) => panel.isRoot?.(this.panelContext))
},
accessibleLabelBack() {
return this.$gettext('Back to %{panel} panel', {
panel: this.rootPanel.title(this.panelContext)
})
}
},
watch: {
activePanelName: {
handler: function (panel, select) {
this.$nextTick(() => {
this.focused = panel ? `#sidebar-panel-${panel}` : `#sidebar-panel-select-${select}`
})
},
immediate: true
},
isOpen: {
handler: function (isOpen) {
if (!isOpen) {
return
}
this.$nextTick(() => {
this.initVisibilityObserver()
})
},
immediate: true
}
},
beforeUnmount() {
visibilityObserver.disconnect()
hiddenObserver.disconnect()
},
methods: {
scrollToElement({ element, panelName }) {
const sideBarPanelBodyEl = document.getElementsByClassName(
`sidebar-panel__body-${panelName}`
)[0]
const sideBarPanelPadding = Number(
window.getComputedStyle(sideBarPanelBodyEl).getPropertyValue('padding')?.split('px')[0]
)
sideBarPanelBodyEl.scrollTo(
0,
element.getBoundingClientRect().y -
sideBarPanelBodyEl.getBoundingClientRect().y -
sideBarPanelPadding
)
},
setSidebarPanel(panel: string) {
this.$emit('selectPanel', panel)
},
resetSidebarPanel() {
this.$emit('selectPanel', null)
},
closeSidebar() {
this.$emit('close')
},
initVisibilityObserver() {
visibilityObserver = new VisibilityObserver({
root: document.querySelector('#app-sidebar'),
threshold: 0.9
})
hiddenObserver = new VisibilityObserver({
root: document.querySelector('#app-sidebar'),
threshold: 0.05
})
const doFocus = () => {
const selector = document.querySelector(this.focused)
if (!selector) {
return
}
selector.focus()
}
const clearOldPanelName = () => {
this.oldPanelName = null
}
if (!this.$refs.panelContainer) {
return
}
visibilityObserver.disconnect()
hiddenObserver.disconnect()
;(this.$refs.panelContainer as HTMLElement[]).forEach((panel) => {
visibilityObserver.observe(panel, {
onEnter: doFocus,
onExit: doFocus
})
hiddenObserver.observe(panel, {
onExit: clearOldPanelName
})
})
},
setOldPanelName() {
this.oldPanelName = this.activePanelName
},
openPanel(panel) {
this.setOldPanelName()
this.setSidebarPanel(panel)
},
closePanel() {
this.setOldPanelName()
this.resetSidebarPanel()
}
}
})
</script>
<style lang="scss">
#app-sidebar {
border-left: 1px solid var(--oc-color-border);
position: relative;
overflow: hidden;
min-width: 440px;
width: 440px;
}
@media only screen and (max-width: 960px) {
#app-sidebar {
min-width: 100%;
width: 100%;
}
.files-wrapper {
flex-wrap: nowrap !important;
}
}
.sidebar-panel {
$root: &;
overflow: hidden;
width: 100%;
max-width: 100%;
height: 100%;
max-height: 100%;
display: grid;
grid-template-rows: auto auto 1fr;
background-color: var(--oc-color-background-default);
top: 0;
position: absolute;
transform: translateX(100%);
transition:
transform 0.4s ease,
visibility 0.4s 0s;
// visibility is here to prevent focusing panel child elements,
// the transition delay keeps care that it will only apply if the element is visible or not.
// hidden: if element is off screen
// visible: if element is on screen
visibility: hidden;
border-top-right-radius: var(--oc-space-medium);
border-bottom-right-radius: var(--oc-space-medium);
@media screen and (prefers-reduced-motion: reduce), (update: slow) {
transition-duration: 0.001ms !important;
}
&.sidebar-panel-default {
&.has-active-sub-panel & {
transform: translateX(-30%);
visibility: hidden;
}
}
&.is-active-default-panel,
&.is-active-sub-panel {
visibility: unset;
transform: translateX(0);
}
&__header {
padding: var(--oc-space-small) var(--oc-space-small) 0 var(--oc-space-small);
&.header {
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
}
& .header {
&__back {
grid-column-start: 1;
}
&__title {
text-align: center;
color: var(--oc-color-text-default);
font-size: var(--oc-font-size-large);
grid-column-start: 2;
}
&__close {
grid-column-start: 3;
}
}
}
&__body {
overflow-y: auto;
overflow-x: hidden;
padding: var(--oc-space-small);
display: flex;
flex-direction: column;
&-content-stretch {
flex: 1;
}
}
&__navigation {
margin: var(--oc-space-small) - var(--oc-space-small) - var(--oc-space-small);
> button {
border-bottom: 1px solid var(--oc-color-border);
width: 100%;
border-radius: 0;
color: var(--oc-color-text-default) !important;
display: grid;
grid-template-columns: auto 1fr auto;
text-align: left;
height: 50px;
padding: 0 var(--oc-space-small);
&:first-of-type {
border-top: 1px solid var(--oc-color-border);
}
&:last-of-type {
border-bottom: 0;
}
&:hover,
&:focus {
border-color: var(--oc-color-border) !important;
}
&:hover {
background-color: var(--oc-color-background-muted) !important;
}
}
}
}
</style>
| owncloud/web/packages/web-pkg/src/components/SideBar/SideBar.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/SideBar/SideBar.vue",
"repo_id": "owncloud",
"token_count": 4785
} | 842 |
export * from './useAbility'
| owncloud/web/packages/web-pkg/src/composables/ability/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/ability/index.ts",
"repo_id": "owncloud",
"token_count": 9
} | 843 |
import PQueue from 'p-queue'
import { IncomingShareResource } from '@ownclouders/web-client/src/helpers/share'
import { isLocationSharesActive, isLocationSpacesActive } from '../../../router'
import { useClientService } from '../../clientService'
import { useLoadingService } from '../../loadingService'
import { useRouter } from '../../router'
import { computed, unref } from 'vue'
import { useGettext } from 'vue3-gettext'
import { FileAction, FileActionOptions } from '../../actions'
import { useMessages, useConfigStore, useResourcesStore } from '../../piniaStores'
export const useFileActionsEnableSync = () => {
const { showMessage, showErrorMessage } = useMessages()
const router = useRouter()
const { $gettext, $ngettext } = useGettext()
const clientService = useClientService()
const loadingService = useLoadingService()
const configStore = useConfigStore()
const resourcesStore = useResourcesStore()
const { updateResourceField } = resourcesStore
const handler = async ({ resources }: FileActionOptions<IncomingShareResource>) => {
const errors = []
const triggerPromises = []
const triggerQueue = new PQueue({
concurrency: configStore.options.concurrentRequests.resourceBatchActions
})
resources.forEach((resource) => {
triggerPromises.push(
triggerQueue.add(async () => {
try {
const { graphAuthenticated } = clientService
await graphAuthenticated.drives.createDriveItem(resource.driveId, {
name: resource.name,
remoteItem: { id: resource.fileId }
})
updateResourceField<IncomingShareResource, any>({
id: resource.id,
field: 'syncEnabled',
value: true
})
} catch (error) {
console.error(error)
errors.push(error)
}
})
)
})
await Promise.all(triggerPromises)
if (errors.length === 0) {
resourcesStore.resetSelection()
if (isLocationSpacesActive(router, 'files-spaces-generic')) {
showMessage({
title: $ngettext(
'Sync for the selected share was enabled successfully',
'Sync for the selected shares was enabled successfully',
resources.length
)
})
}
return
}
showErrorMessage({
title: $ngettext(
'Failed to enable sync for the the selected share',
'Failed to enable sync for the selected shares',
resources.length
),
errors
})
}
const actions = computed((): FileAction<IncomingShareResource>[] => [
{
name: 'enable-sync',
icon: 'check',
handler: (args) => loadingService.addTask(() => handler(args)),
label: () => $gettext('Enable sync'),
isVisible: ({ space, resources }) => {
if (
!isLocationSharesActive(router, 'files-shares-with-me') &&
!isLocationSpacesActive(router, 'files-spaces-generic')
) {
return false
}
if (resources.length === 0) {
return false
}
if (
isLocationSpacesActive(router, 'files-spaces-generic') &&
(unref(space)?.driveType !== 'share' || resources.length > 1 || resources[0].path !== '/')
) {
return false
}
return resources.some((resource) => !resource.syncEnabled)
},
componentType: 'button',
class: 'oc-files-actions-enable-sync-trigger'
}
])
return {
actions
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsEnableSync.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsEnableSync.ts",
"repo_id": "owncloud",
"token_count": 1420
} | 844 |
import { computed, unref } from 'vue'
import { activeApp, useRoute } from '../../router'
const isFilesAppActive = (activeApp: string): boolean => {
// FIXME: we should use this constant but it somehow breaks the unit tests
// return activeApp === FilesApp.appInfo.id
return activeApp === 'files'
}
export const useIsFilesAppActive = () => {
const currentRoute = useRoute()
return computed(() => isFilesAppActive(activeApp(unref(currentRoute))))
}
| owncloud/web/packages/web-pkg/src/composables/actions/helpers/useIsFilesAppActive.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/helpers/useIsFilesAppActive.ts",
"repo_id": "owncloud",
"token_count": 134
} | 845 |
import { computed } from 'vue'
import { useGettext } from 'vue3-gettext'
import { eventBus } from '../../services'
import { SideBarEventTopics } from '../sideBar'
import { Action } from './types'
export const useActionsShowDetails = () => {
const { $gettext } = useGettext()
const actions = computed((): Action[] => [
{
name: 'show-details',
icon: 'information',
label: () => $gettext('Details'),
handler: () => eventBus.publish(SideBarEventTopics.open),
isVisible: ({ resources }) => {
return (resources as unknown[]).length > 0
},
componentType: 'button',
class: 'oc-admin-settings-show-details-trigger'
}
])
return {
actions
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/useActionsShowDetails.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/useActionsShowDetails.ts",
"repo_id": "owncloud",
"token_count": 263
} | 846 |
import { useService } from '../service'
export interface AuthServiceInterface {
handleAuthError(route: any): any
}
export const useAuthService = (): AuthServiceInterface => {
return useService('$authService')
}
| owncloud/web/packages/web-pkg/src/composables/authContext/useAuthService.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/authContext/useAuthService.ts",
"repo_id": "owncloud",
"token_count": 59
} | 847 |
import { eventBus } from '../../services'
export const useEventBus = () => {
return eventBus
}
| owncloud/web/packages/web-pkg/src/composables/eventBus/useEventBus.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/eventBus/useEventBus.ts",
"repo_id": "owncloud",
"token_count": 30
} | 848 |
import { ref, watch, unref } from 'vue'
export const useLocalStorage = (key: string, defaultValue: any = undefined): any => {
const existingValue = window.localStorage.getItem(key)
const variable = ref(defaultValue)
if (existingValue) {
try {
variable.value = JSON.parse(existingValue)
} catch {
variable.value = existingValue
}
}
watch(
() => unref(variable),
(val, old) => {
if (val === old) {
return
}
if (val !== undefined) {
window.localStorage.setItem(key, typeof val === 'string' ? val : JSON.stringify(val))
} else {
window.localStorage.removeItem(key)
}
},
{ deep: true }
)
return variable
}
| owncloud/web/packages/web-pkg/src/composables/localStorage/useLocalStorage.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/localStorage/useLocalStorage.ts",
"repo_id": "owncloud",
"token_count": 283
} | 849 |
import { ContextualHelperData } from 'design-system/src/helpers'
import { defineStore } from 'pinia'
import { v4 as uuidV4 } from 'uuid'
import { Component, ComponentPublicInstance, computed, ref, unref } from 'vue'
export type CustomModalComponent = Component<{ modal: Modal } & Record<string, any>>
export type CustomModalComponentEmits = {
confirm?: () => Promise<void>
cancel?: () => void
'update:confirmDisabled': (value: boolean) => void
} & Record<string, any>
export type CustomModalComponentInstance = ComponentPublicInstance<
{ modal: Modal } & unknown,
{ onConfirm?: () => Promise<unknown>; onCancel?: () => unknown },
any,
any,
any,
CustomModalComponentEmits
>
export type Modal = {
id: string
elementId?: string
elementClass?: string
title: string
variation?: string
icon?: string
message?: string
cancelText?: string
confirmDisabled?: boolean
confirmText?: string
hideActions?: boolean
hideConfirmButton?: boolean
hasInput?: boolean
inputValue?: string
inputType?: string
inputSelectionRange?: [number, number]
inputLabel?: string
inputError?: string
inputDescription?: string
focusTrapInitial?: string
contextualHelperLabel?: string
contextualHelperData?: ContextualHelperData
customComponent?: CustomModalComponent
customComponentAttrs?: () => Record<string, unknown>
onCancel?: () => void
onConfirm?: (value: string) => void | Promise<void>
onInput?: (value: string, setError: (error: string) => void) => void
}
export const useModals = defineStore('modals', () => {
const modals = ref<Modal[]>([])
const activeModal = computed(() => unref(modals).at(-1))
const getModal = (id: Modal['id']) => {
return unref(modals).find((modal) => modal.id === id)
}
const dispatchModal = (data: Omit<Modal, 'id'>) => {
const modal = { ...data, id: uuidV4() as string }
modals.value.push(modal)
return modal
}
const updateModal = <T extends Modal, K extends keyof Modal>(
id: T['id'],
key: K,
value: T[K]
) => {
const modal = getModal(id)
modal[key] = value
}
const removeModal = (id: Modal['id']) => {
modals.value = unref(modals).filter((modal) => modal.id !== id)
}
const setModalActive = (id: Modal['id']) => {
const foundIdx = unref(modals).findIndex((modal) => modal.id === id)
if (foundIdx < 0) {
return
}
const modal = getModal(id)
unref(modals).splice(foundIdx, 1)
modals.value.push(modal)
}
return { modals, activeModal, dispatchModal, updateModal, removeModal, setModalActive }
})
| owncloud/web/packages/web-pkg/src/composables/piniaStores/modals.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/piniaStores/modals.ts",
"repo_id": "owncloud",
"token_count": 895
} | 850 |