Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix content being pushed right when too many tabs in the web app is open #27

Merged
merged 18 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4096125
Merge branch 'report_bug' of https://github.com/MyersResearchGroup/Sy…
Drock54651 Jun 5, 2024
68f5511
save indicator created for global state
Drock54651 Jun 5, 2024
4c8afec
Component that will un-render its contents after a delay, created for…
Drock54651 Jun 5, 2024
a152ba1
Renders save indicator next to the top tabs, might put it in another …
Drock54651 Jun 5, 2024
ab9ca23
Changed variable name
Drock54651 Jun 5, 2024
d51dcbd
Merge branch 'report_bug' of https://github.com/MyersResearchGroup/Sy…
Drock54651 Jun 5, 2024
e24f67f
Changed export name
Drock54651 Jun 6, 2024
60f74d0
Changed comment
Drock54651 Jun 6, 2024
82c3375
Separated saveIndicator display into its own component to easily move…
Drock54651 Jun 6, 2024
2226fe8
Merge branch 'master' of https://github.com/MyersResearchGroup/SynBio…
Drock54651 Jun 6, 2024
57899ab
Moved saving indicator to the explorer
Drock54651 Jun 6, 2024
662252a
Added a checkmark when done saving, also made component more flexible
Drock54651 Jun 6, 2024
aa71129
Depending on if the side panel is open, change maxWidth such that con…
Drock54651 Jun 6, 2024
3dc5116
Moved the save indicator next to "Local Explorer" Label, also added i…
Drock54651 Jun 7, 2024
bb3e884
Changed the saving text
Drock54651 Jun 7, 2024
414f0df
Merge branch 'save-indicator' of https://github.com/MyersResearchGrou…
Drock54651 Jun 7, 2024
28fbcf2
fixed content overflowing when too many tabs open
Drock54651 Jun 8, 2024
bcacba5
More straightforward method to keep content contained
Drock54651 Jun 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/components/Expire.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useEffect, useState } from "react";
import { Text } from "@mantine/core";
// Elements within this component will be unrendered after a specified delay
export default function Expire({delay, children}){
const [visible, setVisible] = useState(true)

useEffect(() =>{
setTimeout(() =>{
setVisible(false)
}, delay)
}, [])

return(
<>
{visible && children}
</>
)
}
9 changes: 6 additions & 3 deletions src/components/activities/Activities.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Box, Tabs, Title, Tooltip } from '@mantine/core'
import { Box, Tabs, Title, Tooltip, Text } from '@mantine/core'
import { useActiveActivity, useActivities } from '../../redux/hooks/activityHooks'
import { getActivity } from '../../activities'
import { SVGIcon } from '../../icons'
import { FaBug } from "react-icons/fa";
import SaveIndicatorDisplay from '../saveIndicatorDisplay'

export default function Activities() {

Expand Down Expand Up @@ -36,7 +36,10 @@ export default function Activities() {
const activityDef = getActivity(activityId)
return (
<Tabs.Panel value={activityId} key={activityId}>
<Title order={6}>{activityDef.title}</Title>
<Title style={{display:"inline"}} order={6}>{activityDef.title}</Title>
<Text style={{display:"inline"}} size={'xs'} ml={10}>
<SaveIndicatorDisplay/>
</Text>
<activityDef.component {...activityState} />
</Tabs.Panel>
)
Expand Down
8 changes: 6 additions & 2 deletions src/components/activities/explorer/ExplorerList.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useCreateFile, useFiles } from '../../../redux/hooks/workingDirectoryHooks'
import CreateNewButton from "./CreateNewButton"
import { Accordion, ScrollArea, Title } from '@mantine/core'
import { Accordion, ScrollArea, Title, Text, Flex } from '@mantine/core'
import { ObjectTypes } from '../../../objectTypes'
import ExplorerListItem from './ExplorerListItem'
import SaveIndicatorDisplay from '../../saveIndicatorDisplay'


export default function ExplorerList({currentDirectory}) {
Expand All @@ -27,7 +28,10 @@ export default function ExplorerList({currentDirectory}) {

return (
<ScrollArea style={{ height: 'calc(100vh - 120px)' }}>
<Title mt={10} order={6}>Current Folder: {currentDirectory}</Title>
<Title mt={10} order={6}>
Current Folder: {currentDirectory}
</Title>

<Accordion
mt={10}
multiple
Expand Down
4 changes: 3 additions & 1 deletion src/components/panels/DragTabs.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState, useRef, useEffect } from "react"
import { Tabs } from '@mantine/core'
import { Text, Tabs } from '@mantine/core'
import { useSelector } from 'react-redux'


export default function DragTabs({
Expand Down Expand Up @@ -114,6 +115,7 @@ export default function DragTabs({
!tabIds.length && setDragState(null)
}, [tabIds.length])


return (
!!tabIds.length &&
<div
Expand Down
8 changes: 4 additions & 4 deletions src/components/panels/Panels.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export default function Panels() {
const panelIds = usePanelIds()
const [activePanel, setActivePanel] = useActivePanel()
const reorderPanels = useReorderPanels()

// first time visitor
const [firstTime] = useLocalStorage({ key: 'first-time-visiting', defaultValue: true })

return (
<div style={{ flexGrow: 1 }}>
return ( // overflow: hidden to prevent content from moving offscreen when too many tabs are open
<div style={{flexGrow: 1, overflow: "hidden"}}>
{panelIds.length ?
<DragTabs
tabComponent={Panel.Tab}
Expand Down
23 changes: 23 additions & 0 deletions src/components/saveIndicatorDisplay.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { CgCheckO } from "react-icons/cg";
import Expire from "./Expire";
import { useSelector } from "react-redux";
import { MdDataSaverOff } from "react-icons/md";

export default function SaveIndicatorDisplay() {
const isSaving = useSelector(state => state.saveIndicator.isSaving)
return (
<>
{isSaving ?
<span>
Saving...
<MdDataSaverOff color="#FFFF00" style={{marginLeft: "5px"}}/>
</span>
:
<Expire delay={3000}>
Saved
<CgCheckO style={{marginLeft: "5px"}} color='green'/>
</Expire>
}
</>
);
}
12 changes: 10 additions & 2 deletions src/redux/hooks/panelsHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createSelector } from "@reduxjs/toolkit"
import { useEffect, useMemo, useRef } from "react"
import { useDispatch, useSelector } from "react-redux"
import { getPanelType, getPanelTypeForObject } from "../../panels"

import { setIsSaving } from "../slices/saveIndicatorSlice"
const { actions, selectors } = panelsSlice


Expand Down Expand Up @@ -104,6 +104,8 @@ export function useActivePanel() {

export function useAutoSavePanel(id, debounceTime) {
const panel = usePanel(id)
useSelector(state => state.saveIndicator)
const dispatch = useDispatch()

// memoize serialization of panel
const serialized = useMemo(() => serializePanel(id), [panel])
Expand All @@ -118,7 +120,13 @@ export function useAutoSavePanel(id, debounceTime) {

// save when debounced serialized content changes
useEffect(() => {
commands.FileSave.execute(id)
const save = async() =>{
dispatch(setIsSaving(true))
await commands.FileSave.execute(id) // saving could be very fast, making it hard for users to see the "Saving..." text.
dispatch(setIsSaving(false))
}
save()

}, [debouncedPanelContent])
}

Expand Down
18 changes: 18 additions & 0 deletions src/redux/slices/saveIndicatorSlice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { createSlice } from "@reduxjs/toolkit"

const initialState = {
isSaving: false
}

export const saveIndicatorSlice = createSlice({
name: "saveIndicator",
initialState,
reducers:{
setIsSaving: (state, action) =>{
state.isSaving = action.payload
}
}
})

export const {setIsSaving} = saveIndicatorSlice.actions
export default saveIndicatorSlice.reducer
4 changes: 3 additions & 1 deletion src/redux/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { configureStore } from '@reduxjs/toolkit'
import panelsSlice from './slices/panelsSlice'
import workingDirectorySlice from "./slices/workingDirectorySlice"
import activitySlice from "./slices/activitySlice"
import saveIndicatorReducer from './slices/saveIndicatorSlice'

export default configureStore({
reducer: {
activities: activitySlice.reducer,
workingDirectory: workingDirectorySlice.reducer,
panels: panelsSlice.reducer,
saveIndicator: saveIndicatorReducer
}
})

export { panelsSlice, workingDirectorySlice, activitySlice }
export { panelsSlice, workingDirectorySlice, activitySlice, saveIndicatorReducer }
Loading