Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mkotsollaris committed Feb 1, 2021
1 parent 178a787 commit 0a92883
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function App() {
load();


}, [setIsPluginEnabled, isPluginEnabled, showSideBar]);
}, [setIsPluginEnabled, isDomainWhitelisted, isPluginEnabled, showSideBar]);

// removing width/height hack
if ((isPluginEnabled && isDomainWhitelisted) || isDevelopment()) {
Expand Down
2 changes: 1 addition & 1 deletion src/AppProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const AppProvider = ({ children }) => {
const { enqueueSnackbar } = useSnackbar();

const [isPluginEnabled, setIsPluginEnabled] = isDevelopment() ? useState(true) : useState(false);
const [showSideBar, setShowSideBar] = isDevelopment() ? useState(true) : useState(false);
const [showSideBar, setShowSideBar] = useState(true);
const [loadingSideBar, setLoadingSideBar] = isDevelopment() ? useState(false) : useState(true);
const [isDomainWhitelisted, setIsDomainWhitelisted] = isDevelopment() ? useState(true) : useState(false);

Expand Down
18 changes: 7 additions & 11 deletions src/facetTreeSideBar/FacetTreeSideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,23 +223,19 @@ export default function FacetTreeSideBar() {
});
const activateDeactivateElement = showSideBar
? (
<CustomIconButtonContainer onClick={() => {
<FacetIconButton iconWidth="30" iconHeight="30" size="medium" title="Enable" key="edit" fill={color.ice} name="edit" onClick={() => {
if (!isDevelopment()) {
setLoadingSideBar(true);
}
sideBarHandler();
}} title="Disable" >
<FacetImage onMouseOver={(e) => { e.currentTarget.src = facetLogo }} onMouseOut={(e) => { e.currentTarget.src = facetLogoIce }} width="27" height="27" title="facet" src={facetLogoIce} />
</CustomIconButtonContainer>
}} />
) : (
<CustomIconButtonContainer onClick={() => {
<FacetIconButton iconWidth="30" iconHeight="30" size="medium" title="Disable" key="edit-outline" name="edit-outline" onClick={() => {
if (!isDevelopment()) {
setLoadingSideBar(true);
setLoadingSideBar(false);
}
sideBarHandler();
}} title="Enable">
<FacetImage onMouseOver={(e) => { e.currentTarget.src = facetLogoIce }} onMouseOut={(e) => { e.currentTarget.src = facetLogo }} width="27" height="27" title="facet" src={facetLogo} />
</CustomIconButtonContainer>
}} />
);

return (
Expand Down Expand Up @@ -296,8 +292,8 @@ export default function FacetTreeSideBar() {
</div>
<div className={classes.drawerHeader}>
{activateDeactivateElement}
<FacetIconButton iconWidth="30" iconHeight="30" size="medium" name="trash-2-outline" onClick={() => { reset(); }} title="Delete All" aria-label="Delete All" />
<FacetIconButton iconWidth="30" iconHeight="30" size="medium" title="save" name="save-outline" onClick={() => { onSaveClick(); }} aria-label="add" />
<FacetIconButton key="trash-2-outline" iconWidth="30" iconHeight="30" size="medium" name="trash-2-outline" onClick={() => { reset(); }} title="Delete All" aria-label="Delete All" />
<FacetIconButton key="save" iconWidth="30" iconHeight="30" size="medium" title="save" name="save-outline" onClick={() => { onSaveClick(); }} aria-label="add" />
</div>
</div>
<Divider style={{ backgroundColor: color.lightGray }} />
Expand Down
3 changes: 1 addition & 2 deletions src/highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ const scriptHasAlreadyBeenInjected = () => {
if (found) {
return;
}
if (script.getAttribute('src') && script.getAttribute('src').includes('facet.run')) {
if (script.getAttribute('src') && script.getAttribute('src').includes('https://api.facet.run/js')) {
found = true;
}
});
Expand All @@ -345,7 +345,6 @@ const initializeSingletonValues = async (eSBar) => {
workspaceId = await getKeyFromLocalStorage(api.workspace.workspaceId);
let getDomainRes = await getOrPostDomain(workspaceId);
domainId = getDomainRes.response.id;
getFacetResponse = await getFacet(domainId);
enqueueSnackbar = eSBar;
}

Expand Down
50 changes: 44 additions & 6 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'typeface-roboto';
import FacetSnackbar from './shared/FacetSnackbar';
import AmplifyService from './services/AmplifyService';
import WelcomeAbroadStandalone from './shared/WelcomeAbroad/WelcomeAbroadStandalone';
import isDevelopment from './utils/isDevelopment';

// duplicate code
const keys = {
Expand All @@ -26,12 +27,55 @@ const keys = {
'FACET_EXTENSION_ALREADY_INTEGRATED': 'FACET_EXTENSION_ALREADY_INTEGRATED',
}


const snackbarConfig = {
autoHideDuration: 5000,
vertical: 'bottom',
horizontal: 'left'
};

function getFacetExtensionCookie(key) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${key}=`);
if (parts.length === 2) return JSON.parse(parts.pop().split(';').shift());
}

if (isDevelopment()) {
if (isActivelyBeingDebugged(domIds.facetizer)) {
ReactDOM.render(
<React.StrictMode>
<div style={{ width: `${styles.drawerWidth}px`, height: '100%' }} id="facet-sidebar">
<SnackbarProvider
style={{ height: '100%' }}
maxSnack={4}
disableWindowBlurListener
autoHideDuration={snackbarConfig.autoHideDuration}
iconVariant={{
error: '✖️',
warning: '⚠️',
}}
anchorOrigin={{
vertical: snackbarConfig.vertical,
horizontal: snackbarConfig.horizontal,
}}
content={(key, message) => (
<FacetSnackbar id={key} {...message} />
)}
>
<AppProvider>
<CoreProvider>
<App />
</CoreProvider>
</AppProvider>
</SnackbarProvider>

</div>
</React.StrictMode >,
document.getElementById(domIds.facetizer),
);
}
}

(async () => {
try {
await chrome.runtime.sendMessage({
Expand Down Expand Up @@ -61,12 +105,6 @@ function getFacetExtensionCookie(key) {

Amplify.configure(awsExports);

const snackbarConfig = {
autoHideDuration: 5000,
vertical: 'bottom',
horizontal: 'left'
}

// TODO fix duplication
if (process.env.NODE_ENV !== 'development') {
Sentry.init({
Expand Down
2 changes: 1 addition & 1 deletion src/shared/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const appId = 'hpkpjkdhgldjhcopdkmljdgceeojoglh';

// helper during local debugging
const isActivelyBeingDebugged = (id) => {
const activelyDebuggingElementIds = [domIds.authentication];
const activelyDebuggingElementIds = [domIds.facetizer];
if (!isDevelopment()) {
return true;
}
Expand Down

0 comments on commit 0a92883

Please sign in to comment.