mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
refactor: remove unused code (#721)
This commit is contained in:
parent
84da61e334
commit
46bf92124d
@ -174,6 +174,3 @@ export const getDates = dateString => {
|
||||
|
||||
return [date, now];
|
||||
};
|
||||
|
||||
export const filterByProject = selectedProject => feature =>
|
||||
feature.project === selectedProject;
|
||||
|
@ -99,21 +99,6 @@ FormButtons.propTypes = {
|
||||
primaryButtonTestId: PropTypes.string,
|
||||
};
|
||||
|
||||
export function getIcon(type) {
|
||||
switch (type) {
|
||||
case 'feature-updated':
|
||||
return 'autorenew';
|
||||
case 'feature-created':
|
||||
return 'add';
|
||||
case 'feature-deleted':
|
||||
return 'remove';
|
||||
case 'feature-archived':
|
||||
return 'archived';
|
||||
default:
|
||||
return 'star';
|
||||
}
|
||||
}
|
||||
|
||||
export const IconLink = ({ url, icon: IconComponent }) => (
|
||||
<a
|
||||
href={url}
|
||||
@ -201,9 +186,6 @@ export function calc(value, total, decimal) {
|
||||
|
||||
return ((value / total) * 100).toFixed(decimal);
|
||||
}
|
||||
export function getDisplayName(WrappedComponent) {
|
||||
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
||||
}
|
||||
|
||||
export const selectStyles = {
|
||||
control: provided => ({
|
||||
|
@ -88,11 +88,6 @@ export function updateWeight(variants, totalWeight) {
|
||||
});
|
||||
}
|
||||
|
||||
export function loadNameFromUrl() {
|
||||
const params = new URLSearchParams(document.location.search);
|
||||
return params.get('name') || '';
|
||||
}
|
||||
|
||||
export const modalStyles = {
|
||||
overlay: {
|
||||
position: 'absolute',
|
||||
@ -115,9 +110,6 @@ export const modalStyles = {
|
||||
},
|
||||
};
|
||||
|
||||
export const updateIndexInArray = (array, index, newValue) =>
|
||||
array.map((v, i) => (i === index ? newValue : v));
|
||||
|
||||
export const showPnpsFeedback = (feedbackList) => {
|
||||
if (!feedbackList) return;
|
||||
if (feedbackList.length > 0) {
|
||||
|
@ -23,7 +23,6 @@ import useFeature from '../../../hooks/api/getters/useFeature/useFeature';
|
||||
import useUiConfig from '../../../hooks/api/getters/useUiConfig/useUiConfig';
|
||||
|
||||
export const CopyFeatureToggle = () => {
|
||||
// static displayName = `AddFeatureComponent-${getDisplayName(Component)}`;
|
||||
const [replaceGroupId, setReplaceGroupId] = useState(true);
|
||||
const [apiError, setApiError] = useState('');
|
||||
const [nameError, setNameError] = useState(undefined);
|
||||
|
@ -1,24 +0,0 @@
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
|
||||
export const useStyles = makeStyles(theme => ({
|
||||
container: {
|
||||
border: `1px solid ${theme.palette.grey[300]}`,
|
||||
borderRadius: '5px',
|
||||
width: '50%',
|
||||
marginLeft: '1rem',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
},
|
||||
headerContainer: {
|
||||
width: '100%',
|
||||
backgroundColor: '#efefef',
|
||||
},
|
||||
header: {
|
||||
color: '#000',
|
||||
textAlign: 'left',
|
||||
margin: '1rem 1.2rem',
|
||||
fontSize: theme.fontSizes.bodySize,
|
||||
fontWeight: 'normal',
|
||||
},
|
||||
}));
|
@ -1,50 +0,0 @@
|
||||
import { Fragment } from 'react';
|
||||
import { IFeatureStrategy } from '../../../../../../interfaces/strategy';
|
||||
import { useStyles } from './FeatureEnvironmentStrategyExecution.styles';
|
||||
import FeatureEnvironmentStrategyExecutionSeparator from './FeatureEnvironmentStrategyExecutionSeparator/FeatureEnvironmentStrategyExecutionSeparator';
|
||||
import FeatureEnvironmentStrategyExecutionWrapper from './FeatureEnvironmentStrategyExecutionWrapper/FeatureEnvironmentStrategyExecutionWrapper';
|
||||
|
||||
interface IFeatureEnvironmentStrategyExecutionProps {
|
||||
strategies: IFeatureStrategy[];
|
||||
}
|
||||
const FeatureEnvironmentStrategyExecution = ({
|
||||
strategies,
|
||||
env,
|
||||
}: IFeatureEnvironmentStrategyExecutionProps) => {
|
||||
const styles = useStyles();
|
||||
|
||||
const renderStrategies = () => {
|
||||
return strategies.map((strategy, index) => {
|
||||
if (index !== strategies.length - 1) {
|
||||
return (
|
||||
<Fragment key={strategy.id}>
|
||||
<FeatureEnvironmentStrategyExecutionWrapper
|
||||
strategyId={strategy.id}
|
||||
/>
|
||||
<FeatureEnvironmentStrategyExecutionSeparator />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<FeatureEnvironmentStrategyExecutionWrapper
|
||||
strategyId={strategy.id}
|
||||
key={strategy.id}
|
||||
/>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div className={styles.headerContainer}>
|
||||
<h6 className={styles.header}>
|
||||
Visual overview of your strategy configuration
|
||||
</h6>
|
||||
</div>
|
||||
|
||||
{renderStrategies()}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FeatureEnvironmentStrategyExecution;
|
@ -1,21 +0,0 @@
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
|
||||
export const useStyles = makeStyles(theme => ({
|
||||
container: {
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
height: '25px',
|
||||
marginTop: '1rem',
|
||||
},
|
||||
separatorBorder: {
|
||||
height: '1px',
|
||||
borderBottom: `2px dotted ${theme.palette.primary.main}`,
|
||||
width: '100%',
|
||||
top: '0',
|
||||
},
|
||||
textContainer: {
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
textPositioning: { position: 'absolute', top: '-20px', zIndex: 300 },
|
||||
}));
|
@ -1,17 +0,0 @@
|
||||
import FeatureStrategiesSeparator from '../../FeatureStrategiesSeparator/FeatureStrategiesSeparator';
|
||||
import { useStyles } from './FeatureEnvironmentStrategyExecutionSeparator.styles';
|
||||
|
||||
const FeatureEnvironmentStrategyExecutionSeparator = () => {
|
||||
const styles = useStyles();
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div className={styles.textContainer}>
|
||||
<div className={styles.textPositioning}>
|
||||
<FeatureStrategiesSeparator text="OR" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FeatureEnvironmentStrategyExecutionSeparator;
|
@ -1,50 +0,0 @@
|
||||
import { useContext } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import FeatureStrategiesUIContext from '../../../../../../../contexts/FeatureStrategiesUIContext';
|
||||
import useFeatureStrategy from '../../../../../../../hooks/api/getters/useFeatureStrategy/useFeatureStrategy';
|
||||
import { IFeatureViewParams } from '../../../../../../../interfaces/params';
|
||||
import FeatureStrategyExecution from '../../../FeatureStrategyExecution/FeatureStrategyExecution';
|
||||
|
||||
interface IFeatureEnvironmentStrategyExecutionWrapperProps {
|
||||
strategyId: string;
|
||||
}
|
||||
|
||||
const FeatureEnvironmentStrategyExecutionWrapper = ({
|
||||
strategyId,
|
||||
}: IFeatureEnvironmentStrategyExecutionWrapperProps) => {
|
||||
const { projectId, featureId } = useParams<IFeatureViewParams>();
|
||||
const { activeEnvironment } = useContext(FeatureStrategiesUIContext);
|
||||
|
||||
const { strategy } = useFeatureStrategy(
|
||||
projectId,
|
||||
featureId,
|
||||
activeEnvironment.name,
|
||||
strategyId,
|
||||
{
|
||||
revalidateOnMount: false,
|
||||
revalidateOnReconnect: false,
|
||||
revalidateIfStale: false,
|
||||
revalidateOnFocus: false,
|
||||
}
|
||||
);
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
padding: '1rem',
|
||||
textAlign: 'center',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
>
|
||||
<FeatureStrategyExecution
|
||||
constraints={strategy.constraints}
|
||||
parameters={strategy.parameters}
|
||||
strategy={strategy}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FeatureEnvironmentStrategyExecutionWrapper;
|
@ -1,10 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import useProjectApi from '../../../../hooks/api/actions/useProjectApi/useProjectApi';
|
||||
import { IPermission } from '../../../../interfaces/project';
|
||||
|
||||
export interface ICheckedPermission {
|
||||
[key: string]: IPermission;
|
||||
}
|
||||
|
||||
const useProjectForm = (
|
||||
initialProjectId = '',
|
||||
|
@ -1,5 +1,4 @@
|
||||
export const ADMIN = 'ADMIN';
|
||||
export const EDITOR = 'EDITOR';
|
||||
export const CREATE_FEATURE = 'CREATE_FEATURE';
|
||||
export const UPDATE_FEATURE = 'UPDATE_FEATURE';
|
||||
export const DELETE_FEATURE = 'DELETE_FEATURE';
|
||||
@ -12,15 +11,11 @@ export const UPDATE_CONTEXT_FIELD = 'UPDATE_CONTEXT_FIELD';
|
||||
export const DELETE_CONTEXT_FIELD = 'DELETE_CONTEXT_FIELD';
|
||||
export const CREATE_PROJECT = 'CREATE_PROJECT';
|
||||
export const UPDATE_PROJECT = 'UPDATE_PROJECT';
|
||||
export const DELETE_PROJECT = 'DELETE_PROJECT';
|
||||
export const DELETE_TAG_TYPE = 'DELETE_TAG_TYPE';
|
||||
export const UPDATE_TAG_TYPE = 'UPDATE_TAG_TYPE';
|
||||
export const CREATE_TAG = 'CREATE_TAG';
|
||||
export const DELETE_TAG = 'DELETE_TAG';
|
||||
export const CREATE_ADDON = 'CREATE_ADDON';
|
||||
export const UPDATE_ADDON = 'UPDATE_ADDON';
|
||||
export const DELETE_ADDON = 'DELETE_ADDON';
|
||||
export const UPDATE_API_TOKEN = 'UPDATE_API_TOKEN';
|
||||
export const CREATE_API_TOKEN = 'CREATE_API_TOKEN';
|
||||
export const DELETE_API_TOKEN = 'DELETE_API_TOKEN';
|
||||
export const DELETE_ENVIRONMENT = 'DELETE_ENVIRONMENT';
|
||||
|
@ -1,102 +0,0 @@
|
||||
export const GoogleSvg = () => (
|
||||
<svg
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="46px"
|
||||
height="46px"
|
||||
viewBox="0 0 46 46"
|
||||
style={{display: 'block', width: '36px', height: '36px'}}
|
||||
>
|
||||
<defs>
|
||||
<filter
|
||||
x="-50%"
|
||||
y="-50%"
|
||||
width="200%"
|
||||
height="200%"
|
||||
filterUnits="objectBoundingBox"
|
||||
id="filter-1"
|
||||
>
|
||||
<feOffset dx="0" dy="1" in="SourceAlpha" result="shadowOffsetOuter1" />
|
||||
<feGaussianBlur
|
||||
stdDeviation="0.5"
|
||||
in="shadowOffsetOuter1"
|
||||
result="shadowBlurOuter1"
|
||||
/>
|
||||
<feColorMatrix
|
||||
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.168 0"
|
||||
in="shadowBlurOuter1"
|
||||
type="matrix"
|
||||
result="shadowMatrixOuter1"
|
||||
/>
|
||||
<feOffset dx="0" dy="0" in="SourceAlpha" result="shadowOffsetOuter2" />
|
||||
<feGaussianBlur
|
||||
stdDeviation="0.5"
|
||||
in="shadowOffsetOuter2"
|
||||
result="shadowBlurOuter2"
|
||||
/>
|
||||
<feColorMatrix
|
||||
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.084 0"
|
||||
in="shadowBlurOuter2"
|
||||
type="matrix"
|
||||
result="shadowMatrixOuter2"
|
||||
/>
|
||||
<feMerge>
|
||||
<feMergeNode in="shadowMatrixOuter1" />
|
||||
<feMergeNode in="shadowMatrixOuter2" />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<rect id="path-2" x="0" y="0" width="40" height="40" rx="2" />
|
||||
</defs>
|
||||
<g
|
||||
id="Google-Button"
|
||||
stroke="none"
|
||||
strokeWidth="1"
|
||||
fill="none"
|
||||
fillRule="evenodd"
|
||||
>
|
||||
<g id="9-PATCH" transform="translate(-608.000000, -160.000000)" />
|
||||
<g
|
||||
id="btn_google_light_normal"
|
||||
transform="translate(-1.000000, -1.000000)"
|
||||
>
|
||||
<g
|
||||
id="button"
|
||||
transform="translate(4.000000, 4.000000)"
|
||||
filter="url(#filter-1)"
|
||||
>
|
||||
<g id="button-bg">
|
||||
<use fill="#FFFFFF" fillRule="evenodd" />
|
||||
<use fill="none" />
|
||||
<use fill="none" />
|
||||
<use fill="none" />
|
||||
</g>
|
||||
</g>
|
||||
<g id="logo_googleg_48dp" transform="translate(15.000000, 15.000000)">
|
||||
<path
|
||||
d="M17.64,9.20454545 C17.64,8.56636364 17.5827273,7.95272727 17.4763636,7.36363636 L9,7.36363636 L9,10.845 L13.8436364,10.845 C13.635,11.97 13.0009091,12.9231818 12.0477273,13.5613636 L12.0477273,15.8195455 L14.9563636,15.8195455 C16.6581818,14.2527273 17.64,11.9454545 17.64,9.20454545 L17.64,9.20454545 Z"
|
||||
id="Shape"
|
||||
fill="#4285F4"
|
||||
/>
|
||||
<path
|
||||
d="M9,18 C11.43,18 13.4672727,17.1940909 14.9563636,15.8195455 L12.0477273,13.5613636 C11.2418182,14.1013636 10.2109091,14.4204545 9,14.4204545 C6.65590909,14.4204545 4.67181818,12.8372727 3.96409091,10.71 L0.957272727,10.71 L0.957272727,13.0418182 C2.43818182,15.9831818 5.48181818,18 9,18 L9,18 Z"
|
||||
id="Shape"
|
||||
fill="#34A853"
|
||||
/>
|
||||
<path
|
||||
d="M3.96409091,10.71 C3.78409091,10.17 3.68181818,9.59318182 3.68181818,9 C3.68181818,8.40681818 3.78409091,7.83 3.96409091,7.29 L3.96409091,4.95818182 L0.957272727,4.95818182 C0.347727273,6.17318182 0,7.54772727 0,9 C0,10.4522727 0.347727273,11.8268182 0.957272727,13.0418182 L3.96409091,10.71 L3.96409091,10.71 Z"
|
||||
id="Shape"
|
||||
fill="#FBBC05"
|
||||
/>
|
||||
<path
|
||||
d="M9,3.57954545 C10.3213636,3.57954545 11.5077273,4.03363636 12.4404545,4.92545455 L15.0218182,2.34409091 C13.4631818,0.891818182 11.4259091,0 9,0 C5.48181818,0 2.43818182,2.01681818 0.957272727,4.95818182 L3.96409091,7.29 C4.67181818,5.16272727 6.65590909,3.57954545 9,3.57954545 L9,3.57954545 Z"
|
||||
id="Shape"
|
||||
fill="#EA4335"
|
||||
/>
|
||||
<path d="M0,0 L18,0 L18,18 L0,18 L0,0 Z" id="Shape" />
|
||||
</g>
|
||||
<g id="handles_square" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
)
|
@ -1 +0,0 @@
|
||||
export const RBAC_ENV = false;
|
@ -3,4 +3,3 @@ export const OK = 200;
|
||||
export const NOT_FOUND = 404;
|
||||
export const FORBIDDEN = 403;
|
||||
export const UNAUTHORIZED = 401;
|
||||
export const NOT_MODIFIED = 304;
|
||||
|
@ -6,25 +6,13 @@ import {
|
||||
handleUnauthorized,
|
||||
} from './errorHandlers';
|
||||
|
||||
export interface IUserApiErrors {
|
||||
addUser?: string;
|
||||
removeUser?: string;
|
||||
updateUser?: string;
|
||||
changePassword?: string;
|
||||
validatePassword?: string;
|
||||
}
|
||||
|
||||
interface IUserPayload {
|
||||
name: string;
|
||||
email: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export const ADD_USER_ERROR = 'addUser';
|
||||
export const UPDATE_USER_ERROR = 'updateUser';
|
||||
export const REMOVE_USER_ERROR = 'removeUser';
|
||||
export const CHANGE_PASSWORD_ERROR = 'changePassword';
|
||||
export const VALIDATE_PASSWORD_ERROR = 'validatePassword';
|
||||
|
||||
const useAdminUsersApi = () => {
|
||||
const { loading, makeRequest, createRequest, errors } = useAPI({
|
||||
|
@ -1,14 +1,6 @@
|
||||
import { Dispatch, SetStateAction, useContext } from 'react';
|
||||
import { useContext } from 'react';
|
||||
import UIContext, { IToastData } from '../contexts/UIContext';
|
||||
|
||||
export interface IToast {
|
||||
show: boolean;
|
||||
type: 'success' | 'info' | 'warning' | 'error';
|
||||
text: string;
|
||||
}
|
||||
|
||||
export type TSetToastData = Dispatch<SetStateAction<IToast>>;
|
||||
|
||||
interface IToastOptions {
|
||||
title: string;
|
||||
text?: string;
|
||||
|
@ -29,10 +29,3 @@ export interface IEnvironmentResponse {
|
||||
export interface ISortOrderPayload {
|
||||
[index: string]: number;
|
||||
}
|
||||
|
||||
export interface IEnvironmentMetrics {
|
||||
name: string;
|
||||
yes: number;
|
||||
no: number;
|
||||
timestamp: string;
|
||||
}
|
||||
|
@ -11,16 +11,6 @@ export interface IEnvironments {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface IFeatureToggleDTO {
|
||||
stale: boolean;
|
||||
archived: boolean;
|
||||
description: string;
|
||||
name: string;
|
||||
project: string;
|
||||
type: string;
|
||||
variants: IFeatureVariant[];
|
||||
}
|
||||
|
||||
export interface IFeatureTogglePayload {
|
||||
description: string;
|
||||
name: string;
|
||||
|
@ -1,8 +1,5 @@
|
||||
export const REPORTING_SELECT_ID = 'REPORTING_SELECT_ID';
|
||||
|
||||
/* NAVIGATION */
|
||||
export const NAVIGATE_TO_CREATE_FEATURE = 'NAVIGATE_TO_CREATE_FEATURE';
|
||||
export const NAVIGATE_TO_CREATE_API_KEY = 'NAVIGATE_TO_CREATE_API_KEY';
|
||||
export const CREATE_API_TOKEN_BUTTON = 'CREATE_API_TOKEN_BUTTON';
|
||||
|
||||
/* CREATE FEATURE */
|
||||
|
@ -1,28 +1,8 @@
|
||||
const defaultErrorMessage = 'Unexpected exception when talking to unleash-api';
|
||||
|
||||
export const headers = {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
export const extractJoiMsg = (body: any) => {
|
||||
return body.details.length > 0
|
||||
? body.details[0].message
|
||||
: defaultErrorMessage;
|
||||
};
|
||||
|
||||
export const extractLegacyMsg = (body: any[]) => {
|
||||
return body && body.length > 0 ? body[0].msg : defaultErrorMessage;
|
||||
};
|
||||
|
||||
export class ServiceError extends Error {
|
||||
constructor(statusCode = 500) {
|
||||
super(defaultErrorMessage);
|
||||
this.name = 'ServiceError';
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
export class AuthenticationError extends Error {
|
||||
constructor(statusCode, body) {
|
||||
super('Authentication required');
|
||||
|
@ -2,13 +2,6 @@ export const getTogglePath = (projectId: string, featureToggleName: string) => {
|
||||
return `/projects/${projectId}/features/${featureToggleName}`;
|
||||
};
|
||||
|
||||
export const getToggleCopyPath = (
|
||||
projectId: string,
|
||||
featureToggleName: string
|
||||
) => {
|
||||
return `/projects/${projectId}/features/${featureToggleName}/strategies/copy`;
|
||||
};
|
||||
|
||||
export const getCreateTogglePath = (
|
||||
projectId: string,
|
||||
newPath: boolean = false,
|
||||
|
@ -44,9 +44,6 @@ const nameMapping = {
|
||||
},
|
||||
};
|
||||
|
||||
export const getHumanReadbleStrategy = strategyName =>
|
||||
nameMapping[strategyName];
|
||||
|
||||
export const getHumanReadableStrategyName = strategyName => {
|
||||
const humanReadableStrategy = nameMapping[strategyName];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user