-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(#65): move the content to tab instead of tree details page
- Loading branch information
Showing
3 changed files
with
117 additions
and
83 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
dashboard/src/components/Tabs/TreeDetails/TreeDetailsBuildTab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
import { useMemo } from 'react'; | ||
|
||
import CardsGroup from '@/components/CardsGroup/CardsGroup'; | ||
import { Colors, IStatusChart } from '@/components/StatusChart/StatusCharts'; | ||
import { ITreeDetails } from '@/routes/TreeDetails/TreeDetails'; | ||
import { ISummary } from '@/components/Summary/Summary'; | ||
import { IListingContent } from '@/components/ListingContent/ListingContent'; | ||
|
||
interface ITreeDetailsBuildTab { | ||
treeDetailsData?: ITreeDetails; | ||
} | ||
|
||
const TreeDetailsBuildTab = ({ | ||
treeDetailsData, | ||
}: ITreeDetailsBuildTab): JSX.Element => { | ||
const cards = useMemo( | ||
() => [ | ||
{ | ||
title: <FormattedMessage id="treeDetails.buildStatus" />, | ||
type: 'chart', | ||
pieCentralLabel: `${ | ||
(treeDetailsData?.builds.invalid ?? 0) + | ||
(treeDetailsData?.builds.valid ?? 0) + | ||
(treeDetailsData?.builds.null ?? 0) | ||
}`, | ||
pieCentralDescription: <FormattedMessage id="treeDetails.executed" />, | ||
elements: [ | ||
{ | ||
value: treeDetailsData?.builds.valid ?? 0, | ||
label: 'Valid', | ||
color: Colors.Green, | ||
}, | ||
{ | ||
value: treeDetailsData?.builds.invalid ?? 0, | ||
label: 'Invalid', | ||
color: Colors.Red, | ||
}, | ||
{ | ||
value: treeDetailsData?.builds.null ?? 0, | ||
label: 'Null', | ||
color: Colors.Gray, | ||
}, | ||
], | ||
} as IStatusChart, | ||
{ | ||
items: treeDetailsData?.configs ?? [], | ||
title: <FormattedMessage id="treeDetails.configs" />, | ||
type: 'listing', | ||
} as IListingContent, | ||
{ | ||
summaryBody: treeDetailsData?.archs ?? [], | ||
title: <FormattedMessage id="treeDetails.summary" />, | ||
summaryHeaders: [ | ||
<FormattedMessage key="treeDetails.arch" id="treeDetails.arch" />, | ||
<FormattedMessage | ||
key="treeDetails.compiler" | ||
id="treeDetails.compiler" | ||
/>, | ||
], | ||
type: 'summary', | ||
} as ISummary, | ||
], | ||
[ | ||
treeDetailsData?.archs, | ||
treeDetailsData?.builds.invalid, | ||
treeDetailsData?.builds.null, | ||
treeDetailsData?.builds.valid, | ||
treeDetailsData?.configs, | ||
], | ||
); | ||
return ( | ||
<div className="pt-4"> | ||
<CardsGroup cards={cards} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TreeDetailsBuildTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,36 @@ | ||
import Tabs, { ITabItem } from '@/components/Tabs/Tabs'; | ||
import { ITreeDetails } from '@/routes/TreeDetails/TreeDetails'; | ||
|
||
const TreeDetailsTab = (): JSX.Element => { | ||
return <Tabs tabs={treeDetailsTab} defaultTab={treeDetailsTab[0]} />; | ||
}; | ||
import TreeDetailsBuildTab from './TreeDetails/TreeDetailsBuildTab'; | ||
|
||
const bootsTab: ITabItem = { | ||
name: 'treeDetails.boots', | ||
content: <></>, | ||
disabled: true, | ||
}; | ||
export interface ITreeDetailsBuildTab { | ||
treeDetailsData?: ITreeDetails; | ||
} | ||
|
||
const testsTab: ITabItem = { | ||
name: 'treeDetails.tests', | ||
content: <></>, | ||
disabled: true, | ||
}; | ||
const TreeDetailsTab = ({ | ||
treeDetailsData, | ||
}: ITreeDetailsBuildTab): JSX.Element => { | ||
const buildsTab: ITabItem = { | ||
name: 'treeDetails.builds', | ||
content: <TreeDetailsBuildTab treeDetailsData={treeDetailsData} />, | ||
disabled: false, | ||
}; | ||
|
||
const buildsTab: ITabItem = { | ||
name: 'treeDetails.builds', | ||
content: <></>, | ||
disabled: false, | ||
}; | ||
const bootsTab: ITabItem = { | ||
name: 'treeDetails.boots', | ||
content: <></>, | ||
disabled: true, | ||
}; | ||
|
||
const treeDetailsTab = [buildsTab, bootsTab, testsTab]; | ||
const testsTab: ITabItem = { | ||
name: 'treeDetails.tests', | ||
content: <></>, | ||
disabled: true, | ||
}; | ||
|
||
const treeDetailsTab = [buildsTab, bootsTab, testsTab]; | ||
|
||
return <Tabs tabs={treeDetailsTab} defaultTab={treeDetailsTab[0]} />; | ||
}; | ||
|
||
export default TreeDetailsTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters