mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-01 13:47:27 +02:00
persistent projects url
This commit is contained in:
parent
77c73dde18
commit
7d45f6c074
@ -25,6 +25,8 @@ import { ProjectHealthChart } from './componentsChart/ProjectHealthChart/Project
|
||||
import { TimeToProductionChart } from './componentsChart/TimeToProductionChart/TimeToProductionChart';
|
||||
import { MetricsSummaryChart } from './componentsChart/MetricsSummaryChart/MetricsSummaryChart';
|
||||
import { UsersPerProjectChart } from './componentsChart/UsersPerProjectChart/UsersPerProjectChart';
|
||||
import { ArrayParam, withDefault } from 'use-query-params';
|
||||
import { usePersistentTableState } from 'hooks/usePersistentTableState';
|
||||
|
||||
const StyledGrid = styled(Box)(({ theme }) => ({
|
||||
display: 'grid',
|
||||
@ -46,7 +48,16 @@ const ChartWidget = styled(Widget)(({ theme }) => ({
|
||||
|
||||
export const ExecutiveDashboard: VFC = () => {
|
||||
const { executiveDashboardData, loading, error } = useExecutiveDashboard();
|
||||
const [projects, setProjects] = useState([allOption.id]);
|
||||
const stateConfig = {
|
||||
projects: withDefault(ArrayParam, [allOption.id]),
|
||||
};
|
||||
const [state, setState] = usePersistentTableState(`insights`, stateConfig);
|
||||
const setProjects = (projects: string[]) => {
|
||||
setState({ projects });
|
||||
};
|
||||
const projects = state.projects
|
||||
? (state.projects.filter(Boolean) as string[])
|
||||
: [];
|
||||
const showAllProjects = projects[0] === allOption.id;
|
||||
const projectsData = useFilteredTrends(
|
||||
executiveDashboardData.projectFlagTrends,
|
||||
@ -139,9 +150,7 @@ export const ExecutiveDashboard: VFC = () => {
|
||||
</Widget>
|
||||
<ChartWidget
|
||||
title={
|
||||
showAllProjects
|
||||
? 'Healthy flags'
|
||||
: 'Health per project'
|
||||
showAllProjects ? 'Healthy flags' : 'Health per project'
|
||||
}
|
||||
>
|
||||
<ProjectHealthChart
|
||||
|
@ -12,7 +12,9 @@ export const allOption = { label: 'ALL', id: '*' };
|
||||
|
||||
interface IProjectSelectProps {
|
||||
selectedProjects: string[];
|
||||
onChange: Dispatch<SetStateAction<string[]>>;
|
||||
onChange:
|
||||
| Dispatch<SetStateAction<string[]>>
|
||||
| ((projects: string[]) => void);
|
||||
}
|
||||
|
||||
export const ProjectSelect: VFC<IProjectSelectProps> = ({
|
||||
|
Loading…
Reference in New Issue
Block a user