Files
raucao 303b26793f Reorder the custom link option and its icon controls
Sort the generic "Custom Link" entry last in the add-integration dialog so
it reads as an "add anything" action after the concrete integrations, and
move the icon controls below the URL and name fields in the custom link
form so the form flows from link details to its optional icon.
2026-11-13 21:09:21 +04:00

102 lines
3.0 KiB
Plaintext

import Component from '@glimmer/component';
import { action } from '@ember/object';
import { fn } from '@ember/helper';
import { on } from '@ember/modifier';
import { service } from '@ember/service';
import { formFor } from '../../../config/integration-forms';
import Avatar from './avatar.gjs';
// Generic "add anything" entries sort after the concrete integrations instead
// of among them.
const LAST_TYPES = new Set(['custom']);
export default class SettingsIntegrationsAddList extends Component {
@service modal;
@service integrations;
get items() {
const types = this.args.props?.types;
// Single-instance integrations that are already connected are managed from
// the Manage dialog instead of being offered again here. An optional
// `types` filter scopes the menu to a subset (e.g. only site links).
return this.integrations.all
.filter(
(integration) =>
(!types || types.includes(integration.id)) &&
!(
integration.supportsMultiple === false &&
integration.instances.length
)
)
.sort((a, b) => {
const aLast = LAST_TYPES.has(a.id);
const bLast = LAST_TYPES.has(b.id);
if (aLast !== bLast) {
return aLast ? 1 : -1;
}
return a.label.localeCompare(b.label);
});
}
@action
add(integration) {
const component = formFor(integration.id);
if (!integration.available || !component) {
return;
}
this.modal.replace({ component, props: { mode: 'add' }, size: 'md' });
}
<template>
<div class="p-6">
<h3
id={{if @titleId @titleId "modal-title"}}
class="text-base font-semibold leading-6 text-gray-900"
>Add Integration</h3>
<div class="mt-2">
<p class="text-sm text-gray-500">
Choose an integration to connect to your dashboard.
</p>
</div>
<div class="mt-4 -mx-3 max-h-[80vh] overflow-y-auto">
{{#each this.items as |integration|}}
<button
type="button"
disabled={{not integration.available}}
data-add={{integration.id}}
{{on "click" (fn this.add integration)}}
class="group flex w-full rounded-xl p-3 select-none focus:outline-hidden
{{if
integration.available
'cursor-pointer hover:bg-gray-100'
'cursor-default'
}}"
>
<Avatar @integration={{integration}} />
<div class="ml-4 flex-auto text-left">
<p
class="text-sm font-medium
{{if integration.available 'text-gray-700' 'text-gray-400'}}"
>
{{integration.label}}
</p>
<p
class="text-sm
{{if integration.available 'text-gray-500' 'text-gray-400'}}"
>
{{integration.description}}
</p>
</div>
</button>
{{/each}}
</div>
</div>
</template>
}