Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Merge branch 'circle-list' of https://github.com/ZupIT/charlescd into…
Browse files Browse the repository at this point in the history
… circle-list
  • Loading branch information
icaroafonsozup committed May 13, 2021
2 parents 9b420f5 + e3277a7 commit 762146c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
13 changes: 13 additions & 0 deletions ui/src/core/providers/circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,16 @@ export const findAllCirclesWithoutActive = (

return baseRequest(`${endpoint}?${params}`);
};

export const findAllCirclesSimple = (
filter: CircleFilter = initialCircleFilter,
except: string
) => {
const params = new URLSearchParams({
size: `${DEFAULT_PAGE_SIZE}`,
name: filter?.name,
except: except
});

return baseRequest(`${endpoint}/simple?${params}`);
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import isUndefined from 'lodash/isUndefined';
import Styled from './styled';
import CustomOption from 'core/components/Form/Select/CustomOptions';
import debounce from 'debounce-promise';
import { useCircle, useCirclesActive } from 'modules/Circles/hooks';
import { useCircle, useCircleSimple } from 'modules/Circles/hooks';
import { normalizeSelectOptions } from 'core/utils/select';
import {
createActionPayload,
Expand Down Expand Up @@ -61,7 +61,7 @@ const AddAction = ({ onGoBack, metricsGroup, circleId, action }: Props) => {
const [selectedAction, setSelectedAction] = useState('');
const [isSaving, setIsSaving] = useState(false);
const [currentCircleOptions, setCurrentCircleOptions] = useState([]);
const { getCirclesData } = useCirclesActive();
const { getCirclesSimple } = useCircleSimple();
const {
getActionGroup,
actionData,
Expand Down Expand Up @@ -128,10 +128,10 @@ const AddAction = ({ onGoBack, metricsGroup, circleId, action }: Props) => {

const loadCirclesByName = debounce(
name =>
getCirclesData({ name }).then(response => {
getCirclesSimple({ name }).then(response => {
const options = normalizeSelectOptions(response.content);
setCurrentCircleOptions(options);
return options;
return options;
}
),
500
Expand Down
13 changes: 12 additions & 1 deletion ui/src/modules/Circles/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
updateCircleManually,
findAllCirclesWithoutActive,
updateCirclePercentage,
createCirclePercentage
createCirclePercentage,
findAllCirclesSimple
} from 'core/providers/circle';
import { undeploy } from 'core/providers/deployment';
import { useDispatch } from 'core/state/hooks';
Expand Down Expand Up @@ -182,6 +183,16 @@ export const useCirclesActive = () => {
};
};

export const useCircleSimple = () => {
const getCirclesSimple = useFetchData<Pagination<Circle>>(
findAllCirclesSimple
);

return {
getCirclesSimple
};
};

export const useCircles = (
type: CIRCLE_TYPES
): [boolean, Function, Function, CirclePagination] => {
Expand Down

0 comments on commit 762146c

Please sign in to comment.