Skip to content

Commit ecda9d6

Browse files
xnhphornm-knime
authored andcommitted
NXT-4419: Use 'isOwnedByAnotherIdentity' to display 'community icon'
NXT-4419 (Distinguish "foreign" (3rd-party) items in search results)
1 parent 9546efe commit ecda9d6

File tree

7 files changed

+62
-11
lines changed

7 files changed

+62
-11
lines changed

org.knime.ui.js/src/api/gateway-api/generated-api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,12 @@ export interface ComponentSearchItem {
13561356
* @memberof ComponentSearchItem
13571357
*/
13581358
icon?: string;
1359+
/**
1360+
* True if the item is owned by an AccountIdentity (e.g. user or team) other than the currently authenticated user.
1361+
* @type {boolean}
1362+
* @memberof ComponentSearchItem
1363+
*/
1364+
isOwnedByAnotherIdentity?: boolean;
13591365
/**
13601366
* The type (a.k.a. \"kind\") of the component
13611367
* @type {string}

org.knime.ui.js/src/components/nodeTemplates/NodeTemplate/NodeTemplate.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { computed, ref } from "vue";
44
import { NodePreview } from "@knime/components";
55
66
import type { NodeRepositoryDisplayModesType } from "@/store/settings";
7-
import type { NodeTemplateWithExtendedPorts } from "@/util/dataMappers";
7+
import type {
8+
ComponentNodeTemplateWithExtendedPorts,
9+
NodeTemplateWithExtendedPorts,
10+
} from "@/util/dataMappers";
811
912
import NodeTemplateIconMode from "./NodeTemplateIconMode.vue";
1013
import NodeTemplateListMode from "./NodeTemplateListMode.vue";
@@ -17,7 +20,9 @@ export type Props = {
1720
* Additional to the properties of the NodeTemplate from the gateway API, this object
1821
* contains the port information (color and kind) which was mapped from the store
1922
*/
20-
nodeTemplate: NodeTemplateWithExtendedPorts;
23+
nodeTemplate:
24+
| NodeTemplateWithExtendedPorts
25+
| ComponentNodeTemplateWithExtendedPorts;
2126
displayMode?: NodeRepositoryDisplayModesType;
2227
isSelected?: boolean;
2328
isDescriptionActive?: boolean;

org.knime.ui.js/src/components/nodeTemplates/NodeTemplate/NodeTemplateIconMode.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import { computed } from "vue";
33
44
import ExtensionCommunityIcon from "@knime/styles/img/icons/extension-community.svg";
55
6-
import type { NodeTemplateWithExtendedPorts } from "@/util/dataMappers";
6+
import type {
7+
ComponentNodeTemplateWithExtendedPorts,
8+
NodeTemplateWithExtendedPorts,
9+
} from "@/util/dataMappers";
710
811
import NodeTemplateHelpIcon from "./NodeTemplateHelpIcon.vue";
12+
import { shouldShowCommunityIcon } from "./nodeTemplateCommunityIcon";
913
1014
type Props = {
11-
nodeTemplate: NodeTemplateWithExtendedPorts;
15+
nodeTemplate:
16+
| NodeTemplateWithExtendedPorts
17+
| ComponentNodeTemplateWithExtendedPorts;
1218
isHovered: boolean;
1319
isDescriptionActive?: boolean;
1420
showFloatingHelpIcon?: boolean;
@@ -27,6 +33,10 @@ const extensionText = computed(() => {
2733
}
2834
return `\n———\n${props.nodeTemplate.extension.name}\nby ${props.nodeTemplate.extension.vendor.name}`;
2935
});
36+
37+
const showCommunityIcon = computed(() =>
38+
shouldShowCommunityIcon(props.nodeTemplate),
39+
);
3040
</script>
3141

3242
<template>
@@ -55,7 +65,7 @@ const extensionText = computed(() => {
5565

5666
<div class="extension-info">
5767
<ExtensionCommunityIcon
58-
v-if="nodeTemplate.extension && !nodeTemplate.extension.vendor?.isKNIME"
68+
v-if="showCommunityIcon"
5969
class="extension-community-icon"
6070
/>
6171
</div>

org.knime.ui.js/src/components/nodeTemplates/NodeTemplate/NodeTemplateListMode.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import { computed } from "vue";
33
44
import ExtensionCommunityIcon from "@knime/styles/img/icons/extension-community.svg";
55
6-
import type { NodeTemplateWithExtendedPorts } from "@/util/dataMappers";
6+
import type {
7+
ComponentNodeTemplateWithExtendedPorts,
8+
NodeTemplateWithExtendedPorts,
9+
} from "@/util/dataMappers";
710
811
import NodeTemplateHelpIcon from "./NodeTemplateHelpIcon.vue";
12+
import { shouldShowCommunityIcon } from "./nodeTemplateCommunityIcon";
913
1014
type Props = {
11-
nodeTemplate: NodeTemplateWithExtendedPorts;
15+
nodeTemplate:
16+
| NodeTemplateWithExtendedPorts
17+
| ComponentNodeTemplateWithExtendedPorts;
1218
isHovered: boolean;
1319
showFloatingHelpIcon?: boolean;
1420
isSelected?: boolean;
@@ -23,15 +29,15 @@ const props = withDefaults(defineProps<Props>(), {
2329
2430
const emit = defineEmits(["helpIconClick"]);
2531
26-
const isCommunityExtension = computed(
27-
() => !props.nodeTemplate.extension?.vendor?.isKNIME,
32+
const showCommunityIcon = computed(() =>
33+
shouldShowCommunityIcon(props.nodeTemplate),
2834
);
2935
</script>
3036

3137
<template>
3238
<div
3339
class="node-template-list-mode"
34-
:class="{ 'with-community-icon': isCommunityExtension }"
40+
:class="{ 'with-community-icon': showCommunityIcon }"
3541
:title="
3642
nodeTemplate.extension && nodeTemplate.extension.vendor
3743
? `${nodeTemplate.extension.name} \nby “${nodeTemplate.extension.vendor.name}”`
@@ -50,7 +56,7 @@ const isCommunityExtension = computed(
5056
</div>
5157

5258
<ExtensionCommunityIcon
53-
v-if="isCommunityExtension"
59+
v-if="showCommunityIcon"
5460
class="extension-community-icon"
5561
/>
5662

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type {
2+
ComponentNodeTemplateWithExtendedPorts,
3+
NodeTemplateWithExtendedPorts,
4+
} from "@/util/dataMappers";
5+
6+
export const isComponentNodeTemplate = (
7+
data: NodeTemplateWithExtendedPorts | ComponentNodeTemplateWithExtendedPorts,
8+
): data is ComponentNodeTemplateWithExtendedPorts => Boolean(data.component);
9+
10+
export const shouldShowCommunityIcon = (
11+
data: NodeTemplateWithExtendedPorts | ComponentNodeTemplateWithExtendedPorts,
12+
): boolean => {
13+
if (isComponentNodeTemplate(data)) {
14+
return data.isOwnedByAnotherIdentity;
15+
}
16+
17+
return Boolean(data.extension?.vendor && !data.extension.vendor.isKNIME);
18+
};

org.knime.ui.js/src/util/dataMappers/common.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ export type NodeTemplateWithExtendedPorts = NodeTemplate & {
1212
};
1313

1414
export type ComponentNodeTemplateWithExtendedPorts = NodeTemplate & {
15+
/**
16+
* True if the component is owned by an account other than the current user.
17+
* Mirrors the gateway API isOwnedByAnotherIdentity flag.
18+
*/
19+
isOwnedByAnotherIdentity: boolean;
1520
description: string;
1621
inPorts: Array<ExtendedPortType & { name: string; description: string }>;
1722
outPorts: Array<ExtendedPortType & { name: string; description: string }>;

org.knime.ui.js/src/util/dataMappers/componentSearch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const toNodeTemplateWithExtendedPorts = (
4747
name: input.name,
4848
type: input.type,
4949
component: true,
50+
isOwnedByAnotherIdentity: input.isOwnedByAnotherIdentity ?? false,
5051
icon: input.icon,
5152
inPorts,
5253
outPorts,

0 commit comments

Comments
 (0)