-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): add real data to the overview page (#1301)
The data shown in the overview in the new UI branch is just hard-coded. This PR aims to add some real data to it. At this point we are only considering three sections: localization, storage and software. <details> <summary>The overview page displaying real data</summary>  </details> ## (Not) Adopting a state management library As part of this PR, we experimented with [Jotai](https://jotai.org/). However, we decided to postpone the adoption of a state management library because we might need to do some further research and consider other options. If you are curious, you can checkout to commit cfe8d82. We need to decide how much logic we want to move out of our React code. For having kind of a "shared" `useState`, Jotai is great. If you want to put some logic to load and synchronize the state, then perhaps we should go with another option (e.g., [zustand](https://docs.pmnd.rs/zustand/getting-started/introduction), [recoil](https://recoiljs.org/), or even [react-query](https://tanstack.com/query/v4/docs/framework/react/overview)).
- Loading branch information
Showing
8 changed files
with
262 additions
and
432 deletions.
There are no files selected for viewing
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
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
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
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
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,76 @@ | ||
/* | ||
* Copyright (c) [2022-2023] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React, { useEffect, useState } from "react"; | ||
import { _ } from "~/i18n"; | ||
import { useInstallerClient } from "~/context/installer"; | ||
import { List, ListItem, Text, TextContent, TextVariants } from "@patternfly/react-core"; | ||
import { Em } from "~/components/core"; | ||
|
||
export default function SoftwareSummary() { | ||
const [proposal, setProposal] = useState({}); | ||
const [patterns, setPatterns] = useState([]); | ||
const [selectedPatterns, setSelectedPatterns] = useState(undefined); | ||
const client = useInstallerClient(); | ||
|
||
useEffect(() => { | ||
client.software.getProposal().then(setProposal); | ||
client.software.getPatterns().then(setPatterns); | ||
}, [client]); | ||
|
||
useEffect(() => { | ||
return client.software.onSelectedPatternsChanged(() => { | ||
client.software.getProposal().then(setProposal); | ||
}); | ||
}, [client, setProposal]); | ||
|
||
useEffect(() => { | ||
if (proposal.patterns === undefined) return; | ||
|
||
const ids = Object.keys(proposal.patterns); | ||
const selected = patterns.filter(p => ids.includes(p.name)).sort((a, b) => a.order - b.order); | ||
setSelectedPatterns(selected); | ||
}, [client, proposal, patterns]); | ||
|
||
if (selectedPatterns === undefined) { | ||
return; | ||
} | ||
|
||
// TRANSLATORS: %s will be replaced with the installation size, example: | ||
// "5GiB". | ||
const [msg1, msg2] = _("The installation will take %s including:").split("%s"); | ||
|
||
return ( | ||
<TextContent> | ||
<Text component={TextVariants.h3}>{_("Software")}</Text> | ||
<Text> | ||
{msg1} | ||
<Em>{`${proposal.size}`}</Em> | ||
{msg2} | ||
</Text> | ||
<List> | ||
{selectedPatterns.map(p => ( | ||
<ListItem key={p.name}>{p.description}</ListItem> | ||
))} | ||
</List> | ||
</TextContent> | ||
); | ||
} |
Oops, something went wrong.