Skip to content

Commit

Permalink
fix(ChangelogDialog): add stories, fix locale, export type
Browse files Browse the repository at this point in the history
  • Loading branch information
Feverqwe committed Nov 14, 2023
1 parent 7b17aa7 commit 042599e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/components/ChangelogDialog/ChangelogDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Dialog, Icon, Link, Loader} from '@gravity-ui/uikit';

import {block} from '../utils/cn';

import ErrorContainer from './components/ErrorContainer/ErrorContainer';
import {ErrorContainer} from './components/ErrorContainer/ErrorContainer';
import {Item} from './components/Item/Item';
import i18n from './i18n';
import type {ChangelogItem} from './types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ const DefaultTemplate: StoryFn<ChangelogDialogProps> = (props: ChangelogDialogPr
};

export const Default = DefaultTemplate.bind({});

Default.args = {
open: false,
items,
Expand All @@ -129,3 +128,17 @@ Default.args = {
console.log('retry');
},
};

export const Loading = DefaultTemplate.bind({});
Loading.args = {
...Default.args,
open: true,
loading: true,
};

export const Error = DefaultTemplate.bind({});
Error.args = {
...Default.args,
open: true,
error: true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ $block: '.#{variables.$ns}changelog-dialog-error-container';
}

&__error-image {
color: var(--g-color-base-warning-heavy);
width: 32px;
height: 32px;
color: var(--g-color-text-warning);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {FC, useMemo} from 'react';

import {TriangleExclamation} from '@gravity-ui/icons';
import {Icon} from '@gravity-ui/uikit';

import {PlaceholderContainer} from '../../../PlaceholderContainer';
import {block} from '../../../utils/cn';
Expand All @@ -15,29 +16,27 @@ interface ErrorContainerProps {
error?: boolean | {title?: string; description?: string};
}

const ErrorContainer: FC<ErrorContainerProps> = ({onRetryClick, error}) => {
export const ErrorContainer: FC<ErrorContainerProps> = ({onRetryClick, error}) => {
const {title, description} = useMemo(() => {
return error && typeof error === 'object' ? error : {};
}, [error]);

return (
<PlaceholderContainer
size={'s'}
title={title || i18n('context_error-title')}
title={title || i18n('label_error-title')}
description={description}
image={
<div className={b('error-image-container')}>
<TriangleExclamation className={b('error-image')} />
<Icon data={TriangleExclamation} className={b('error-image')} size={32} />
</div>
}
action={
onRetryClick && {
text: i18n('action_retry'),
text: i18n('button_retry'),
handler: onRetryClick,
}
}
/>
);
};

export default ErrorContainer;
4 changes: 2 additions & 2 deletions src/components/ChangelogDialog/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"button_view_story": "View story",
"label_empty": "No data",
"action_read-more": "Read more",
"context_error-title": "Unable load changelog",
"action_retry": "Retry"
"label_error-title": "Unable load changelog",
"button_retry": "Retry"
}
4 changes: 2 additions & 2 deletions src/components/ChangelogDialog/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"button_view_story": "Посмотреть сториз",
"label_empty": "Нет данных",
"action_read-more": "Читать далее",
"context_error-title": "Не удалось загрузить список изменений",
"action_retry": "Повторить"
"label_error-title": "Не удалось загрузить список изменений",
"button_retry": "Повторить"
}

0 comments on commit 042599e

Please sign in to comment.