Skip to content

Commit

Permalink
replaced select in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskari committed Sep 22, 2023
1 parent 85141c6 commit 39d9082
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
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-2576
image: europe-docker.pkg.dev/kyma-project/dev/busola-web:PR-2589
imagePullPolicy: Always
resources:
requests:
Expand Down
23 changes: 10 additions & 13 deletions src/components/Preferences/LanguageSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useSetRecoilState } from 'recoil';
import { Select } from 'fundamental-react';
import { Select, Option } from '@ui5/webcomponents-react';
import { languageAtom } from 'state/preferences/languageAtom';
import { Option } from 'fundamental-react/lib/Select/Select';

const AVAILABLE_LANGUAGES = [{ key: 'en', text: 'English' }];

export default function LanguageSettings() {
const { t, i18n } = useTranslation();
const { t } = useTranslation();
const setLanguage = useSetRecoilState(languageAtom);

const selectLanguage = (
event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>,
language: Option,
) => {
setLanguage(language.key);
const onChange = (event: any) => {
const selectedLanguage = event.detail.selectedOption.value;
setLanguage(selectedLanguage);
};

return (
<div className="preferences-row">
<span className="fd-has-color-status-4">{t('settings.language')}</span>
<Select
options={AVAILABLE_LANGUAGES}
selectedKey={i18n.language}
onSelect={selectLanguage}
/>
<Select onChange={onChange}>
{AVAILABLE_LANGUAGES.map(language => (
<Option value={language.key}>{language.text}</Option>
))}
</Select>
</div>
);
}
24 changes: 12 additions & 12 deletions src/components/Preferences/OtherSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { useTranslation } from 'react-i18next';
import { useRecoilState } from 'recoil';
import { Select } from 'fundamental-react';
import { useSetRecoilState } from 'recoil';
import { Select, Option } from '@ui5/webcomponents-react';
import { pageSizeState } from 'state/preferences/pageSizeAtom';
const AVAILABLE_PAGE_SIZES = [10, 20, 50];

export default function OtherSettings() {
const { t } = useTranslation();

const [pageSize, setPageSize] = useRecoilState(pageSizeState);
const setPageSize = useSetRecoilState(pageSizeState);

const pageSizeOptions = AVAILABLE_PAGE_SIZES.map(s => ({
key: s.toString(),
text: s.toString(),
}));
const onChange = (event: any) => {
const selectedSize = event.detail.selectedOption.value;
setPageSize(parseInt(selectedSize));
};

return (
<div className="preferences-row">
<span className="fd-has-color-status-4">
{t('settings.other.default-page-size')}
</span>
<Select
options={pageSizeOptions}
selectedKey={pageSize.toString()}
onSelect={(_, { key }) => setPageSize(parseInt(key))}
/>
<Select onChange={onChange}>
{AVAILABLE_PAGE_SIZES.map(size => (
<Option value={size.toString()}>{size.toString()}</Option>
))}
</Select>
</div>
);
}

0 comments on commit 39d9082

Please sign in to comment.