Skip to content

Commit 52efa9e

Browse files
authored
RI-7463 sentinel databases rerender (#5126)
Updated design for Sentinel, pages both discovery page, and results page refactor common components to be used amongst the rest of the discovery pages Added stories, and test in the stories for the corresponding pages
1 parent e7e1412 commit 52efa9e

File tree

61 files changed

+1660
-924
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1660
-924
lines changed

.storybook/helpers/styles.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import styled from 'styled-components'
22
import { Theme } from 'uiSrc/components/base/theme/types'
3+
import PageBody from 'uiSrc/components/base/layout/page/PageBody'
34

4-
export const StyledContainer = styled.div`
5-
padding: 50px;
5+
export const StyledContainer = styled(PageBody)`
66
height: max-content;
7+
max-height: 100%;
78
overflow: hidden;
89
overflow-y: auto;
910
background-color: ${({ theme }: { theme: Theme }) =>

.storybook/preview-head.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
min-height: 100vh;
1414
}
1515

16+
#storybook-root {
17+
position: absolute;
18+
inset: 0;
19+
display: flex;
20+
flex-direction: column;
21+
}
22+
1623
.sbdocs-wrapper div:has(>div>.toc-wrapper){
1724
width:14rem;
1825
}

.storybook/preview.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { CommonStyles, themeDark, themeLight, themeOld } from '@redis-ui/styles'
99
import 'modern-normalize/modern-normalize.css'
1010
import '@redis-ui/styles/normalized-styles.css'
1111
import '@redis-ui/styles/fonts.css'
12+
import 'uiSrc/pages/home/styles.scss'
1213
import { RootStoryLayout } from './RootStoryLayout'
1314
import { StoryContextProvider } from './Story.context'
1415
import { useStoryContext } from 'storybook/internal/preview-api'
@@ -18,12 +19,13 @@ import { type Theme } from 'uiSrc/components/base/theme/types'
1819
import { Provider } from 'react-redux'
1920
import { store } from 'uiSrc/slices/store'
2021
import Router from 'uiSrc/Router'
22+
import { StyledContainer } from './helpers/styles'
2123

