Skip to content

Commit

Permalink
UI5 Tokens (#2578)
Browse files Browse the repository at this point in the history
* replaced Tokens and adjusted css

* bump deployment

* fix namespace tests

* fix component tests

* remove unnecessary ts-ignore
  • Loading branch information
chriskari authored Sep 19, 2023
1 parent 966e07d commit ab727d5
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 83 deletions.
2 changes: 1 addition & 1 deletion resources/backend/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
spec:
containers:
- name: backend
image: europe-docker.pkg.dev/kyma-project/dev/busola-backend:PR-2579
image: europe-docker.pkg.dev/kyma-project/dev/busola-backend:PR-2578
imagePullPolicy: Always
resources:
limits:
Expand Down
2 changes: 1 addition & 1 deletion resources/web/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: busola
image: europe-docker.pkg.dev/kyma-project/dev/busola-web:PR-2579
image: europe-docker.pkg.dev/kyma-project/dev/busola-web:PR-2578
imagePullPolicy: Always
resources:
requests:
Expand Down
20 changes: 11 additions & 9 deletions src/command-pallette/CommandPalletteUI/components/components.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Button } from '@ui5/webcomponents-react';
import { Token } from 'fundamental-react';
import { Button, Icon, Token } from '@ui5/webcomponents-react';
import { Trans, useTranslation } from 'react-i18next';
import { EMPTY_TEXT_PLACEHOLDER } from 'shared/constants';
import './components.scss';
Expand Down Expand Up @@ -46,13 +45,16 @@ export function NamespaceContextDisplay({
<div className="namespace-context">
<span className="namespace-name">{t('namespaces.name_singular')}:</span>
<Token
// @ts-ignore fd-react types are wrong yet again
buttonLabel={t('command-palette.search.remove-ns-context')}
className="y-fd-token y-fd-token--no-button y-fd-token--gap fd-margin-end--tiny fd-margin-begin--tiny"
onClick={() => setNamespaceContext(null)}
>
{namespaceContext}
</Token>
className="fd-margin-end--tiny fd-margin-begin--tiny"
text={namespaceContext}
closeIcon={
<Icon
name="decline"
onClick={() => setNamespaceContext(null)}
aria-label={t('command-palette.search.remove-ns-context')}
/>
}
/>
</div>
);
}
Expand Down
15 changes: 6 additions & 9 deletions src/shared/components/Labels/Labels.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import classNames from 'classnames';
import { EMPTY_TEXT_PLACEHOLDER } from 'shared/constants';
import { Token } from '@ui5/webcomponents-react';
import './Labels.scss';

