Skip to content

Commit

Permalink
ui improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish8689 committed Aug 11, 2024
1 parent eb3cdda commit e17b4dd
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const TagsV1 = ({
{...tagProps}>
{/* Wrap only content to avoid redirect on closeable icons */}
<Link
className="no-underline h-full"
className="no-underline h-full w-full"
data-testid="tag-redirect-link"
to={redirectLink}>
{tagContent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ const TestConnectionModal: FC<TestConnectionModalProps> = ({
width={748}
onCancel={onCancel}
onOk={onConfirm}>
<Space className="p-x-md w-full" direction="vertical" size={16}>
<Space
className="p-x-md w-full overflow-hidden"
direction="vertical"
size={16}>
<Progress
className="test-connection-progress-bar"
format={getProgressFormat}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ export const TRANSPORTATION_STRATEGY_OPTIONS = Object.values(
label: strategy,
value: strategy,
}));

export const NOT_INCLUDE_EMAIL_CONFIG_VALUE = ['templates'];
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import PageHeader from '../../components/PageHeader/PageHeader.component';
import PageLayoutV1 from '../../components/PageLayoutV1/PageLayoutV1';
import TestEmail from '../../components/Settings/Email/TestEmail/TestEmail.component';
import { ROUTES } from '../../constants/constants';
import { NOT_INCLUDE_EMAIL_CONFIG_VALUE } from '../../constants/EmailConfig.constants';
import { GlobalSettingsMenuCategory } from '../../constants/GlobalSettings.constants';
import { ERROR_PLACEHOLDER_TYPE } from '../../enums/common.enum';
import { SMTPSettings } from '../../generated/email/smtpSettings';
Expand Down Expand Up @@ -90,32 +91,34 @@ function EmailConfigSettingsPage() {

const emailConfigFieldsArray = Object.keys(emailConfigValues).sort();

return emailConfigFieldsArray.map((configValue) => {
const title = getEmailConfigFieldLabels(configValue);
const emailConfigValue =
emailConfigValues[configValue as keyof SMTPSettings];
const displayValue =
isBoolean(emailConfigValue) || isNumber(emailConfigValue)
? `${emailConfigValue}`
: emailConfigValue;

return (
<Col key={title} span={12}>
<Row align="middle">
<Col span={24}>
<Typography.Text className="m-0 text-grey-muted">
{`${title}:`}
</Typography.Text>
</Col>
<Col span={24}>
<Typography.Text className="">
{isEmpty(displayValue) ? '--' : displayValue}
</Typography.Text>
</Col>
</Row>
</Col>
);
});
return emailConfigFieldsArray
.filter((value) => !NOT_INCLUDE_EMAIL_CONFIG_VALUE.includes(value))
.map((configValue) => {
const title = getEmailConfigFieldLabels(configValue);
const emailConfigValue =
emailConfigValues[configValue as keyof SMTPSettings];
const displayValue =
isBoolean(emailConfigValue) || isNumber(emailConfigValue)
? `${emailConfigValue}`
: emailConfigValue;

return (
<Col key={title} span={12}>
<Row align="middle">
<Col span={24}>
<Typography.Text className="m-0 text-grey-muted">
{`${title}:`}
</Typography.Text>
</Col>
<Col span={24}>
<Typography.Text className="">
{isEmpty(displayValue) ? '--' : displayValue}
</Typography.Text>
</Col>
</Row>
</Col>
);
});
}, [emailConfigValues]);

const configValuesContainer = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from '@testing-library/react';
import React, { ReactNode } from 'react';
import { deleteTag, getAllClassifications } from '../../rest/tagAPI';
import { checkPermission } from '../../utils/PermissionsUtils';
import { getClassifications } from '../../utils/TagsUtils';
import TagsPage from './TagsPage';
import {
Expand Down Expand Up @@ -517,6 +518,14 @@ describe('Test TagsPage page', () => {
expect(tagsComponent).toBeInTheDocument();
});

it("Should not render add classification button if doesn't have create permission", async () => {
(checkPermission as jest.Mock).mockReturnValueOnce(false);

render(<TagsPage />);

expect(screen.queryByTestId('add-classification')).not.toBeInTheDocument();
});

describe('Render Sad Paths', () => {
it.skip('Show error message on failing of deleteTag API', async () => {
(deleteTag as jest.Mock).mockImplementationOnce(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,31 +544,28 @@ const TagsPage = () => {
<Typography.Text className="text-sm font-semibold">
{t('label.classification-plural')}
</Typography.Text>
<Tooltip
title={
!createClassificationPermission &&
t('message.no-permission-for-action')
}>
<Button
block
className=" text-primary"
data-testid="add-classification"
disabled={!createClassificationPermission}
onClick={() => {
setIsAddingClassification((prevState) => !prevState);
}}>
<div className="d-flex items-center justify-center">
<PlusIcon className="anticon" />
<Typography.Text
className="p-l-xss"
ellipsis={{ tooltip: true }}>
{t('label.add-entity', {
entity: t('label.classification'),
})}
</Typography.Text>
</div>
</Button>
</Tooltip>
{createClassificationPermission && (
<Tooltip title={t('message.no-permission-for-action')}>
<Button
block
className=" text-primary"
data-testid="add-classification"
onClick={() => {
setIsAddingClassification((prevState) => !prevState);
}}>
<div className="d-flex items-center justify-center">
<PlusIcon className="anticon" />
<Typography.Text
className="p-l-xss"
ellipsis={{ tooltip: true }}>
{t('label.add-entity', {
entity: t('label.classification'),
})}
</Typography.Text>
</div>
</Button>
</Tooltip>
)}
</Space>

{classifications.map((category: Classification) => (
Expand Down

0 comments on commit e17b4dd

Please sign in to comment.