2224
const parameters: Parameters = {
2325
parameters: {
2426
layout: 'centered',
2527
},
26-
actions: { argTypesRegex: '^on[A-Z].*' },
28+
actions: { argTypesRegex: '^on.*' },
2729
controls: {
2830
disableSaveFromUI: true,
2931
matchers: {
@@ -51,7 +53,7 @@ const parameters: Parameters = {
5153
const GlobalStoryStyles = createGlobalStyle`
5254
.sb-show-main, .docs-story {
5355
background: ${({ theme }: { theme: Theme }) => theme.globals.body.bgColor};
54-
color: ${({ theme }: { theme: Theme }) => theme.globals.body.textColor};
56+
color: ${({ theme }: { theme: Theme }) => theme.components.typography.colors.primary};
5557
}
5658
`
5759

@@ -65,7 +67,9 @@ const preview: Preview = {
6567
<TooltipProvider>
6668
<RootStoryLayout storyContext={useStoryContext()}>
6769
<CommonStyles />
68-
<Story />
70+
<StyledContainer>
71+
<Story />
72+
</StyledContainer>
6973
</RootStoryLayout>
7074
</TooltipProvider>
7175
</Provider>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import React, { ReactNode } from 'react'
2+
3+
import { Col, FlexItem, Row } from 'uiSrc/components/base/layout/flex'
4+
import { EmptyButton } from 'uiSrc/components/base/forms/buttons'
5+
import { ChevronLeftIcon } from 'uiSrc/components/base/icons'
6+
import {
7+
PageSubTitle,
8+
PageTitle,
9+
SearchContainer,
10+
SearchForm,
11+
} from 'uiSrc/components/auto-discover/index'
12+
import { SearchInput } from 'uiSrc/components/base/inputs'
13+
14+
type HeaderProps = {
15+
title: ReactNode
16+
subTitle?: ReactNode
17+
onBack: () => void
18+
onQueryChange: (query: string) => void
19+
backButtonText?: string
20+
}
21+
export const Header = ({
22+
title,
23+
subTitle,
24+
onBack,
25+
onQueryChange,
26+
backButtonText = 'Add databases',
27+
}: HeaderProps) => {
28+
return (
29+
<Row align="center" justify="between" grow={false}>
30+
<Col align="start" justify="start" gap="m">
31+
<EmptyButton
32+
icon={ChevronLeftIcon}
33+
onClick={onBack}
34+
data-testid="btn-back-adding"
35+
>
36+
{backButtonText}
37+
</EmptyButton>
38+
<PageTitle color="primary" data-testid="title">
39+
{title}
40+
</PageTitle>
41+
{subTitle && (
42+
<FlexItem grow>
43+
<PageSubTitle>{subTitle}</PageSubTitle>
44+
</FlexItem>
45+
)}
46+
</Col>
47+
<Row justify="end" gap="s" grow={false}>
48+
<SearchContainer>
49+
<SearchForm>
50+
<SearchInput
51+
placeholder="Search..."
52+
onChange={onQueryChange}
53+
aria-label="Search"
54+
data-testid="search"
55+
/>
56+
</SearchForm>
57+
</SearchContainer>
58+
</Row>
59+
</Row>
60+
)
61+
}

redisinsight/ui/src/components/auto-discover/index.ts

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
import React from 'react'
12
import styled from 'styled-components'
23
import { Checkbox } from 'uiSrc/components/base/forms/checkbox/Checkbox'
34
import { Text, Title } from 'uiSrc/components/base/text'
45
import { Theme } from 'uiSrc/components/base/theme/types'
5-
import { FlexItem } from 'uiSrc/components/base/layout/flex'
6+
import { Col, FlexItem } from 'uiSrc/components/base/layout/flex'
67
import { FormField } from 'uiSrc/components/base/forms/FormField'
78
import { IconButton } from 'uiSrc/components/base/forms/buttons'
89
import { CopyIcon } from 'uiSrc/components/base/icons'
910

1011
export const PageTitle = styled(Title).attrs({
11-
size: 'M',
12+
size: 'L',
1213
})`
1314
padding-bottom: ${({ theme }: { theme: Theme }) => theme.core.space.space050};
1415
`
1516
export const PageSubTitle = styled(Text).attrs({
1617
size: 'S',
17-
color: 'subdued',
1818
component: 'span',
1919
})`
2020
padding-bottom: ${({ theme }: { theme: Theme }) => theme.core.space.space100};
@@ -26,12 +26,28 @@ export const SearchContainer = styled(FlexItem)`
2626
export const SearchForm = styled(FormField)`
2727
width: 266px;
2828
`
29-
export const Footer = styled(FlexItem).attrs({
30-
grow: false,
31-
})`
29+
export const Footer = styled(FlexItem).attrs<{
30+
grow?: boolean | number
31+
padding?: React.ComponentProps<typeof FlexItem>['padding']
32+
}>(({ grow, padding }) => ({
33+
grow: grow ?? false,
34+
padding: padding ?? 6,
35+
}))`
3236
border-top: 1px solid
3337
${({ theme }: { theme: Theme }) => theme.semantic.color.border.neutral400};
3438
`
39+
40+
export const DatabaseContainer = styled(Col)`
41+
position: relative;
42+
padding: ${({ theme }: { theme: Theme }) =>
43+
`${theme.core.space.space250} ${theme.core.space.space200} 0 ${theme.core.space.space200}`};
44+
@media only screen and (min-width: 768px) {
45+
padding: ${({ theme }: { theme: Theme }) =>
46+
`${theme.core.space.space400} ${theme.core.space.space200} 0 ${theme.core.space.space400}`};
47+
max-width: calc(100vw - 95px);
48+
}
49+
`
50+
3551
export const DatabaseWrapper = styled.div`
3652
height: auto;
3753
scrollbar-width: thin;
@@ -42,34 +58,36 @@ export const DatabaseWrapper = styled.div`
4258
theme.semantic.color.background.neutral100};
4359
flex-grow: 1;
4460
overflow: hidden;
45-
46-
.column_status {
47-
text-transform: capitalize;
48-
}
4961
`
5062
export const SelectAllCheckbox = styled(Checkbox)`
5163
& svg {
5264
margin: 0 !important;
5365
}
5466
`
5567
export const CellText = styled(Text).attrs({
56-
size: 'S',
68+
size: 'M',
5769
component: 'span',
58-
})``
59-
60-
export const CopyPublicEndpointText = styled(CellText)`
70+
})`
6171
max-width: 100%;
6272
display: inline-block;
6373
width: auto;
6474
white-space: nowrap;
6575
text-overflow: ellipsis;
6676
overflow: hidden;
77+
`
78+
79+
export const CopyPublicEndpointText = styled(CellText)`
6780
vertical-align: top;
6881
`
82+
83+
export const StatusColumnText = styled(CellText)`
84+
text-transform: capitalize;
85+
`
6986
export const CopyBtn = styled(IconButton).attrs({
7087
icon: CopyIcon,
88+
size: 'L',
7189
})`
72-
margin-left: 25px;
90+
margin-left: 15px;
7391
opacity: 0;
7492
height: 0;
7593
transition: opacity 0.25s ease-in-out;
@@ -83,8 +101,6 @@ export const CopyTextContainer = styled.div`
83101
padding-right: 34px;
84102
position: relative;
85103
* {
86-
color: ${({ theme }: { theme: Theme }) =>
87-
theme.semantic.color.text.primary500};
88104
}
89105
90106
&:hover ${CopyBtn} {

redisinsight/ui/src/components/base/forms/buttons/Button.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Button } from '@redis-ui/components'
22
import React from 'react'
33
import { LoaderLargeIcon } from 'uiSrc/components/base/icons'
44
import { BaseButtonProps } from 'uiSrc/components/base/forms/buttons/button.styles'
5+
import { Spacer } from 'uiSrc/components/base/layout'
6+
import styled from 'styled-components'
57

68
type ButtonSize = 'small' | 'medium' | 'large'
79
type SizeKey = 'small' | 's' | 'medium' | 'm' | 'large' | 'l'
@@ -59,7 +61,11 @@ export const IconSizes = {
5961
medium: '20px',
6062
large: '24px',
6163
}
62-
64+
const Wrapper = styled.div`
65+
svg {
66+
display: block;
67+
}
68+
`
6369
export const ButtonIcon = ({
6470
buttonSide,
6571
icon,
@@ -82,11 +88,12 @@ export const ButtonIcon = ({
8288
if (size) {
8389
iconSize = IconSizes[size]
8490
}
91+
const spacer = <Spacer size="s" direction="horizontal" />
8592
return (
86-
<Button.Icon
87-
title={`button-icon ${iconSide}`}
88-
icon={renderIcon}
89-
customSize={iconSize}
90-
/>
93+
<Wrapper>
94+
{buttonSide === 'right' && spacer}
95+
<Button.Icon icon={renderIcon} customSize={iconSize} />
96+
{buttonSide === 'left' && spacer}
97+
</Wrapper>
9198
)
9299
}

redisinsight/ui/src/components/base/icons/Icon.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { useTheme } from '@redis-ui/styles'
33
import cx from 'classnames'
44
import { IconSizeType } from '@redis-ui/icons'
55
import { MonochromeIconProps } from 'uiSrc/components/base/icons'
6+
import { Theme } from 'uiSrc/components/base/theme/types'
67

78
type BaseIconProps = Omit<MonochromeIconProps, 'color' | 'size'> & {
89
icon: React.ComponentType<any>
910
color?:
10-
| keyof ReturnType<typeof useTheme>['semantic']['color']['icon']
11+
| keyof Theme['semantic']['color']['icon']
1112
| 'currentColor'
1213
| (string & {})
1314
size?: IconSizeType | null
@@ -30,7 +31,7 @@ const sizesMap = {
3031
* @returns A boolean indicating if the color is valid and a type predicate
3132
*/
3233
function isValidIconColor(
33-
theme: ReturnType<typeof useTheme>,
34+
theme: Theme,
3435
color: string | number | symbol,
3536
): color is keyof typeof theme.semantic.color.icon {
3637
return color in theme.semantic.color.icon

0 commit comments

Comments
 (0)