added a teams link to the breadcrumbs trail when the team page was used to navigate to something (the team is in the url)
This commit is contained in:
parent
b0274ad639
commit
b6c1f44e03
3 changed files with 36 additions and 10 deletions
|
|
@ -219,6 +219,10 @@ export default function SmartBreadcrumb(props: Props) {
|
|||
return binsPath() + "/" + binID();
|
||||
};
|
||||
|
||||
const teamsPath = (): string => {
|
||||
return "/teams";
|
||||
}
|
||||
|
||||
const getBreadcrumbMap = (): { [key: string]: string } => {
|
||||
const { groupName, deviceName, componentName, reportTarget, binName } = props;
|
||||
const deviceLabel: string = deviceName ? deviceName : "Device " + deviceID();
|
||||
|
|
@ -248,7 +252,8 @@ export default function SmartBreadcrumb(props: Props) {
|
|||
[firmwarePath()]: "Firmware",
|
||||
[usersPath()]: "Users",
|
||||
[binsPath()]: "Bins",
|
||||
[binPath()]: binLabel
|
||||
[binPath()]: binLabel,
|
||||
[teamsPath()]: "Teams"
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -258,7 +263,7 @@ export default function SmartBreadcrumb(props: Props) {
|
|||
|
||||
const breadcrumbLinks = (): ReactNode[] => {
|
||||
const breadcrumbMap = getBreadcrumbMap();
|
||||
// console.log(breadcrumbMap)
|
||||
//console.log(breadcrumbMap)
|
||||
|
||||
let links: ReactNode[] = [];
|
||||
let pathnames = location.pathname.split("/").filter((x: any) => x);
|
||||
|
|
@ -277,10 +282,13 @@ export default function SmartBreadcrumb(props: Props) {
|
|||
const lastPath = index === pathnames.length - 1;
|
||||
//console.log(lastPath)
|
||||
const to = `/${pathnames.slice(0, index + 1).join("/")}`;
|
||||
|
||||
//console.log("to: " + to)
|
||||
let label = breadcrumbMap[to];
|
||||
//console.log("label: "+label)
|
||||
let result = to.split("/").filter(str => str !== "");
|
||||
//console.log("result: " + result.toString())
|
||||
if (!label) {
|
||||
//console.log("no label")
|
||||
if (result.length > 1) {
|
||||
if (result[result.length - 1] !== "components") {
|
||||
label = breadcrumbMap["/" + result[result.length - 1]];
|
||||
|
|
@ -292,11 +300,12 @@ export default function SmartBreadcrumb(props: Props) {
|
|||
}
|
||||
|
||||
if (!blacklist.includes(to) && label) {
|
||||
//console.log("push link")
|
||||
links.push(linkComponent(to, label, lastPath));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//console.log(links)
|
||||
return links;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ export default function DeviceComponent() {
|
|||
true
|
||||
);
|
||||
let userPromise = userAPI.getUser(user.settings.id, deviceScope(deviceID.toString()));
|
||||
let prefPromise = deviceAPI.listDeviceComponentPreferences(deviceID);
|
||||
let prefPromise = deviceAPI.listDeviceComponentPreferences(deviceID, getContextKeys().slice(0, -1), getContextTypes().slice(0, -1));
|
||||
Promise.all([componentsPromise, userPromise, prefPromise])
|
||||
.then((responses: any) => {
|
||||
const rawComponents: Array<any> = or(responses[0].data.components, []).sort(
|
||||
|
|
|
|||
|
|
@ -171,6 +171,14 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
|||
types?: string[]
|
||||
) => {
|
||||
let url = pondURL(
|
||||
"/devices/" +
|
||||
id +
|
||||
(keys ? "?keys=" + keys.toString() : "") +
|
||||
(types ? "&types=" + types.toString() : ""),
|
||||
demo
|
||||
);
|
||||
if (as) {
|
||||
url = pondURL(
|
||||
"/devices/" +
|
||||
id +
|
||||
"?as=" + as +
|
||||
|
|
@ -178,6 +186,7 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
|||
(types ? "&types=" + types.toString() : ""),
|
||||
demo
|
||||
);
|
||||
}
|
||||
return new Promise<AxiosResponse<pond.Device>>((resolve, reject) => {
|
||||
get<pond.Device>(url).then(resp => {
|
||||
resp.data = pond.Device.fromObject(resp.data)
|
||||
|
|
@ -498,11 +507,19 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
|||
let url = pondURL(
|
||||
"/devices/" +
|
||||
id +
|
||||
"/componentPreferences?as=" +
|
||||
as +
|
||||
"/componentPreferences" +
|
||||
(keys ? "?keys=" + keys.toString() : "") +
|
||||
(types ? "&types=" + types.toString() : "")
|
||||
)
|
||||
if (as) {
|
||||
url = pondURL(
|
||||
"/devices/" +
|
||||
id +
|
||||
"/componentPreferences?as=" + as +
|
||||
(keys ? "&keys=" + keys.toString() : "") +
|
||||
(types ? "&types=" + types.toString() : "")
|
||||
)
|
||||
}
|
||||
return new Promise<AxiosResponse<pond.ListDeviceComponentPreferencesResponse>>((resolve, reject) => {
|
||||
get<pond.ListDeviceComponentPreferencesResponse>(url).then(resp => {
|
||||
resp.data = pond.ListDeviceComponentPreferencesResponse.fromObject(resp.data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue