Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/ui/src/components/base/Combobox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ function setInitialFocus() {

function determineOpenDirection(
triggerRect: DOMRect,
dropdownRect: DOMRect,
dropdownRect: { width: number; height: number },
viewport: ViewportRect,
): 'up' | 'down' {
if (props.forceDirection) {
Expand All @@ -499,7 +499,7 @@ function determineOpenDirection(

function calculateVerticalPosition(
triggerRect: DOMRect,
dropdownRect: DOMRect,
dropdownRect: { width: number; height: number },
direction: 'up' | 'down',
viewport: ViewportRect,
): number {
Expand All @@ -513,7 +513,7 @@ function calculateVerticalPosition(

function calculateHorizontalPosition(
triggerRect: DOMRect,
dropdownRect: DOMRect,
dropdownRect: { width: number; height: number },
viewport: ViewportRect,
): number {
const minLeft = viewport.offsetLeft + DROPDOWN_VIEWPORT_MARGIN
Expand Down Expand Up @@ -556,7 +556,7 @@ async function updateDropdownPosition() {
await nextTick()

const triggerRect = effectiveTriggerEl.value.getBoundingClientRect()
const width = resolveDropdownWidth(triggerRect.width)
const width = resolveDropdownWidth(effectiveTriggerEl.value.offsetWidth)
const minWidth = resolveCssSize(props.dropdownMinWidth) ?? '0px'

dropdownStyle.value = {
Expand All @@ -567,7 +567,10 @@ async function updateDropdownPosition() {

await nextTick()

const dropdownRect = dropdownRef.value.getBoundingClientRect()
const dropdownRect = {
width: dropdownRef.value.offsetWidth,
height: dropdownRef.value.offsetHeight,
}
const viewport = getViewportRect()

const direction = determineOpenDirection(triggerRect, dropdownRect, viewport)
Expand Down
8 changes: 6 additions & 2 deletions packages/ui/src/components/base/buttons/ButtonLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ const resolvedRel = computed(() => {
return props.target === '_blank' ? 'noopener noreferrer' : undefined
})

// https://github.com/vuejs/vue-router/issues/2005 moment
const linkAttrs = computed(() =>
usesRouter.value ? { to: props.to } : !props.disabled ? { href: props.href } : {},
)

function handleClick(event: MouseEvent) {
if (!props.disabled) return
event.preventDefault()
Expand All @@ -52,8 +57,7 @@ function handleClick(event: MouseEvent) {
:color="props.color"
:size="props.size"
:interaction="props.interaction"
:to="usesRouter ? props.to : undefined"
:href="!usesRouter && !props.disabled ? props.href : undefined"
v-bind="linkAttrs"
:target="props.target"
:rel="resolvedRel"
:download="!props.disabled ? props.download : undefined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ArrowLeftRightIcon,
BoxIcon,
ExternalIcon,
FileIcon,
GlassesIcon,
PaintbrushIcon,
SearchIcon,
Expand Down Expand Up @@ -104,6 +105,10 @@ const messages = defineMessages({
id: 'instances.managed-content-modal.open-in-slicer',
defaultMessage: 'Open in Slicer',
},
downloadFile: {
id: 'instances.managed-content-modal.download-file',
defaultMessage: 'Download File',
},
})

export interface ManagedContentModalState {
Expand Down Expand Up @@ -314,6 +319,15 @@ const externalSlicerUrls = computed(() => {
}
return urls
})
const externalUrls = computed(() => {
const urls: Record<string, string> = {}
for (const item of items.value) {
if (item.external && item.external_url) {
urls[item.id] = item.external_url
}
}
return urls
})
const hasExternalSlicerUrls = computed(() => Object.keys(externalSlicerUrls.value).length > 0)
const showTableActions = computed(() => props.enableToggle || hasExternalSlicerUrls.value)

Expand Down Expand Up @@ -598,6 +612,18 @@ defineExpose({ show, showLoading, hide, getState, restore, updateItem, setItems
>
<ExternalIcon class="size-4" />
</ButtonLink>
<ButtonLink
v-if="externalUrls[item.id]"
v-tooltip="formatMessage(messages.downloadFile)"
type="quiet"
:aria-label="formatMessage(messages.downloadFile)"
:href="externalUrls[item.id]"
target="_blank"
rel="noopener noreferrer"
class="!w-9 !px-0 !rounded-full"
>
<FileIcon class="size-4" />
</ButtonLink>
</template>
</ContentCardTable>
</div>
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/locales/en-US/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,9 @@
"instances.content-install.show-unavailable": {
"defaultMessage": "Show unavailable"
},
"instances.managed-content-modal.download-file": {
"defaultMessage": "Download File"
},
"instances.managed-content-modal.empty-description": {
"defaultMessage": "This source does not include any managed content."
},
Expand Down
Loading