mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
Save collapse status of secondary navigation
Pushed-by: Florian Scholdei<florian.scholdei@cloudogu.com> Co-authored-by: Florian Scholdei<florian.scholdei@cloudogu.com> Co-authored-by: Konstantin Schaper<konstantin.schaper@cloudogu.com> Committed-by: Florian Scholdei<florian.scholdei@cloudogu.com>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
import React from "react";
|
||||
import EditRepoNavLink from "./EditRepoNavLink";
|
||||
import { mount, shallow } from "@scm-manager/ui-tests";
|
||||
import { LocalStorageProvider } from "@scm-manager/ui-api";
|
||||
|
||||
describe("GeneralNavLink", () => {
|
||||
it("should render nothing, if the modify link is missing", () => {
|
||||
@@ -31,7 +32,7 @@ describe("GeneralNavLink", () => {
|
||||
namespace: "space",
|
||||
name: "name",
|
||||
type: "git",
|
||||
_links: {}
|
||||
_links: {},
|
||||
};
|
||||
|
||||
const navLink = shallow(<EditRepoNavLink repository={repository} editUrl="" />);
|
||||
@@ -45,12 +46,16 @@ describe("GeneralNavLink", () => {
|
||||
type: "git",
|
||||
_links: {
|
||||
update: {
|
||||
href: "/repositories"
|
||||
}
|
||||
}
|
||||
href: "/repositories",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const navLink = mount(<EditRepoNavLink repository={repository} editUrl="" />);
|
||||
const navLink = mount(
|
||||
<LocalStorageProvider>
|
||||
<EditRepoNavLink repository={repository} editUrl="" />
|
||||
</LocalStorageProvider>
|
||||
);
|
||||
expect(navLink.text()).toBe("repositoryRoot.menu.generalNavLink");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,12 +24,13 @@
|
||||
import React from "react";
|
||||
import { mount, shallow } from "@scm-manager/ui-tests";
|
||||
import "@scm-manager/ui-tests";
|
||||
import { LocalStorageProvider } from "@scm-manager/ui-api";
|
||||
import PermissionsNavLink from "./PermissionsNavLink";
|
||||
|
||||
describe("PermissionsNavLink", () => {
|
||||
it("should render nothing, if the modify link is missing", () => {
|
||||
const repository = {
|
||||
_links: {}
|
||||
_links: {},
|
||||
};
|
||||
|
||||
const navLink = shallow(<PermissionsNavLink repository={repository} permissionUrl="" />);
|
||||
@@ -40,12 +41,16 @@ describe("PermissionsNavLink", () => {
|
||||
const repository = {
|
||||
_links: {
|
||||
permissions: {
|
||||
href: "/permissions"
|
||||
}
|
||||
}
|
||||
href: "/permissions",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const navLink = mount(<PermissionsNavLink repository={repository} permissionUrl="" />);
|
||||
const navLink = mount(
|
||||
<LocalStorageProvider>
|
||||
<PermissionsNavLink repository={repository} permissionUrl="" />
|
||||
</LocalStorageProvider>
|
||||
);
|
||||
expect(navLink.text()).toBe("repositoryRoot.menu.permissionsNavLink");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
import React from "react";
|
||||
import { mount, shallow } from "@scm-manager/ui-tests";
|
||||
import "@scm-manager/ui-tests";
|
||||
import { LocalStorageProvider } from "@scm-manager/ui-api";
|
||||
import RepositoryNavLink from "./RepositoryNavLink";
|
||||
|
||||
describe("RepositoryNavLink", () => {
|
||||
@@ -32,7 +33,7 @@ describe("RepositoryNavLink", () => {
|
||||
namespace: "Namespace",
|
||||
name: "Repo",
|
||||
type: "GIT",
|
||||
_links: {}
|
||||
_links: {},
|
||||
};
|
||||
|
||||
const navLink = shallow(
|
||||
@@ -54,19 +55,21 @@ describe("RepositoryNavLink", () => {
|
||||
type: "GIT",
|
||||
_links: {
|
||||
sources: {
|
||||
href: "/sources"
|
||||
}
|
||||
}
|
||||
href: "/sources",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const navLink = mount(
|
||||
<RepositoryNavLink
|
||||
repository={repository}
|
||||
linkName="sources"
|
||||
to="/sources"
|
||||
label="Sources"
|
||||
activeOnlyWhenExact={true}
|
||||
/>
|
||||
<LocalStorageProvider>
|
||||
<RepositoryNavLink
|
||||
repository={repository}
|
||||
linkName="sources"
|
||||
to="/sources"
|
||||
label="Sources"
|
||||
activeOnlyWhenExact={true}
|
||||
/>
|
||||
</LocalStorageProvider>
|
||||
);
|
||||
expect(navLink.text()).toBe("Sources");
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
import React from "react";
|
||||
import React, { FC } from "react";
|
||||
import { Repository } from "@scm-manager/ui-types";
|
||||
import { NavLink } from "@scm-manager/ui-components";
|
||||
import { RouteProps } from "react-router-dom";
|
||||
@@ -40,16 +40,12 @@ type Props = {
|
||||
/**
|
||||
* Component renders only if the repository contains the link with the given name.
|
||||
*/
|
||||
class RepositoryNavLink extends React.Component<Props> {
|
||||
render() {
|
||||
const { repository, linkName } = this.props;
|
||||
|
||||
if (!repository._links[linkName]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <NavLink {...this.props} />;
|
||||
const RepositoryNavLink: FC<Props> = ({ repository, linkName, ...props }) => {
|
||||
if (!repository._links[linkName]) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return <NavLink {...props} />;
|
||||
};
|
||||
|
||||
export default RepositoryNavLink;
|
||||
|
||||
Reference in New Issue
Block a user