1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

chore: useProject cleanup (#6700)

This commit is contained in:
Jaanus Sellin 2024-03-27 10:28:43 +02:00 committed by GitHub
parent 4271c6ff74
commit f89c2aa829
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 8 additions and 14 deletions

View File

@ -9,7 +9,7 @@ import { InactiveUsersList } from './InactiveUsersList/InactiveUsersList';
import { AccessMatrix } from './AccessMatrix/AccessMatrix'; import { AccessMatrix } from './AccessMatrix/AccessMatrix';
import { PremiumFeature } from '../../common/PremiumFeature/PremiumFeature'; import { PremiumFeature } from '../../common/PremiumFeature/PremiumFeature';
import { ConditionallyRender } from '../../common/ConditionallyRender/ConditionallyRender'; import { ConditionallyRender } from '../../common/ConditionallyRender/ConditionallyRender';
import useUiConfig from '../../../hooks/api/getters/useUiConfig/useUiConfig'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
export const UsersAdmin = () => { export const UsersAdmin = () => {
const { isEnterprise } = useUiConfig(); const { isEnterprise } = useUiConfig();

View File

@ -1,4 +1,4 @@
import { useUiFlag } from '../../../hooks/useUiFlag'; import { useUiFlag } from 'hooks/useUiFlag';
import { ConditionallyRender } from '../../common/ConditionallyRender/ConditionallyRender'; import { ConditionallyRender } from '../../common/ConditionallyRender/ConditionallyRender';
import { Banner } from '../Banner/Banner'; import { Banner } from '../Banner/Banner';
import type { IBanner } from '../../../interfaces/banner'; import type { IBanner } from '../../../interfaces/banner';

View File

@ -15,7 +15,7 @@ import { StickyProvider } from 'component/common/Sticky/StickyProvider';
const server = testServerSetup(); const server = testServerSetup();
const projectWithCollaborationMode = (mode: ProjectMode) => const projectWithCollaborationMode = (mode: ProjectMode) =>
testServerRoute(server, '/api/admin/projects/default', { mode }); testServerRoute(server, '/api/admin/projects/default/overview', { mode });
const changeRequestsEnabledIn = ( const changeRequestsEnabledIn = (
env: 'development' | 'production' | 'custom', env: 'development' | 'production' | 'custom',

View File

@ -22,8 +22,8 @@ import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi';
import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; import { useFeature } from 'hooks/api/getters/useFeature/useFeature';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
import useProject from 'hooks/api/getters/useProject/useProject';
import { FeatureNamingPatternInfo } from '../FeatureNamingPatternInfo/FeatureNamingPatternInfo'; import { FeatureNamingPatternInfo } from '../FeatureNamingPatternInfo/FeatureNamingPatternInfo';
import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview';
const StyledPage = styled(Paper)(({ theme }) => ({ const StyledPage = styled(Paper)(({ theme }) => ({
overflow: 'visible', overflow: 'visible',
@ -81,7 +81,7 @@ export const CopyFeatureToggle = () => {
const { const {
project: { featureNaming }, project: { featureNaming },
} = useProject(projectId); } = useProjectOverview(projectId);
const setValue: ChangeEventHandler<HTMLInputElement> = (event) => { const setValue: ChangeEventHandler<HTMLInputElement> = (event) => {
const value = trim(event.target.value); const value = trim(event.target.value);

View File

@ -7,7 +7,6 @@ import type { FeatureSchema } from 'openapi';
import { formatUnknownError } from 'utils/formatUnknownError'; import { formatUnknownError } from 'utils/formatUnknownError';
import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi'; import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi';
import useProject from 'hooks/api/getters/useProject/useProject';
import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi'; import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi';
import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests';
@ -43,7 +42,6 @@ export const BulkDisableDialog = ({
const [selected, setSelected] = useState(environments[0]); const [selected, setSelected] = useState(environments[0]);
const { bulkToggleFeaturesEnvironmentOff } = useFeatureApi(); const { bulkToggleFeaturesEnvironmentOff } = useFeatureApi();
const { addChange } = useChangeRequestApi(); const { addChange } = useChangeRequestApi();
const { refetch: refetchProject } = useProject(projectId);
const { setToastApiError, setToastData } = useToast(); const { setToastApiError, setToastData } = useToast();
const { isChangeRequestConfigured } = useChangeRequestsEnabled(projectId); const { isChangeRequestConfigured } = useChangeRequestsEnabled(projectId);
const { refetch: refetchChangeRequests } = const { refetch: refetchChangeRequests } =
@ -85,7 +83,6 @@ export const BulkDisableDialog = ({
data.map((feature) => feature.name), data.map((feature) => feature.name),
selected, selected,
); );
refetchProject();
setToastData({ setToastData({
text: 'Your feature toggles have been disabled', text: 'Your feature toggles have been disabled',
type: 'success', type: 'success',

View File

@ -21,7 +21,6 @@ import {
useNavigate, useNavigate,
} from 'react-router-dom'; } from 'react-router-dom';
import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; import { useFeature } from 'hooks/api/getters/useFeature/useFeature';
import useProject from 'hooks/api/getters/useProject/useProject';
import { import {
CREATE_FEATURE, CREATE_FEATURE,
DELETE_FEATURE, DELETE_FEATURE,
@ -137,7 +136,6 @@ export const StyledLink = styled(Link)(({ theme }) => ({
export const FeatureView = () => { export const FeatureView = () => {
const projectId = useRequiredPathParam('projectId'); const projectId = useRequiredPathParam('projectId');
const featureId = useRequiredPathParam('featureId'); const featureId = useRequiredPathParam('featureId');
const { refetch: projectRefetch } = useProject(projectId);
const { favorite, unfavorite } = useFavoriteFeaturesApi(); const { favorite, unfavorite } = useFavoriteFeaturesApi();
const { refetchFeature } = useFeature(projectId, featureId); const { refetchFeature } = useFeature(projectId, featureId);
const { setToastData, setToastApiError } = useToast(); const { setToastData, setToastApiError } = useToast();
@ -379,7 +377,6 @@ export const FeatureView = () => {
<FeatureArchiveDialog <FeatureArchiveDialog
isOpen={showDelDialog} isOpen={showDelDialog}
onConfirm={() => { onConfirm={() => {
projectRefetch();
navigate(`/projects/${projectId}`); navigate(`/projects/${projectId}`);
}} }}
onClose={() => setShowDelDialog(false)} onClose={() => setShowDelDialog(false)}

View File

@ -4,7 +4,7 @@ import { Box, Button } from '@mui/material';
import { Dialogue } from 'component/common/Dialogue/Dialogue'; import { Dialogue } from 'component/common/Dialogue/Dialogue';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import useUiConfig from '../../../hooks/api/getters/useUiConfig/useUiConfig'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
interface IErrorProps { interface IErrorProps {
error: Error; error: Error;

View File

@ -9,7 +9,7 @@ import {
UPDATE_FEATURE_STRATEGY, UPDATE_FEATURE_STRATEGY,
} from '../component/providers/AccessProvider/permissions'; } from '../component/providers/AccessProvider/permissions';
import { useAuthPermissions } from './api/getters/useAuth/useAuthPermissions'; import { useAuthPermissions } from './api/getters/useAuth/useAuthPermissions';
import useProject from './api/getters/useProject/useProject'; import useProjectOverview from './api/getters/useProjectOverview/useProjectOverview';
/** /**
* This is for features not integrated with change request. * This is for features not integrated with change request.
@ -90,7 +90,7 @@ const useIsProjectMember = (projectId: string) => {
const useIsAllowedUser = (projectId: string) => { const useIsAllowedUser = (projectId: string) => {
const isProjectMember = useIsProjectMember(projectId); const isProjectMember = useIsProjectMember(projectId);
const { project } = useProject(projectId); const { project } = useProjectOverview(projectId);
const isProtectedProject = project.mode === 'protected'; const isProtectedProject = project.mode === 'protected';
return isProtectedProject ? isProjectMember : true; return isProtectedProject ? isProjectMember : true;
}; };