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 { 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
|
||||||
|
@ -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> = ({
|
||||||
|
Loading…
Reference in New Issue
Block a user