2020-08-02 10:55:55 +03:00
|
|
|
import * as Strings from "~/common/strings";
|
|
|
|
|
2020-08-18 22:41:41 +03:00
|
|
|
// NOTE(jim):
|
|
|
|
// Recursion for nested entities (any number).
|
2020-07-27 06:39:07 +03:00
|
|
|
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 };
|
|
|
|
};
|
|
|
|
|
|
|
|
const constructFilesTreeForNavigation = (library) => {
|
2020-08-03 11:10:58 +03:00
|
|
|
return {
|
|
|
|
...library[0],
|
|
|
|
name: `Data`,
|
2020-09-10 02:52:45 +03:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
id: "V1_NAVIGATION_ARCHIVE",
|
|
|
|
decorator: "ARCHIVE",
|
|
|
|
name: "Archive",
|
|
|
|
pageTitle: "Archive on Filecoin",
|
|
|
|
children: null,
|
|
|
|
},
|
|
|
|
],
|
2020-08-03 11:10:58 +03:00
|
|
|
};
|
2020-04-09 00:29:13 +03:00
|
|
|
};
|
|
|
|
|
2020-07-27 07:26:41 +03:00
|
|
|
const constructSlatesTreeForNavigation = (slates) => {
|
|
|
|
return slates.map((s) => {
|
|
|
|
return {
|
|
|
|
...s,
|
2020-07-27 11:33:39 +03:00
|
|
|
slateId: s.id,
|
2020-08-26 00:58:38 +03:00
|
|
|
name: s.data.name || s.slatename,
|
2020-07-27 07:26:41 +03:00
|
|
|
pageTitle: `Viewing ${s.slatename}`,
|
|
|
|
decorator: "SLATE",
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const generate = ({ library = [], slates = [] }) => [
|
2020-04-09 00:29:13 +03:00
|
|
|
{
|
2020-08-18 22:28:33 +03:00
|
|
|
id: "V1_NAVIGATION_HOME",
|
2020-08-18 22:43:41 +03:00
|
|
|
decorator: "HOME",
|
2020-06-19 06:57:57 +03:00
|
|
|
name: "Home",
|
2020-07-16 04:36:29 +03:00
|
|
|
pageTitle: "Welcome back!",
|
2020-04-09 00:29:13 +03:00
|
|
|
children: null,
|
|
|
|
},
|
2020-08-08 03:15:49 +03:00
|
|
|
{
|
2020-08-18 22:41:41 +03:00
|
|
|
id: "V1_NAVIGATION_DIRECTORY",
|
2020-08-18 22:43:41 +03:00
|
|
|
decorator: "DIRECTORY",
|
2020-08-18 22:41:41 +03:00
|
|
|
name: "Directory",
|
|
|
|
pageTitle: "Your directory",
|
2020-08-08 03:15:49 +03:00
|
|
|
children: null,
|
|
|
|
},
|
2020-07-16 04:36:29 +03:00
|
|
|
{
|
2020-08-18 22:28:33 +03:00
|
|
|
id: "V1_NAVIGATION_SLATES",
|
2020-08-18 22:43:41 +03:00
|
|
|
decorator: "SLATES",
|
2020-07-16 04:36:29 +03:00
|
|
|
name: "Slates",
|
2020-07-29 02:24:15 +03:00
|
|
|
pageTitle: "Slates",
|
2020-08-10 04:22:52 +03:00
|
|
|
children: constructSlatesTreeForNavigation(slates),
|
2020-07-16 04:36:29 +03:00
|
|
|
},
|
2020-08-31 21:19:46 +03:00
|
|
|
{
|
|
|
|
id: "V1_NAVIGATION_SLATE",
|
2020-09-04 01:42:08 +03:00
|
|
|
decorator: "PUBLIC_SLATE",
|
2020-08-31 21:19:46 +03:00
|
|
|
name: "Slate",
|
|
|
|
pageTitle: "Slate",
|
|
|
|
children: null,
|
|
|
|
ignore: true,
|
|
|
|
},
|
2020-08-08 03:15:49 +03:00
|
|
|
constructFilesTreeForNavigation(library),
|
2020-08-25 05:31:42 +03:00
|
|
|
/*
|
2020-04-09 00:29:13 +03:00
|
|
|
{
|
2020-08-18 22:28:33 +03:00
|
|
|
id: "V1_NAVIGATION_LOCAL",
|
2020-08-18 22:43:41 +03:00
|
|
|
decorator: "LOCAL_DATA",
|
2020-08-08 03:15:49 +03:00
|
|
|
name: "Local",
|
2020-08-18 22:41:41 +03:00
|
|
|
pageTitle: "Your local data",
|
2020-08-08 03:15:49 +03:00
|
|
|
children: [],
|
|
|
|
ignore: false,
|
2020-04-09 00:29:13 +03:00
|
|
|
},
|
|
|
|
{
|
2020-08-18 22:28:33 +03:00
|
|
|
id: "V1_NAVIGATION_WALLET",
|
2020-08-18 22:43:41 +03:00
|
|
|
decorator: "WALLET",
|
2020-08-03 11:10:58 +03:00
|
|
|
name: "Wallet",
|
2020-08-03 00:01:59 +03:00
|
|
|
pageTitle: "Your wallet and addresses",
|
|
|
|
children: [
|
|
|
|
{
|
2020-08-18 22:28:33 +03:00
|
|
|
id: "V1_NAVIGATION_DEAL_HISTORY",
|
2020-08-18 22:43:41 +03:00
|
|
|
decorator: "DEALS",
|
2020-08-03 00:01:59 +03:00
|
|
|
name: "Deal history",
|
|
|
|
pageTitle: "Your deal history",
|
|
|
|
},
|
|
|
|
],
|
2020-08-25 05:31:42 +03:00
|
|
|
},
|
2020-08-18 22:41:41 +03:00
|
|
|
{
|
|
|
|
id: "V1_NAVIGATION_NETWORK",
|
2020-08-18 22:43:41 +03:00
|
|
|
decorator: "NETWORK",
|
2020-08-18 22:41:41 +03:00
|
|
|
name: "Network",
|
|
|
|
pageTitle: "The Filecoin Network",
|
|
|
|
children: null,
|
|
|
|
},
|
2020-08-25 05:31:42 +03:00
|
|
|
*/
|
2020-08-04 10:35:55 +03:00
|
|
|
{
|
2020-08-18 22:28:33 +03:00
|
|
|
id: "V1_NAVIGATION_API",
|
2020-08-18 22:43:41 +03:00
|
|
|
decorator: "SETTINGS_DEVELOPER",
|
2020-08-08 03:15:49 +03:00
|
|
|
name: "API",
|
|
|
|
pageTitle: "Developer API",
|
2020-09-03 10:33:43 +03:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
id: "V1_NAVIGATION_NETWORK",
|
|
|
|
decorator: "NETWORK",
|
|
|
|
name: "Filecoin Network",
|
|
|
|
pageTitle: "The Filecoin Network",
|
|
|
|
children: null,
|
|
|
|
},
|
|
|
|
],
|
2020-08-08 03:15:49 +03:00
|
|
|
},
|
|
|
|
{
|
2020-08-31 21:19:46 +03:00
|
|
|
id: "V1_NAVIGATION_PROFILE_EDIT",
|
2020-08-18 22:43:41 +03:00
|
|
|
decorator: "EDIT_ACCOUNT",
|
2020-08-08 03:15:49 +03:00
|
|
|
name: "Profile & Account Settings",
|
|
|
|
pageTitle: "Your Profile & Account Settings",
|
|
|
|
children: null,
|
|
|
|
ignore: true,
|
|
|
|
},
|
|
|
|
{
|
2020-08-18 22:28:33 +03:00
|
|
|
id: "V1_NAVIGATION_FILECOIN_SETTINGS",
|
2020-08-18 22:43:41 +03:00
|
|
|
decorator: "SETTINGS",
|
2020-08-08 03:15:49 +03:00
|
|
|
name: "Filecoin Settings",
|
|
|
|
pageTitle: "Filecoin Settings.",
|
|
|
|
children: null,
|
|
|
|
ignore: true,
|
2020-08-04 10:35:55 +03:00
|
|
|
},
|
2020-08-31 21:19:46 +03:00
|
|
|
{
|
|
|
|
id: "V1_NAVIGATION_PROFILE",
|
2020-09-04 01:42:08 +03:00
|
|
|
decorator: "PUBLIC_PROFILE",
|
2020-08-31 21:19:46 +03:00
|
|
|
name: "Profile",
|
|
|
|
pageTitle: "Profile",
|
|
|
|
children: null,
|
|
|
|
ignore: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "V1_NAVIGATION_FILE",
|
|
|
|
decorator: "FILE",
|
|
|
|
name: "File",
|
|
|
|
pageTitle: "File",
|
|
|
|
children: null,
|
|
|
|
ignore: true,
|
|
|
|
},
|
2020-04-09 00:29:13 +03:00
|
|
|
];
|