const SHORTENING_TRESHOLD = 60;
Expand All @@ -25,23 +26,19 @@ export const Labels = ({
return (
<div className={classNames('labels', className)}>
{separatedLabels.map((label, id) => (
<span
<Token
aria-label={label}
className="fd-token fd-token--readonly"
key={id}
className="token fd-margin-end--tiny"
readOnly
text={label}
title={
(shortenLongLabels &&
label.length > SHORTENING_TRESHOLD &&
label) ||
undefined
}
>
<span className="fd-token__text fd-has-font-size-small">
{shortenLongLabels && label.length > SHORTENING_TRESHOLD
? shortenLabel(label)
: label}
</span>
</span>
/>
))}
</div>
);
Expand Down
12 changes: 4 additions & 8 deletions src/shared/components/Labels/Labels.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
.labels {
display: flex;
flex-wrap: wrap;
}

.fd-token {
margin-bottom: 4px;
margin-right: 4px;
white-space: normal;
height: auto;
line-height: 1rem;
padding: 0.25rem 0.4rem !important;
}
.token {
margin-top: 4px;
margin-bottom: 4px;
}
6 changes: 4 additions & 2 deletions src/shared/components/Labels/test/Labels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { render } from '@testing-library/react';

describe('Labels', () => {
it('Labels should render with labels', () => {
const { queryByText } = render(
const { container } = render(
<Labels labels={{ testLabel: 'testValue' }} />,
);

expect(queryByText('testLabel=testValue')).toBeInTheDocument();
expect(
container.querySelector("[text='testLabel=testValue']"),
).toBeInTheDocument();
});
});
16 changes: 9 additions & 7 deletions src/shared/components/Selector/tests/Selector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Selector tests', () => {
},
};

const { getByText } = render(
const { container, getByText } = render(
<ThemeProvider>
<Selector
selector={mockedSelector}
Expand All @@ -48,7 +48,7 @@ describe('Selector tests', () => {
);

expect(getByText('Related Pods for test-namespace')).toBeInTheDocument();
expect(getByText('test=test')).toBeInTheDocument(); // selector labels
expect(container.querySelector("[text='test=test']")).toBeInTheDocument(); // selector labels
});

it('Renders Selector with matchExpressions and without pods list', () => {
Expand All @@ -61,7 +61,7 @@ describe('Selector tests', () => {
],
};

const { getByText } = render(
const { container, getByText } = render(
<ThemeProvider>
<Selector
selector={mockedSelector}
Expand All @@ -73,10 +73,12 @@ describe('Selector tests', () => {
);

expect(getByText('match-expressions.title')).toBeInTheDocument(); //title of the matchExpressions table
expect(getByText('test=test')).toBeInTheDocument();
expect(container.querySelector("[text='test=test']")).toBeInTheDocument();
expect(getByText('test-key')).toBeInTheDocument(); // matchExpressions elements
expect(getByText('In')).toBeInTheDocument();
expect(getByText('test-value')).toBeInTheDocument();
expect(
container.querySelector("[text='test-value']"),
).toBeInTheDocument();
});

it('Renders custom message when selector labels are null ', () => {
Expand Down Expand Up @@ -149,7 +151,7 @@ describe('Selector tests', () => {
},
};

const { getByText } = render(
const { container, getByText } = render(
<ThemeProvider>
<Selector
selector={mockedSelector}
Expand All @@ -162,7 +164,7 @@ describe('Selector tests', () => {
);

expect(getByText('Custom Resources')).toBeInTheDocument();
expect(getByText('test=test')).toBeInTheDocument();
expect(container.querySelector("[text='test=test']")).toBeInTheDocument();
});
});
});
16 changes: 7 additions & 9 deletions src/shared/components/Tokens.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import React from 'react';

import { Token } from 'fundamental-react';
import { Token } from '@ui5/webcomponents-react';
import { EMPTY_TEXT_PLACEHOLDER } from 'shared/constants';

const Tokens = ({ tokens }) => (
<div>
<>
{tokens?.length
? tokens.map(scope => (
<Token
key={scope}
buttonLabel=""
className="y-fd-token y-fd-token--no-button y-fd-token--gap fd-margin-end--tiny"
readOnly={true}
>
{scope}
</Token>
className="fd-margin-end--tiny"
readOnly
text={scope}
/>
))
: EMPTY_TEXT_PLACEHOLDER}
</div>
</>
);

export { Tokens };
33 changes: 0 additions & 33 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,6 @@ body {
margin-right: 0.2rem;
}

.fd-token {
font-size: 0.75rem !important;
flex: none !important;
padding: 0 8px !important;

&--readonly {
.fd-token__close {
display: none !important;
}

&::after {
content: none !important;
}

&:hover {
background-color: initial !important;
border-color: initial !important;
}
}

.fd-token__close {
padding-right: 0;
display: inline;
}
}

.fd-dialog,
.fd-panel,
.fd-action-bar {
Expand Down Expand Up @@ -204,13 +178,6 @@ li {
visibility: hidden !important;
}

.no-dismiss-tokens {
.fd-token::after,
&.fd-token::after {
content: none !important;
}
}

.clearfix::after {
content: '';
clear: both;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ context('Test Protected Resources', () => {
.contains('Config Maps')
.click();

cy.get('ui5-table-row')
cy.get('a.fd-link')
.contains(NAME)
.click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ context('Test reduced permissions 2', () => {

cy.get('[aria-label="search-input"]').type('kube-public');

cy.get('[role="row"]')
cy.get('a.fd-link')
.contains('kube-public')
.click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ context('Test reduced permissions', () => {
.contains('Service Accounts')
.click();

cy.contains(SA_NAME).click();
cy.get('a.fd-link')
.contains(SA_NAME)
.click();

cy.contains('Generate TokenRequest').click();

Expand Down
4 changes: 3 additions & 1 deletion tests/integration/tests/namespace/test-replica-sets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ context('Test Replica Sets', () => {
.contains('Replica Sets')
.click();

cy.contains(REPLICA_SET_NAME).click();
cy.get('a.fd-link')
.contains(REPLICA_SET_NAME)
.click();

cy.contains(REPLICA_SET_NAME);
});
Expand Down

0 comments on commit ab727d5

Please sign in to comment.