mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Check for showInPreferencesTab tab for a link to show
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
0c93c6dbf0
commit
d0bb70452a
@ -90,8 +90,9 @@ describe("preferences - navigation to extension specific preferences", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const someTestExtension = getRendererExtensionFake(extensionStubWithExtensionSpecificPreferenceItems);
|
const someTestExtension = getRendererExtensionFake(extensionStubWithExtensionSpecificPreferenceItems);
|
||||||
const extensionWithoutPreferences = getRendererExtensionFake(extensionStubWithoutPreferences);
|
const extensionWithoutPreferences = getRendererExtensionFake(extensionStubWithoutPreferences);
|
||||||
|
const extensionWithSpecificTab = getRendererExtensionFake(extensionStubWithShowInPreferencesTab);
|
||||||
|
|
||||||
await applicationBuilder.addExtensions(someTestExtension, extensionWithoutPreferences);
|
await applicationBuilder.addExtensions(someTestExtension, extensionWithoutPreferences, extensionWithSpecificTab);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("doesn't show link for extension without preferences", () => {
|
it("doesn't show link for extension without preferences", () => {
|
||||||
@ -99,6 +100,12 @@ describe("preferences - navigation to extension specific preferences", () => {
|
|||||||
|
|
||||||
expect(actual).toBeNull();
|
expect(actual).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("doesn't show link for preferences with 'showInPreferencesTab' param", () => {
|
||||||
|
const actual = rendered.queryByTestId("tab-link-for-extension-specified-preferences-page-id");
|
||||||
|
|
||||||
|
expect(actual).toBeNull();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when extension with specific preferences is enabled", () => {
|
describe("when extension with specific preferences is enabled", () => {
|
||||||
@ -207,3 +214,20 @@ const someOtherExtensionStubWithExtensionSpecificPreferenceItems: Partial<LensRe
|
|||||||
const extensionStubWithoutPreferences: Partial<LensRendererExtension> = {
|
const extensionStubWithoutPreferences: Partial<LensRendererExtension> = {
|
||||||
id: "without-preferences-id",
|
id: "without-preferences-id",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const extensionStubWithShowInPreferencesTab: Partial<LensRendererExtension> = {
|
||||||
|
id: "specified-preferences-page-id",
|
||||||
|
|
||||||
|
appPreferences: [
|
||||||
|
{
|
||||||
|
title: "Test preference item",
|
||||||
|
id: "very-other-preference-item-id",
|
||||||
|
showInPreferencesTab: "some-tab",
|
||||||
|
|
||||||
|
components: {
|
||||||
|
Hint: () => <div data-testid="very-other-preference-item-hint" />,
|
||||||
|
Input: () => <div data-testid="very-other-preference-item-input" />,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|||||||
@ -21,7 +21,11 @@ const extensionPreferencesNavigationItemRegistratorInjectable = getInjectable({
|
|||||||
const navigateToExtensionPreferences = di.inject(
|
const navigateToExtensionPreferences = di.inject(
|
||||||
navigateToExtensionPreferencesInjectable,
|
navigateToExtensionPreferencesInjectable,
|
||||||
);
|
);
|
||||||
const isVisible = extension.appPreferences.length > 0;
|
const extensionHasPreferences = extension.appPreferences.length > 0;
|
||||||
|
const extensionHasGeneralPreferences = extension.appPreferences.some(preferences =>
|
||||||
|
!preferences.showInPreferencesTab,
|
||||||
|
);
|
||||||
|
const isVisible = extensionHasPreferences && extensionHasGeneralPreferences;
|
||||||
const extensionRoute = di.inject(extensionPreferencesRouteInjectable);
|
const extensionRoute = di.inject(extensionPreferencesRouteInjectable);
|
||||||
const extensionPreferencesRouteIsActive = di.inject(routeIsActiveInjectable, extensionRoute);
|
const extensionPreferencesRouteIsActive = di.inject(routeIsActiveInjectable, extensionRoute);
|
||||||
const pathParameters = di.inject(currentPathParametersInjectable);
|
const pathParameters = di.inject(currentPathParametersInjectable);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user