2020-07-27 06:39:07 +03:00
|
|
|
// NOTE(jim)
|
|
|
|
// Return the desired navigation entity based on the constructed navigation
|
|
|
|
// and targetId
|
|
|
|
export const getCurrentById = (navigation, targetId) => {
|
|
|
|
let target = null;
|
|
|
|
let activeIds = {};
|
|
|
|
|
|
|
|
const findById = (state, id) => {
|
|
|
|
for (let i = 0; i < state.length; i++) {
|
|
|
|
if (state[i].id === id) {
|
|
|
|
target = state[i];
|
|
|
|
activeIds[state[i].id] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!target && state[i].children) {
|
|
|
|
activeIds[state[i].id] = true;
|
|
|
|
findById(state[i].children, id);
|
|
|
|
|
|
|
|
if (!target) {
|
|
|
|
activeIds[state[i].id] = false;
|
|
|
|
}
|
2020-04-09 00:29:13 +03:00
|
|
|
}
|
|
|
|
}
|
2020-07-27 06:39:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
findById(navigation, targetId);
|
|
|
|
|
|
|
|
return { target, activeIds };
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO(jim): We don't really need this.
|
|
|
|
// Remove it at some point.
|
|
|
|
const constructFilesTreeForNavigation = (library) => {
|
|
|
|
for (let i = 0; i < library.length; i++) {
|
|
|
|
library[i].children = [];
|
2020-06-09 21:00:36 +03:00
|
|
|
}
|
2020-04-09 00:29:13 +03:00
|
|
|
|
2020-06-09 21:00:36 +03:00
|
|
|
return library;
|
2020-04-09 00:29:13 +03:00
|
|
|
};
|
|
|
|
|
2020-07-02 13:54:33 +03:00
|
|
|
export const generate = (library) => [
|
2020-04-09 00:29:13 +03:00
|
|
|
{
|
|
|
|
id: 1,
|
2020-06-19 06:57:57 +03:00
|
|
|
name: "Home",
|
2020-07-16 04:36:29 +03:00
|
|
|
pageTitle: "Welcome back!",
|
2020-06-19 06:57:57 +03:00
|
|
|
decorator: "HOME",
|
2020-04-09 00:29:13 +03:00
|
|
|
children: null,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
2020-06-19 06:57:57 +03:00
|
|
|
name: "Wallet",
|
2020-07-16 04:36:29 +03:00
|
|
|
pageTitle: "Your wallet and addresses",
|
2020-06-19 06:57:57 +03:00
|
|
|
decorator: "WALLET",
|
2020-07-23 13:05:13 +03:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
id: 6,
|
|
|
|
name: "Deal history",
|
|
|
|
pageTitle: "Your deal history",
|
|
|
|
decorator: "DEALS",
|
|
|
|
},
|
|
|
|
],
|
2020-04-09 00:29:13 +03:00
|
|
|
},
|
2020-06-09 21:00:36 +03:00
|
|
|
...constructFilesTreeForNavigation(library),
|
2020-07-16 04:36:29 +03:00
|
|
|
{
|
|
|
|
id: 3,
|
|
|
|
name: "Slates",
|
|
|
|
pageTitle: "Your slates",
|
|
|
|
decorator: "SLATES",
|
|
|
|
children: [],
|
|
|
|
},
|
2020-07-27 06:20:34 +03:00
|
|
|
// TODO(colin):
|
|
|
|
// re-enable this when we do local offline.
|
2020-07-21 08:45:15 +03:00
|
|
|
{
|
|
|
|
id: 4,
|
|
|
|
name: "Local",
|
|
|
|
pageTitle: "Your local data",
|
|
|
|
decorator: "LOCAL_DATA",
|
|
|
|
children: [],
|
2020-07-27 06:20:34 +03:00
|
|
|
ignore: true,
|
2020-07-21 08:45:15 +03:00
|
|
|
},
|
2020-07-22 10:41:29 +03:00
|
|
|
{
|
|
|
|
id: 5,
|
|
|
|
name: "Profile",
|
|
|
|
pageTitle: "Your local data",
|
|
|
|
decorator: "PROFILE_PAGE",
|
|
|
|
children: [],
|
|
|
|
},
|
2020-04-09 00:29:13 +03:00
|
|
|
{
|
|
|
|
id: 13,
|
2020-06-19 06:57:57 +03:00
|
|
|
name: "Edit account",
|
|
|
|
pageTitle: "your account",
|
|
|
|
decorator: "EDIT_ACCOUNT",
|
2020-04-09 00:29:13 +03:00
|
|
|
children: null,
|
|
|
|
ignore: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 14,
|
2020-07-16 04:36:29 +03:00
|
|
|
name: "Filecoin Settings",
|
|
|
|
pageTitle: "Your hot and cold deal settings.",
|
2020-06-19 06:57:57 +03:00
|
|
|
decorator: "SETTINGS",
|
2020-04-09 00:29:13 +03:00
|
|
|
children: null,
|
|
|
|
ignore: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 15,
|
|
|
|
name: null,
|
2020-06-19 06:57:57 +03:00
|
|
|
pageTitle: "files",
|
|
|
|
decorator: "FILE",
|
2020-04-09 00:29:13 +03:00
|
|
|
children: null,
|
|
|
|
ignore: true,
|
|
|
|
},
|
2020-07-16 04:36:29 +03:00
|
|
|
{
|
|
|
|
id: 16,
|
|
|
|
name: "API Key & Tokens",
|
|
|
|
pageTitle: "you",
|
|
|
|
decorator: "SETTINGS_DEVELOPER",
|
|
|
|
children: null,
|
|
|
|
ignore: true,
|
|
|
|
},
|
2020-07-27 06:20:34 +03:00
|
|
|
{
|
|
|
|
id: 17,
|
|
|
|
name: null,
|
|
|
|
pageTitle: "slate",
|
|
|
|
decorator: "SLATE",
|
|
|
|
children: null,
|
|
|
|
ignore: true,
|
|
|
|
},
|
2020-04-09 00:29:13 +03:00
|
|
|
];
|