Skip to content

Commit

Permalink
Disable adding workspace on reaching max workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvdv committed Jun 15, 2022
1 parent a544726 commit c9c0edb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
8 changes: 5 additions & 3 deletions src/components/workspace/WorkspacesLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ const WorkspacesLayout = () => {
tabList={tabListInjectedProps => (
<>
{renderTabs(tabListInjectedProps)}
<div className='workspace-tab workspace-tab__add' onClick={addWorkspace}>
+
</div>
{!workspacesStore.isFull && (
<button className='workspace-tab workspace-tab__add' onClick={addWorkspace}>
+
</button>
)}
</>
)}
tabPanels={workspacesStore.workspaces.map(workspace => (
Expand Down
9 changes: 1 addition & 8 deletions src/stores/RootStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
***************************************************************************** */

import { action, computed } from 'mobx';
import { nanoid } from 'nanoid';
import ApiSchema from '../api/ApiSchema';
import WorkspacesStore, { WorkspacesUrlState } from './workspace/WorkspacesStore';
Expand Down Expand Up @@ -56,11 +55,6 @@ export default class RootStore {
window.history.replaceState({}, '', window.location.pathname);
}

@computed
public get isBookmarksFull(): boolean {
return this.workspacesStore.selectedStore.bookmarksStore.isBookmarksFull;
}

private parseUrlState = (): WorkspacesUrlState | null => {
try {
if (window.location.search.split('&').length > 1) {
Expand Down Expand Up @@ -121,7 +115,6 @@ export default class RootStore {
}
};

@action
public handleQuotaExceededError = async (unsavedData?: DbData) => {
const errorId = nanoid();
this.notificationsStore.addMessage({
Expand All @@ -137,7 +130,7 @@ export default class RootStore {
});
};

public clearAppData = async (errorId: string, unsavedData?: DbData) => {
private clearAppData = async (errorId: string, unsavedData?: DbData) => {
this.notificationsStore.deleteMessage(errorId);
try {
await this.api.indexedDb.clearAllData();
Expand Down
7 changes: 2 additions & 5 deletions src/stores/workspace/WorkspacesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import FiltersHistoryStore from '../FiltersHistoryStore';
export type WorkspacesUrlState = Array<WorkspaceUrlState>;

export default class WorkspacesStore {
public readonly MAX_WORKSPACES_COUNT = 12;
public readonly MAX_WORKSPACES_COUNT = 10;

public selectedStore = new SelectedStore(this, this.api.indexedDb);

Expand All @@ -48,10 +48,6 @@ export default class WorkspacesStore {

@observable workspaces: Array<WorkspaceStore> = [];

@computed get eventStores() {
return this.workspaces.map(workspace => workspace.eventsStore);
}

@computed get isFull() {
return this.workspaces.length === this.MAX_WORKSPACES_COUNT;
}
Expand Down Expand Up @@ -82,6 +78,7 @@ export default class WorkspacesStore {

@action
public addWorkspace = (workspace: WorkspaceStore) => {
if (this.isFull) return;
this.workspaces.push(workspace);
this.tabsStore.setActiveWorkspace(this.workspaces.length - 1);
};
Expand Down
1 change: 1 addition & 0 deletions src/styles/workspace.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

&__add {
background-color: #dee5ed;
border: none;
text-align: center;
padding: 7px;
color: $workspaceTabActiveBackground;
Expand Down

0 comments on commit c9c0edb

Please sign in to comment.