Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
3
Browse files Browse the repository at this point in the history
Signed-off-by: bCatanant <[email protected]>
  • Loading branch information
bCatanant committed May 14, 2021
1 parent 8ce6f89 commit 18d0ebe
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 34 deletions.
2 changes: 1 addition & 1 deletion ui/src/core/components/Form/Number/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

export const isNumber = (value: string) => /[0-9]/.test(value);
export const isNumber = (value: string) => /(\.|[0-9])/.test(value);

export const isIntoMax = (value: string, max: number) => parseInt(value) > max;
5 changes: 5 additions & 0 deletions ui/src/core/components/Page/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ export const PlaceholderCardItems = [
text: 'Go to Metrics',
linkTo: routes.metrics
},
{
icon: 'circles',
text: 'Go to Circles',
linkTo: routes.circles
},
];
67 changes: 37 additions & 30 deletions ui/src/core/components/Page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface Props {
title?: string;
subtitle?: string;
hasCards?: boolean;
currentPage?: string;
className?: string;
}

Expand Down Expand Up @@ -59,37 +60,43 @@ Page.Placeholder = ({
title,
subtitle,
hasCards,
currentPage,
children,
className
}: Props) => (
<Styled.Placeholder data-testid="page-placeholder" className={className}>
<Icon name={icon} />
<Styled.PlaceholderText>
{title && (
<Text.h1 color="dark" weight="bold" align="center">
{title}
</Text.h1>
)}
{subtitle && (
<Text.h1 color="dark" weight="bold" align="center">
{subtitle}
</Text.h1>
)}
</Styled.PlaceholderText>
{hasCards && (
<Styled.PlaceholderCardWrapper>
{map(PlaceholderCardItems, ({ icon, text, linkTo }: Action) => (
<Styled.PlaceholderCard to={linkTo} data-testid={icon} key={icon}>
<Icon name={icon} color="dark" size="15px" />
<Text.h4 color="dark" weight="bold">
{text}
</Text.h4>
</Styled.PlaceholderCard>
))}
</Styled.PlaceholderCardWrapper>
)}
{children}
</Styled.Placeholder>
);
}: Props) => {

return <Styled.Placeholder data-testid="page-placeholder" className={className}>
<Icon name={icon} />
<Styled.PlaceholderText>
{title && (
<Text.h1 color="dark" weight="bold" align="center">
{title}
</Text.h1>
)}
{subtitle && (
<Text.h1 color="dark" weight="bold" align="center">
{subtitle}
</Text.h1>
)}
</Styled.PlaceholderText>
{hasCards && (
<Styled.PlaceholderCardWrapper>
{map(PlaceholderCardItems, ({ icon, text, linkTo }: Action) => (
<>
{!(currentPage === icon) &&
<Styled.PlaceholderCard to={linkTo} data-testid={icon} key={icon}>
<Icon name={icon} color="dark" size="15px" />
<Text.h4 color="dark" weight="bold">
{text}
</Text.h4>
</Styled.PlaceholderCard>
}
</>
))}
</Styled.PlaceholderCardWrapper>
)}
{children}
</Styled.Placeholder>
};

export default Page;
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const AddAction = ({ onGoBack, metricsGroup, circleId, action }: Props) => {

const loadCirclesByName = debounce(
name =>
getCirclesSimple({ name }).then(response => {
getCirclesSimple({ name, circleId }).then(response => {
const options = normalizeSelectOptions(response.content);
setCurrentCircleOptions(options);
return options;
Expand Down
1 change: 1 addition & 0 deletions ui/src/modules/Circles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const Circles = () => {
icon="placeholder-circles"
title={`Welcome, ${profileName}! What do you like to do?`}
hasCards={true}
currentPage="circles"
/>
);

Expand Down
1 change: 1 addition & 0 deletions ui/src/modules/Metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const Metrics = () => {
icon="placeholder-metrics"
title={'Select the metric you want to view from the side menu.'}
hasCards={true}
currentPage="metrics"
/>
);

Expand Down
6 changes: 4 additions & 2 deletions ui/src/modules/Modules/Placeholder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@

import React from 'react';
import { getProfileByKey } from 'core/utils/profile';
import PlaceholderComponent from 'core/components/Placeholder';
import Page from 'core/components/Page';

const Placeholder = () => {
const profileName = getProfileByKey('name');

return (
<PlaceholderComponent
<Page.Placeholder
icon="empty-modules"
title={`Hello, ${profileName}!`}
subtitle="Select or create a module in the side menu."
hasCards={true}
currentPage="modules"
/>
);
};
Expand Down

0 comments on commit 18d0ebe

Please sign in to comment.