Skip to content

Commit c14509d

Browse files
committed
refactor: rename disabledTabs to hiddenTabs
1 parent a40b18c commit c14509d

4 files changed

Lines changed: 20 additions & 19 deletions

File tree

src/library-authoring/common/context/SidebarContext.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ export type SidebarContextData = {
8484
setSidebarTab: (tab: SidebarInfoTab) => void;
8585
defaultTab: DefaultTabs;
8686
setDefaultTab: (tabs: DefaultTabs) => void;
87-
disabledTabs: Array<SidebarInfoTab>;
88-
setDisabledTabs: (tabs: ComponentInfoTab[]) => void;
87+
hiddenTabs: Array<SidebarInfoTab>;
88+
setHiddenTabs: (tabs: ComponentInfoTab[]) => void;
8989
};
9090

9191
/**
@@ -118,7 +118,7 @@ export const SidebarProvider = ({
118118
unit: UNIT_INFO_TABS.Preview,
119119
collection: COLLECTION_INFO_TABS.Manage,
120120
});
121-
const [disabledTabs, setDisabledTabs] = useState<Array<SidebarInfoTab>>([]);
121+
const [hiddenTabs, setHiddenTabs] = useState<Array<SidebarInfoTab>>([]);
122122

123123
const [sidebarTab, setSidebarTab] = useStateWithUrlSearchParam<SidebarInfoTab>(
124124
defaultTab.component,
@@ -197,8 +197,8 @@ export const SidebarProvider = ({
197197
setSidebarTab,
198198
defaultTab,
199199
setDefaultTab,
200-
disabledTabs,
201-
setDisabledTabs,
200+
hiddenTabs,
201+
setHiddenTabs,
202202
};
203203

204204
return contextValue;
@@ -218,8 +218,8 @@ export const SidebarProvider = ({
218218
setSidebarTab,
219219
defaultTab,
220220
setDefaultTab,
221-
disabledTabs,
222-
setDisabledTabs,
221+
hiddenTabs,
222+
setHiddenTabs,
223223
]);
224224

225225
return (
@@ -253,8 +253,8 @@ export function useSidebarContext(): SidebarContextData {
253253
collection: COLLECTION_INFO_TABS.Manage,
254254
},
255255
setDefaultTab: () => {},
256-
disabledTabs: [],
257-
setDisabledTabs: () => {},
256+
hiddenTabs: [],
257+
setHiddenTabs: () => {},
258258
};
259259
}
260260
return ctx;

src/library-authoring/component-info/ComponentInfo.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const ComponentInfo = () => {
109109
sidebarComponentInfo,
110110
sidebarAction,
111111
defaultTab,
112-
disabledTabs,
112+
hiddenTabs,
113113
} = useSidebarContext();
114114
const [
115115
isPublishConfirmationOpen,
@@ -156,8 +156,9 @@ const ComponentInfo = () => {
156156
});
157157
}, [publishComponent, showToast, intl]);
158158

159+
// TODO: refactor sidebar Tabs to handle rendering and disabledTabs in one place.
159160
const renderTab = React.useCallback((infoTab: ComponentInfoTab, component: React.ReactNode, title: string) => {
160-
if (disabledTabs.includes(infoTab)) {
161+
if (hiddenTabs.includes(infoTab)) {
161162
// For some reason, returning anything other than empty list breaks the tab style
162163
return [];
163164
}
@@ -166,7 +167,7 @@ const ComponentInfo = () => {
166167
{component}
167168
</Tab>
168169
);
169-
}, [disabledTabs, defaultTab.component]);
170+
}, [hiddenTabs, defaultTab.component]);
170171

171172
return (
172173
<>

src/library-authoring/containers/UnitInfo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const UnitInfo = () => {
2626
const { setUnitId } = useLibraryContext();
2727
const { componentPickerMode } = useComponentPickerContext();
2828
const {
29-
defaultTab, disabledTabs, sidebarComponentInfo, sidebarTab, setSidebarTab,
29+
defaultTab, hiddenTabs, sidebarComponentInfo, sidebarTab, setSidebarTab,
3030
} = useSidebarContext();
3131
const { insideUnit, navigateTo } = useLibraryRoutes();
3232

@@ -51,7 +51,7 @@ const UnitInfo = () => {
5151
const showOpenUnitButton = !insideUnit || componentPickerMode;
5252

5353
const renderTab = useCallback((infoTab: UnitInfoTab, component: React.ReactNode, title: string) => {
54-
if (disabledTabs.includes(infoTab)) {
54+
if (hiddenTabs.includes(infoTab)) {
5555
// For some reason, returning anything other than empty list breaks the tab style
5656
return [];
5757
}
@@ -60,7 +60,7 @@ const UnitInfo = () => {
6060
{component}
6161
</Tab>
6262
);
63-
}, [disabledTabs, defaultTab.unit, unitId]);
63+
}, [hiddenTabs, defaultTab.unit, unitId]);
6464

6565
return (
6666
<Stack>

src/library-authoring/units/LibraryUnitPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const LibraryUnitPage = () => {
8484
sidebarComponentInfo,
8585
openInfoSidebar,
8686
setDefaultTab,
87-
setDisabledTabs,
87+
setHiddenTabs,
8888
} = useSidebarContext();
8989

9090
useEffect(() => {
@@ -93,16 +93,16 @@ export const LibraryUnitPage = () => {
9393
component: COMPONENT_INFO_TABS.Manage,
9494
unit: UNIT_INFO_TABS.Organize,
9595
});
96-
setDisabledTabs([COMPONENT_INFO_TABS.Preview, UNIT_INFO_TABS.Preview]);
96+
setHiddenTabs([COMPONENT_INFO_TABS.Preview, UNIT_INFO_TABS.Preview]);
9797
return () => {
9898
setDefaultTab({
9999
component: COMPONENT_INFO_TABS.Preview,
100100
unit: UNIT_INFO_TABS.Preview,
101101
collection: COLLECTION_INFO_TABS.Manage,
102102
});
103-
setDisabledTabs([]);
103+
setHiddenTabs([]);
104104
};
105-
}, [setDefaultTab, setDisabledTabs]);
105+
}, [setDefaultTab, setHiddenTabs]);
106106

107107
useEffect(() => {
108108
openInfoSidebar(componentId, collectionId, unitId);

0 commit comments

Comments
 (0)