-
-
Notifications
You must be signed in to change notification settings - Fork 317
Display integration names on the services settings page #2942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Pierre-Gilles
wants to merge
2
commits into
master
Choose a base branch
from
claude/services-page-integration-names
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
front/src/routes/settings/settings-service/serviceIntegration.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import get from 'get-value'; | ||
|
|
||
| import { integrations } from '../../../config/integrations'; | ||
| import { SERVICE_TYPES } from '../../../../../server/utils/constants'; | ||
|
|
||
| /** | ||
| * Returns how a service should be presented in the services list: | ||
| * - slug: identity of the service in the list (its selector, unique) | ||
| * - i18nKey: translation key of the integration name (built-in integrations) | ||
| * - name: raw name to display when there is no translation | ||
| * - external: true for a community integration | ||
| * - discriminant: technical identity, displayed only when two integrations | ||
| * share the same name (see utils/integrationNames) | ||
| * - url: integration page of the service, when it has one | ||
| * @param {object} service - Service returned by the API. | ||
| * @returns {object} Display identity of the service. | ||
| */ | ||
| function getServiceIntegration(service) { | ||
| if (service.type === SERVICE_TYPES.EXTERNAL) { | ||
| // The service name is the technical selector (ext-<owner>-<repo>): display | ||
| // the manifest name, the same title as the integration card in the catalog | ||
| return { | ||
| slug: service.selector, | ||
| name: get(service, 'manifest.name') || service.name, | ||
| external: true, | ||
| // the store slug (owner/repo) reads better than the selector built from | ||
| // it; dev installs have none, their selector is the only identity | ||
| discriminant: service.store_slug || service.selector, | ||
| url: null | ||
|
cursor[bot] marked this conversation as resolved.
Outdated
|
||
| }; | ||
| } | ||
| const integrationPage = integrations.find( | ||
| integration => get(integration, 'link', { default: integration.key }).toLowerCase() === service.selector | ||
| ); | ||
| if (!integrationPage) { | ||
| // Service without a front-end page (usb, example...): no link | ||
| return { slug: service.selector, name: service.name, url: null }; | ||
| } | ||
| return { | ||
| slug: service.selector, | ||
| i18nKey: `integration.${integrationPage.key}.title`, | ||
| name: service.name, | ||
| url: `/dashboard/integration/${integrationPage.type}/${(integrationPage.link || integrationPage.key).toLowerCase()}` | ||
| }; | ||
| } | ||
|
|
||
| export default getServiceIntegration; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .serviceName { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 0.5rem; | ||
| max-width: 400px; | ||
| overflow: hidden; | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * Two community integrations can display the same name (two repositories | ||
| * publishing a manifest with the same name, or two dev installs of the same | ||
| * integration): those are the only ones that carry their technical identity | ||
| * next to their name, so the common case stays readable. Built-in integrations | ||
| * have unique names, and are told apart from community ones by the "community" | ||
| * tag displayed next to them. | ||
| * | ||
| * Integrations are described by: | ||
| * - slug: identity of the integration, the key of the returned map | ||
| * - name: name to display, before disambiguation | ||
| * - external: true for a community integration | ||
| * - discriminant: technical identity, appended to the name when needed | ||
| * | ||
| * @param {Array} integrations - Listed integrations, duplicates allowed. | ||
| * @returns {Map} Name to display, by integration slug. | ||
| */ | ||
| function disambiguateIntegrationNames(integrations) { | ||
| // names are compared lowercased: two manifests differing only by case read | ||
| // as the same name in the list | ||
| const slugsByName = new Map(); | ||
| integrations.forEach(integration => { | ||
| if (integration && integration.external) { | ||
| const key = integration.name.toLowerCase(); | ||
| const slugs = slugsByName.get(key) || new Set(); | ||
| slugs.add(integration.slug); | ||
| slugsByName.set(key, slugs); | ||
| } | ||
| }); | ||
| const nameBySlug = new Map(); | ||
| integrations.forEach(integration => { | ||
| if (!integration || nameBySlug.has(integration.slug)) { | ||
| return; | ||
| } | ||
| const isDuplicated = integration.external && slugsByName.get(integration.name.toLowerCase()).size > 1; | ||
| nameBySlug.set( | ||
| integration.slug, | ||
| isDuplicated ? `${integration.name} (${integration.discriminant})` : integration.name | ||
| ); | ||
| }); | ||
| return nameBySlug; | ||
| } | ||
|
|
||
| export default disambiguateIntegrationNames; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.