Skip to content

Commit

Permalink
add back the settings button to the dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Feb 25, 2024
1 parent 3447d3c commit a735049
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/content-scripts/content_script/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@ export async function main(
requestSearcher: remoteFunction('search'),
annotationsFunctions,
onDemandDisplay,
bgScriptBG,
})
},
}
Expand Down Expand Up @@ -1012,6 +1013,7 @@ export async function main(
localStorage: browser.storage.local,
services: createUIServices(),
renderUpdateNotifBanner: () => null,
bgScriptBG,
}

if (
Expand Down
2 changes: 2 additions & 0 deletions src/content-scripts/content_script/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { AnalyticsCoreInterface } from '@worldbrain/memex-common/lib/analyt
import type { SyncSettingsStore } from 'src/sync-settings/util'
import type { ErrorDisplayProps } from 'src/search-injection/error-display'
import type { SearchDisplayProps } from 'src/search-injection/search-display'
import { RemoteBGScriptInterface } from 'src/background-script/types'

export interface ContentScriptRegistry {
registerRibbonScript(main: RibbonScriptMain): Promise<void>
Expand Down Expand Up @@ -74,6 +75,7 @@ export interface InPageUIInjectionsDependencies {
errorDisplayProps?: ErrorDisplayProps
searchDisplayProps?: SearchDisplayProps
}
bgScriptBG: RemoteBGScriptInterface
}

export type HighlightsScriptMain = (
Expand Down
35 changes: 18 additions & 17 deletions src/dashboard-refactor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,9 @@ export class DashboardContainer extends StatefulUIElement<
}}
/>
</SearchSection>
{!this.props.inPageMode && (
<RightHeader>

<RightHeader>
{!this.props.inPageMode && (
<ActionWrapper>
<PrimaryAction
onClick={() =>
Expand All @@ -532,21 +533,21 @@ export class DashboardContainer extends StatefulUIElement<
innerRef={this.syncStatusButtonRef}
/>
</ActionWrapper>
{!this.props.inPageMode && (
<>
<Icon
onClick={() =>
window.open(SETTINGS_URL, '_self')
}
heightAndWidth="22px"
padding={'6px'}
filePath={icons.settings}
/>
{this.renderStatusMenu(syncStatusIconState)}
</>
)}
</RightHeader>
)}
)}
<>
<Icon
onClick={() =>
this.props.inPageMode
? this.props.openSettings()
: window.open(SETTINGS_URL, '_blank')
}
heightAndWidth="22px"
padding={'6px'}
filePath={icons.settings}
/>
{this.renderStatusMenu(syncStatusIconState)}
</>
</RightHeader>
</HeaderContainer>
)
}
Expand Down
3 changes: 3 additions & 0 deletions src/dashboard-refactor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import type {
} from '@worldbrain/memex-common/lib/common-ui/styles/types'
import { ImageSupportInterface } from 'src/image-support/background/types'
import { RemoteCopyPasterInterface } from 'src/copy-paster/background/types'
import { RemoteBGScriptInterface } from 'src/background-script/types'

export interface RootState {
loadState: TaskState
Expand Down Expand Up @@ -120,6 +121,8 @@ export type DashboardDependencies = {
>
imageSupportBG: ImageSupportInterface<'caller'>
closeInPageMode?: () => void
openSettings?: () => void
bgScriptBG: RemoteBGScriptInterface
} & (
| {
inPageMode: true
Expand Down
5 changes: 5 additions & 0 deletions src/search-injection/search-display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import type { DashboardDependencies } from 'src/dashboard-refactor/types'
import * as constants from './constants'
import { DashboardContainer } from 'src/dashboard-refactor'
import { InPageSearchModal } from '@worldbrain/memex-common/lib/common-ui/components/inPage-search-modal'
import { RemoteBGScriptInterface } from 'src/background-script/types'

type RootProps = Omit<DashboardDependencies, 'theme' | 'openSpaceInWebUI'> & {
rootEl: HTMLElement
bgScriptBG: RemoteBGScriptInterface
}

interface RootState {
Expand Down Expand Up @@ -60,6 +62,9 @@ class Root extends React.PureComponent<RootProps, RootState> {
getRootElement={() => rootEl}
onResultSelect={(exportedResultText) => null}
closeInPageMode={() => this.removeRoot(rootEl)}
openSettings={() => {
this.props.bgScriptBG.openOptionsTab('settings')
}}
/>
</InPageSearchModal>
</ThemeProvider>
Expand Down

0 comments on commit a735049

Please sign in to comment.