Skip to content

367 subscription productblocks outside the current subscription #1048

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

Merged
merged 8 commits into from
May 14, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/shiny-trainers-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@orchestrator-ui/orchestrator-ui-components": minor
---

Adds a different style if a productblock is outside the subscription boundary
2 changes: 1 addition & 1 deletion apps/wfo-ui
Original file line number Diff line number Diff line change
@@ -109,6 +109,7 @@ export const WfoSubscription = ({ subscriptionId }: WfoSubscriptionProps) => {
productBlockInstances={
subscriptionDetail.productBlockInstances
}
subscriptionId={subscriptionId}
/>
)}
{selectedTab === SubscriptionDetailTab.GENERAL_TAB && (
Original file line number Diff line number Diff line change
@@ -5,9 +5,14 @@ import { useTranslations } from 'next-intl';
import { EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';

import { WfoLoading, WfoTextAnchor } from '@/components';
import { TreeContext, TreeContextType } from '@/contexts';
import {
ProductBlockInstance,
Subscription,
TreeBlock,
WfoTreeNodeMap,
} from '@/types';

import { TreeContext, TreeContextType } from '../../contexts';
import { ProductBlockInstance, TreeBlock, WfoTreeNodeMap } from '../../types';
import { getTokenName } from '../../utils/getTokenName';
import { WfoTree } from '../WfoTree';
import { getWfoTreeNodeDepth } from '../WfoTree';
@@ -16,10 +21,12 @@ import { getProductBlockTitle } from './utils';

interface WfoSubscriptionDetailTreeProps {
productBlockInstances: ProductBlockInstance[];
subscriptionId: Subscription['subscriptionId'];
}

export const WfoSubscriptionDetailTree = ({
productBlockInstances,
subscriptionId,
}: WfoSubscriptionDetailTreeProps) => {
const t = useTranslations('subscriptions.detail');
const [, setSelectedTreeNode] = useState(-1);
@@ -39,6 +46,8 @@ export const WfoSubscriptionDetailTree = ({
label: '',
callback: () => {},
children: [],
isOutsideCurrentSubscription:
productBlockInstance.ownerSubscriptionId !== subscriptionId,
};

// Does this node have a parent?
@@ -142,8 +151,8 @@ export const WfoSubscriptionDetailTree = ({
)}
{selectedIds.length !== 0 &&
selectedIds.map((id, index) => {
const block =
productBlockInstances[selectedIds[index]];
const block = idToNodeMap[selectedIds[index]];

return (
<WfoSubscriptionProductBlock
key={index}
@@ -157,6 +166,9 @@ export const WfoSubscriptionDetailTree = ({
block.productBlockInstanceValues
}
inUseByRelations={block.inUseByRelations}
isOutsideCurrentSubscription={
block.isOutsideCurrentSubscription
}
id={id}
/>
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState } from 'react';

import { useTranslations } from 'next-intl';
import { useRouter } from 'next/router';

import {
EuiBadge,
@@ -31,6 +30,7 @@ interface WfoSubscriptionProductBlockProps {
productBlockInstanceValues: FieldValue[];
inUseByRelations: InUseByRelation[];
id: number;
isOutsideCurrentSubscription?: boolean;
}

export const HIDDEN_KEYS = ['title', 'name', 'label'];
@@ -40,15 +40,14 @@ export const WfoSubscriptionProductBlock = ({
subscriptionInstanceId,
productBlockInstanceValues,
inUseByRelations,
isOutsideCurrentSubscription = false,
}: WfoSubscriptionProductBlockProps) => {
const router = useRouter();
const subscriptionId = router.query['subscriptionId'];

const t = useTranslations('subscriptions.detail');
const { theme } = useOrchestratorTheme();
const {
iconStyle,
panelStyle,
panelStyleOutsideCurrentSubscription,
leftColumnStyle,
rightColumnStyle,
rowStyle,
@@ -59,7 +58,15 @@ export const WfoSubscriptionProductBlock = ({
return (
<>
<EuiSpacer size={'m'}></EuiSpacer>
<EuiPanel color="transparent" hasShadow={false} css={panelStyle}>
<EuiPanel
color="transparent"
hasShadow={false}
css={
isOutsideCurrentSubscription
? panelStyleOutsideCurrentSubscription
: panelStyle
}
>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<div css={iconStyle}>
@@ -118,8 +125,7 @@ export const WfoSubscriptionProductBlock = ({
<b>{t('ownerSubscriptionId')}</b>
</td>
<td css={rightColumnStyle}>
{subscriptionId ===
ownerSubscriptionId ? (
{!isOutsideCurrentSubscription ? (
<>
<EuiBadge>
{t('self')}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { css } from '@emotion/react';

import { WfoTheme } from '@/hooks';
import type { WfoTheme } from '@/hooks';

export const getStyles = ({ theme, toSecondaryColor }: WfoTheme) => {
export const getStyles = (wfoTheme: WfoTheme) => {
const { theme, toSecondaryColor } = wfoTheme;
const iconStyle = css({
width: 45,
height: 45,
@@ -16,6 +17,11 @@ export const getStyles = ({ theme, toSecondaryColor }: WfoTheme) => {
backgroundColor: theme.colors.lightestShade,
});

const panelStyleOutsideCurrentSubscription = css({
backgroundColor: toSecondaryColor(theme.colors.lightestShade),
border: `dashed 1px ${theme.colors.lightShade}`,
});

const rowStyle = css({
'&:first-child': {
borderTop: `solid 1px ${theme.colors.lightShade}`,
@@ -45,5 +51,6 @@ export const getStyles = ({ theme, toSecondaryColor }: WfoTheme) => {
leftColumnStyle,
rightColumnStyle,
rowStyle,
panelStyleOutsideCurrentSubscription,
};
};
Original file line number Diff line number Diff line change
@@ -12,17 +12,12 @@ import {

import { TreeContext, TreeContextType } from '@/contexts';
import { useOrchestratorTheme, useWithOrchestratorTheme } from '@/hooks';
import { TreeBlock } from '@/types';

import { getStyles } from './styles';

type Item = {
id: number;
icon: string;
label: string | number | boolean;
};

type WfoTreeNodeProps = {
item: Item;
item: TreeBlock;
hasChildren: boolean;
level: number;
};
@@ -33,8 +28,11 @@ export const WfoTreeNode: FC<WfoTreeNodeProps> = ({
level,
}) => {
const { theme } = useOrchestratorTheme();
const { expandIconContainerStyle, treeContainerStyle } =
useWithOrchestratorTheme(getStyles);
const {
expandIconContainerStyle,
treeContainerStyle,
treeItemOtherSubscriptionStyle,
} = useWithOrchestratorTheme(getStyles);
const t = useTranslations('common');
const {
expandedIds,
@@ -83,13 +81,23 @@ export const WfoTreeNode: FC<WfoTreeNodeProps> = ({
'aria-label': t('deselect'),
alwaysShow: true,
}}
css={
item.isOutsideCurrentSubscription &&
treeItemOtherSubscriptionStyle
}
/>
) : (
<EuiListGroupItem
onClick={() => toggleSelectedId(item.id)}
label={item.label}
isActive={selected}
style={{ borderRadius: 6 }}
style={{
borderRadius: 6,
}}
css={
item.isOutsideCurrentSubscription &&
treeItemOtherSubscriptionStyle
}
/>
)}
</EuiFlexItem>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { WfoTheme } from '@/hooks';
import type { WfoTheme } from '@/hooks';

export const getStyles = ({ theme }: WfoTheme) => {
export const getStyles = (wfoTheme: WfoTheme) => {
const { theme, toSecondaryColor } = wfoTheme;
const expandIconContainerStyle = {
cursor: 'pointer',
};
@@ -11,8 +12,14 @@ export const getStyles = ({ theme }: WfoTheme) => {
marginRight: `-${theme.size.s}`,
};

const treeItemOtherSubscriptionStyle = {
backgroundColor: toSecondaryColor(theme.colors.lightestShade),
border: `thin dashed ${theme.colors.lightShade}`,
};

return {
expandIconContainerStyle: expandIconContainerStyle,
treeContainerStyle: treeContainerStyle,
treeItemOtherSubscriptionStyle,
};
};
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ describe('getWfoTreeNodeDepth', () => {
callback: jest.fn(),
productBlockInstanceValues: [field],
inUseByRelations: [],
isOutsideCurrentSubscription: false,
children: [
{
id: 2,
@@ -25,6 +26,7 @@ describe('getWfoTreeNodeDepth', () => {
productBlockInstanceValues: [field],
inUseByRelations: [],
children: [],
isOutsideCurrentSubscription: false,
},
{
id: 3,
@@ -36,6 +38,7 @@ describe('getWfoTreeNodeDepth', () => {
callback: jest.fn(),
productBlockInstanceValues: [field],
inUseByRelations: [],
isOutsideCurrentSubscription: false,
children: [
{
id: 4,
@@ -48,6 +51,7 @@ describe('getWfoTreeNodeDepth', () => {
productBlockInstanceValues: [field],
inUseByRelations: [],
children: [],
isOutsideCurrentSubscription: false,
},
],
},
@@ -91,6 +95,7 @@ describe('getWfoTreeNodeDepth', () => {
productBlockInstanceValues: [field],
inUseByRelations: [],
children: [],
isOutsideCurrentSubscription: false,
};

expect(() =>
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { WfoTheme, useOrchestratorTheme } from './useOrchestratorTheme';
import { useOrchestratorTheme } from './useOrchestratorTheme';
import type { WfoTheme } from './useOrchestratorTheme';

export function useWithOrchestratorTheme<T>(
getStylesFunction: (wfoTheme: WfoTheme) => T,
getStylesFunction: (theme: WfoTheme) => T,
) {
return getStylesFunction(useOrchestratorTheme());
const wfoTheme = useOrchestratorTheme();
return getStylesFunction(wfoTheme);
}
1 change: 1 addition & 0 deletions packages/orchestrator-ui-components/src/types/types.ts
Original file line number Diff line number Diff line change
@@ -92,6 +92,7 @@ export interface TreeBlock extends ProductBlockInstance {
label: string | number | boolean;
callback: () => void;
children: TreeBlock[];
isOutsideCurrentSubscription: boolean;
}

export interface ProductDefinition {