Skip to content

Commit 8c3489b

Browse files
committed
update database-collection
1 parent 4678b4d commit 8c3489b

File tree

3 files changed

+63
-10
lines changed

3 files changed

+63
-10
lines changed

packages/databases-collections-list/src/collections.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Collection = {
1919
index_size: number;
2020
properties: { id: string }[];
2121
source?: Collection;
22+
ns_source: 'provisioned' | 'privileges';
2223
};
2324

2425
const COLLECTION_CARD_WIDTH = spacing[6] * 4;
@@ -176,6 +177,7 @@ const CollectionsList: React.FunctionComponent<{
176177
name={coll.name}
177178
type="collection"
178179
status={coll.status}
180+
isProvisioned={coll.ns_source === 'provisioned'}
179181
data={data}
180182
badges={badges}
181183
onItemClick={onItemClick}

packages/databases-collections-list/src/databases.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Database = {
1313
data_size: number;
1414
index_count: number;
1515
collectionsLength: number;
16+
ns_source: 'provisioned' | 'privileges' | 'roles';
1617
};
1718

1819
const DATABASE_CARD_WIDTH = spacing[6] * 4;
@@ -68,6 +69,7 @@ const DatabasesList: React.FunctionComponent<{
6869
type="database"
6970
viewType={viewType}
7071
status={db.status}
72+
isProvisioned={db.ns_source === 'provisioned'}
7173
data={[
7274
{
7375
label: 'Storage size',

packages/databases-collections-list/src/namespace-card.tsx

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,29 @@ const cardTitleGroup = css({
3232
display: 'flex',
3333
alignItems: 'center',
3434
gap: spacing[3],
35-
marginBottom: spacing[2],
3635
});
3736

3837
const CardTitleGroup: React.FunctionComponent = ({ children }) => {
3938
return <div className={cardTitleGroup}>{children}</div>;
4039
};
4140

41+
const inactiveLightStyles = css({
42+
color: palette.gray.dark1,
43+
});
44+
45+
const inactiveDarkStyles = css({
46+
color: palette.gray.light1,
47+
});
48+
49+
const inactiveCardStyles = css({
50+
borderStyle: 'dashed',
51+
borderWidth: 2,
52+
});
53+
54+
const tooltipTriggerStyles = css({
55+
display: 'flex',
56+
});
57+
4258
const cardNameWrapper = css({
4359
// Workaround for uncollapsible text in flex children
4460
minWidth: 0,
@@ -64,15 +80,21 @@ const cardName = css({
6480
fontWeight: '600 !important' as unknown as number,
6581
});
6682

67-
const CardName: React.FunctionComponent<{ children: string }> = ({
68-
children,
69-
}) => {
83+
const CardName: React.FunctionComponent<{
84+
children: string;
85+
isProvisioned: boolean;
86+
}> = ({ children, isProvisioned }) => {
7087
const darkMode = useDarkMode();
7188
return (
7289
<div title={children} className={cardNameWrapper}>
7390
<Subtitle
7491
as="div"
75-
className={cx(cardName, darkMode ? cardNameDark : cardNameLight)}
92+
className={cx(
93+
cardName,
94+
darkMode ? cardNameDark : cardNameLight,
95+
!isProvisioned && !darkMode && inactiveLightStyles,
96+
!isProvisioned && darkMode && inactiveDarkStyles
97+
)}
7698
>
7799
{children}
78100
</Subtitle>
@@ -163,6 +185,7 @@ export type NamespaceItemCardProps = {
163185
status: 'initial' | 'fetching' | 'refreshing' | 'ready' | 'error';
164186
data: DataProp[];
165187
badges?: BadgeProp[] | null;
188+
isProvisioned: boolean;
166189
onItemClick(id: string): void;
167190
onItemDeleteClick?: (id: string) => void;
168191
};
@@ -195,9 +218,11 @@ export const NamespaceItemCard: React.FunctionComponent<
195218
onItemDeleteClick,
196219
badges = null,
197220
viewType,
221+
isProvisioned,
198222
...props
199223
}) => {
200224
const readOnly = usePreference('readOnly');
225+
const darkMode = useDarkMode();
201226
const [hoverProps, isHovered] = useHoverState();
202227
const [focusProps, focusState] = useFocusState();
203228

@@ -207,7 +232,7 @@ export const NamespaceItemCard: React.FunctionComponent<
207232

208233
const hasDeleteHandler = !!onItemDeleteClick;
209234
const cardActions: ItemAction<NamespaceAction>[] = useMemo(() => {
210-
return readOnly || !hasDeleteHandler
235+
return readOnly || !hasDeleteHandler || !isProvisioned
211236
? []
212237
: [
213238
{
@@ -216,7 +241,7 @@ export const NamespaceItemCard: React.FunctionComponent<
216241
icon: 'Trash',
217242
},
218243
];
219-
}, [type, readOnly, hasDeleteHandler]);
244+
}, [type, readOnly, isProvisioned, hasDeleteHandler]);
220245

221246
const defaultActionProps = useDefaultAction(onDefaultAction);
222247

@@ -238,7 +263,16 @@ export const NamespaceItemCard: React.FunctionComponent<
238263
);
239264

240265
const cardProps = mergeProps(
241-
{ className: card },
266+
{
267+
className: cx(
268+
card,
269+
!isProvisioned && [
270+
!darkMode && inactiveLightStyles,
271+
darkMode && inactiveDarkStyles,
272+
inactiveCardStyles,
273+
]
274+
),
275+
},
242276
defaultActionProps,
243277
hoverProps,
244278
focusProps,
@@ -262,7 +296,22 @@ export const NamespaceItemCard: React.FunctionComponent<
262296
{...cardProps}
263297
>
264298
<CardTitleGroup>
265-
<CardName>{name}</CardName>
299+
<CardName isProvisioned={isProvisioned}>{name}</CardName>
300+
301+
{!isProvisioned && (
302+
<Tooltip
303+
align="bottom"
304+
justify="start"
305+
trigger={
306+
<div className={tooltipTriggerStyles}>
307+
<Icon glyph={'InfoWithCircle'} />
308+
</div>
309+
}
310+
>
311+
You have privileges to this namespace, but it is not in your list of
312+
current namespaces
313+
</Tooltip>
314+
)}
266315

267316
{viewType === 'list' && badgesGroup}
268317

@@ -283,7 +332,7 @@ export const NamespaceItemCard: React.FunctionComponent<
283332
<NamespaceParam
284333
key={idx}
285334
label={label}
286-
hint={hint}
335+
hint={isProvisioned && hint}
287336
value={value}
288337
status={status}
289338
viewType={viewType}

0 commit comments

Comments
 (0)