Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
haneabogdan committed Nov 13, 2023
1 parent 7140c8f commit 9011566
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import usePressEnter from '@hooks/usePressEnter';
import {Option} from '@models/form';

import CustomSingleValue from '../CustomComponents/SingleValue';
import {DefaultDropdownIndicator, DefaultOptionComponent} from '../DefaultComponents';
import {DefaultClearIndicator, DefaultOptionComponent} from '../DefaultComponents';
import ClearIndicator from '../DefaultComponents/ClearIndicator';

Check warning on line 11 in packages/web/src/components/atoms/ReactSelect/CreatableSingleSelect/CreatableSingleSelect.tsx

View workflow job for this annotation

GitHub Actions / Lint (20)

'ClearIndicator' is defined but never used
import MultiValueRemove from '../DefaultComponents/MultiValueRemove';

Check warning on line 12 in packages/web/src/components/atoms/ReactSelect/CreatableSingleSelect/CreatableSingleSelect.tsx

View workflow job for this annotation

GitHub Actions / Lint (20)

'MultiValueRemove' is defined but never used
import {customSingleValueStyles, customTheme} from '../ReactSelect.styled';

type SingleSelectProps = {
Expand Down Expand Up @@ -59,13 +61,23 @@ const CreatableSingleSelect: React.FC<SingleSelectProps> = props => {
}
};

const selectionStyles = {
clearIndicator: (base: any, state: any) => ({
...base,
cursor: 'pointer',
color: state.isFocused ? 'red' : 'green',
fontWeight: 500,
}),
// Add more custom styles here if needed
};

return (
<CreatableSelect
ref={ref}
value={value}
defaultValue={defaultValue}
menuPlacement={menuPlacement}
isClearable={false}
isClearable
onChange={onChange}
placeholder={placeholder}
options={options}
Expand All @@ -80,11 +92,14 @@ const CreatableSingleSelect: React.FC<SingleSelectProps> = props => {
styles={customSingleValueStyles(validation, stylePlaceholderAsValue)}
components={{
Option: CustomOptionComponent,
DropdownIndicator: DefaultDropdownIndicator,
// removing default dropdown indicator
DropdownIndicator: () => null,
ClearIndicator: DefaultClearIndicator,
SingleValue: CustomSingleValue,
}}
data-test={dataTest}
isDisabled={disabled}
noOptionsMessage={() => null}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {ClearIndicatorProps, components} from 'react-select';

import {ReactComponent as RemoveIcon} from '@assets/closeCircle.svg';

import {Option} from '@models/form';

const ClearIndicator = (props: ClearIndicatorProps<Option>) => {
return (
<components.ClearIndicator {...props}>
<RemoveIcon width={16} height={16} />
</components.ClearIndicator>
);
};

export default ClearIndicator;
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export {default as DefaultMultiValueLabel} from './MultiValueLabel';
export {default as DefaultOptionComponent} from './Option';
export {default as DefaultMultiValueRemove} from './MultiValueRemove';
export {default as DefaultDropdownIndicator} from './DropdownIndicator';
export {default as DefaultClearIndicator} from './ClearIndicator';
2 changes: 2 additions & 0 deletions packages/web/src/plugins/test-sources/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type GeneralPlugin from '@plugins/general/plugin';
import type RtkPlugin from '@plugins/rtk/plugin';

import {repositoryApi} from '@services/repository';
import {secretsApi} from '@services/secrets';
import {sourcesApi, useGetSourcesQuery} from '@services/sources';

import {initializeSourcesStore, useSources, useSourcesField, useSourcesPick, useSourcesSync} from '@store/sources';
Expand Down Expand Up @@ -56,6 +57,7 @@ export default createPlugin('oss/test-sources')

.init(tk => {
tk.slots.rtkServices.add(sourcesApi);
tk.slots.rtkServices.add(secretsApi);
tk.slots.rtkServices.add(repositoryApi);

tk.slots.siderItems.add({path: '/sources', icon: SourcesIcon, title: 'Sources'}, {order: -20});
Expand Down
8 changes: 4 additions & 4 deletions packages/web/src/utils/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ export type GetSourceFormValues = {
export const getSourceFormValues = (entityDetails: Test, testSources: SourceWithRepository[]): GetSourceFormValues => {
const {content} = entityDetails;

if (!content?.type) {
return {source: ''};
}

if (entityDetails.source) {
const sourceDetails = testSources.find(source => source.name === entityDetails.source);

Expand All @@ -119,6 +115,10 @@ export const getSourceFormValues = (entityDetails: Test, testSources: SourceWith
};
}

if (!content?.type) {
return {source: ''};
}

if (content.type === 'string') {
return {
source: content.type,
Expand Down

0 comments on commit 9011566

Please sign in to comment.