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="M12 2c5.634 0 10 4.127 10 9.7 0 5.573-4.366 9.7-10 9.7a10.894 10.894 0 0 1-2.895-.384.8.8 0 0 0-.534.039l-1.984.876a.8.8 0 0 1-1.123-.707l-.055-1.78a.797.797 0 0 0-.268-.57C3.195 17.135 2 14.617 2 11.7 2 6.127 6.367 2 12 2zM5.995 14.537c-.282.447.268.951.689.631l3.155-2.394a.6.6 0 0 1 .723 0l2.337 1.75a1.5 1.5 0 0 0 2.169-.4l2.937-4.66c.282-.448-.268-.952-.689-.633l-3.155 2.396a.6.6 0 0 1-.723 0l-2.337-1.75a1.5 1.5 0 0 0-2.169.4l-2.937 4.66z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/messenger-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/messenger-fill.svg",
"repo_id": "owncloud",
"token_count": 369
} | 738 |
<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 16zm-1.95-9H15v2h-4.95a2.5 2.5 0 0 0 4.064 1.41l1.7 1.133A4.5 4.5 0 0 1 8.028 13H7v-2h1.027a4.5 4.5 0 0 1 7.788-2.543L14.114 9.59A2.5 2.5 0 0 0 10.05 11z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/money-euro-circle-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/money-euro-circle-line.svg",
"repo_id": "owncloud",
"token_count": 250
} | 739 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4.5 10.5c-.825 0-1.5.675-1.5 1.5s.675 1.5 1.5 1.5S6 12.825 6 12s-.675-1.5-1.5-1.5zm15 0c-.825 0-1.5.675-1.5 1.5s.675 1.5 1.5 1.5S21 12.825 21 12s-.675-1.5-1.5-1.5zm-7.5 0c-.825 0-1.5.675-1.5 1.5s.675 1.5 1.5 1.5 1.5-.675 1.5-1.5-.675-1.5-1.5-1.5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/more-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/more-line.svg",
"repo_id": "owncloud",
"token_count": 264
} | 740 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M4.965 5.096l3.546 12.41 3.04-6.08 5.637-2.255L4.965 5.096zM2.899 2.3l18.806 6.268a.5.5 0 0 1 .028.939L13 13l-4.425 8.85a.5.5 0 0 1-.928-.086L2.26 2.911A.5.5 0 0 1 2.9 2.3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/navigation-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/navigation-line.svg",
"repo_id": "owncloud",
"token_count": 203
} | 741 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 2c4.97 0 9 4.043 9 9.031V20H3v-8.969C3 6.043 7.03 2 12 2zM9.5 21h5a2.5 2.5 0 1 1-5 0z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/notification-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/notification-fill.svg",
"repo_id": "owncloud",
"token_count": 146
} | 742 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M9 18H4v-8h5v8zm6 0h-5V6h5v12zm6 0h-5V2h5v16zm1 4H3v-2h19v2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/numbers-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/numbers-fill.svg",
"repo_id": "owncloud",
"token_count": 140
} | 743 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M7 11a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9zm10.5 4a4 4 0 1 1 0-8 4 4 0 0 1 0 8zm0 1a4.5 4.5 0 0 1 4.5 4.5v.5h-9v-.5a4.5 4.5 0 0 1 4.5-4.5zM7 12a5 5 0 0 1 5 5v4H2v-4a5 5 0 0 1 5-5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/parent-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/parent-fill.svg",
"repo_id": "owncloud",
"token_count": 212
} | 744 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M15 7a1 1 0 0 1 2 0v10a1 1 0 1 1-2 0V7zM7 7a1 1 0 1 1 2 0v10a1 1 0 1 1-2 0V7z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/pause-mini-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/pause-mini-fill.svg",
"repo_id": "owncloud",
"token_count": 138
} | 745 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21 16.42v3.536a1 1 0 0 1-.93.998c-.437.03-.794.046-1.07.046-8.837 0-16-7.163-16-16 0-.276.015-.633.046-1.07A1 1 0 0 1 4.044 3H7.58a.5.5 0 0 1 .498.45c.023.23.044.413.064.552A13.901 13.901 0 0 0 9.35 8.003c.095.2.033.439-.147.567l-2.158 1.542a13.047 13.047 0 0 0 6.844 6.844l1.54-2.154a.462.462 0 0 1 .573-.149 13.901 13.901 0 0 0 4 1.205c.139.02.322.042.55.064a.5.5 0 0 1 .449.498z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/phone-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/phone-fill.svg",
"repo_id": "owncloud",
"token_count": 311
} | 746 |
<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 16zM10.622 8.415l4.879 3.252a.4.4 0 0 1 0 .666l-4.88 3.252a.4.4 0 0 1-.621-.332V8.747a.4.4 0 0 1 .622-.332z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/play-circle-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/play-circle-line.svg",
"repo_id": "owncloud",
"token_count": 212
} | 747 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M6 19H3a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h3V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v4h3a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-3v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-2zm0-2v-1a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1h2V9H4v8h2zM8 4v3h8V4H8zm0 13v3h8v-3H8zm-3-7h3v2H5v-2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/printer-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/printer-line.svg",
"repo_id": "owncloud",
"token_count": 269
} | 748 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M13.828 1.686l8.486 8.486-1.415 1.414-.707-.707-4.242 4.242-.707 3.536-1.415 1.414-4.242-4.243-4.95 4.95-1.414-1.414 4.95-4.95-4.243-4.242 1.414-1.415L8.88 8.05l4.242-4.242-.707-.707 1.414-1.415zm.708 3.536l-4.671 4.67-2.822.565 6.5 6.5.564-2.822 4.671-4.67-4.242-4.243z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/pushpin-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/pushpin-line.svg",
"repo_id": "owncloud",
"token_count": 256
} | 749 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21 2C6 2 4 16 3 22h1.998c.666-3.333 2.333-5.166 5.002-5.5 4-.5 7-4 8-7l-1.5-1 1-1c1-1 2.004-2.5 3.5-5.5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/quill-pen-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/quill-pen-fill.svg",
"repo_id": "owncloud",
"token_count": 161
} | 750 |
<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-7a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/record-circle-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/record-circle-fill.svg",
"repo_id": "owncloud",
"token_count": 146
} | 751 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2zm.5 5H8v10h2v-3h2.217l2.18 3h2.472l-2.55-3.51a3.5 3.5 0 0 0-1.627-6.486l-.192-.004zm0 2a1.5 1.5 0 0 1 1.493 1.356L14 10.5l-.007.144a1.5 1.5 0 0 1-1.349 1.35L12.5 12H10V9h2.5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/registered-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/registered-fill.svg",
"repo_id": "owncloud",
"token_count": 244
} | 752 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M11 20L1 12l10-8v5c5.523 0 10 4.477 10 10 0 .273-.01.543-.032.81C19.46 16.95 16.458 15 13 15h-2v5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/reply-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/reply-fill.svg",
"repo_id": "owncloud",
"token_count": 142
} | 753 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21 2v20h-2v-8h-3V7a5 5 0 0 1 5-5zM9 13.9V22H7v-8.1A5.002 5.002 0 0 1 3 9V3h2v7h2V3h2v7h2V3h2v6a5.002 5.002 0 0 1-4 4.9z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/restaurant-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/restaurant-fill.svg",
"repo_id": "owncloud",
"token_count": 178
} | 754 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M8.498 20h7.004A6.523 6.523 0 0 1 12 23.502 6.523 6.523 0 0 1 8.498 20zM18 14.805l2 2.268V19H4v-1.927l2-2.268V9c0-3.483 2.504-6.447 6-7.545C15.496 2.553 18 5.517 18 9v5.805zM12 11a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/rocket-2-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/rocket-2-fill.svg",
"repo_id": "owncloud",
"token_count": 209
} | 755 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M6.343 14.621L3.515 17.45l3.535 3.535L20.485 7.55 16.95 4.015l-2.122 2.121 1.415 1.414-1.415 1.414-1.414-1.414-2.121 2.122 2.121 2.12L12 13.208l-2.121-2.121-2.122 2.121 1.415 1.414-1.415 1.415-1.414-1.415zM17.657 1.893l4.95 4.95a1 1 0 0 1 0 1.414l-14.85 14.85a1 1 0 0 1-1.414 0l-4.95-4.95a1 1 0 0 1 0-1.414l14.85-14.85a1 1 0 0 1 1.414 0z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/ruler-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/ruler-line.svg",
"repo_id": "owncloud",
"token_count": 290
} | 756 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M7 19v-6h10v6h2V7.828L16.172 5H5v14h2zM4 3h13l4 4v13a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm5 12v4h6v-4H9z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/save-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/save-line.svg",
"repo_id": "owncloud",
"token_count": 173
} | 757 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M9.446 8.032L12 10.586l6.728-6.728a2 2 0 0 1 2.828 0l-12.11 12.11a4 4 0 1 1-1.414-1.414L10.586 12 8.032 9.446a4 4 0 1 1 1.414-1.414zm5.38 5.38l6.73 6.73a2 2 0 0 1-2.828 0l-5.317-5.316 1.415-1.415zm-7.412 3.174a2 2 0 1 0-2.828 2.828 2 2 0 0 0 2.828-2.828zm0-9.172a2 2 0 1 0-2.828-2.828 2 2 0 0 0 2.828 2.828z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/scissors-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/scissors-line.svg",
"repo_id": "owncloud",
"token_count": 283
} | 758 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M8.686 4l2.607-2.607a1 1 0 0 1 1.414 0L15.314 4H19a1 1 0 0 1 1 1v3.686l2.607 2.607a1 1 0 0 1 0 1.414L20 15.314V19a1 1 0 0 1-1 1h-3.686l-2.607 2.607a1 1 0 0 1-1.414 0L8.686 20H5a1 1 0 0 1-1-1v-3.686l-2.607-2.607a1 1 0 0 1 0-1.414L4 8.686V5a1 1 0 0 1 1-1h3.686zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/settings-2-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/settings-2-fill.svg",
"repo_id": "owncloud",
"token_count": 270
} | 759 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M10 3v2H5v14h14v-5h2v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h6zm7.707 4.707L12 13.414 10.586 12l5.707-5.707L13 3h8v8l-3.293-3.293z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/share-box-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/share-box-fill.svg",
"repo_id": "owncloud",
"token_count": 182
} | 760 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M18 17.883V16l5 3-5 3v-2.09a9 9 0 0 1-6.997-5.365L11 14.54l-.003.006A9 9 0 0 1 2.725 20H2v-2h.725a7 7 0 0 0 6.434-4.243L9.912 12l-.753-1.757A7 7 0 0 0 2.725 6H2V4h.725a9 9 0 0 1 8.272 5.455L11 9.46l.003-.006A9 9 0 0 1 18 4.09V2l5 3-5 3V6.117a7 7 0 0 0-5.159 4.126L12.088 12l.753 1.757A7 7 0 0 0 18 17.883z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/shuffle-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/shuffle-fill.svg",
"repo_id": "owncloud",
"token_count": 270
} | 761 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M12 3c4.284 0 8.22 1.497 11.31 3.996L22.498 8H18v5.571L12 21 .69 6.997C3.78 4.497 7.714 3 12 3zm10 16v2h-2v-2h2zm0-9v7h-2v-7h2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/signal-wifi-error-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/signal-wifi-error-fill.svg",
"repo_id": "owncloud",
"token_count": 170
} | 762 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M7 6a1 1 0 0 1 1 1v10a1 1 0 0 1-2 0V7a1 1 0 0 1 1-1zm2.079 6.408a.5.5 0 0 1 0-.816l7.133-5.036a.5.5 0 0 1 .788.409v10.07a.5.5 0 0 1-.788.409l-7.133-5.036z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/skip-back-mini-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/skip-back-mini-fill.svg",
"repo_id": "owncloud",
"token_count": 190
} | 763 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M13 17v3h5v2H6v-2h5v-3H4a1 1 0 0 1-1-1V4H2V2h20v2h-1v12a1 1 0 0 1-1 1h-7zM10 6v7l5-3.5L10 6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/slideshow-2-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/slideshow-2-fill.svg",
"repo_id": "owncloud",
"token_count": 162
} | 764 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M21 18v3h-2v-3h-2v-3h6v3h-2zM5 18v3H3v-3H1v-3h6v3H5zm6-12V3h2v3h2v3H9V6h2zm0 5h2v10h-2V11zm-8 2V3h2v10H3zm16 0V3h2v10h-2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/sound-module-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/sound-module-fill.svg",
"repo_id": "owncloud",
"token_count": 195
} | 765 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M5 5v14h14V5H5zM4 3h16a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm3 5a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm10 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm0 10a1 1 0 1 1 0-2 1 1 0 0 1 0 2zM7 18a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm5-3a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 2a5 5 0 1 1 0-10 5 5 0 0 1 0 10zm0-4a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/speaker-3-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/speaker-3-line.svg",
"repo_id": "owncloud",
"token_count": 290
} | 766 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M20.083 15.2l1.202.721a.5.5 0 0 1 0 .858l-8.77 5.262a1 1 0 0 1-1.03 0l-8.77-5.262a.5.5 0 0 1 0-.858l1.202-.721L12 20.05l8.083-4.85zm0-4.7l1.202.721a.5.5 0 0 1 0 .858L12 17.65l-9.285-5.571a.5.5 0 0 1 0-.858l1.202-.721L12 15.35l8.083-4.85zm-7.569-9.191l8.771 5.262a.5.5 0 0 1 0 .858L12 13 2.715 7.429a.5.5 0 0 1 0-.858l8.77-5.262a1 1 0 0 1 1.03 0zM12 3.332L5.887 7 12 10.668 18.113 7 12 3.332z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/stack-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/stack-line.svg",
"repo_id": "owncloud",
"token_count": 340
} | 767 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M17.2 20l1.8 1.5v.5H5v-.5L6.8 20H5a2 2 0 0 1-2-2V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4v11a2 2 0 0 1-2 2h-1.8zM13 5v6h6V7a2 2 0 0 0-2-2h-4zm-2 0H7a2 2 0 0 0-2 2v4h6V5zm8 8H5v5h14v-5zM7.5 17a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3zm9 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/subway-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/subway-line.svg",
"repo_id": "owncloud",
"token_count": 279
} | 768 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M5.596 5l4.904 5.928L15.404 5H18l-6.202 7.497L18 19.994V20h-2.59l-4.91-5.934L5.59 20H3v-.006l6.202-7.497L3 5h2.596zM21.55 6.58a.8.8 0 1 0-1.32-.36l-1.155.33A2.001 2.001 0 0 1 21 4a2 2 0 0 1 1.373 3.454L20.744 9H23v1h-4V9l2.55-2.42z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/superscript.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/superscript.svg",
"repo_id": "owncloud",
"token_count": 241
} | 769 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M21.678 7.98l-1.415 1.413-2.12-2.12-2.122 2.12 3.535 3.536-1.414 1.414-.707-.707L11.071 20H5.414l-2.121 2.121-1.414-1.414L4 18.586v-5.657l6.364-6.364-.707-.707 1.414-1.414 3.536 3.535 2.12-2.121-2.12-2.121 1.414-1.415 5.657 5.657zm-5.657 4.242l-4.243-4.243-1.414 1.414 2.121 2.122-1.414 1.414-2.121-2.121-1.414 1.414 2.12 2.121-1.413 1.414-2.122-2.121-.121.121V18h4.243l5.778-5.778z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/syringe-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/syringe-line.svg",
"repo_id": "owncloud",
"token_count": 317
} | 770 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M8 10.255V5a4 4 0 1 1 8 0v5.255a7 7 0 1 1-8 0zM8 16a4 4 0 1 0 8 0H8z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/temp-cold-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/temp-cold-fill.svg",
"repo_id": "owncloud",
"token_count": 131
} | 771 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M8.965 18a3.5 3.5 0 0 1-6.93 0H1V6a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2h3l3 4.056V18h-2.035a3.5 3.5 0 0 1-6.93 0h-5.07zM15 7H3v8.05a3.5 3.5 0 0 1 5.663.95h5.674c.168-.353.393-.674.663-.95V7zm2 6h4v-.285L18.992 10H17v3zm.5 6a1.5 1.5 0 1 0 0-3.001 1.5 1.5 0 0 0 0 3.001zM7 17.5a1.5 1.5 0 1 0-3 0 1.5 1.5 0 0 0 3 0z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/truck-line.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/truck-line.svg",
"repo_id": "owncloud",
"token_count": 296
} | 772 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0H24V24H0z"/>
<path d="M12 1l3 5h-2v7.381l3-1.499-.001-.882H15V7h4v4h-1.001L18 13.118l-5 2.5v1.553c1.166.412 2 1.523 2 2.829 0 1.657-1.343 3-3 3s-3-1.343-3-3c0-1.187.69-2.213 1.69-2.7L6 14l-.001-2.268C5.402 11.386 5 10.74 5 10c0-1.105.895-2 2-2s2 .895 2 2c0 .74-.402 1.387-1 1.732V13l3 2.086V6H9l3-5z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/usb-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/usb-fill.svg",
"repo_id": "owncloud",
"token_count": 272
} | 773 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M3 3.993C3 3.445 3.445 3 3.993 3h16.014c.548 0 .993.445.993.993v16.014a.994.994 0 0 1-.993.993H3.993A.994.994 0 0 1 3 20.007V3.993zm7.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/video-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/video-fill.svg",
"repo_id": "owncloud",
"token_count": 227
} | 774 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm8 5.5v7h2v-7h-2zm-.285 0H8.601l-1.497 4.113L5.607 8.5H3.493l2.611 6.964h2L10.715 8.5zm5.285 5h1.5a2.5 2.5 0 1 0 0-5H14v7h2v-2zm0-2v-1h1.5a.5.5 0 1 1 0 1H16z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/vip-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/vip-fill.svg",
"repo_id": "owncloud",
"token_count": 255
} | 775 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M5.889 16H2a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h3.889l5.294-4.332a.5.5 0 0 1 .817.387v15.89a.5.5 0 0 1-.817.387L5.89 16zm13.517 4.134l-1.416-1.416A8.978 8.978 0 0 0 21 12a8.982 8.982 0 0 0-3.304-6.968l1.42-1.42A10.976 10.976 0 0 1 23 12c0 3.223-1.386 6.122-3.594 8.134zm-3.543-3.543l-1.422-1.422A3.993 3.993 0 0 0 16 12c0-1.43-.75-2.685-1.88-3.392l1.439-1.439A5.991 5.991 0 0 1 18 12c0 1.842-.83 3.49-2.137 4.591z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/volume-up-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/volume-up-fill.svg",
"repo_id": "owncloud",
"token_count": 347
} | 776 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<path fill="none" d="M0 0h24v24H0z"/>
<path d="M11 21v-1.07A7.002 7.002 0 0 1 5 13V8a7 7 0 1 1 14 0v5a7.002 7.002 0 0 1-6 6.93V21h4v2H7v-2h4zm1-12a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm0 2a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
</g>
</svg>
| owncloud/web/packages/design-system/src/assets/icons/webcam-fill.svg/0 | {
"file_path": "owncloud/web/packages/design-system/src/assets/icons/webcam-fill.svg",
"repo_id": "owncloud",
"token_count": 190
} | 777 |
import { mount } from 'web-test-helpers'
import OcAvatar from './OcAvatar.vue'
import { extractInitials } from './extractInitials'
describe('extractInitials', () => {
describe('should allow alphanumeric characters', () => {
it.each([
['test', 'T'],
['Test', 'T'],
['1Test', '1'],
['test user', 'TU'],
['test User', 'TU'],
['Test User', 'TU'],
['1234 5678', '15'],
['test-user', 'TU'],
['test -user', 'TU'],
['test - user', 'TU'],
['test user one', 'TUO'],
['test-user-one', 'TUO'],
['test user one primary', 'TUO'],
['testUser One Primary', 'TOP']
])("user name '%s'", (input, expected) => {
expect(extractInitials(input)).toBe(expected)
})
})
describe('should omit special chars from user names', () => {
it.each([
['.', ''],
['._-()[]{}', ''],
['test User (with@email.com)', 'TUW']
])("user name '%s'", (input, expected) => {
expect(extractInitials(input)).toBe(expected)
})
})
describe('should allow letters from non-latin alphabets', () => {
it.each([
['१२३ ४५६', '१४'],
['अंशु वर्मा', 'अव'],
['किरण पराजुली', 'कप'],
['Kiran पराजुली', 'Kप'],
['किरण Parajuli', 'कP']
])("user name '%s'", (input, expected) => {
expect(extractInitials(input)).toBe(expected)
})
})
})
describe('OcAvatar', () => {
const selectors = {
initials: '.avatarInitials'
}
describe('prop value', () => {
describe('when src is set', () => {
let wrapper
beforeEach(() => {
wrapper = getWrapper({
src: 'http://some-image.jpg'
})
})
it('should render oc image', () => {
const imageElement = wrapper.find('img')
expect(imageElement.exists()).toBeTruthy()
expect(imageElement.attributes('src')).toBe('http://some-image.jpg')
})
it('should not render user initial', () => {
expect(wrapper.find(selectors.initials).exists()).toBeFalsy()
})
it('should not render background', () => {
expect(wrapper.attributes('style')).not.toContain('background-color: ')
})
})
describe('when username is set', () => {
it("should render user initials for username 'test user'", () => {
const wrapper = getWrapper({
userName: 'test user'
})
const userInitialElement = wrapper.find(selectors.initials)
expect(userInitialElement.exists()).toBeTruthy()
expect(userInitialElement.text()).toBe('TU')
})
})
describe('when width is set', () => {
let wrapper
beforeEach(() => {
wrapper = getWrapper({
width: 100
})
})
it('should set width and height of the avatar wrapper', () => {
expect(wrapper.attributes('style')).toContain('width: 100px; height: 100px;')
})
it('should determine font size and line height', () => {
expect(wrapper.attributes('style')).toContain('line-height: 100px;')
expect(wrapper.attributes('style')).toContain('font-size: 40px;')
})
})
describe('accessibleLabel', () => {
it('should not be set when value is empty string', () => {
const wrapper = getWrapper({
accessibleLabel: ''
})
expect(wrapper.attributes('aria-label')).toBeFalsy()
expect(wrapper.attributes('role')).toBeFalsy()
expect(wrapper.attributes('aria-hidden')).toBe('true')
expect(wrapper.attributes('focusable')).toBe('false')
})
it('should be set when value is not empty string', () => {
const wrapper = getWrapper({
accessibleLabel: 'test label'
})
expect(wrapper.attributes('aria-label')).toBe('test label')
expect(wrapper.attributes('role')).toBe('img')
expect(wrapper.attributes('aria-hidden')).toBeFalsy()
expect(wrapper.attributes('focusable')).toBeFalsy()
})
})
})
})
function getWrapper(props) {
return mount(OcAvatar, {
props
})
}
| owncloud/web/packages/design-system/src/components/OcAvatar/OcAvatar.spec.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcAvatar/OcAvatar.spec.ts",
"repo_id": "owncloud",
"token_count": 1809
} | 778 |
<template>
<nav :id="id" :class="`oc-breadcrumb oc-breadcrumb-${variation}`">
<ol class="oc-breadcrumb-list oc-flex oc-m-rm oc-p-rm">
<li
v-for="(item, index) in displayItems"
:key="index"
:data-key="index"
:data-item-id="item.id"
:aria-hidden="item.isTruncationPlaceholder"
:class="[
'oc-breadcrumb-list-item',
'oc-flex',
'oc-flex-middle',
{
'oc-invisible-sr':
hiddenItems.indexOf(item) !== -1 ||
(item.isTruncationPlaceholder && hiddenItems.length === 0)
}
]"
@dragover.prevent
@dragenter.prevent="dropItemStyling(item, index, false, $event)"
@dragleave.prevent="dropItemStyling(item, index, true, $event)"
@mouseleave="dropItemStyling(item, index, true, $event)"
@drop="dropItemEvent(item, index)"
>
<router-link
v-if="item.to"
:aria-current="getAriaCurrent(index)"
:to="item.isTruncationPlaceholder ? lastHiddenItem.to : item.to"
>
<span class="oc-breadcrumb-item-text oc-breadcrumb-item-navigable">{{ item.text }}</span>
</router-link>
<oc-button
v-else-if="item.onClick"
:aria-current="getAriaCurrent(index)"
appearance="raw"
class="oc-flex"
@click="item.onClick"
>
<span
:class="[
'oc-breadcrumb-item-text',
'oc-breadcrumb-item-navigable',
{
'oc-breadcrumb-item-text-last': index === displayItems.length - 1
}
]"
v-text="item.text"
/>
</oc-button>
<span
v-else
class="oc-breadcrumb-item-text"
:aria-current="getAriaCurrent(index)"
tabindex="-1"
v-text="item.text"
/>
<oc-icon
v-if="index !== displayItems.length - 1"
color="var(--oc-color-text-default)"
name="arrow-right-s"
class="oc-mx-xs"
fill-type="line"
/>
<template v-if="showContextActions && index === displayItems.length - 1">
<oc-button
id="oc-breadcrumb-contextmenu-trigger"
v-oc-tooltip="contextMenuLabel"
:aria-label="contextMenuLabel"
appearance="raw"
>
<oc-icon name="more-2" color="var(--oc-color-text-default)" />
</oc-button>
<oc-drop
drop-id="oc-breadcrumb-contextmenu"
toggle="#oc-breadcrumb-contextmenu-trigger"
mode="click"
close-on-click
:padding-size="contextMenuPadding"
>
<!-- @slot Add context actions that open in a dropdown when clicking on the "three dots" button -->
<slot name="contextMenu" />
</oc-drop>
</template>
</li>
</ol>
<oc-button
v-if="parentFolderTo && displayItems.length > 1"
appearance="raw"
type="router-link"
:aria-label="$gettext('Navigate one level up')"
:to="parentFolderTo"
class="oc-breadcrumb-mobile-navigation"
>
<oc-icon name="arrow-left-s" fill-type="line" size="large" class="oc-mr-m" />
</oc-button>
</nav>
<div v-if="displayItems.length > 1" class="oc-breadcrumb-mobile-current">
<span class="oc-text-truncate" aria-current="page" v-text="currentFolder.text" />
</div>
</template>
<script lang="ts">
import { computed, defineComponent, nextTick, PropType, ref, unref, watch } from 'vue'
import { useGettext } from 'vue3-gettext'
import { AVAILABLE_SIZES, EVENT_ITEM_DROPPED_BREADCRUMB } from '../../helpers/constants'
import OcButton from '../OcButton/OcButton.vue'
import OcDrop from '../OcDrop/OcDrop.vue'
import OcIcon from '../OcIcon/OcIcon.vue'
import uniqueId from '../../utils/uniqueId'
import { BreadcrumbItem } from './types'
/**
* Displays a breadcrumb. Each item in the items property has the following elements:
*
* - text: mandatory element, holds the text which is to be displayed in the breadcrumb
* - to: optional element, the vue router link
*/
export default defineComponent({
name: 'OcBreadcrumb',
status: 'ready',
release: '1.0.0',
components: {
OcDrop,
OcIcon,
OcButton
},
props: {
/**
* Id for the breadcrumbs. If it's empty, a generated one will be used.
*/
id: {
type: String,
required: false,
default: () => uniqueId('oc-breadcrumbs-')
},
/**
* Array of breadcrumb items
*/
items: {
type: Array as PropType<BreadcrumbItem[]>,
required: true
},
/**
* Variation of breadcrumbs
* Can be `default` or `lead`
*/
variation: {
type: String,
required: false,
default: 'default',
validator: (value) => value === 'lead' || value === 'default'
},
/**
* Defines the padding size around the drop content. Defaults to `medium`.
*
* @values xsmall, small, medium, large, xlarge, xxlarge, xxxlarge, remove
*/
contextMenuPadding: {
type: String,
required: false,
default: 'medium',
validator: (value) => {
return [...AVAILABLE_SIZES, 'remove'].some((e) => e === value)
}
},
/**
* Defines the maximum width of the breadcrumb. If the breadcrumb is wider than the given value, the breadcrumb
* will be reduced from the left side.
* If the value is -1, the breadcrumb will not be reduced.
*/
maxWidth: {
type: Number,
required: false,
default: -1
},
/**
* Defines the number of items that should be always displayed at the beginning of the breadcrumb.
* The default value is 2. e.g. Personal > ... > XYZ
*/
truncationOffset: {
type: Number,
required: false,
default: 2
},
/**
* Determines if the last breadcrumb item should have context menu actions.
*/
showContextActions: {
type: Boolean,
default: false
}
},
emits: [EVENT_ITEM_DROPPED_BREADCRUMB],
setup(props, { emit }) {
const { $gettext } = useGettext()
const visibleItems = ref<BreadcrumbItem[]>([])
const hiddenItems = ref<BreadcrumbItem[]>([])
const displayItems = ref<BreadcrumbItem[]>(props.items.slice())
const getBreadcrumbElement = (id): HTMLElement => {
return document.querySelector(`.oc-breadcrumb-list [data-item-id="${id}"]`)
}
const isDropAllowed = (item: BreadcrumbItem, index: number): boolean => {
return !(
!item.id ||
index === unref(displayItems).length - 1 ||
item.isTruncationPlaceholder ||
item.isStaticNav
)
}
const dropItemEvent = (item, index) => {
if (!isDropAllowed(item, index)) {
return
}
item.to.path = item.to.path || '/'
emit(EVENT_ITEM_DROPPED_BREADCRUMB, item.to)
}
const calculateTotalBreadcrumbWidth = () => {
let totalBreadcrumbWidth = 100 // 100px margin to the right to avoid breadcrumb from getting too close to the controls
visibleItems.value.forEach((item) => {
const breadcrumbElement = getBreadcrumbElement(item.id)
const itemClientWidth = breadcrumbElement?.getBoundingClientRect()?.width || 0
totalBreadcrumbWidth += itemClientWidth
})
return totalBreadcrumbWidth
}
const reduceBreadcrumb = (offsetIndex) => {
const breadcrumbMaxWidth = props.maxWidth
if (!breadcrumbMaxWidth) {
return
}
const totalBreadcrumbWidth = calculateTotalBreadcrumbWidth()
const isOverflowing = breadcrumbMaxWidth < totalBreadcrumbWidth
if (!isOverflowing || visibleItems.value.length <= props.truncationOffset + 1) {
return
}
// Remove from the left side
const removed = visibleItems.value.splice(offsetIndex, 1)
hiddenItems.value.push(removed[0])
reduceBreadcrumb(offsetIndex)
}
const lastHiddenItem = computed(() =>
hiddenItems.value.length >= 1 ? unref(hiddenItems)[unref(hiddenItems).length - 1] : { to: {} }
)
const renderBreadcrumb = () => {
displayItems.value = [...props.items]
if (displayItems.value.length > props.truncationOffset - 1) {
displayItems.value.splice(props.truncationOffset - 1, 0, {
text: '...',
allowContextActions: false,
to: {},
isTruncationPlaceholder: true
})
}
visibleItems.value = [...displayItems.value]
hiddenItems.value = []
nextTick(() => {
reduceBreadcrumb(props.truncationOffset)
})
}
watch([() => props.maxWidth, () => props.items], renderBreadcrumb, { immediate: true })
const currentFolder = computed<BreadcrumbItem>(() => {
if (props.items.length === 0 || !props.items) {
return undefined
}
return [...props.items].reverse()[0]
})
const parentFolderTo = computed(() => {
return [...props.items].reverse()[1]?.to
})
const contextMenuLabel = computed(() => {
return $gettext('Show actions for current folder')
})
const getAriaCurrent = (index): 'page' | null => {
return props.items.length - 1 === index ? 'page' : null
}
const dropItemStyling = (item: BreadcrumbItem, index: number, leaving: boolean, event) => {
if (!isDropAllowed(item, index)) {
return
}
const hasFilePayload = (event.dataTransfer?.types || []).some((e) => e === 'Files')
if (hasFilePayload) return
if (event.currentTarget?.contains(event.relatedTarget)) {
return
}
const classList = getBreadcrumbElement(item.id).children[0].classList
const className = 'oc-breadcrumb-item-dragover'
leaving ? classList.remove(className) : classList.add(className)
}
return {
currentFolder,
parentFolderTo,
contextMenuLabel,
getAriaCurrent,
visibleItems,
hiddenItems,
renderBreadcrumb,
displayItems,
lastHiddenItem,
dropItemEvent,
dropItemStyling
}
}
})
</script>
<style lang="scss">
.oc-breadcrumb {
overflow: visible;
&-item-dragover {
transition:
background 0.06s,
border 0s 0.08s,
border-color 0s,
border-width 0.06s;
background-color: var(--oc-color-background-highlight);
box-shadow: 0 0 0 5px var(--oc-color-background-highlight);
border-radius: 5px;
}
&-item-text {
max-width: 200px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
&-last {
vertical-align: text-bottom;
}
}
&-item-navigable:hover {
text-decoration: underline;
}
&-mobile-current,
&-mobile-navigation {
@media (min-width: $oc-breakpoint-small-default) {
display: none !important;
}
}
&-list {
@media (max-width: $oc-breakpoint-xsmall-max) {
display: none !important;
}
list-style: none;
align-items: baseline;
flex-wrap: nowrap;
#oc-breadcrumb-contextmenu-trigger > span {
vertical-align: middle;
border: 3px solid transparent;
}
#oc-breadcrumb-contextmenu li button {
display: inline-flex;
}
> li button {
display: inline;
}
> :nth-child(n + 2)::before {
color: var(--oc-color-text-default);
display: inline-block;
}
> :last-child > span {
color: var(--oc-color-text-default);
}
}
/* stylelint-disable */
&-list-item {
a:first-of-type,
button:first-of-type,
span:first-of-type {
font-size: var(--oc-font-size-medium);
color: var(--oc-color-text-default);
display: inline-block;
vertical-align: sub;
line-height: normal;
}
}
&-lead &-list-item {
a,
button,
span {
font-size: var(--oc-font-size-large);
}
}
}
</style>
<docs>
```js
<template>
<section>
<div>
<oc-breadcrumb :items="items" />
</div>
<div>
<oc-breadcrumb :items="items" variation="lead" />
<oc-breadcrumb :items="items" >
<template v-slot:contextMenu>
<p class="oc-my-rm">I'm an example item</p>
</template>
</oc-breadcrumb>
</div>
</section>
</template>
<script>
export default {
data: () => {
return {
items: [
{text:'First folder',to:{path:'folder'}},
{text:'Subfolder', to: {path: 'subfolder'}},
{text:'Deep',to:{path:'deep'}},
{text:'Deeper ellipsize in responsive mode'},
]
}
}
}
</script>
```
</docs>
| owncloud/web/packages/design-system/src/components/OcBreadcrumb/OcBreadcrumb.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcBreadcrumb/OcBreadcrumb.vue",
"repo_id": "owncloud",
"token_count": 5633
} | 779 |
<template>
<div class="oc-error-log">
<oc-textarea
class="oc-error-log-textarea oc-mt-s oc-text-small"
:label="contentLabel"
:model-value="content"
rows="4"
readonly
/>
<div class="oc-flex oc-flex-between oc-mt-s">
<div class="oc-flex">
<div v-if="showCopied" class="oc-flex oc-flex-middle">
<oc-icon variation="success" name="checkbox-circle" />
<p class="oc-error-log-content-copied oc-ml-s oc-my-rm" v-text="$gettext('Copied')" />
</div>
</div>
<oc-button
size="small"
variation="primary"
appearance="filled"
@click="copyContentToClipboard"
>
{{ $gettext('Copy') }}
</oc-button>
</div>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, ref } from 'vue'
import { useGettext } from 'vue3-gettext'
export default defineComponent({
name: 'OcErrorLog',
status: 'ready',
release: '2.0.0',
props: {
/**
* Content to be displayed
*/
content: {
type: String,
required: true
}
},
setup(props) {
const { $gettext } = useGettext()
const showCopied = ref(false)
const contentLabel = computed(() => {
return $gettext(
'Copy the following information and pass them to technical support to troubleshoot the problem:'
)
})
const copyContentToClipboard = () => {
navigator.clipboard.writeText(props.content)
showCopied.value = true
setTimeout(() => (showCopied.value = false), 500)
}
return {
contentLabel,
showCopied,
copyContentToClipboard
}
}
})
</script>
<style lang="scss">
.oc-error-log {
&-textarea {
resize: none;
label {
color: var(--oc-color-text-muted);
}
}
&-content-copied {
color: var(--oc-color-swatch-success-default);
}
}
</style>
<docs>
Component to display error log.
```js
<oc-error-log>
<oc-error-log content="X-REQUEST-ID: 123456789" />
</oc-error-log>
```
</docs>
| owncloud/web/packages/design-system/src/components/OcErrorLog/OcErrorLog.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcErrorLog/OcErrorLog.vue",
"repo_id": "owncloud",
"token_count": 905
} | 780 |
import OcLogo from './OcLogo.vue'
import { shallowMount, mount } from 'web-test-helpers'
import OcImage from '../OcImage/OcImage.vue'
describe('OcLogo', () => {
const requiredProps = {
src: 'http://some-image-link.jpg',
alt: 'test alt'
}
function getWrapper(props = {}) {
return shallowMount(OcLogo, {
props: {
...requiredProps,
...props
},
global: {
stubs: { 'oc-img': true }
}
})
}
const wrapper = getWrapper()
it('should set the provided src to image element', () => {
const imageElement = wrapper.find('oc-img-stub')
expect(imageElement.attributes('src')).toBe('http://some-image-link.jpg')
})
it('should set the provided alt to image element', () => {
const imageElement = wrapper.find('oc-img-stub')
expect(imageElement.attributes('alt')).toBe('test alt')
})
it('should add provided class to the image element', () => {
const component = {
template: "<oc-logo src='image-link' alt='imageText' class='test-class'></oc-logo>",
components: { OcLogo },
name: 'TestOcLogo'
}
const wrapper = mount(component, { global: { stubs: { 'oc-img': OcImage } } })
expect(wrapper.attributes('class')).toContain('test-class')
})
})
| owncloud/web/packages/design-system/src/components/OcLogo/OcLogo.spec.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcLogo/OcLogo.spec.ts",
"repo_id": "owncloud",
"token_count": 500
} | 781 |
<template>
<div class="oc-progress-pie" :data-fill="_fill">
<div class="oc-progress-pie-container" />
<label v-if="showLabel" class="oc-progress-pie-label oc-text-muted" v-text="_label" />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
/**
* Show progress to the users in a pie shape.
*/
export default defineComponent({
name: 'OcProgressPie',
status: 'ready',
release: '1.0.0',
props: {
/**
* Current value of the progress
*/
progress: {
type: Number,
default: 0,
required: true,
validator: (value: number) => {
return value >= 0 && value <= 100
}
},
/**
* Maximum value.
*/
max: {
type: Number,
default: 100
},
/**
* Defines if the label shall be shown.
*/
showLabel: {
type: Boolean,
default: false
}
},
computed: {
_fill() {
return Math.round((100 / this.max) * this.progress)
},
_label() {
if (this.max === 100) {
return this.progress + '%'
} else {
return `${this.progress}/${this.max}`
}
}
}
})
</script>
<style lang="scss">
$default-size: 64px;
.oc-progress-pie {
float: left;
height: $default-size;
margin: 15px;
position: relative;
width: $default-size;
*,
*::before,
*::after {
box-sizing: border-box;
}
// Shadow
&::after {
border: calc($default-size / 10) solid var(--oc-color-swatch-passive-hover);
border-radius: 50%;
box-sizing: border-box;
content: '';
display: block;
height: 100%;
width: 100%;
}
&-container {
clip: rect(0, $default-size, $default-size, calc($default-size / 2));
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
&::before,
&::after {
border: calc($default-size / 10) solid var(--oc-color-swatch-brand-default);
border-color: var(--oc-color-swatch-brand-default);
border-radius: 50%;
clip: rect(0, calc($default-size / 2), $default-size, 0);
content: '';
display: block;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
}
&-label {
color: var(--oc-color-text-muted) !important;
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
}
@for $i from 0 through 100 {
.oc-progress-pie[data-fill='#{$i}'] {
.oc-progress-pie-container::before {
transform: rotate($i * 3.6deg);
}
@if $i <= 50 {
.oc-progress-pie-container::after {
display: none;
}
} @else {
.oc-progress-pie-container {
clip: rect(auto, auto, auto, auto);
}
.oc-progress-pie-container::after {
transform: rotate(180deg);
}
}
}
}
</style>
<docs>
```js
<section>
<h3 class="oc-heading-divider">
Pie shape progress
</h3>
<oc-progress-pie :progress="33" />
<oc-progress-pie :progress="33" show-label/>
<oc-progress-pie :progress="2" :max="4" />
<oc-progress-pie :progress="4" :max="6" show-label />
</section>
```
</docs>
| owncloud/web/packages/design-system/src/components/OcProgressPie/OcProgressPie.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcProgressPie/OcProgressPie.vue",
"repo_id": "owncloud",
"token_count": 1372
} | 782 |
import { shallowMount, mount } from 'web-test-helpers'
import Table from './OcTable.vue'
const fields = [
{
name: 'id',
title: 'Id'
},
{
name: 'resource',
title: 'Resource',
headerType: 'slot',
type: 'slot'
},
{
name: 'doubled',
title: 'Doubled',
type: 'callback',
callback: function (value) {
return `Double of ${value} is ${value * 2}`
}
}
]
const data = [
{
id: '4b136c0a-5057-11eb-ac70-eba264112003',
resource: 'hello-world.txt',
icon: 'text',
doubled: 2
},
{
id: '8468c9f0-5057-11eb-924b-934c6fd827a2',
resource: 'I am a folder',
icon: 'folder',
doubled: 6
},
{
id: '9c4cf97e-5057-11eb-8044-b3d5df9caa21',
resource: 'this is fine.png',
icon: 'image',
doubled: 12
}
]
describe('OcTable', () => {
it('displays all field types', () => {
const wrapper = mount(Table, {
props: {
fields,
data
},
slots: {
resourceHeader: '<span class="slot-header">Hello world!</span>',
resource: `
<div class="slot">
<span>
Hello world!
</span>
</div>
`
}
})
expect(wrapper.html().indexOf('4b136c0a-5057-11eb-ac70-eba264112003')).toBeGreaterThan(-1)
expect(wrapper.html().indexOf('Double of 2 is 4')).toBeGreaterThan(-1)
expect(wrapper.findAll('.slot').length).toBe(data.length)
expect(wrapper.findAll('.slot-header').length).toBe(1)
})
it('hides header', () => {
const wrapper = shallowMount(Table, {
props: {
fields,
data,
hasHeader: false
}
})
expect(wrapper.findAll('oc-thead-stub').length).toBe(0)
})
it('enables hover effect', () => {
const wrapper = shallowMount(Table, {
props: {
fields,
data,
hover: true
}
})
expect(wrapper.classes()).toContain('oc-table-hover')
})
it('extracts field title', () => {
const wrapper = shallowMount(Table, {
props: {
fields: [
{
name: 'resource-name'
}
],
data: [
{
id: 'documents',
name: 'Documents'
}
]
},
global: { renderStubDefaultSlot: true }
})
expect(wrapper.html().indexOf('resource-name')).toBeGreaterThan(-1)
})
it('extracts cell props', () => {
const wrapper = shallowMount(Table, {
props: {
fields: [
{
name: 'name',
title: 'Name'
},
{
name: 'description',
title: 'Description',
alignH: 'right',
alignV: 'top',
width: 'expand'
}
],
data: [
{
id: 'size',
name: 'Size',
description: 'Size of the resource'
}
]
},
global: { renderStubDefaultSlot: true }
})
expect(wrapper.html().indexOf('alignh="right"')).toBeGreaterThan(-1)
expect(wrapper.html().indexOf('alignv="top"')).toBeGreaterThan(-1)
expect(wrapper.html().indexOf('width="expand"')).toBeGreaterThan(-1)
})
it('adds sticky header', () => {
const wrapper = shallowMount(Table, {
props: {
fields,
data,
sticky: true
}
})
expect(wrapper.classes()).toContain('oc-table-sticky')
})
it('highlights a row', () => {
const wrapper = shallowMount(Table, {
props: {
fields,
data,
highlighted: '4b136c0a-5057-11eb-ac70-eba264112003'
},
global: { renderStubDefaultSlot: true }
})
expect(wrapper.findAll('.oc-table-highlighted').length).toEqual(1)
})
it('highlights multiple rows', () => {
const wrapper = shallowMount(Table, {
props: {
fields,
data,
highlighted: [
'4b136c0a-5057-11eb-ac70-eba264112003',
'8468c9f0-5057-11eb-924b-934c6fd827a2'
]
},
global: { renderStubDefaultSlot: true }
})
expect(wrapper.findAll('.oc-table-highlighted').length).toEqual(2)
})
it('adds data-item-id for rows', () => {
const wrapper = shallowMount(Table, {
props: {
fields,
data,
highlighted: []
},
global: { renderStubDefaultSlot: true }
})
expect(wrapper.html().indexOf('data-item-id')).toBeGreaterThan(-1)
})
it('accepts itemDomSelector closure', () => {
const wrapper = shallowMount(Table, {
props: {
fields,
data,
highlighted: [],
itemDomSelector: (item) => ['custom', item.id].join('-')
},
global: { renderStubDefaultSlot: true }
})
data.forEach((item) => {
expect(wrapper.find(['.oc-tbody-tr-custom', item.id].join('-')).exists()).toBeTruthy()
})
})
it('emits contextmenu-clicked event upon right click on table row', async () => {
const wrapper = shallowMount(Table, {
props: {
fields,
data,
highlighted: []
},
global: { renderStubDefaultSlot: true, stubs: { OcTr: false } }
})
await wrapper.find('.oc-tbody-tr').trigger('contextmenu')
expect(wrapper.emitted().contextmenuClicked.length).toBe(1)
})
it('enable dragDrop should enable draggable on rows', () => {
const wrapper = shallowMount(Table, {
props: {
fields,
data,
highlighted: [],
dragDrop: true
},
global: { renderStubDefaultSlot: true }
})
expect(wrapper.html().indexOf('draggable')).toBeGreaterThan(-1)
})
})
| owncloud/web/packages/design-system/src/components/OcTable/OcTable.spec.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/OcTable/OcTable.spec.ts",
"repo_id": "owncloud",
"token_count": 2674
} | 783 |
<template>
<component :is="tag">
<template v-for="(fragments, lineIndex) in lines">
<span
v-for="(fragment, fragmentIndex) in fragments"
:key="'line-' + lineIndex + '-fragment-' + fragmentIndex"
>
<!-- eslint-disable vue/no-v-for-template-key-on-child -->
<component
:is="fragment.tag"
:style="{
display:
fragment.value.startsWith(' ') || fragment.value.endsWith(' ')
? 'inline'
: 'inline-block'
}"
:class="{ 'highlighted-fragment': fragment.highlighted }"
>
{{ fragment.value }}
</component>
</span>
<br v-if="lineIndex < lines.length - 1" :key="'line-' + lineIndex + '-br'" />
</template>
</component>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'DocsHighlightedText',
props: {
tag: {
type: String,
default: 'span'
},
fragmentTag: {
type: String,
default: 'span',
validator: function (value: string) {
return ['span', 'i', 'em', 'b', 'strong'].includes(value)
}
},
value: {
type: String,
required: true
},
highlighted: {
type: String,
default: null
}
},
computed: {
lines() {
const regex = new RegExp('\\n')
const lines = this.value.split(regex)
return lines
.filter((line, index) => {
// note: split creates an empty first and last element. this removes those (if they are really empty)
return !((index === 0 || index === lines.length - 1) && !line.length)
})
.map((line) => this.buildFragments(line))
}
},
methods: {
buildFragments(line) {
if (this.highlighted) {
const regex = new RegExp('(' + this.highlighted + ')', 'gi')
const textFragments = line.split(regex)
if (textFragments.length > 1) {
return textFragments.map((fragment) => {
return {
tag: this.fragmentTag,
value: fragment,
highlighted: fragment.match(regex)
}
})
}
}
// if not highlighting or no matches found (i.e. result = whole value), return a single fragment
return [
{
tag: this.fragmentTag,
value: line,
highlighted: false
}
]
}
}
})
</script>
<style lang="scss">
.highlighted-fragment {
background-color: yellow;
}
</style>
| owncloud/web/packages/design-system/src/components/_DocsHighlightedText/_DocsHighlightedText.vue/0 | {
"file_path": "owncloud/web/packages/design-system/src/components/_DocsHighlightedText/_DocsHighlightedText.vue",
"repo_id": "owncloud",
"token_count": 1196
} | 784 |
import { onBeforeUnmount, ref, watch } from 'vue'
/**
*
* @param {Ref<Element>} target - ref with element to be observed
* @param {('show'|'showHide')} mode - showHide shows and hides the element on screen enter or leave, show only detects entering the screen and the keeps it rendered
* @param {string} rootMargin - margin that will be added around the element to detect visibility
* @returns {{isVisible: Ref<boolean>}}
*/
export const useIsVisible = ({ target, mode = 'show', rootMargin = '100px' }) => {
const isSupported = window && 'IntersectionObserver' in window
if (!isSupported) {
return {
isVisible: ref(true)
}
}
const isVisible = ref(false)
const observer = new IntersectionObserver(
(intersectionObserverEntries: IntersectionObserverEntry[]) => {
/**
* In some edge cases intersectionObserverEntries contains 2 entries with the first one having wrong rootBounds.
* This happens for some reason when the table is being re-sorted immediately after being rendered.
* Therefore we always check the last entry for isIntersecting.
*/
const isIntersecting = intersectionObserverEntries.at(-1).isIntersecting
isVisible.value = isIntersecting
/**
* if given mode is `showHide` we need to keep the observation alive.
*/
if (mode === 'showHide') {
return
}
/**
* if the mode is `show` which is the default, the implementation needs to unsubscribe the target from the observer
*/
if (!isVisible.value) {
return
}
observer.unobserve(target.value)
},
{
rootMargin
}
)
watch(target, () => {
observer.observe(target.value)
})
onBeforeUnmount(() => observer.disconnect())
return {
isVisible
}
}
| owncloud/web/packages/design-system/src/composables/useIsVisible/index.ts/0 | {
"file_path": "owncloud/web/packages/design-system/src/composables/useIsVisible/index.ts",
"repo_id": "owncloud",
"token_count": 624
} | 785 |
// fade-in left to right
@media (prefers-reduced-motion: reduce) {
.oc-fade-in {
animation: none;
}
}
@media (prefers-reduced-motion: no-preference) {
.oc-fade-in {
animation: fade-in 0.3s;
}
}
@keyframes fade-in {
0% {
opacity: 0;
transform: translateX(-20px);
}
100% {
opacity: 1;
transform: translateX(0);
}
}
| owncloud/web/packages/design-system/src/styles/theme/oc-animations.scss/0 | {
"file_path": "owncloud/web/packages/design-system/src/styles/theme/oc-animations.scss",
"repo_id": "owncloud",
"token_count": 163
} | 786 |
---
breakpoint:
small:
default:
old: breakpoint-small
value: 640px
max:
old: breakpoint-small-max
value: 959px
medium:
default:
old: breakpoint-medium
value: 960px
max:
old: breakpoint-medium-max
value: 1199px
large:
default:
value: 1200px
max:
value: 1599px
xlarge:
value: 1600px
xsmall:
max:
value: 639px
| owncloud/web/packages/design-system/src/tokens/ods/breakpoint.yaml/0 | {
"file_path": "owncloud/web/packages/design-system/src/tokens/ods/breakpoint.yaml",
"repo_id": "owncloud",
"token_count": 204
} | 787 |
module.exports = {
env: {
browser: true,
es6: true,
amd: true
},
extends: ['plugin:vue/vue3-recommended', 'plugin:prettier-vue/recommended'],
parser: 'vue-eslint-parser',
parserOptions: {
parser: {
js: '@babel/eslint-parser',
ts: '@typescript-eslint/parser'
},
requireConfigFile: false,
sourceType: 'module'
},
rules: {
/**
* TODO: fix project import issues and then enable it
* 'sort-imports': 'warn',
*/
'require-await': 'warn',
'no-new': 'off',
'node/no-callback-literal': 'off',
'unused-imports/no-unused-imports': 'error',
'nonblock-statement-body-position': ['error', 'below'],
curly: 'error',
// Vue 3 rules: (need to be fixed, but can be done incrementally)
'vue/no-deprecated-events-api': 'warn'
},
globals: {
require: false,
requirejs: false
},
plugins: ['unused-imports'],
overrides: [
{
files: ['**/*.vue'],
extends: ['plugin:vue/recommended', 'plugin:prettier-vue/recommended'],
rules: {
'vue/multi-word-component-names': 'warn',
'vue/no-multiple-template-root': 'off',
'vue/no-v-model-argument': 'off',
'vue/no-v-text-v-html-on-component': 'warn'
}
},
{
files: ['**/*.ts'],
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended'],
rules: {
'@typescript-eslint/no-extra-semi': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'prefer-const': 'warn'
}
}
]
}
| owncloud/web/packages/eslint-config/index.js/0 | {
"file_path": "owncloud/web/packages/eslint-config/index.js",
"repo_id": "owncloud",
"token_count": 758
} | 788 |
<template>
<form autocomplete="off" @submit.prevent="$emit('confirm')">
<oc-text-input
id="create-group-input-display-name"
v-model="group.displayName"
class="oc-mb-s"
:label="$gettext('Group name') + '*'"
:error-message="formData.displayName.errorMessage"
:fix-message-line="true"
@update:model-value="validateDisplayName"
/>
<input type="submit" class="oc-hidden" />
</form>
</template>
<script lang="ts">
import { useGettext } from 'vue3-gettext'
import { computed, defineComponent, ref, PropType, unref, watch } from 'vue'
import { Group } from '@ownclouders/web-client/src/generated'
import { MaybeRef, Modal, useClientService, useMessages } from '@ownclouders/web-pkg'
import { useGroupSettingsStore } from '../../composables'
export default defineComponent({
name: 'CreateGroupModal',
props: {
modal: { type: Object as PropType<Modal>, required: true }
},
emits: ['confirm', 'update:confirmDisabled'],
setup(props, { emit, expose }) {
const { $gettext } = useGettext()
const { showMessage, showErrorMessage } = useMessages()
const clientService = useClientService()
const groupSettingsStore = useGroupSettingsStore()
const group: MaybeRef<Group> = ref({ displayName: '' })
const formData = ref({
displayName: {
errorMessage: '',
valid: false
}
})
const isFormInvalid = computed(() => {
return Object.keys(unref(formData))
.map((k) => !!unref(formData)[k].valid)
.includes(false)
})
watch(
isFormInvalid,
() => {
emit('update:confirmDisabled', unref(isFormInvalid))
},
{ immediate: true }
)
const onConfirm = async () => {
if (unref(isFormInvalid)) {
return Promise.reject()
}
try {
const client = clientService.graphAuthenticated
const response = await client.groups.createGroup(unref(group))
showMessage({ title: $gettext('Group was created successfully') })
groupSettingsStore.upsertGroup(response?.data)
} catch (error) {
console.error(error)
showErrorMessage({
title: $gettext('Failed to create group'),
errors: [error]
})
}
}
expose({ onConfirm })
return {
clientService,
group,
formData,
isFormInvalid,
// unit tests
onConfirm
}
},
methods: {
async validateDisplayName() {
if (this.group.displayName.trim() === '') {
this.formData.displayName.errorMessage = this.$gettext('Group name cannot be empty')
this.formData.displayName.valid = false
return false
}
if (this.group.displayName.length > 255) {
this.formData.displayName.errorMessage = this.$gettext(
'Group name cannot exceed 255 characters'
)
this.formData.displayName.valid = false
return false
}
try {
const client = this.clientService.graphAuthenticated
await client.groups.getGroup(this.group.displayName)
this.formData.displayName.errorMessage = this.$gettext(
'Group "%{groupName}" already exists',
{
groupName: this.group.displayName
}
)
this.formData.displayName.valid = false
return false
} catch (e) {}
this.formData.displayName.errorMessage = ''
this.formData.displayName.valid = true
return true
}
}
})
</script>
| owncloud/web/packages/web-app-admin-settings/src/components/Groups/CreateGroupModal.vue/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/components/Groups/CreateGroupModal.vue",
"repo_id": "owncloud",
"token_count": 1429
} | 789 |
<template>
<div>
<oc-select
:model-value="selectedOption"
:label="$gettext('Login')"
:options="options"
:placeholder="$gettext('Select...')"
:warning-message="
currentUserSelected ? $gettext('Your own login status will remain unchanged.') : ''
"
@update:model-value="changeSelectedOption"
/>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, onMounted, PropType, ref, unref, watch } from 'vue'
import { useGettext } from 'vue3-gettext'
import { User } from '@ownclouders/web-client/src/generated'
import { useClientService, useUserStore, Modal, useMessages } from '@ownclouders/web-pkg'
import { useUserSettingsStore } from '../../composables/stores/userSettings'
type LoginOption = {
label: string
value: boolean
}
export default defineComponent({
name: 'LoginModal',
props: {
modal: { type: Object as PropType<Modal>, required: true },
users: {
type: Array as PropType<User[]>,
required: true
}
},
emits: ['update:confirmDisabled'],
setup(props, { emit, expose }) {
const { showMessage, showErrorMessage } = useMessages()
const clientService = useClientService()
const { $gettext, $ngettext } = useGettext()
const userStore = useUserStore()
const userSettingsStore = useUserSettingsStore()
const selectedOption = ref<LoginOption>()
const options = ref([
{ label: $gettext('Allowed'), value: true },
{ label: $gettext('Forbidden'), value: false }
])
watch(
selectedOption,
() => {
emit('update:confirmDisabled', !unref(selectedOption))
},
{ immediate: true }
)
const changeSelectedOption = (option: LoginOption) => {
selectedOption.value = option
}
const currentUserSelected = computed(() => {
return props.users.some((u) => u.id === userStore.user.id)
})
onMounted(() => {
if (props.users.every((u) => u.accountEnabled !== false)) {
selectedOption.value = unref(options).find(({ value }) => !!value)
} else if (props.users.every((u) => u.accountEnabled === false)) {
selectedOption.value = unref(options).find(({ value }) => !value)
}
})
const onConfirm = async () => {
const affectedUsers = props.users.filter(({ id }) => userStore.user.id !== id)
const client = clientService.graphAuthenticated
const promises = affectedUsers.map(({ id }) =>
client.users.editUser(id, { accountEnabled: unref(selectedOption).value })
)
const results = await Promise.allSettled(promises)
function isFulfilled<T>(
result: PromiseSettledResult<T>
): result is PromiseFulfilledResult<T> {
return result.status === 'fulfilled'
}
const succeeded = results.filter(isFulfilled)
if (succeeded.length) {
const title =
succeeded.length === 1 && affectedUsers.length === 1
? $gettext('Login for user "%{user}" was edited successfully', {
user: affectedUsers[0].displayName
})
: $ngettext(
'%{userCount} user login was edited successfully',
'%{userCount} users logins edited successfully',
succeeded.length,
{ userCount: succeeded.length.toString() },
true
)
showMessage({ title })
}
function isRejected<T>(result: PromiseSettledResult<T>): result is PromiseRejectedResult {
return result.status === 'rejected'
}
const failed = results.filter(isRejected)
if (failed.length) {
failed.forEach(console.error)
const title =
failed.length === 1 && affectedUsers.length === 1
? $gettext('Failed edit login for user "%{user}"', {
user: affectedUsers[0].displayName
})
: $ngettext(
'Failed to edit %{userCount} user login',
'Failed to edit %{userCount} user logins',
failed.length,
{ userCount: failed.length.toString() },
true
)
showErrorMessage({
title,
errors: (failed as PromiseRejectedResult[]).map((f) => f.reason)
})
}
try {
const usersResponse = await Promise.all(
succeeded.map(({ value }) => {
return client.users.getUser(value.data.id)
})
)
usersResponse.forEach(({ data }) => {
userSettingsStore.upsertUser(data)
})
} catch (e) {
console.error(e)
}
}
expose({ onConfirm })
return {
selectedOption,
options,
changeSelectedOption,
currentUserSelected,
// unit tests
onConfirm
}
}
})
</script>
| owncloud/web/packages/web-app-admin-settings/src/components/Users/LoginModal.vue/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/components/Users/LoginModal.vue",
"repo_id": "owncloud",
"token_count": 2042
} | 790 |
import { useModals, useCapabilityStore } from '@ownclouders/web-pkg'
import { computed } from 'vue'
import { useGettext } from 'vue3-gettext'
import { UserAction } from '@ownclouders/web-pkg'
import CreateUserModal from '../../../components/Users/CreateUserModal.vue'
export const useUserActionsCreateUser = () => {
const { dispatchModal } = useModals()
const capabilityStore = useCapabilityStore()
const { $gettext } = useGettext()
const actions = computed((): UserAction[] => [
{
name: 'create-user',
icon: 'add',
componentType: 'button',
class: 'oc-users-actions-create-user',
label: () => $gettext('New user'),
isVisible: () => !capabilityStore.graphUsersCreateDisabled,
handler: () => {
dispatchModal({
title: $gettext('Create user'),
customComponent: CreateUserModal
})
}
}
])
return {
actions
}
}
| owncloud/web/packages/web-app-admin-settings/src/composables/actions/users/useUserActionsCreateUser.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/composables/actions/users/useUserActionsCreateUser.ts",
"repo_id": "owncloud",
"token_count": 351
} | 791 |
<template>
<div>
<app-template
ref="template"
:breadcrumbs="breadcrumbs"
:show-app-bar="false"
:is-side-bar-open="isSideBarOpen"
:side-bar-active-panel="sideBarActivePanel"
:side-bar-available-panels="sideBarAvailablePanels"
>
<template #mainContent>
<div class="oc-px-m">
<InfoSection />
<AppearanceSection />
</div>
</template>
</app-template>
</div>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue'
import AppTemplate from '../components/AppTemplate.vue'
import InfoSection from '../components/General/InfoSection.vue'
import AppearanceSection from '../components/General/AppearanceSection.vue'
import DetailsPanel from '../components/General/SideBar/DetailsPanel.vue'
import { useGettext } from 'vue3-gettext'
import { useSideBar } from '@ownclouders/web-pkg'
export default defineComponent({
components: {
AppearanceSection,
AppTemplate,
InfoSection
},
setup() {
const template = ref()
const { $gettext } = useGettext()
const sideBarAvailablePanels = [
{
name: 'DetailsPanel',
icon: 'settings-4',
title: () => $gettext('Details'),
component: DetailsPanel,
isRoot: () => true,
isVisible: () => true
}
]
return {
template,
sideBarAvailablePanels,
...useSideBar()
}
},
computed: {
breadcrumbs() {
return [
{ text: this.$gettext('Administration Settings'), to: { path: '/admin-settings' } },
{
text: this.$gettext('General')
}
]
}
}
})
</script>
| owncloud/web/packages/web-app-admin-settings/src/views/General.vue/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/src/views/General.vue",
"repo_id": "owncloud",
"token_count": 690
} | 792 |
import MembersRoleSection from '../../../../../src/components/Spaces/SideBar/MembersRoleSection.vue'
import { defaultPlugins, shallowMount } from 'web-test-helpers'
import { mock } from 'vitest-mock-extended'
import { SpaceRole } from '@ownclouders/web-client/src/helpers'
describe('MembersRoleSection', () => {
it('should render all members accordingly', () => {
const members = [
mock<SpaceRole>({ kind: 'user', displayName: 'einstein' }),
mock<SpaceRole>({ kind: 'group', displayName: 'physic-lovers' })
]
const { wrapper } = getWrapper({ members })
expect(wrapper.html()).toMatchSnapshot()
})
})
function getWrapper({ members = [] } = {}) {
return {
wrapper: shallowMount(MembersRoleSection, {
props: {
members
},
global: {
plugins: [...defaultPlugins()]
}
})
}
}
| owncloud/web/packages/web-app-admin-settings/tests/unit/components/Spaces/SideBar/MembersRoleSection.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/components/Spaces/SideBar/MembersRoleSection.spec.ts",
"repo_id": "owncloud",
"token_count": 317
} | 793 |
import { useMessages } from '@ownclouders/web-pkg'
import { useGeneralActionsResetLogo } from '../../../../../src/composables/actions/general/useGeneralActionsResetLogo'
import { mock } from 'vitest-mock-extended'
import { unref } from 'vue'
import {
defaultComponentMocks,
RouteLocation,
mockAxiosResolve,
getComposableWrapper
} from 'web-test-helpers'
describe('resetLogo', () => {
beforeEach(() => {
vi.useFakeTimers()
})
afterEach(() => {
vi.useRealTimers()
})
describe('handler', () => {
it('should show message on request success', () => {
getWrapper({
setup: async ({ actions }, { clientService, router }) => {
clientService.httpAuthenticated.delete.mockResolvedValue(mockAxiosResolve())
await unref(actions)[0].handler()
vi.runAllTimers()
expect(router.go).toHaveBeenCalledTimes(1)
const { showMessage } = useMessages()
expect(showMessage).toHaveBeenCalledTimes(1)
}
})
})
it('should show message on request error', () => {
vi.spyOn(console, 'error').mockImplementation(() => undefined)
getWrapper({
setup: async ({ actions }, { clientService, router }) => {
clientService.httpAuthenticated.delete.mockRejectedValue(new Error(''))
await unref(actions)[0].handler()
vi.runAllTimers()
expect(router.go).toHaveBeenCalledTimes(0)
const { showErrorMessage } = useMessages()
expect(showErrorMessage).toHaveBeenCalledTimes(1)
}
})
})
})
})
function getWrapper({
setup
}: {
setup: (
instance: ReturnType<typeof useGeneralActionsResetLogo>,
{
clientService,
router
}: {
clientService: ReturnType<typeof defaultComponentMocks>['$clientService']
router: ReturnType<typeof defaultComponentMocks>['$router']
}
) => void
}) {
const mocks = defaultComponentMocks({
currentRoute: mock<RouteLocation>({ name: 'admin-settings-general' })
})
return {
wrapper: getComposableWrapper(
() => {
const instance = useGeneralActionsResetLogo()
setup(instance, {
clientService: mocks.$clientService,
router: mocks.$router
})
},
{
mocks,
provide: mocks
}
)
}
}
| owncloud/web/packages/web-app-admin-settings/tests/unit/composables/actions/general/useGeneralActionsResetLogo.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/composables/actions/general/useGeneralActionsResetLogo.spec.ts",
"repo_id": "owncloud",
"token_count": 963
} | 794 |
import Users from '../../../src/views/Users.vue'
import { ItemFilter, OptionsConfig, UserAction, useAppDefaults } from '@ownclouders/web-pkg'
import { mock, mockDeep } from 'vitest-mock-extended'
import { defaultComponentMocks, defaultPlugins, mount, shallowMount } from 'web-test-helpers'
import { AxiosResponse } from 'axios'
import { ClientService, queryItemAsString } from '@ownclouders/web-pkg'
import { User } from '@ownclouders/web-client/src/generated'
import { useAppDefaultsMock } from 'web-test-helpers/src/mocks/useAppDefaultsMock'
import { useUserActionsCreateUser } from '../../../src/composables/actions/users/useUserActionsCreateUser'
import { ref } from 'vue'
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
queryItemAsString: vi.fn(),
useAppDefaults: vi.fn()
}))
vi.mock('../../../src/composables/actions/users/useUserActionsCreateUser')
vi.mocked(useAppDefaults).mockImplementation(() => useAppDefaultsMock())
const getDefaultUser = () => {
return {
id: '1',
displayName: 'Admin',
givenName: 'Admin',
surname: 'Admin',
memberOf: [],
mail: 'admin@example.org',
drive: {
id: '1',
name: 'admin',
quota: { remaining: 5000000000, state: 'normal', total: 5000000000, used: 0 }
},
appRoleAssignments: [
{
appRoleId: '1',
id: '1',
principalId: '1',
principalType: 'User',
resourceDisplayName: 'ownCloud Infinite Scale',
resourceId: 'some-graph-app-id'
}
]
}
}
const getDefaultApplications = () => {
return [
{
appRoles: [
{
displayName: 'Admin',
id: '1'
},
{
displayName: 'Guest',
id: '2'
},
{
displayName: 'Space Admin',
id: '3'
},
{
displayName: 'User',
id: '4'
}
],
displayName: 'ownCloud Infinite Scale',
id: 'some-graph-app-id'
}
]
}
const getClientService = () => {
const clientService = mockDeep<ClientService>()
clientService.graphAuthenticated.users.listUsers.mockResolvedValue(
mock<AxiosResponse>({ data: { value: [getDefaultUser()] } })
)
clientService.graphAuthenticated.users.getUser.mockResolvedValue(
mock<AxiosResponse>({ data: getDefaultUser() })
)
clientService.graphAuthenticated.users.editUser.mockResolvedValue(
mock<AxiosResponse>({ data: getDefaultUser() })
)
clientService.graphAuthenticated.groups.listGroups.mockResolvedValue(
mock<AxiosResponse>({ data: { value: [] } })
)
clientService.graphAuthenticated.applications.listApplications.mockResolvedValue(
mock<AxiosResponse>({ data: { value: getDefaultApplications() } })
)
return clientService
}
const selectors = {
itemFilterGroupsStub: 'item-filter-stub[filtername="groups"]',
itemFilterRolesStub: 'item-filter-stub[filtername="roles"]',
createUserButton: '#create-user-btn'
}
describe('Users view', () => {
describe('list view', () => {
it('renders list initially', async () => {
const { wrapper } = getMountedWrapper({ mountType: mount, users: [getDefaultUser()] })
await wrapper.vm.loadResourcesTask.last
expect(wrapper.html()).toMatchSnapshot()
})
it('renders initially warning if filters are mandatory', async () => {
const { wrapper } = getMountedWrapper({
mountType: mount,
options: { userListRequiresFilter: true }
})
await wrapper.vm.loadResourcesTask.last
expect(wrapper.html()).toMatchSnapshot()
})
})
describe('create user button', () => {
it('should be displayed if action enabled', () => {
const { wrapper } = getMountedWrapper({
mountType: mount,
createUserActionEnabled: true
})
const createUserButton = wrapper.find(selectors.createUserButton)
expect(createUserButton.exists()).toBeTruthy()
})
it('should not be displayed if action disabled', () => {
const { wrapper } = getMountedWrapper({
mountType: mount,
createUserActionEnabled: false
})
const createUserButton = wrapper.find(selectors.createUserButton)
expect(createUserButton.exists()).toBeFalsy()
})
})
describe('computed method "sideBarAvailablePanels"', () => {
it('should contain EditPanel when one user is selected', () => {
const { wrapper } = getMountedWrapper()
expect(
wrapper.vm.sideBarAvailablePanels
.find(({ name }) => name === 'EditPanel')
.isVisible({ items: [{ id: '1' }] })
).toBeTruthy()
})
it('should contain DetailsPanel no user is selected', () => {
const { wrapper } = getMountedWrapper()
expect(
wrapper.vm.sideBarAvailablePanels
.find(({ name }) => name === 'DetailsPanel')
.isVisible({ items: [] })
).toBeTruthy()
})
it('should not contain EditPanel when multiple users are selected', () => {
const { wrapper } = getMountedWrapper()
expect(
wrapper.vm.sideBarAvailablePanels
.find(({ name }) => name === 'EditPanel')
.isVisible({ items: [{ id: '1' }, { id: '2' }] })
).toBeFalsy()
})
})
describe('batch actions', () => {
it('do not display when no user selected', async () => {
const { wrapper } = getMountedWrapper({ mountType: mount })
await wrapper.vm.loadResourcesTask.last
expect(wrapper.find('batch-actions-stub').exists()).toBeFalsy()
})
it('display when one user selected', async () => {
const { wrapper } = getMountedWrapper({ mountType: mount, selectedUsers: [{ id: '1' }] })
await wrapper.vm.loadResourcesTask.last
await wrapper.vm.$nextTick()
expect(wrapper.find('batch-actions-stub').exists()).toBeTruthy()
})
it('display when more than one users selected', async () => {
const { wrapper } = getMountedWrapper({
mountType: mount,
selectedUsers: [{ id: '1' }, { id: '2' }]
})
await wrapper.vm.loadResourcesTask.last
await wrapper.vm.$nextTick()
expect(wrapper.find('batch-actions-stub').exists()).toBeTruthy()
})
})
describe('filter', () => {
describe('groups', () => {
it('does filter users by groups when the "selectionChange"-event is triggered', async () => {
const clientService = getClientService()
const { wrapper } = getMountedWrapper({ mountType: mount, clientService })
await wrapper.vm.loadResourcesTask.last
expect(clientService.graphAuthenticated.users.listUsers).toHaveBeenCalledTimes(1)
wrapper
.findComponent<typeof ItemFilter>(selectors.itemFilterGroupsStub)
.vm.$emit('selectionChange', [{ id: '1' }])
await wrapper.vm.$nextTick()
expect(clientService.graphAuthenticated.users.listUsers).toHaveBeenCalledTimes(2)
expect(clientService.graphAuthenticated.users.listUsers).toHaveBeenNthCalledWith(
2,
'displayName',
"(memberOf/any(m:m/id eq '1'))",
['appRoleAssignments']
)
})
it('does filter initially if group ids are given via query param', async () => {
const groupIdsQueryParam = '1+2'
const clientService = getClientService()
const { wrapper } = getMountedWrapper({
mountType: mount,
clientService,
groupFilterQuery: groupIdsQueryParam
})
await wrapper.vm.loadResourcesTask.last
expect(clientService.graphAuthenticated.users.listUsers).toHaveBeenCalledWith(
'displayName',
"(memberOf/any(m:m/id eq '1') or memberOf/any(m:m/id eq '2'))",
['appRoleAssignments']
)
})
})
describe('roles', () => {
it('does filter users by roles when the "selectionChange"-event is triggered', async () => {
const clientService = getClientService()
const { wrapper } = getMountedWrapper({ mountType: mount, clientService })
await wrapper.vm.loadResourcesTask.last
expect(clientService.graphAuthenticated.users.listUsers).toHaveBeenCalledTimes(1)
wrapper
.findComponent<typeof ItemFilter>(selectors.itemFilterRolesStub)
.vm.$emit('selectionChange', [{ id: '1' }])
await wrapper.vm.$nextTick()
expect(clientService.graphAuthenticated.users.listUsers).toHaveBeenCalledTimes(2)
expect(clientService.graphAuthenticated.users.listUsers).toHaveBeenNthCalledWith(
2,
'displayName',
"(appRoleAssignments/any(m:m/appRoleId eq '1'))",
['appRoleAssignments']
)
})
it('does filter initially if role ids are given via query param', async () => {
const roleIdsQueryParam = '1+2'
const clientService = getClientService()
const { wrapper } = getMountedWrapper({
mountType: mount,
clientService,
roleFilterQuery: roleIdsQueryParam
})
await wrapper.vm.loadResourcesTask.last
expect(clientService.graphAuthenticated.users.listUsers).toHaveBeenCalledWith(
'displayName',
"(appRoleAssignments/any(m:m/appRoleId eq '1') or appRoleAssignments/any(m:m/appRoleId eq '2'))",
['appRoleAssignments']
)
})
})
describe('displayName', () => {
it('does filter initially if displayName is given via query param', async () => {
const displayNameFilterQueryParam = 'Albert'
const clientService = getClientService()
const { wrapper } = getMountedWrapper({
mountType: mount,
clientService,
displayNameFilterQuery: displayNameFilterQueryParam
})
await wrapper.vm.loadResourcesTask.last
expect(clientService.graphAuthenticated.users.listUsers).toHaveBeenCalledWith(
'displayName',
"contains(displayName,'Albert')",
['appRoleAssignments']
)
})
})
})
})
function getMountedWrapper({
mountType = shallowMount,
clientService = getClientService(),
displayNameFilterQuery = null,
groupFilterQuery = null,
roleFilterQuery = null,
options = {},
createUserActionEnabled = true,
users = [],
selectedUsers = []
}: {
mountType?: typeof shallowMount | typeof mount
clientService?: ReturnType<typeof mockDeep<ClientService>>
displayNameFilterQuery?: string
groupFilterQuery?: string
roleFilterQuery?: string
options?: OptionsConfig
createUserActionEnabled?: boolean
users?: User[]
selectedUsers?: User[]
} = {}) {
vi.mocked(queryItemAsString).mockImplementationOnce(() => displayNameFilterQuery)
vi.mocked(queryItemAsString).mockImplementationOnce(() => groupFilterQuery)
vi.mocked(queryItemAsString).mockImplementationOnce(() => roleFilterQuery)
vi.mocked(queryItemAsString).mockImplementationOnce(() => displayNameFilterQuery)
vi.mocked(useUserActionsCreateUser).mockReturnValue(
mock<ReturnType<typeof useUserActionsCreateUser>>({
actions: ref([mock<UserAction>({ isVisible: () => createUserActionEnabled })])
})
)
const mocks = {
...defaultComponentMocks()
}
mocks.$clientService = clientService
const user = { id: '1', uuid: '1' }
return {
mocks,
wrapper: mountType(Users, {
global: {
plugins: [
...defaultPlugins({
piniaOptions: {
userState: { user },
configState: { options },
userSettingsStore: { users, selectedUsers }
}
})
],
mocks,
provide: mocks,
stubs: {
AppLoadingSpinner: true,
ViewOptions: true,
OcBreadcrumb: true,
NoContentMessage: true,
ItemFilter: true,
BatchActions: true,
OcButton: true
}
}
})
}
}
| owncloud/web/packages/web-app-admin-settings/tests/unit/views/Users.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-admin-settings/tests/unit/views/Users.spec.ts",
"repo_id": "owncloud",
"token_count": 4745
} | 795 |
[main]
host = https://www.transifex.com
[o:owncloud-org:p:owncloud-web:r:external]
file_filter = locale/<lang>/LC_MESSAGES/app.po
minimum_perc = 0
source_file = template.pot
source_lang = en
type = PO
| owncloud/web/packages/web-app-external/l10n/.tx/config/0 | {
"file_path": "owncloud/web/packages/web-app-external/l10n/.tx/config",
"repo_id": "owncloud",
"token_count": 83
} | 796 |
<template>
<div
v-oc-tooltip="
isRemoteUploadInProgress ? $gettext('Please wait until all imports have finished') : null
"
>
<oc-button
:class="btnClass"
justify-content="left"
appearance="raw"
:disabled="isRemoteUploadInProgress"
@click="triggerUpload"
>
<resource-icon :resource="resource" size="medium" />
<span :id="uploadLabelId">{{ buttonLabel }}</span>
</oc-button>
<input
:id="inputId"
ref="input"
v-bind="inputAttrs"
class="upload-input-target"
type="file"
:aria-labelledby="uploadLabelId"
:name="isFolder ? 'file' : 'folder'"
tabindex="-1"
/>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, onMounted, onBeforeUnmount, ref } from 'vue'
import { Resource } from '@ownclouders/web-client/src'
import { useService, ResourceIcon } from '@ownclouders/web-pkg'
import type { UppyService } from '@ownclouders/web-pkg'
export default defineComponent({
components: { ResourceIcon },
props: {
btnLabel: {
type: String,
required: false,
default: ''
},
btnClass: {
type: String,
required: false,
default: ''
},
isFolder: {
type: Boolean,
required: false,
default: false
}
},
setup(props) {
const uppyService = useService<UppyService>('$uppyService')
const isRemoteUploadInProgress = ref(uppyService.isRemoteUploadInProgress())
let uploadStartedSub
let uploadCompletedSub
const resource = computed(() => {
return { extension: '', isFolder: props.isFolder } as Resource
})
const onUploadStarted = () =>
(isRemoteUploadInProgress.value = uppyService.isRemoteUploadInProgress())
const onUploadCompleted = () => (isRemoteUploadInProgress.value = false)
onMounted(() => {
uploadStartedSub = uppyService.subscribe('uploadStarted', onUploadStarted)
uploadCompletedSub = uppyService.subscribe('uploadCompleted', onUploadCompleted)
})
onBeforeUnmount(() => {
uppyService.unsubscribe('uploadStarted', uploadStartedSub)
uppyService.unsubscribe('uploadCompleted', uploadCompletedSub)
})
return {
isRemoteUploadInProgress,
resource
}
},
computed: {
inputId() {
if (this.isFolder) {
return 'files-folder-upload-input'
}
return 'files-file-upload-input'
},
uploadLabelId() {
if (this.isFolder) {
return 'files-folder-upload-button'
}
return 'files-file-upload-button'
},
buttonLabel() {
if (this.btnLabel) {
return this.btnLabel
}
if (this.isFolder) {
return this.$gettext('Folder')
}
return this.$gettext('Files')
},
inputAttrs() {
if (this.isFolder) {
return {
webkitdirectory: true,
mozdirectory: true,
allowdirs: true
}
}
return { multiple: true }
}
},
mounted() {
this.$uppyService.registerUploadInput(this.$refs.input as HTMLInputElement)
},
beforeUnmount() {
this.$uppyService.removeUploadInput(this.$refs.input as HTMLInputElement)
},
methods: {
triggerUpload() {
;(this.$refs.input as HTMLInputElement).click()
}
}
})
</script>
<style scoped>
.upload-input-target {
position: absolute;
left: -99999px;
}
</style>
| owncloud/web/packages/web-app-files/src/components/AppBar/Upload/ResourceUpload.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/AppBar/Upload/ResourceUpload.vue",
"repo_id": "owncloud",
"token_count": 1383
} | 797 |
<template>
<div id="oc-no-selection" class="oc-text-center oc-mt-xl">
<oc-icon size="xxlarge" name="drag-drop" fill-type="line" />
<p data-testid="selectedFilesText" v-text="selectedFilesString" />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'NoSelection',
computed: {
selectedFilesString() {
return this.$gettext('Select a file or folder to view details')
}
}
})
</script>
| owncloud/web/packages/web-app-files/src/components/SideBar/NoSelection.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/SideBar/NoSelection.vue",
"repo_id": "owncloud",
"token_count": 174
} | 798 |
<template>
<div id="oc-files-sharing-sidebar" class="oc-position-relative">
<div class="oc-flex oc-flex-between oc-flex-center oc-flex-middle">
<div class="oc-flex oc-py-s">
<h3 v-translate class="oc-text-bold oc-text-medium oc-m-rm">Members</h3>
<oc-contextual-helper v-if="helpersEnabled" class="oc-pl-xs" v-bind="spaceAddMemberHelp" />
</div>
<div class="oc-flex">
<div v-if="isFilterOpen" class="oc-flex">
<oc-text-input
v-model="filterTerm"
class="oc-text-truncate space-members-filter oc-mr-s"
label=""
:placeholder="$gettext('Filter members')"
/>
<oc-button
v-oc-tooltip="$gettext('Close filter')"
class="close-filter-btn"
:aria-label="$gettext('Close filter')"
appearance="raw"
@click="toggleFilter"
>
<oc-icon name="close" fill-type="line" size="small" />
</oc-button>
</div>
<oc-button
v-else
v-oc-tooltip="$gettext('Filter members')"
class="open-filter-btn"
:aria-label="$gettext('Filter members')"
appearance="raw"
@click="toggleFilter"
>
<oc-icon name="search" fill-type="line" size="small" />
</oc-button>
</div>
</div>
<invite-collaborator-form
v-if="canShare({ space: resource, resource })"
key="new-collaborator"
:save-button-label="$gettext('Add')"
:invite-label="$gettext('Search')"
class="oc-my-s"
/>
<template v-if="hasCollaborators">
<ul
id="files-collaborators-list"
ref="collaboratorList"
class="oc-list oc-list-divider oc-overflow-hidden oc-m-rm"
:aria-label="$gettext('Space members')"
>
<li v-for="collaborator in filteredSpaceMembers" :key="collaborator.id">
<collaborator-list-item
:share="collaborator"
:modifiable="isModifiable(collaborator)"
@on-delete="deleteMemberConfirm(collaborator)"
/>
</li>
</ul>
</template>
</div>
</template>
<script lang="ts">
import { storeToRefs } from 'pinia'
import CollaboratorListItem from './Collaborators/ListItem.vue'
import InviteCollaboratorForm from './Collaborators/InviteCollaborator/InviteCollaboratorForm.vue'
import { GraphShareRoleIdMap } from '@ownclouders/web-client/src/helpers/share'
import {
createLocationSpaces,
isLocationSpacesActive,
useCanShare,
useConfigStore,
useMessages,
useModals,
useSharesStore,
useSpacesStore,
useUserStore
} from '@ownclouders/web-pkg'
import { defineComponent, inject, Ref } from 'vue'
import { shareSpaceAddMemberHelp } from '../../../helpers/contextualHelpers'
import {
ProjectSpaceResource,
CollaboratorShare,
buildSpace
} from '@ownclouders/web-client/src/helpers'
import { useClientService } from '@ownclouders/web-pkg'
import Fuse from 'fuse.js'
import Mark from 'mark.js'
import { defaultFuseOptions } from '@ownclouders/web-pkg'
export default defineComponent({
name: 'SpaceMembers',
components: {
CollaboratorListItem,
InviteCollaboratorForm
},
setup() {
const userStore = useUserStore()
const clientService = useClientService()
const { canShare } = useCanShare()
const { dispatchModal } = useModals()
const { deleteShare } = useSharesStore()
const spacesStore = useSpacesStore()
const { upsertSpace, removeSpaceMember } = spacesStore
const { spaceMembers } = storeToRefs(spacesStore)
const configStore = useConfigStore()
const { options: configOptions } = storeToRefs(configStore)
const { user } = storeToRefs(userStore)
return {
user,
clientService,
configStore,
configOptions,
resource: inject<Ref<ProjectSpaceResource>>('resource'),
dispatchModal,
spaceMembers,
deleteShare,
upsertSpace,
removeSpaceMember,
canShare,
...useMessages()
}
},
data: () => {
return {
filterTerm: '',
isFilterOpen: false,
markInstance: null
}
},
computed: {
filteredSpaceMembers() {
return this.filter(this.spaceMembers, this.filterTerm)
},
helpersEnabled() {
return this.configStore.options.contextHelpers
},
spaceAddMemberHelp() {
return shareSpaceAddMemberHelp({ configStore: this.configStore })
},
hasCollaborators() {
return this.spaceMembers.length > 0
}
},
watch: {
isFilterOpen() {
this.filterTerm = ''
},
filterTerm() {
this.$nextTick(() => {
if (this.$refs.collaboratorList) {
this.markInstance = new Mark(this.$refs.collaboratorList)
this.markInstance.unmark()
this.markInstance.mark(this.filterTerm, {
element: 'span',
className: 'mark-highlight'
})
}
})
}
},
methods: {
filter(collection: CollaboratorShare[], term: string) {
if (!(term || '').trim()) {
return collection
}
const searchEngine = new Fuse(collection, {
...defaultFuseOptions,
keys: ['sharedWith.displayName', 'sharedWith.name']
})
return searchEngine.search(term).map((r) => r.item)
},
toggleFilter() {
this.isFilterOpen = !this.isFilterOpen
},
isModifiable(share: CollaboratorShare) {
if (!this.canShare({ space: this.resource, resource: this.resource })) {
return false
}
if (share.role.id !== GraphShareRoleIdMap.SpaceManager) {
return true
}
// forbid to remove last manager of a space
const managers = this.spaceMembers.filter(
({ role }) => role.id === GraphShareRoleIdMap.SpaceManager
)
return managers.length > 1
},
deleteMemberConfirm(share: CollaboratorShare) {
this.dispatchModal({
variation: 'danger',
title: this.$gettext('Remove member'),
confirmText: this.$gettext('Remove'),
message: this.$gettext('Are you sure you want to remove this member?'),
hasInput: false,
onConfirm: async () => {
try {
const currentUserRemoved = share.sharedWith.id === this.user.id
await this.deleteShare({
clientService: this.clientService,
space: this.resource,
resource: this.resource,
collaboratorShare: share
})
if (!currentUserRemoved) {
const client = this.clientService.graphAuthenticated
const graphResponse = await client.drives.getDrive(share.resourceId)
this.upsertSpace(buildSpace(graphResponse.data))
}
this.removeSpaceMember({ member: share })
this.showMessage({
title: this.$gettext('Share was removed successfully')
})
if (currentUserRemoved) {
if (isLocationSpacesActive(this.$router, 'files-spaces-projects')) {
await this.$router.go(0)
return
}
await this.$router.push(createLocationSpaces('files-spaces-projects'))
}
} catch (error) {
console.error(error)
this.showErrorMessage({
title: this.$gettext('Failed to remove share'),
errors: [error]
})
}
}
})
}
}
})
</script>
<style>
.space-members-filter {
max-width: 160px;
}
.avatars-wrapper {
height: 40px;
}
</style>
| owncloud/web/packages/web-app-files/src/components/SideBar/Shares/SpaceMembers.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/components/SideBar/Shares/SpaceMembers.vue",
"repo_id": "owncloud",
"token_count": 3342
} | 799 |
import {
Key,
KeyboardActions,
ModifierKey,
useClipboardStore,
useResourcesStore
} from '@ownclouders/web-pkg'
import { SpaceResource } from '@ownclouders/web-client'
import { unref } from 'vue'
import { useFileActionsPaste } from '@ownclouders/web-pkg'
export const useKeyboardTableSpaceActions = (keyActions: KeyboardActions, space: SpaceResource) => {
const { copyResources, cutResources } = useClipboardStore()
const resourcesStore = useResourcesStore()
const { actions: pasteFileActions } = useFileActionsPaste()
const pasteFileAction = unref(pasteFileActions)[0].handler
keyActions.bindKeyAction({ modifier: ModifierKey.Ctrl, primary: Key.C }, () => {
copyResources(resourcesStore.selectedResources)
})
keyActions.bindKeyAction({ modifier: ModifierKey.Ctrl, primary: Key.V }, () => {
pasteFileAction({ space: space })
})
keyActions.bindKeyAction({ modifier: ModifierKey.Ctrl, primary: Key.X }, () => {
cutResources(resourcesStore.selectedResources)
})
}
| owncloud/web/packages/web-app-files/src/composables/keyboardActions/useKeyboardTableSpaceActions.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/composables/keyboardActions/useKeyboardTableSpaceActions.ts",
"repo_id": "owncloud",
"token_count": 316
} | 800 |
import ListComponent from '../../components/Search/List.vue'
import { SearchFunction, SearchList, SearchResult } from '@ownclouders/web-pkg'
import { Component } from 'vue'
export const searchLimit = 200
export default class List implements SearchList {
public readonly component: Component
private readonly searchFunction: SearchFunction
constructor(searchFunction: SearchFunction) {
this.component = ListComponent
this.searchFunction = searchFunction
}
public search(term: string): Promise<SearchResult> {
return this.searchFunction(term, searchLimit)
}
}
| owncloud/web/packages/web-app-files/src/search/sdk/list.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/search/sdk/list.ts",
"repo_id": "owncloud",
"token_count": 157
} | 801 |
<template>
<div class="oc-flex">
<files-view-wrapper class="oc-flex-column">
<app-bar :has-bulk-actions="true" :is-side-bar-open="isSideBarOpen">
<template #navigation>
<SharesNavigation />
</template>
</app-bar>
<app-loading-spinner v-if="areResourcesLoading" />
<template v-else>
<div
class="shared-with-me-filters oc-flex oc-flex-between oc-flex-wrap oc-flex-bottom oc-mx-m oc-mb-m"
>
<div class="oc-flex">
<div class="oc-mr-m oc-flex oc-flex-middle">
<oc-icon name="filter-2" class="oc-mr-xs" />
<span v-text="$gettext('Filter:')" />
</div>
<item-filter-inline
class="share-visibility-filter"
filter-name="share-visibility"
:filter-options="visibilityOptions"
@toggle-filter="setAreHiddenFilesShown"
/>
<item-filter
:allow-multiple="true"
:filter-label="$gettext('Share Type')"
:filterable-attributes="['label']"
:items="shareTypes"
:option-filter-label="$gettext('Filter share types')"
:show-option-filter="true"
id-attribute="key"
class="share-type-filter oc-ml-s"
display-name-attribute="label"
filter-name="shareType"
>
<template #item="{ item }">
<span class="oc-ml-s" v-text="item.label" />
</template>
</item-filter>
<item-filter
:allow-multiple="true"
:filter-label="$gettext('Shared By')"
:filterable-attributes="['displayName']"
:items="fileOwners"
:option-filter-label="$gettext('Filter shared by')"
:show-option-filter="true"
id-attribute="id"
class="shared-by-filter oc-ml-s"
display-name-attribute="displayName"
filter-name="sharedBy"
>
<template #image="{ item }">
<avatar-image :width="32" :userid="item.id" :user-name="item.displayName" />
</template>
<template #item="{ item }">
<span class="oc-ml-s" v-text="item.displayName" />
</template>
</item-filter>
</div>
<div>
<oc-text-input
v-model="filterTerm"
class="search-filter"
:label="$gettext('Search')"
autocomplete="off"
/>
</div>
</div>
<shared-with-me-section
id="files-shared-with-me-view"
:display-thumbnails="displayThumbnails"
:file-list-header-y="fileListHeaderY"
:items="items"
:is-side-bar-open="isSideBarOpen"
:sort-by="sortBy"
:sort-dir="sortDir"
:sort-handler="handleSort"
:title="shareSectionTitle"
:empty-message="
areHiddenFilesShown ? $gettext('No hidden shares') : $gettext('No shares')
"
:grouping-settings="groupingSettings"
/>
</template>
</files-view-wrapper>
<file-side-bar
:is-open="isSideBarOpen"
:active-panel="sideBarActivePanel"
:space="selectedShareSpace"
/>
</div>
</template>
<script lang="ts">
import Fuse from 'fuse.js'
import Mark from 'mark.js'
import { useResourcesViewDefaults } from '../../composables'
import {
AppLoadingSpinner,
FileSideBar,
InlineFilterOption,
ItemFilter,
useConfigStore,
useResourcesStore
} from '@ownclouders/web-pkg'
import { AppBar, ItemFilterInline } from '@ownclouders/web-pkg'
import { queryItemAsString, useRouteQuery } from '@ownclouders/web-pkg'
import SharedWithMeSection from '../../components/Shares/SharedWithMeSection.vue'
import { computed, defineComponent, onMounted, ref, unref, watch } from 'vue'
import FilesViewWrapper from '../../components/FilesViewWrapper.vue'
import { useGetMatchingSpace, useSort } from '@ownclouders/web-pkg'
import { useGroupingSettings } from '@ownclouders/web-pkg'
import SharesNavigation from 'web-app-files/src/components/AppBar/SharesNavigation.vue'
import { useGettext } from 'vue3-gettext'
import { useOpenWithDefaultApp, defaultFuseOptions } from '@ownclouders/web-pkg'
import { IncomingShareResource, ShareTypes } from '@ownclouders/web-client/src/helpers'
import { uniq } from 'lodash-es'
export default defineComponent({
components: {
SharesNavigation,
FilesViewWrapper,
AppBar,
AppLoadingSpinner,
SharedWithMeSection,
FileSideBar,
ItemFilterInline,
ItemFilter
},
setup() {
const { openWithDefaultApp } = useOpenWithDefaultApp()
const configStore = useConfigStore()
const resourcesStore = useResourcesStore()
const {
areResourcesLoading,
sortFields,
fileListHeaderY,
loadResourcesTask,
selectedResources,
selectedResourcesIds,
sideBarActivePanel,
isSideBarOpen,
paginatedResources,
scrollToResourceFromRoute
} = useResourcesViewDefaults<IncomingShareResource, any, any>()
const { $gettext } = useGettext()
const areHiddenFilesShown = ref(false)
const filterTerm = ref('')
const markInstance = ref<Mark>()
const shareSectionTitle = computed(() => {
return unref(areHiddenFilesShown) ? $gettext('Hidden Shares') : $gettext('Shares')
})
const visibilityOptions = computed(() => [
{ name: 'visible', label: $gettext('Shares') },
{ name: 'hidden', label: $gettext('Hidden Shares') }
])
const setAreHiddenFilesShown = (value: InlineFilterOption) => {
areHiddenFilesShown.value = value.name === 'hidden'
resourcesStore.resetSelection()
}
const visibleShares = computed(() => unref(paginatedResources).filter((r) => !r.hidden))
const hiddenShares = computed(() => unref(paginatedResources).filter((r) => r.hidden))
const currentItems = computed(() => {
return unref(areHiddenFilesShown) ? unref(hiddenShares) : unref(visibleShares)
})
const selectedShareTypesQuery = useRouteQuery('q_shareType')
const selectedSharedByQuery = useRouteQuery('q_sharedBy')
const filteredItems = computed(() => {
let result = unref(currentItems)
const selectedShareTypes = queryItemAsString(unref(selectedShareTypesQuery))?.split('+')
if (selectedShareTypes?.length) {
result = result.filter(({ shareTypes }) => {
return selectedShareTypes
.map((t) => ShareTypes[t].value)
.some((t) => shareTypes.includes(t))
})
}
const selectedSharedBy = queryItemAsString(unref(selectedSharedByQuery))?.split('+')
if (selectedSharedBy?.length) {
result = result.filter(({ sharedBy }) =>
sharedBy.some(({ id }) => selectedSharedBy.includes(id))
)
}
if (unref(filterTerm).trim()) {
const usersSearchEngine = new Fuse(result, { ...defaultFuseOptions, keys: ['name'] })
const fuseResult = usersSearchEngine.search(unref(filterTerm)).map((r) => r.item)
result = fuseResult.filter((item) => result.includes(item))
}
return result
})
watch(filteredItems, () => {
if (!unref(areResourcesLoading)) {
if (!unref(markInstance)) {
markInstance.value = new Mark('.oc-resource-details')
}
unref(markInstance).unmark()
unref(markInstance).mark(unref(filterTerm), {
element: 'span',
className: 'mark-highlight'
})
}
})
const { sortBy, sortDir, items, handleSort } = useSort({
items: filteredItems,
fields: sortFields
})
const { getMatchingSpace } = useGetMatchingSpace()
const displayThumbnails = computed(() => configStore.options.disablePreviews)
const selectedShareSpace = computed(() => {
if (unref(selectedResources).length !== 1) {
return null
}
const resource = unref(selectedResources)[0]
return getMatchingSpace(resource)
})
const openWithDefaultAppQuery = useRouteQuery('openWithDefaultApp')
const performLoaderTask = async () => {
await loadResourcesTask.perform()
scrollToResourceFromRoute(unref(items), 'files-app-bar')
if (queryItemAsString(unref(openWithDefaultAppQuery)) === 'true') {
openWithDefaultApp({
space: unref(selectedShareSpace),
resource: unref(selectedResources)[0]
})
}
}
const shareTypes = computed(() => {
const uniqueShareTypes = uniq(unref(paginatedResources).flatMap((i) => i.shareTypes))
return ShareTypes.getByValues(uniqueShareTypes)
})
const fileOwners = computed(() => {
const flatList = unref(paginatedResources)
.map((i) => i.sharedBy)
.flat()
return [...new Map(flatList.map((item) => [item.displayName, item])).values()]
})
onMounted(() => {
performLoaderTask()
})
return {
loadResourcesTask,
areResourcesLoading,
selectedResources,
selectedResourcesIds,
fileListHeaderY,
isSideBarOpen,
sideBarActivePanel,
selectedShareSpace,
areHiddenFilesShown,
visibilityOptions,
displayThumbnails,
hiddenShares,
setAreHiddenFilesShown,
shareSectionTitle,
visibleShares,
shareTypes,
fileOwners,
filterTerm,
handleSort,
sortBy,
sortDir,
items,
// CERN
...useGroupingSettings({ sortBy: sortBy, sortDir: sortDir })
}
}
})
</script>
<style lang="scss" scoped>
.search-filter {
width: 16rem;
}
</style>
| owncloud/web/packages/web-app-files/src/views/shares/SharedWithMe.vue/0 | {
"file_path": "owncloud/web/packages/web-app-files/src/views/shares/SharedWithMe.vue",
"repo_id": "owncloud",
"token_count": 4245
} | 802 |
import { mockDeep } from 'vitest-mock-extended'
import ResourceUpload from 'web-app-files/src/components/AppBar/Upload/ResourceUpload.vue'
import { defaultComponentMocks, defaultPlugins, defaultStubs, mount } from 'web-test-helpers'
import { UppyService } from '@ownclouders/web-pkg'
import { OcButton } from 'design-system/src/components'
describe('Resource Upload Component', () => {
describe('file upload', () => {
it('should render component', () => {
const { wrapper } = getWrapper()
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.html()).toMatchSnapshot()
})
})
describe('folder upload', () => {
it('should render component', () => {
const { wrapper } = getWrapper({ isFolder: true })
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.html()).toMatchSnapshot()
})
})
describe('when upload file button is clicked', () => {
it('should call "triggerUpload"', async () => {
const { wrapper } = getWrapper()
const spyTriggerUpload = vi.spyOn(wrapper.vm, 'triggerUpload')
const uploadButton = wrapper.find('button')
const fileUploadInput = wrapper.find('#files-file-upload-input')
;(fileUploadInput.element as HTMLElement).click = vi.fn()
await wrapper.vm.$forceUpdate()
await uploadButton.trigger('click')
expect(spyTriggerUpload).toHaveBeenCalledTimes(1)
expect((fileUploadInput.element as HTMLElement).click).toHaveBeenCalledTimes(1)
})
})
it('should be disabled when a remote upload is running', () => {
const uppyService = mockDeep<UppyService>()
uppyService.isRemoteUploadInProgress.mockReturnValue(true)
const { wrapper } = getWrapper({ isFolder: true }, uppyService)
expect(wrapper.findComponent<typeof OcButton>('button').props('disabled')).toBeTruthy()
})
})
function getWrapper(props = {}, uppyService = mockDeep<UppyService>()) {
const mocks = {
...defaultComponentMocks(),
$uppyService: uppyService
}
return {
mocks,
wrapper: mount(ResourceUpload, {
props,
global: {
mocks,
stubs: defaultStubs,
provide: mocks,
plugins: [...defaultPlugins()]
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/components/AppBar/Upload/ResourceUpload.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/components/AppBar/Upload/ResourceUpload.spec.ts",
"repo_id": "owncloud",
"token_count": 801
} | 803 |
import { mock } from 'vitest-mock-extended'
import { Resource } from '@ownclouders/web-client'
import { defaultPlugins, mount } from 'web-test-helpers'
import PrivateLinkItem from 'web-app-files/src/components/SideBar/PrivateLinkItem.vue'
import { useMessages } from '@ownclouders/web-pkg'
const folder = mock<Resource>({
type: 'folder',
owner: {
id: 'marie',
displayName: 'Marie'
},
mdate: 'Wed, 21 Oct 2015 07:28:00 GMT',
size: '740',
name: 'lorem.txt',
privateLink: 'https://example.com/fake-private-link'
})
// @vitest-environment jsdom
describe('PrivateLinkItem', () => {
beforeEach(() => {
vi.useFakeTimers()
})
afterEach(() => {
vi.useRealTimers()
})
it('should render a button', () => {
const { wrapper } = getWrapper()
expect(wrapper.html()).toMatchSnapshot()
})
it('upon clicking it should copy the private link to the clipboard button, render a success message and change icon for half a second', async () => {
Object.assign(window.navigator, {
clipboard: {
writeText: vi.fn().mockImplementation(() => Promise.resolve())
}
})
const { wrapper } = getWrapper()
const { showMessage } = useMessages()
expect(showMessage).not.toHaveBeenCalled()
await wrapper.trigger('click')
expect(wrapper.html()).toMatchSnapshot()
expect(window.navigator.clipboard.writeText).toHaveBeenCalledWith(folder.privateLink)
expect(showMessage).toHaveBeenCalledTimes(1)
vi.advanceTimersByTime(550)
wrapper.vm.$nextTick(() => {
expect(wrapper.html()).toMatchSnapshot()
})
})
})
function getWrapper() {
const capabilities = { files: { privateLinks: true } }
return {
wrapper: mount(PrivateLinkItem, {
global: {
plugins: [...defaultPlugins({ piniaOptions: { capabilityState: { capabilities } } })],
provide: {
resource: folder
}
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/components/SideBar/PrivateLinkItem.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/components/SideBar/PrivateLinkItem.spec.ts",
"repo_id": "owncloud",
"token_count": 711
} | 804 |
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`FileShares > collaborators list > renders sharedWithLabel and sharee list 1`] = `
"<div id="oc-files-sharing-sidebar" class="oc-position-relative">
<div class="oc-flex">
<h3 class="oc-text-bold oc-text-medium oc-m-rm" data-msgid="Share with people" data-current-language="en">Share with people</h3>
<oc-contextual-helper-stub title="Share with people" text="Use the input field to search for users and groups. Select them to share the item." list="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]" endtext="" readmorelink="https://doc.owncloud.com/go?to=webui-users-sharing" class="oc-pl-xs"></oc-contextual-helper-stub>
</div>
<invite-collaborator-form-stub savebuttonlabel="Share" invitelabel="" class="oc-my-s"></invite-collaborator-form-stub>
<div class="avatars-wrapper oc-flex oc-flex-middle oc-flex-between">
<h4 class="oc-text-bold oc-my-rm">Shared with</h4>
</div>
<portal-target name="app.files.sidebar.sharing.shared-with.top" slot-props="[object Object]" multiple="true"></portal-target>
<ul id="files-collaborators-list" class="oc-list oc-list-divider oc-overflow-hidden oc-m-rm" aria-label="Share receivers">
<li>
<collaborator-list-item-stub share="[object Object]" issharedenied="false" modifiable="true" resourcename="[Function]" deniable="false" islocked="[Function]"></collaborator-list-item-stub>
</li>
<li>
<collaborator-list-item-stub share="[object Object]" issharedenied="false" modifiable="true" resourcename="[Function]" deniable="false" islocked="[Function]"></collaborator-list-item-stub>
</li>
<li>
<collaborator-list-item-stub share="[object Object]" issharedenied="false" modifiable="true" resourcename="[Function]" deniable="false" islocked="[Function]"></collaborator-list-item-stub>
</li>
<li>
<collaborator-list-item-stub share="[object Object]" issharedenied="false" modifiable="true" resourcename="[Function]" deniable="false" islocked="[Function]"></collaborator-list-item-stub>
</li>
<portal-target name="app.files.sidebar.sharing.shared-with.bottom" slot-props="[object Object]" multiple="true"></portal-target>
</ul>
<div class="oc-flex oc-flex-center"><button type="button" class="oc-button oc-rounded oc-button-m oc-button-justify-content-center oc-button-gap-m oc-button-passive oc-button-passive-raw toggle-shares-list-btn">
<!--v-if-->
<!-- @slot Content of the button --> Show less
</button></div>
<!--v-if-->
</div>"
`;
exports[`FileShares > current space > loads space members if a space is given and the current user is member 1`] = `
"<div id="oc-files-sharing-sidebar" class="oc-position-relative">
<div class="oc-flex">
<h3 class="oc-text-bold oc-text-medium oc-m-rm" data-msgid="Share with people" data-current-language="en">Share with people</h3>
<oc-contextual-helper-stub title="Share with people" text="Use the input field to search for users and groups. Select them to share the item." list="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]" endtext="" readmorelink="https://doc.owncloud.com/go?to=webui-users-sharing" class="oc-pl-xs"></oc-contextual-helper-stub>
</div>
<invite-collaborator-form-stub savebuttonlabel="Share" invitelabel="" class="oc-my-s"></invite-collaborator-form-stub>
<div class="avatars-wrapper oc-flex oc-flex-middle oc-flex-between">
<h4 class="oc-text-bold oc-my-rm">Shared with</h4>
</div>
<portal-target name="app.files.sidebar.sharing.shared-with.top" slot-props="[object Object]" multiple="true"></portal-target>
<ul id="files-collaborators-list" class="oc-list oc-list-divider oc-overflow-hidden oc-mb-l" aria-label="Share receivers">
<li>
<collaborator-list-item-stub share="[object Object]" issharedenied="false" modifiable="false" resourcename="[Function]" deniable="false" islocked="[Function]"></collaborator-list-item-stub>
</li>
<portal-target name="app.files.sidebar.sharing.shared-with.bottom" slot-props="[object Object]" multiple="true"></portal-target>
</ul>
<!--v-if-->
<h4 class="oc-text-bold oc-my-s">Space members</h4>
<ul id="space-collaborators-list" class="oc-list oc-list-divider oc-overflow-hidden oc-m-rm" aria-label="Space members">
<li>
<collaborator-list-item-stub share="[object Object]" issharedenied="false" modifiable="false" resourcename="[Function]" deniable="false" islocked="false"></collaborator-list-item-stub>
</li>
<li>
<collaborator-list-item-stub share="[object Object]" issharedenied="false" modifiable="false" resourcename="[Function]" deniable="false" islocked="false"></collaborator-list-item-stub>
</li>
</ul>
<!--v-if-->
</div>"
`;
| owncloud/web/packages/web-app-files/tests/unit/components/SideBar/Shares/__snapshots__/FileShares.spec.ts.snap/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/components/SideBar/Shares/__snapshots__/FileShares.spec.ts.snap",
"repo_id": "owncloud",
"token_count": 1765
} | 805 |
import SharedViaLink from '../../../../src/views/shares/SharedViaLink.vue'
import { useResourcesViewDefaults } from 'web-app-files/src/composables'
import { useResourcesViewDefaultsMock } from 'web-app-files/tests/mocks/useResourcesViewDefaultsMock'
import { ref } from 'vue'
import { mock, mockDeep } from 'vitest-mock-extended'
import { Resource } from '@ownclouders/web-client'
import {
defaultPlugins,
mount,
defaultComponentMocks,
defaultStubs,
RouteLocation
} from 'web-test-helpers'
import { ResourceTable } from '@ownclouders/web-pkg'
vi.mock('web-app-files/src/composables')
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
useFileActions: vi.fn()
}))
describe('SharedViaLink 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({ loading: true })
expect(wrapper.find('oc-spinner-stub').exists()).toBeTruthy()
})
it('shows the no-content-message after loading', () => {
const { wrapper } = getMountedWrapper()
expect(wrapper.find('oc-spinner-stub').exists()).toBeFalsy()
expect(wrapper.find('.no-content-message').exists()).toBeTruthy()
})
it('shows the files table when files are available', () => {
const mockedFiles = [mockDeep<Resource>(), mockDeep<Resource>()]
const { wrapper } = getMountedWrapper({ files: mockedFiles })
expect(wrapper.find('.no-content-message').exists()).toBeFalsy()
expect(wrapper.find('resource-table-stub').exists()).toBeTruthy()
expect(
wrapper.findComponent<typeof ResourceTable>('resource-table-stub').props().resources.length
).toEqual(mockedFiles.length)
})
})
})
function getMountedWrapper({ mocks = {}, files = [], loading = false } = {}) {
vi.mocked(useResourcesViewDefaults).mockImplementation(() =>
useResourcesViewDefaultsMock({
paginatedResources: ref(files),
areResourcesLoading: ref(loading)
})
)
const defaultMocks = {
...defaultComponentMocks({
currentRoute: mock<RouteLocation>({ name: 'files-shares-via-link' })
}),
...(mocks && mocks)
}
return {
mocks: defaultMocks,
wrapper: mount(SharedViaLink, {
global: {
plugins: [...defaultPlugins()],
mocks: defaultMocks,
provide: defaultMocks,
stubs: defaultStubs
}
})
}
}
| owncloud/web/packages/web-app-files/tests/unit/views/shares/SharedViaLink.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-files/tests/unit/views/shares/SharedViaLink.spec.ts",
"repo_id": "owncloud",
"token_count": 1029
} | 806 |
import { defaultComponentMocks, getComposableWrapper, RouteLocation } from 'web-test-helpers'
import { unref } from 'vue'
import { Resource } from '@ownclouders/web-client'
import { mock, mockDeep } from 'vitest-mock-extended'
import { extensions } from '../../src/extensions'
import { ApplicationSetupOptions, UppyService } from '@ownclouders/web-pkg'
const getAction = (opts: ApplicationSetupOptions) => {
const { action } = unref(extensions(opts))[0]
return action
}
describe('useFileActionsImport', () => {
describe('isVisible', () => {
it('is false when no companion url is given', () => {
getWrapper({
currentFolder: mock<Resource>({ canUpload: () => true }),
setup: () => {
const action = unref(extensions({ applicationConfig: {} }))[0].action
expect(action.isVisible()).toBeFalsy()
}
})
})
it('is false on public link pages', () => {
getWrapper({
routeName: 'files-public-link',
setup: () => {
const action = getAction({
applicationConfig: {
companionUrl: 'companionUrl'
}
})
expect(action.isVisible()).toBeFalsy()
}
})
})
it('is false when no write access is given', () => {
getWrapper({
currentFolder: mock<Resource>({ canUpload: () => false }),
setup: () => {
const action = getAction({
applicationConfig: {
companionUrl: 'companionUrl'
}
})
expect(action.isVisible()).toBeFalsy()
}
})
})
it('is false when no supported clouds are given', () => {
getWrapper({
currentFolder: mock<Resource>({ canUpload: () => true }),
setup: () => {
const action = unref(
extensions({
applicationConfig: {
companionUrl: 'companionUrl',
supportedClouds: []
}
})
)[0].action
expect(action.isVisible()).toBeFalsy()
}
})
})
it('is true on generic space view when write access is given', () => {
getWrapper({
currentFolder: mock<Resource>({ canUpload: () => true }),
setup: () => {
const action = getAction({
applicationConfig: {
companionUrl: 'companionUrl'
}
})
expect(action.isVisible()).toBeTruthy()
}
})
})
})
describe('isDisabled', () => {
it('is true when uploads are running', () => {
const uppyService = mockDeep<UppyService>()
uppyService.getCurrentUploads.mockReturnValue({ id: '1' })
getWrapper({
uppyService,
setup: () => {
const action = getAction({ applicationConfig: { companionUrl: 'companionUrl' } })
expect(action.isDisabled()).toBeTruthy()
}
})
})
it('is false when no uploads are running', () => {
const uppyService = mockDeep<UppyService>()
uppyService.getCurrentUploads.mockReturnValue({})
getWrapper({
uppyService,
setup: () => {
const action = getAction({ applicationConfig: { companionUrl: 'companionUrl' } })
expect(action.isDisabled()).toBeFalsy()
}
})
})
})
describe('handler', () => {
it.each([
{ supportedClouds: undefined, calls: 4 },
{ supportedClouds: ['OneDrive'], calls: 2 },
{ supportedClouds: ['GoogleDrive'], calls: 2 },
{ supportedClouds: ['WebdavPublicLink'], calls: 2 }
])('should only add supported clouds as uppy plugin', ({ supportedClouds, calls }) => {
const uppyService = mockDeep<UppyService>()
getWrapper({
uppyService,
setup: async () => {
const action = getAction({
applicationConfig: { companionUrl: 'companionUrl', supportedClouds }
})
await action.handler()
expect(uppyService.addPlugin).toHaveBeenCalledTimes(calls)
}
})
})
})
})
function getWrapper({
routeName = 'files-spaces-generic',
currentFolder = mock<Resource>(),
uppyService = mockDeep<UppyService>(),
setup = () => undefined
} = {}) {
const mocks = {
...defaultComponentMocks({ currentRoute: mock<RouteLocation>({ name: routeName }) }),
$uppyService: uppyService
}
return {
wrapper: getComposableWrapper(setup, {
mocks,
provide: mocks,
pluginOptions: { piniaOptions: { resourcesStore: { currentFolder } } }
})
}
}
| owncloud/web/packages/web-app-importer/tests/unit/extensions.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-app-importer/tests/unit/extensions.spec.ts",
"repo_id": "owncloud",
"token_count": 1965
} | 807 |
import translations from '../l10n/translations.json'
import { AppWrapperRoute } from '@ownclouders/web-pkg'
import PdfViewer from './App.vue'
// just a dummy function to trick gettext tools
function $gettext(msg) {
return msg
}
const routes = [
{
path: '/:driveAliasAndItem(.*)?',
component: AppWrapperRoute(PdfViewer, {
applicationId: 'pdf-viewer',
urlForResourceOptions: {
disposition: 'inline'
}
}),
name: 'pdf-viewer',
meta: {
authContext: 'hybrid',
title: $gettext('PDF Viewer'),
patchCleanPath: true
}
}
]
const appInfo = {
name: $gettext('PDF Viewer'),
id: 'pdf-viewer',
icon: 'resource-type-pdf',
iconFillType: 'fill',
iconColor: 'var(--oc-color-icon-pdf)',
extensions: [
{
extension: 'pdf',
routeName: 'pdf-viewer'
}
]
}
export default {
appInfo,
routes,
translations
}
| owncloud/web/packages/web-app-pdf-viewer/src/index.ts/0 | {
"file_path": "owncloud/web/packages/web-app-pdf-viewer/src/index.ts",
"repo_id": "owncloud",
"token_count": 371
} | 808 |
{
"name": "web-app-search",
"version": "0.0.0",
"private": true,
"description": "ownCloud web search",
"license": "AGPL-3.0",
"devDependencies": {
"web-test-helpers": "workspace:*"
},
"dependencies": {
"mark.js": "^8.11.1"
},
"peerDependencies": {
"@ownclouders/web-client": "workspace:*",
"@ownclouders/web-pkg": "workspace:*",
"lodash-es": "^4.17.21",
"pinia": "2.1.7",
"vue3-gettext": "2.4.0",
"web-app-files": "workspace:*"
}
}
| owncloud/web/packages/web-app-search/package.json/0 | {
"file_path": "owncloud/web/packages/web-app-search/package.json",
"repo_id": "owncloud",
"token_count": 236
} | 809 |
[main]
host = https://www.transifex.com
[o:owncloud-org:p:owncloud-web:r:webfinger]
file_filter = locale/<lang>/LC_MESSAGES/app.po
minimum_perc = 0
source_file = template.pot
source_lang = en
type = PO
| owncloud/web/packages/web-app-webfinger/l10n/.tx/config/0 | {
"file_path": "owncloud/web/packages/web-app-webfinger/l10n/.tx/config",
"repo_id": "owncloud",
"token_count": 84
} | 810 |
6.5.0-SNAPSHOT | owncloud/web/packages/web-client/src/generated/.openapi-generator/VERSION/0 | {
"file_path": "owncloud/web/packages/web-client/src/generated/.openapi-generator/VERSION",
"repo_id": "owncloud",
"token_count": 10
} | 811 |
/** @deprecated */
export abstract class SharePermissionBit {
static readonly Internal: number = 0
static readonly Read: number = 1
static readonly Update: number = 2
static readonly Create: number = 4
static readonly Delete: number = 8
static readonly Share: number = 16
}
// map human readable role names to graph share role ids
export const GraphShareRoleIdMap = {
Viewer: 'b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5',
SpaceViewer: 'a8d5fe5e-96e3-418d-825b-534dbdf22b99',
FileEditor: '2d00ce52-1fc2-4dbc-8b95-a73b73395f5a',
FolderEditor: 'fb6c3e19-e378-47e5-b277-9732f9de6e21',
SpaceEditor: '58c63c02-1d89-4572-916a-870abc5a1b7d',
SpaceManager: '312c0871-5ef7-4b3a-85b6-0e4074c64049'
} as const
| owncloud/web/packages/web-client/src/helpers/share/constants.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/helpers/share/constants.ts",
"repo_id": "owncloud",
"token_count": 304
} | 812 |
import { fetchEventSource, FetchEventSourceInit } from '@microsoft/fetch-event-source'
export enum MESSAGE_TYPE {
NOTIFICATION = 'userlog-notification',
POSTPROCESSING_FINISHED = 'postprocessing-finished',
FILE_LOCKED = 'file-locked',
FILE_UNLOCKED = 'file-unlocked',
ITEM_RENAMED = 'item-renamed',
ITEM_TRASHED = 'item-trashed',
ITEM_RESTORED = 'item-restored'
}
export class RetriableError extends Error {
name = 'RetriableError'
}
const RECONNECT_RANDOM_OFFSET = 15000
export class SSEAdapter implements EventSource {
url: string
fetchOptions: FetchEventSourceInit
private abortController: AbortController
private eventListenerMap: Record<string, ((event: MessageEvent) => any)[]>
readyState: number
readonly withCredentials: boolean
readonly CONNECTING: 0
readonly OPEN: 1
readonly CLOSED: 2
onerror: ((this: EventSource, ev: Event) => any) | null
onmessage: ((this: EventSource, ev: MessageEvent) => any) | null
onopen: ((this: EventSource, ev: Event) => any) | null
constructor(url: string, fetchOptions: FetchEventSourceInit) {
this.url = url
this.fetchOptions = fetchOptions
this.abortController = new AbortController()
this.eventListenerMap = {}
this.readyState = this.CONNECTING
this.connect()
}
private connect() {
return fetchEventSource(this.url, {
openWhenHidden: true,
signal: this.abortController.signal,
fetch: this.fetchProvider.bind(this),
// eslint-disable-next-line require-await
onopen: async () => {
const event = new Event('open')
this.onopen?.bind(this)(event)
this.readyState = this.OPEN
},
onmessage: (msg) => {
const event = new MessageEvent('message', { data: msg.data })
this.onmessage?.bind(this)(event)
const type = msg.event
const eventListeners = this.eventListenerMap[type]
eventListeners?.forEach((l) => l(event))
},
onclose: () => {
this.readyState = this.CLOSED
throw new RetriableError()
},
onerror: (err) => {
console.error(err)
const event = new CustomEvent('error', { detail: err })
this.onerror?.bind(this)(event)
/*
* Try to reconnect after 30 seconds plus random time in seconds.
* This prevents all clients try to reconnect concurrent on server error, to reduce load.
*/
return 30000 + Math.floor(Math.random() * RECONNECT_RANDOM_OFFSET)
}
})
}
fetchProvider(...args) {
const [resource, config] = args
const fetchConfig = { ...config, ...this.fetchOptions }
return window.fetch(resource, fetchConfig)
}
close() {
this.abortController.abort('closed')
}
addEventListener(type: string, listener: (this: EventSource, event: MessageEvent) => any): void {
this.eventListenerMap[type] = this.eventListenerMap[type] || []
this.eventListenerMap[type].push(listener)
}
removeEventListener(
type: string,
listener: (this: EventSource, event: MessageEvent) => any
): void {
this.eventListenerMap[type] = this.eventListenerMap[type]?.filter((func) => func !== listener)
}
dispatchEvent(): boolean {
throw new Error('Method not implemented.')
}
updateAccessToken(token: string) {
this.fetchOptions.headers['Authorization'] = `Bearer ${token}`
}
updateLanguage(language: string) {
this.fetchOptions.headers['Accept-Language'] = language
// Force reconnect, to make the language change effect instantly
this.close()
this.connect()
}
}
let eventSource: SSEAdapter = null
export const sse = (baseURI: string, fetchOptions: FetchEventSourceInit): EventSource => {
if (!eventSource) {
eventSource = new SSEAdapter(
new URL('ocs/v2.php/apps/notifications/api/v1/notifications/sse', baseURI).href,
fetchOptions
)
}
return eventSource
}
| owncloud/web/packages/web-client/src/sse.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/sse.ts",
"repo_id": "owncloud",
"token_count": 1414
} | 813 |
import { unref } from 'vue'
import { Resource, SpaceResource } from '../helpers'
import { urlJoin } from '../utils'
import { GetFileContentsFactory } from './getFileContents'
import { WebDavOptions } from './types'
import { DAV } from './client'
export const GetFileUrlFactory = (
dav: DAV,
getFileContentsFactory: ReturnType<typeof GetFileContentsFactory>,
{ capabilities, clientService, user }: WebDavOptions
) => {
return {
async getFileUrl(
space: SpaceResource,
resource: Resource,
{
disposition = 'attachment',
signUrlTimeout = 86400,
version = null,
doHeadRequest = false
}: {
disposition?: 'inline' | 'attachment'
signUrlTimeout?: number
version?: string
doHeadRequest?: boolean
}
): Promise<string> {
const inlineDisposition = disposition === 'inline'
const isUrlSigningEnabled = unref(capabilities)?.core['support-url-signing'] === true
const { path } = resource
let { downloadURL } = resource
let signed = true
if (!downloadURL && !inlineDisposition) {
// compute unsigned url
const webDavPath = space ? urlJoin(space.webDavPath, path) : resource.webDavPath
downloadURL = version
? dav.getFileUrl(urlJoin('meta', resource.fileId, 'v', version))
: dav.getFileUrl(webDavPath)
if (unref(user) && doHeadRequest) {
await clientService.httpAuthenticated.head(downloadURL)
}
// sign url
if (isUrlSigningEnabled && unref(user)) {
downloadURL = await clientService.ocsUserContext.signUrl(downloadURL, signUrlTimeout)
} else {
signed = false
}
}
// FIXME: re-introduce query parameters
// They are not supported by getFileContents() and as we don't need them right now, I'm disabling the feature completely for now
//
// // Since the pre-signed url contains query parameters and the caller of this method
// // can also provide query parameters we have to combine them.
// const queryStr = qs.stringify(options.query || null)
// const [url, signedQuery] = downloadURL.split('?')
// const combinedQuery = [queryStr, signedQuery].filter(Boolean).join('&')
// downloadURL = [url, combinedQuery].filter(Boolean).join('?')
if (!signed || inlineDisposition) {
const response = await getFileContentsFactory.getFileContents(space, resource, {
responseType: 'blob'
})
downloadURL = URL.createObjectURL(response.body)
}
return downloadURL
},
revokeUrl: (url: string) => {
if (url && url.startsWith('blob:')) {
URL.revokeObjectURL(url)
}
}
}
}
| owncloud/web/packages/web-client/src/webdav/getFileUrl.ts/0 | {
"file_path": "owncloud/web/packages/web-client/src/webdav/getFileUrl.ts",
"repo_id": "owncloud",
"token_count": 1050
} | 814 |
import { SharePermission, SharePermissions } from '../../../../src/helpers/share'
describe('SharePermission', () => {
describe('enabled', () => {
it.each([
[
'true if bitmask contains bit',
{
bit: 4,
bitmask: 7,
result: true
}
],
[
'false if bitmask lacks bit',
{
bit: 4,
bitmask: 11,
result: false
}
]
])('returns %s', (name: string, { bit, bitmask, result }) => {
const p = new SharePermission('', bit, '')
expect(p.enabled(bitmask)).toBe(result)
})
})
})
describe('SharePermissions', () => {
describe('permissionsToBitmask', () => {
it.each([
[
'empty permissions',
{
permissions: [],
bitmask: 0
}
],
[
'single permission',
{
permissions: [SharePermissions.read],
bitmask: SharePermissions.read.bit
}
],
[
'duplicated permission does not duplicate bitmask',
{
permissions: [SharePermissions.read, SharePermissions.read],
bitmask: SharePermissions.read.bit
}
],
[
'multiple permissions add up in bitmask',
{
permissions: [SharePermissions.read, SharePermissions.create],
bitmask: SharePermissions.read.bit + SharePermissions.create.bit
}
]
])('%s', (name, { permissions, bitmask }) => {
expect(SharePermissions.permissionsToBitmask(permissions)).toBe(bitmask)
})
})
describe('bitmaskToPermissions', () => {
it.each([
[
'bitmask 0 results in empty permission list',
{
bitmask: 0,
permissions: []
}
],
[
'bitmask 1 results in permission list with read permission',
{
bitmask: SharePermissions.read.bit,
permissions: [SharePermissions.read]
}
],
[
'bitmask 9 results in permission list with read and delete permission',
{
bitmask: SharePermissions.read.bit + SharePermissions.delete.bit,
permissions: [SharePermissions.read, SharePermissions.delete]
}
]
])('%s', (name, { bitmask, permissions }) => {
expect(
SharePermissions.bitmaskToPermissions(bitmask)
.map((p) => p.key)
.sort()
).toEqual(permissions.map((p) => p.key).sort())
})
})
})
| owncloud/web/packages/web-client/tests/unit/helpers/share/permission.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-client/tests/unit/helpers/share/permission.spec.ts",
"repo_id": "owncloud",
"token_count": 1168
} | 815 |
import { computed, Ref, unref } from 'vue'
export const useGroupingSettings = ({
sortBy,
sortDir
}: {
sortBy: Ref<string>
sortDir: Ref<string>
}) => {
const groupingSettings = computed(() => {
return {
groupingBy: localStorage.getItem('grouping-shared-with-me') || 'Shared on',
showGroupingOptions: true,
groupingFunctions: {
'Name alphabetically': function (row) {
localStorage.setItem('grouping-shared-with-me', 'Name alphabetically')
if (!isNaN(row.name.charAt(0))) {
return '#'
}
if (row.name.charAt(0) === '.') {
return row.name.charAt(1).toLowerCase()
}
return row.name.charAt(0).toLowerCase()
},
'Shared on': function (row) {
localStorage.setItem('grouping-shared-with-me', 'Shared on')
const recently = Date.now() - 604800000
const lastMonth = Date.now() - 2592000000
if (Date.parse(row.sdate) < lastMonth) {
return 'Older'
}
if (Date.parse(row.sdate) >= recently) {
return 'Recently'
} else {
return 'Last month'
}
},
'Share owner': function (row) {
localStorage.setItem('grouping-shared-with-me', 'Share owner')
return row.share?.owner?.displayName
},
None: function () {
localStorage.setItem('grouping-shared-with-me', 'None')
}
},
sortGroups: {
'Name alphabetically': function (groups) {
// sort in alphabetical order by group name
const sortedGroups = groups.sort(function (a, b) {
if (a.name < b.name) {
return -1
}
if (a.name > b.name) {
return 1
}
return 0
})
// if sorting is done by name, reverse groups depending on asc/desc
if (unref(sortBy) === 'name' && unref(sortDir) === 'desc') {
sortedGroups.reverse()
}
return sortedGroups
},
'Shared on': function (groups) {
// sort in order: 1-Recently, 2-Last month, 3-Older
const sortedGroups = []
const options = ['Recently', 'Last month', 'Older']
for (const o of options) {
const found = groups.find((el) => el.name.toLowerCase() === o.toLowerCase())
if (found) {
sortedGroups.push(found)
}
}
// if sorting is done by sdate, reverse groups depending on asc/desc
if (unref(sortBy) === 'sdate' && unref(sortDir) === 'asc') {
sortedGroups.reverse()
}
return sortedGroups
},
'Share owner': function (groups) {
// sort in alphabetical order by group name
const sortedGroups = groups.sort(function (a, b) {
if (a.name < b.name) {
return -1
}
if (a.name > b.name) {
return 1
}
return 0
})
// if sorting is done by owner, reverse groups depending on asc/desc
if (unref(sortBy) === 'owner' && unref(sortDir) === 'desc') {
sortedGroups.reverse()
}
return sortedGroups
}
}
}
})
return {
groupingSettings
}
}
| owncloud/web/packages/web-pkg/src/cern/composables/useGroupingSettings.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/cern/composables/useGroupingSettings.ts",
"repo_id": "owncloud",
"token_count": 1661
} | 816 |
<template>
<div id="oc-files-context-menu">
<oc-list
v-for="(section, sectionIndex) in menuSections"
:id="`oc-files-context-actions-${section.name}`"
:key="`section-${section.name}-list`"
class="oc-files-context-actions"
:class="getSectionClasses(sectionIndex)"
>
<action-menu-item
v-for="(action, actionIndex) in section.items"
:key="`section-${section.name}-action-${actionIndex}`"
:action="action"
:appearance="appearance"
:variation="variation"
:action-options="actionOptions"
class="context-menu oc-files-context-action oc-px-s oc-rounded oc-menu-item-hover"
/>
</oc-list>
</div>
</template>
<script lang="ts">
import { defineComponent, PropType } from 'vue'
import ActionMenuItem from './ActionMenuItem.vue'
import { Action, ActionOptions } from '../../composables/actions'
type MenuSection = {
name: string
items: Action[]
}
export default defineComponent({
name: 'ContextActionMenu',
components: { ActionMenuItem },
props: {
menuSections: {
type: Array as PropType<MenuSection[]>,
required: true
},
appearance: {
type: String,
default: 'raw'
},
variation: {
type: String,
default: 'passive'
},
actionOptions: {
type: Object as PropType<ActionOptions>,
required: true
}
},
methods: {
getSectionClasses(index) {
const classes = []
if (!this.menuSections.length) {
return classes
}
if (index < this.menuSections.length - 1) {
classes.push('oc-pb-s')
}
if (index > 0) {
classes.push('oc-pt-s')
}
if (index < this.menuSections.length - 1) {
classes.push('oc-files-context-actions-border')
}
return classes
}
}
})
</script>
<style lang="scss">
.oc-files-context-actions {
text-align: left;
white-space: normal;
> li {
padding-left: 0 !important;
padding-right: 0 !important;
a,
button,
span {
display: inline-flex;
font-weight: normal !important;
gap: 10px;
justify-content: flex-start;
vertical-align: top;
width: 100%;
text-align: left;
}
}
&-border {
border-bottom: 1px solid var(--oc-color-border);
}
}
</style>
| owncloud/web/packages/web-pkg/src/components/ContextActions/ContextActionMenu.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/ContextActions/ContextActionMenu.vue",
"repo_id": "owncloud",
"token_count": 1003
} | 817 |
<template>
<div>
<div class="item-inline-filter oc-flex-inline" :class="`item-inline-filter-${filterName}`">
<oc-button
v-for="(option, index) in filterOptions"
:id="option.name"
:key="index"
class="item-inline-filter-option"
:class="{ 'item-inline-filter-option-selected': activeOption === option.name }"
appearance="raw"
@click="toggleFilter(option)"
>
<span class="oc-text-truncate item-inline-filter-option-label" v-text="option.label" />
</oc-button>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref, unref } from 'vue'
import omit from 'lodash-es/omit'
import { useRoute, useRouteQuery, useRouter, queryItemAsString } from '../../composables'
import { PropType } from 'vue'
import { InlineFilterOption } from './types'
export default defineComponent({
name: 'ItemFilterInline',
props: {
filterName: {
type: String,
required: true
},
filterOptions: {
type: Array as PropType<InlineFilterOption[]>,
required: true
}
},
emits: ['toggleFilter'],
setup: function (props, { emit }) {
const router = useRouter()
const currentRoute = useRoute()
const activeOption = ref<string>(props.filterOptions[0].name)
const queryParam = `q_${props.filterName}`
const currentRouteQuery = useRouteQuery(queryParam)
const setRouteQuery = (optionName: string) => {
return router.push({
query: {
...omit(unref(currentRoute).query, [queryParam]),
[queryParam]: optionName
}
})
}
const toggleFilter = async (option: InlineFilterOption) => {
activeOption.value = option.name
await setRouteQuery(option.name)
emit('toggleFilter', option)
}
onMounted(() => {
const queryStr = queryItemAsString(unref(currentRouteQuery))
if (queryStr && props.filterOptions.some(({ name }) => name === queryStr)) {
activeOption.value = queryStr
emit(
'toggleFilter',
props.filterOptions.find(({ name }) => name === queryStr)
)
}
})
return {
queryParam,
activeOption,
toggleFilter
}
}
})
</script>
<style lang="scss">
.item-inline-filter {
border-radius: 99px;
border: 1px solid var(--oc-color-text-muted);
button {
text-decoration: none;
font-size: var(--oc-font-size-xsmall);
line-height: 1rem;
height: 24px;
padding: var(--oc-space-xsmall) var(--oc-space-small) !important;
}
button:first-child {
border-top-left-radius: 99px !important;
border-bottom-left-radius: 99px !important;
border-top-right-radius: 0px !important;
border-bottom-right-radius: 0px !important;
}
button:last-child {
border-top-left-radius: 0px !important;
border-bottom-left-radius: 0px !important;
border-top-right-radius: 99px !important;
border-bottom-right-radius: 99px !important;
}
&-option-selected {
background-color: var(--oc-color-swatch-primary-default) !important;
color: var(--oc-color-text-inverse) !important;
}
}
</style>
| owncloud/web/packages/web-pkg/src/components/Filters/ItemFilterInline.vue/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/Filters/ItemFilterInline.vue",
"repo_id": "owncloud",
"token_count": 1257
} | 818 |
export { default as ResourcePreview } from './ResourcePreview.vue'
export * from './types'
| owncloud/web/packages/web-pkg/src/components/Search/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/Search/index.ts",
"repo_id": "owncloud",
"token_count": 25
} | 819 |
import { defineComponent } from 'vue'
import { IconFillType } from '../../helpers/resource'
import { Item } from '@ownclouders/web-client/src/helpers'
export interface SideBarPanelContext<R extends Item, P extends Item, T extends Item> {
root?: R
parent?: P
items?: T[]
}
export interface SideBarPanel<R extends Item, P extends Item, T extends Item> {
name: string
icon: string
iconFillType?: IconFillType
title(context: SideBarPanelContext<R, P, T>): string
isVisible(context: SideBarPanelContext<R, P, T>): boolean
component: ReturnType<typeof defineComponent>
componentAttrs?(context: SideBarPanelContext<R, P, T>): any
/**
* defines if the panel is a `root` level panel in the right sidebar.
* In the long run this should be configured by admins or even users, as it's ideally not to be decided by extension developer.
*/
isRoot?(context: SideBarPanelContext<R, P, T>): boolean
}
| owncloud/web/packages/web-pkg/src/components/SideBar/types.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/components/SideBar/types.ts",
"repo_id": "owncloud",
"token_count": 282
} | 820 |
import { computed, unref } from 'vue'
import { FileAction, useModals, useResourcesStore } from '../../../composables'
import { CreateShortcutModal } from '../../../components'
import { useGettext } from 'vue3-gettext'
import { storeToRefs } from 'pinia'
import { SpaceResource } from '@ownclouders/web-client'
export const useFileActionsCreateNewShortcut = ({ space }: { space: SpaceResource }) => {
const { dispatchModal } = useModals()
const { $gettext } = useGettext()
const resourcesStore = useResourcesStore()
const { currentFolder } = storeToRefs(resourcesStore)
const actions = computed((): FileAction[] => {
return [
{
name: 'create-shortcut',
icon: 'external-link',
handler: () => {
dispatchModal({
title: $gettext('Create a Shortcut'),
confirmText: $gettext('Create'),
customComponent: CreateShortcutModal,
customComponentAttrs: () => ({ space })
})
},
label: () => {
return $gettext('New Shortcut')
},
isVisible: () => {
return unref(currentFolder)?.canCreate()
},
componentType: 'button',
class: 'oc-files-actions-create-new-shortcut'
}
]
})
return {
actions
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsCreateNewShortcut.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsCreateNewShortcut.ts",
"repo_id": "owncloud",
"token_count": 520
} | 821 |
import { computed, unref } from 'vue'
import { useGettext } from 'vue3-gettext'
import { useClientService } from '../../clientService'
import { useRouter } from '../../router'
import { FileAction, FileActionOptions } from '../types'
import { Drive } from '@ownclouders/web-client/src/generated'
import { buildSpace } from '@ownclouders/web-client/src/helpers'
import { useMessages, useSpacesStore, useUserStore } from '../../piniaStores'
export const useFileActionsSetReadme = () => {
const { showMessage, showErrorMessage } = useMessages()
const userStore = useUserStore()
const router = useRouter()
const { $gettext } = useGettext()
const clientService = useClientService()
const spacesStore = useSpacesStore()
const handler = async ({ space, resources }: FileActionOptions) => {
try {
const { graphAuthenticated, webdav } = clientService
const fileContent = (await webdav.getFileContents(space, { path: resources[0].path })).body
try {
await webdav.getFileInfo(space, { path: '.space' })
} catch (_) {
await webdav.createFolder(space, { path: '.space' })
}
await webdav.putFileContents(space, {
path: `/.space/readme.md`,
content: fileContent
})
const file = await webdav.getFileInfo(space, { path: '.space/readme.md' })
const { data: updatedDriveData } = await graphAuthenticated.drives.updateDrive(
space.id as string,
{
special: [
{
specialFolder: {
name: 'readme'
},
id: file.id
}
]
} as Drive,
{}
)
spacesStore.updateSpaceField({
id: space.id,
field: 'spaceReadmeData',
value: buildSpace(updatedDriveData).spaceReadmeData
})
showMessage({ title: $gettext('Space description was set successfully') })
} catch (error) {
console.error(error)
showErrorMessage({
title: $gettext('Failed to set space description'),
errors: [error]
})
}
}
const actions = computed((): FileAction[] => [
{
name: 'set-space-readme',
icon: 'markdown',
handler,
label: () => {
return $gettext('Set as space description')
},
isVisible: ({ space, resources }) => {
if (resources.length !== 1) {
return false
}
if (!resources[0].mimeType?.startsWith('text/')) {
return false
}
if (unref(router.currentRoute).name !== 'files-spaces-generic') {
return false
}
if (!space) {
return false
}
return space.canEditReadme({ user: userStore.user })
},
componentType: 'button',
class: 'oc-files-actions-set-space-readme-trigger'
}
])
return {
actions
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsSetReadme.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/files/useFileActionsSetReadme.ts",
"repo_id": "owncloud",
"token_count": 1209
} | 822 |
import { SpaceAction, SpaceActionOptions } from '../types'
import { computed } from 'vue'
import { useGettext } from 'vue3-gettext'
import { useOpenWithDefaultApp } from '../useOpenWithDefaultApp'
import { getRelativeSpecialFolderSpacePath } from '@ownclouders/web-client/src/helpers'
import { useClientService } from '../../clientService'
import { useUserStore } from '../../piniaStores'
export const useSpaceActionsEditReadmeContent = () => {
const clientService = useClientService()
const { openWithDefaultApp } = useOpenWithDefaultApp()
const userStore = useUserStore()
const { $gettext } = useGettext()
const handler = async ({ resources }: SpaceActionOptions) => {
const markdownResource = await clientService.webdav.getFileInfo(resources[0], {
path: getRelativeSpecialFolderSpacePath(resources[0], 'readme')
})
openWithDefaultApp({ space: resources[0], resource: markdownResource })
}
const actions = computed((): SpaceAction[] => [
{
name: 'editReadmeContent',
icon: 'article',
label: () => {
return $gettext('Edit description')
},
handler,
isVisible: ({ resources }) => {
if (resources.length !== 1) {
return false
}
if (!resources[0].canEditReadme({ user: userStore.user })) {
return false
}
return !!resources[0].spaceReadmeData
},
componentType: 'button',
class: 'oc-files-actions-edit-readme-content-trigger'
}
])
return {
actions
}
}
| owncloud/web/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsEditReadmeContent.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsEditReadmeContent.ts",
"repo_id": "owncloud",
"token_count": 548
} | 823 |
import { Ref, ref, unref, MaybeRef } from 'vue'
import { dirname } from 'path'
import { ClientService } from '../../services'
import { useAppFileHandling } from './useAppFileHandling'
import { Resource } from '@ownclouders/web-client'
import { FileContext } from './types'
import { RouteLocationNormalizedLoaded } from 'vue-router'
import { useFileRouteReplace } from '../router/useFileRouteReplace'
import { DavProperty } from '@ownclouders/web-client/src/webdav/constants'
import { useAuthService } from '../authContext/useAuthService'
import { isMountPointSpaceResource } from '@ownclouders/web-client/src/helpers'
import { useResourcesStore, useSpacesStore } from '../piniaStores'
import { storeToRefs } from 'pinia'
interface AppFolderHandlingOptions {
currentRoute: Ref<RouteLocationNormalizedLoaded>
clientService?: ClientService
}
export interface AppFolderHandlingResult {
isFolderLoading: Ref<boolean>
activeFiles: Ref<Array<Resource>>
loadFolderForFileContext(context: MaybeRef<FileContext>): Promise<any>
}
export function useAppFolderHandling({
currentRoute,
clientService
}: AppFolderHandlingOptions): AppFolderHandlingResult {
const isFolderLoading = ref(false)
const { webdav } = clientService
const { replaceInvalidFileRoute } = useFileRouteReplace()
const { getFileInfo } = useAppFileHandling({ clientService })
const authService = useAuthService()
const spacesStore = useSpacesStore()
const resourcesStore = useResourcesStore()
const { activeResources } = storeToRefs(resourcesStore)
const loadFolderForFileContext = async (context: MaybeRef<FileContext>) => {
isFolderLoading.value = true
resourcesStore.clearResourceList()
try {
context = unref(context)
const space = unref(context.space)
const pathResource = await getFileInfo(context, {
davProperties: [DavProperty.FileId]
})
replaceInvalidFileRoute({
space,
resource: pathResource,
path: unref(context.item),
fileId: unref(context.itemId)
})
const isSpaceRoot = spacesStore.spaces.some(
(s) => isMountPointSpaceResource(s) && s.root.remoteItem.id === pathResource.id
)
if (isSpaceRoot) {
const resource = await getFileInfo(context)
resourcesStore.initResourceList({ currentFolder: resource, resources: [resource] })
isFolderLoading.value = false
return
}
const path = dirname(pathResource.path)
const { resource, children } = await webdav.listFiles(space, {
path
})
if (resource.type === 'file') {
resourcesStore.initResourceList({
// FIXME: currentFolder should be null?!
currentFolder: resource,
resources: [resource]
})
} else {
resourcesStore.initResourceList({ currentFolder: resource, resources: children })
}
} catch (error) {
if (error.statusCode === 401) {
return authService.handleAuthError(unref(currentRoute))
}
resourcesStore.setCurrentFolder(null)
console.error(error)
}
isFolderLoading.value = false
}
return {
isFolderLoading,
loadFolderForFileContext,
activeFiles: activeResources
}
}
| owncloud/web/packages/web-pkg/src/composables/appDefaults/useAppFolderHandling.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/appDefaults/useAppFolderHandling.ts",
"repo_id": "owncloud",
"token_count": 1121
} | 824 |
import { useClientService } from '../clientService'
import { triggerDownloadWithFilename } from '../../../src/helpers'
import { useGettext } from 'vue3-gettext'
import { ClientService } from '../../services'
import { useMessages } from '../piniaStores'
import { Resource, SpaceResource } from '@ownclouders/web-client'
export interface DownloadFileOptions {
clientService?: ClientService
}
export const useDownloadFile = (options?: DownloadFileOptions) => {
const { showErrorMessage } = useMessages()
const clientService = options?.clientService || useClientService()
const { $gettext } = useGettext()
const downloadFile = async (space: SpaceResource, file: Resource, version: string = null) => {
try {
const url = await clientService.webdav.getFileUrl(space, file, {
version,
doHeadRequest: true
})
triggerDownloadWithFilename(url, file.name)
} catch (e) {
console.error(e)
showErrorMessage({
title: $gettext('Download failed'),
desc: $gettext('File could not be located'),
errors: [e]
})
}
}
return {
downloadFile
}
}
| owncloud/web/packages/web-pkg/src/composables/download/useDownloadFile.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/download/useDownloadFile.ts",
"repo_id": "owncloud",
"token_count": 385
} | 825 |
import { useEventListener } from '@vueuse/core'
import { Ref, ref, unref } from 'vue'
import * as uuid from 'uuid'
interface KeyboardActionsOptions {
skipDisabledKeyBindingsCheck?: boolean
}
export enum Key {
C = 'c',
V = 'v',
X = 'x',
A = 'a',
S = 's',
Space = ' ',
ArrowUp = 'ArrowUp',
ArrowDown = 'ArrowDown',
ArrowLeft = 'ArrowLeft',
ArrowRight = 'ArrowRight',
Esc = 'Escape'
}
export enum ModifierKey {
Ctrl = 'Control',
Shift = 'Shift'
}
export interface KeyboardActions {
actions: Ref<Array<KeyboardAction>>
selectionCursor: Ref<number>
removeKeyAction: (id: string) => void
resetSelectionCursor: () => void
bindKeyAction: (keys: { primary: Key; modifier?: ModifierKey }, callback: () => void) => string
}
export interface KeyboardAction {
id: string
primary: Key
modifier: ModifierKey | null
callback: (event: KeyboardEvent) => void
}
const areCustomKeyBindingsDisabled = () => {
const activeElementTag = document.activeElement.tagName
const type = document.activeElement.getAttribute('type')
if (
['textarea', 'input', 'select'].includes(activeElementTag.toLowerCase()) &&
type !== 'checkbox'
) {
return true
}
const closestSelectionEl = window.getSelection().focusNode as HTMLElement
if (!closestSelectionEl) {
return false
}
let customKeyBindings
try {
customKeyBindings = closestSelectionEl?.closest("[data-custom-key-bindings-disabled='true']")
} catch {
customKeyBindings = closestSelectionEl?.parentElement.closest(
"[data-custom-key-bindings-disabled='true']"
)
}
if (customKeyBindings) {
return true
}
const isTextSelected = window.getSelection().type === 'Range'
return isTextSelected
}
export const useKeyboardActions = (options?: KeyboardActionsOptions): KeyboardActions => {
const actions = ref<Array<KeyboardAction>>([])
const selectionCursor = ref(0)
const listener = (event: KeyboardEvent): void => {
if (!options?.skipDisabledKeyBindingsCheck && areCustomKeyBindingsDisabled()) {
return
}
const { key, ctrlKey, metaKey, shiftKey } = event
let modifier = null
if (metaKey || ctrlKey) {
modifier = ModifierKey.Ctrl
} else if (shiftKey) {
modifier = ModifierKey.Shift
}
unref(actions)
.filter((action) => {
return action.primary === key && action.modifier === modifier
})
.forEach((action) => {
event.preventDefault()
action.callback(event)
})
}
const bindKeyAction = (
keys: { primary: Key; modifier?: ModifierKey },
callback: () => void
): string => {
const id = uuid.v4()
actions.value.push({
id,
...keys,
modifier: keys.modifier ?? null,
callback
})
return id
}
const removeKeyAction = (id: string): void => {
actions.value = actions.value.filter((action) => action.id !== id)
}
const resetSelectionCursor = (): void => {
selectionCursor.value = 0
}
useEventListener(document, 'keydown', listener)
return {
actions,
bindKeyAction,
removeKeyAction,
selectionCursor,
resetSelectionCursor
}
}
| owncloud/web/packages/web-pkg/src/composables/keyboardActions/useKeyboardActions.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/keyboardActions/useKeyboardActions.ts",
"repo_id": "owncloud",
"token_count": 1131
} | 826 |
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { Resource } from '@ownclouders/web-client'
import { ClipboardActions } from '../../helpers'
import { useGettext } from 'vue3-gettext'
import { useMessages } from './messages'
export const useClipboardStore = defineStore('clipboard', () => {
const { $gettext } = useGettext()
const { showMessage } = useMessages()
const action = ref<ClipboardActions>()
const resources = ref<Resource[]>([])
const copyResources = (r: Resource[]) => {
action.value = ClipboardActions.Copy
resources.value = r
showMessage({ title: $gettext('Copied to clipboard!'), status: 'success' })
}
const cutResources = (r: Resource[]) => {
action.value = ClipboardActions.Cut
resources.value = r
showMessage({ title: $gettext('Cut to clipboard!'), status: 'success' })
}
const clearClipboard = () => {
action.value = undefined
resources.value = []
}
return {
action,
resources,
copyResources,
cutResources,
clearClipboard
}
})
export type ClipboardStore = ReturnType<typeof useClipboardStore>
| owncloud/web/packages/web-pkg/src/composables/piniaStores/clipboard.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/piniaStores/clipboard.ts",
"repo_id": "owncloud",
"token_count": 374
} | 827 |
export * from './eventTopics'
export * from './usePortalTarget'
| owncloud/web/packages/web-pkg/src/composables/portalTarget/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/portalTarget/index.ts",
"repo_id": "owncloud",
"token_count": 20
} | 828 |
import { computed, Ref, unref } from 'vue'
import { useRouter } from './useRouter'
import { QueryValue } from './types'
let lastNavigation = Promise.resolve()
export const useRouteQuery = (name: string, defaultValue?: QueryValue): Ref<QueryValue> => {
const router = useRouter()
return computed({
get() {
return unref(router.currentRoute).query[name] || defaultValue
},
set(v) {
if (unref(router.currentRoute).query[name] === v) {
return
}
const navigation = lastNavigation.then(async () => {
try {
await router.replace({
// FIXME: passing the path does not seem to be required at runtime, but somehow is required in tests
path: unref(router.currentRoute).path,
query: {
...unref(router.currentRoute).query,
[name]: v
}
})
} catch (e) {}
})
lastNavigation = navigation
}
})
}
| owncloud/web/packages/web-pkg/src/composables/router/useRouteQuery.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/router/useRouteQuery.ts",
"repo_id": "owncloud",
"token_count": 406
} | 829 |
import { onBeforeUnmount, readonly, ref, Ref, unref } from 'vue'
import { EventBus, eventBus as defaultEventBus } from '../../services/eventBus'
import { SideBarEventTopics } from './eventTopics'
import { useLocalStorage } from '../localStorage'
interface SideBarResult {
isSideBarOpen: Ref<boolean>
sideBarActivePanel: Ref<string>
onPanelActive: (name: string, callback: (string: any) => void) => void
}
interface SideBarOptions {
bus?: EventBus
}
export const useSideBar = (options?: SideBarOptions): SideBarResult => {
const eventBus = options?.bus || defaultEventBus
const isSideBarOpen = useLocalStorage(`oc_sideBarOpen`, false)
const sideBarActivePanel = ref(null)
const toggleSideBarToken = eventBus.subscribe(SideBarEventTopics.toggle, () => {
isSideBarOpen.value = !unref(isSideBarOpen)
})
const closeSideBarToken = eventBus.subscribe(SideBarEventTopics.close, () => {
isSideBarOpen.value = false
sideBarActivePanel.value = null
})
const openSideBarToken = eventBus.subscribe(SideBarEventTopics.open, () => {
isSideBarOpen.value = true
sideBarActivePanel.value = null
})
const openSideBarWithPanelToken = eventBus.subscribe(
SideBarEventTopics.openWithPanel,
(panelName: string) => {
isSideBarOpen.value = true
sideBarActivePanel.value = panelName
}
)
const setActiveSideBarPanelToken = eventBus.subscribe(
SideBarEventTopics.setActivePanel,
(panelName: string) => {
sideBarActivePanel.value = panelName
}
)
onBeforeUnmount(() => {
eventBus.unsubscribe(SideBarEventTopics.toggle, toggleSideBarToken)
eventBus.unsubscribe(SideBarEventTopics.close, closeSideBarToken)
eventBus.unsubscribe(SideBarEventTopics.open, openSideBarToken)
eventBus.unsubscribe(SideBarEventTopics.openWithPanel, openSideBarWithPanelToken)
eventBus.unsubscribe(SideBarEventTopics.setActivePanel, setActiveSideBarPanelToken)
})
const onPanelActive = (name: string, callback: (string) => void) => {
eventBus.subscribe(SideBarEventTopics.setActivePanel, (panelName: string) => {
if (name !== panelName) {
return
}
// acount for threshold
setTimeout(() => {
callback(panelName)
}, 100)
})
}
return {
isSideBarOpen: readonly(isSideBarOpen),
sideBarActivePanel: readonly(sideBarActivePanel),
onPanelActive
}
}
| owncloud/web/packages/web-pkg/src/composables/sideBar/useSideBar.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/composables/sideBar/useSideBar.ts",
"repo_id": "owncloud",
"token_count": 819
} | 830 |
/**
* generic error implementation which captures the stackTrace and has custom naming
*/
export class RuntimeError extends Error {
name = 'RuntimeError'
constructor(message?: unknown, ...additional: unknown[]) {
super([message, ...additional].filter(Boolean).join(', '))
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor)
}
}
}
/**
* error dedicated to api type errors
*/
export class ApiError extends RuntimeError {
name = 'ApiError'
}
| owncloud/web/packages/web-pkg/src/errors/types.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/errors/types.ts",
"repo_id": "owncloud",
"token_count": 153
} | 831 |
/**
* Asserts whether given resource can be moved
* @param {String} resource Resource which is to be moved
* @param {Object} parentPath Path of the parent folder of the resource
* @return {Boolean} can be moved
*/
export function canBeMoved(resource, parentPath) {
// TODO: Find a better way to prevent moving shared resources than by checking if the current folder is root
// TODO: Find a way to disable move action when shares are mounted in different folder then root
const isExternal = resource.isReceivedShare() || resource.isMounted()
const isMountedInRoot = parentPath === '' && isExternal
return resource.canBeDeleted() && !isMountedInRoot
}
| owncloud/web/packages/web-pkg/src/helpers/permissions.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/helpers/permissions.ts",
"repo_id": "owncloud",
"token_count": 170
} | 832 |
import { DateTime } from 'luxon'
import { getLocaleFromLanguage } from '../locale'
import { CapabilityStore } from '../../composables'
// TODO: move to useExpirationRules composable
export type ExpirationRules = { enforced: boolean; default: DateTime; min: DateTime; max: DateTime }
export const getExpirationRules = ({
capabilityStore,
currentLanguage
}: {
capabilityStore: CapabilityStore
currentLanguage: string
}): ExpirationRules => {
const expireDate = capabilityStore.sharingPublicExpireDate
let defaultExpireDate: DateTime = null
let maxExpireDateFromCaps: DateTime = null
if (expireDate.days) {
const days = parseInt(expireDate.days)
defaultExpireDate = DateTime.now()
.setLocale(getLocaleFromLanguage(currentLanguage))
.plus({ days })
.toJSDate()
}
if (expireDate.enforced) {
const days = parseInt(expireDate.days)
maxExpireDateFromCaps = DateTime.now()
.setLocale(getLocaleFromLanguage(currentLanguage))
.plus({ days })
.toJSDate()
}
return {
enforced: expireDate.enforced,
default: defaultExpireDate,
min: DateTime.now().setLocale(getLocaleFromLanguage(currentLanguage)).toJSDate(),
max: maxExpireDateFromCaps
}
}
| owncloud/web/packages/web-pkg/src/helpers/share/link.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/helpers/share/link.ts",
"repo_id": "owncloud",
"token_count": 419
} | 833 |
import { defineComponent } from 'vue'
/**
* we need to inject the vue files into the route builders,
* this is because we also import the provided helpers from other js|ts files
* like mixins, rollup seems to have a problem to import files which contain vue file imports
* into js files which then again get imported by other vue files...
*/
type Component = ReturnType<typeof defineComponent>
export interface RouteComponents {
App: Component
Favorites: Component
FilesDrop: Component
SearchResults: Component
Shares: {
SharedWithMe: Component
SharedWithOthers: Component
SharedViaLink: Component
}
Spaces: {
DriveResolver: Component
Projects: Component
}
Trash: {
Overview: Component
}
}
| owncloud/web/packages/web-pkg/src/router/router.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/router/router.ts",
"repo_id": "owncloud",
"token_count": 206
} | 834 |
export * from './previewService'
export * from './types'
| owncloud/web/packages/web-pkg/src/services/preview/index.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/src/services/preview/index.ts",
"repo_id": "owncloud",
"token_count": 18
} | 835 |
import { ref } from 'vue'
import AppBar from '../../../../src/components/AppBar/AppBar.vue'
import { mock } from 'vitest-mock-extended'
import { Resource, SpaceResource } from '@ownclouders/web-client'
import {
defaultComponentMocks,
defaultPlugins,
shallowMount,
RouteLocation
} from 'web-test-helpers'
import { ArchiverService } from '../../../../src/services'
import { FolderView } from '../../../../src/ui/types'
import { ViewOptions } from '../../../../src'
import { OcBreadcrumb } from 'design-system/src/components'
const selectors = {
ocBreadcrumbStub: 'oc-breadcrumb-stub',
batchActionsStub: 'batch-actions-stub',
viewOptionsStub: 'view-options-stub',
sidebarToggleStub: 'sidebar-toggle-stub',
mobileNavPortal: 'portal-target[name="app.runtime.mobile.nav"]'
}
const selectedFiles = [mock<Resource>(), mock<Resource>()]
const actionSlot = "<button class='action-slot'>Click</button>"
const contentSlot = "<div class='content-slot'>Foo</div>"
const breadcrumbItems = [
{ text: 'Example1', to: '/' },
{ text: 'Example2', to: '/foo' }
]
const breadCrumbItemWithContextActionAllowed = {
text: 'Example Special',
to: '/bar',
allowContextActions: true
}
describe('AppBar component', () => {
describe('renders', () => {
it('by default no breadcrumbs, no bulkactions, no sharesnavigation but viewoptions and sidebartoggle', () => {
const { wrapper } = getShallowWrapper()
expect(wrapper.html()).toMatchSnapshot()
})
describe('breadcrumbs', () => {
it('if given, by default without breadcrumbsContextActionsItems', () => {
const { wrapper } = getShallowWrapper([], {}, { breadcrumbs: breadcrumbItems })
expect(wrapper.find(selectors.ocBreadcrumbStub).exists()).toBeTruthy()
expect(
wrapper.findComponent<typeof OcBreadcrumb>(selectors.ocBreadcrumbStub).props('items')
).toEqual(breadcrumbItems)
})
it('if given, with breadcrumbsContextActionsItems if allowed on last breadcrumb item', () => {
const { wrapper } = getShallowWrapper(
[],
{},
{ breadcrumbs: [...breadcrumbItems, breadCrumbItemWithContextActionAllowed] }
)
expect(wrapper.find(selectors.ocBreadcrumbStub).exists()).toBeTruthy()
expect(
wrapper.findComponent<typeof OcBreadcrumb>(selectors.ocBreadcrumbStub).props('items')
).toEqual([...breadcrumbItems, breadCrumbItemWithContextActionAllowed])
})
it('not if no breadcrumb items given', () => {
const { wrapper } = getShallowWrapper([], {}, { breadcrumbs: [] })
expect(wrapper.find(selectors.ocBreadcrumbStub).exists()).toBeFalsy()
})
it('not if one breadcrumb item is given in mobile view', () => {
const { wrapper } = getShallowWrapper(
[],
{},
{ breadcrumbs: [breadcrumbItems[0]] },
mock<RouteLocation>(),
true
)
expect(wrapper.find(selectors.ocBreadcrumbStub).exists()).toBeFalsy()
})
})
describe('bulkActions', () => {
it('if enabled', () => {
const { wrapper } = getShallowWrapper(selectedFiles, {}, { hasBulkActions: true })
expect(wrapper.find(selectors.batchActionsStub).exists()).toBeTruthy()
})
it('if 1 file selected on trash routes', () => {
const { wrapper } = getShallowWrapper(
[selectedFiles[0]],
{},
{ hasBulkActions: true },
mock<RouteLocation>({
name: 'files-trash-generic',
path: '/files/trash/personal/admin'
})
)
expect(wrapper.find(selectors.batchActionsStub).exists()).toBeTruthy()
})
})
describe('mobile navigation portal', () => {
it.each([
{ items: [], shows: true },
{ items: [breadcrumbItems[0]], shows: true },
{ items: [breadcrumbItems[0], breadcrumbItems[1]], shows: false }
])('if less than 2 breadcrumb items given', ({ items, shows }) => {
const { wrapper } = getShallowWrapper([], {}, { breadcrumbs: items })
expect(wrapper.find(selectors.mobileNavPortal).exists()).toBe(shows)
})
})
describe('viewoptions', () => {
it('show if options are available', () => {
const { wrapper } = getShallowWrapper([], {}, { hasViewOptions: true })
expect(wrapper.find(selectors.viewOptionsStub).exists()).toBeTruthy()
})
it('hide if options are not available', () => {
const { wrapper } = getShallowWrapper([], {}, { hasViewOptions: false })
expect(wrapper.find(selectors.viewOptionsStub).exists()).toBeFalsy()
})
it('passes viewModes array to ViewOptions', () => {
const viewModes = [mock<FolderView>]
const { wrapper } = getShallowWrapper([], {}, { hasViewOptions: true, viewModes })
expect(
wrapper.findComponent<typeof ViewOptions>(selectors.viewOptionsStub).props('viewModes')
).toEqual(viewModes)
})
})
it('if given, with content in the actions slot', () => {
const { wrapper } = getShallowWrapper([], { actions: actionSlot })
expect(wrapper.html()).toMatchSnapshot()
})
it('if given, with content in the content slot', () => {
const { wrapper } = getShallowWrapper([], { content: contentSlot })
expect(wrapper.html()).toMatchSnapshot()
})
})
})
function getShallowWrapper(
selected = [],
slots = {},
props: { [key: string]: any } = {
breadcrumbs: [],
displayViewModeSwitch: false,
hasBulkActions: false,
hasSidebarToggle: true,
hasViewOptions: true
},
currentRoute = mock<RouteLocation>({
name: 'files-spaces-generic',
path: '/files/spaces/personal/admin'
}),
isMobileWidth = false
) {
const mocks = {
...defaultComponentMocks({
currentRoute
}),
$archiverService: mock<ArchiverService>()
}
mocks.$route.meta.title = 'ExampleTitle'
return {
wrapper: shallowMount(AppBar, {
props: { ...props, space: mock<SpaceResource>() },
slots,
global: {
plugins: [
...defaultPlugins({
piniaOptions: {
resourcesStore: { resources: selected, selectedIds: selected.map(({ id }) => id) }
}
})
],
provide: { ...mocks, isMobileWidth: ref(isMobileWidth) },
mocks
}
})
}
}
| owncloud/web/packages/web-pkg/tests/unit/components/AppBar/AppBar.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/components/AppBar/AppBar.spec.ts",
"repo_id": "owncloud",
"token_count": 2590
} | 836 |
import { shallowMount } from 'web-test-helpers'
import { AVAILABLE_SIZES } from 'design-system/src/helpers/constants'
import ResourceIcon from '../../../../src/components/FilesList/ResourceIcon.vue'
import {
ResourceIconMapping,
resourceIconMappingInjectionKey
} from '../../../../src/helpers/resource'
import { Resource } from '@ownclouders/web-client'
const resourceIconMapping: ResourceIconMapping = {
extension: {
'not-a-real-extension': {
name: 'resource-type-madeup-extension',
color: 'red'
}
},
mimeType: {
'not-a-real-mimetype': {
name: 'resource-type-file',
color: 'var(--oc-color-text-default)'
}
}
}
describe('OcResourceIcon', () => {
;['file', 'folder', 'space'].forEach((type) => {
match({
type
})
})
match(
{
type: 'file',
extension: 'not-a-real-extension'
},
'with extension "not-a-real-extension"'
)
match(
{
type: 'file',
mimeType: 'not-a-real-mimetype'
},
'with mimetype "not-a-real-mimetype"'
)
})
function match(resource: Partial<Resource>, additionalText?: string) {
AVAILABLE_SIZES.forEach((size) => {
it(`renders OcIcon for resource type ${resource.type}${
additionalText ? ` ${additionalText}` : ''
} in size ${size}`, () => {
const { wrapper } = getWrapper({ resource, size })
expect(wrapper.html()).toMatchSnapshot()
})
})
}
function getWrapper({ resource, size }: { resource: Partial<Resource>; size: string }) {
return {
wrapper: shallowMount(ResourceIcon, {
global: {
provide: {
[resourceIconMappingInjectionKey]: resourceIconMapping
}
},
props: {
resource: resource as Resource,
size
}
})
}
}
| owncloud/web/packages/web-pkg/tests/unit/components/FilesList/ResourceIcon.spec.ts/0 | {
"file_path": "owncloud/web/packages/web-pkg/tests/unit/components/FilesList/ResourceIcon.spec.ts",
"repo_id": "owncloud",
"token_count": 731
} | 837 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.