1
0
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:
Tymoteusz Czech 2024-02-29 21:14:31 +01:00
parent 77c73dde18
commit 7d45f6c074
No known key found for this signature in database
GPG Key ID: 133555230D88D75F
2 changed files with 16 additions and 5 deletions

View File

@ -25,6 +25,8 @@ import { ProjectHealthChart } from './componentsChart/ProjectHealthChart/Project
import { TimeToProductionChart } from './componentsChart/TimeToProductionChart/TimeToProductionChart'; import { TimeToProductionChart } from './componentsChart/TimeToProductionChart/TimeToProductionChart';
import { MetricsSummaryChart } from './componentsChart/MetricsSummaryChart/MetricsSummaryChart'; import { MetricsSummaryChart } from './componentsChart/MetricsSummaryChart/MetricsSummaryChart';
import { UsersPerProjectChart } from './componentsChart/UsersPerProjectChart/UsersPerProjectChart'; import { UsersPerProjectChart } from './componentsChart/UsersPerProjectChart/UsersPerProjectChart';
import { ArrayParam, withDefault } from 'use-query-params';
import { usePersistentTableState } from 'hooks/usePersistentTableState';
const StyledGrid = styled(Box)(({ theme }) => ({ const StyledGrid = styled(Box)(({ theme }) => ({
display: 'grid', display: 'grid',
@ -46,7 +48,16 @@ const ChartWidget = styled(Widget)(({ theme }) => ({
export const ExecutiveDashboard: VFC = () => { export const ExecutiveDashboard: VFC = () => {
const { executiveDashboardData, loading, error } = useExecutiveDashboard(); 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 showAllProjects = projects[0] === allOption.id;
const projectsData = useFilteredTrends( const projectsData = useFilteredTrends(
executiveDashboardData.projectFlagTrends, executiveDashboardData.projectFlagTrends,
@ -139,9 +150,7 @@ export const ExecutiveDashboard: VFC = () => {
</Widget> </Widget>
<ChartWidget <ChartWidget
title={ title={
showAllProjects showAllProjects ? 'Healthy flags' : 'Health per project'
? 'Healthy flags'
: 'Health per project'
} }
> >
<ProjectHealthChart <ProjectHealthChart

View File

@ -12,7 +12,9 @@ export const allOption = { label: 'ALL', id: '*' };
interface IProjectSelectProps { interface IProjectSelectProps {
selectedProjects: string[]; selectedProjects: string[];
onChange: Dispatch<SetStateAction<string[]>>; onChange:
| Dispatch<SetStateAction<string[]>>
| ((projects: string[]) => void);
} }
export const ProjectSelect: VFC<IProjectSelectProps> = ({ export const ProjectSelect: VFC<IProjectSelectProps> = ({