Skip to content

Commit

Permalink
Merge branch 'staging' into deployments/staging/makerdao
Browse files Browse the repository at this point in the history
  • Loading branch information
froid1911 committed Apr 23, 2024
2 parents e657a2c + 5f3b172 commit 2c40c7f
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy-makerdao-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
email: ${{ secrets.HEROKU_EMAIL }}
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
docker_options: "--build-arg BASE_PATH=/alpha/makerdao/connect --build-arg VITE_BASE_HREF=/alpha/makerdao/connect/ --build-arg VITE_ROUTER_BASENAME=/alpha/makerdao/connect --build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }} --build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }} --build-arg VITE_DEFAULT_DRIVE_URL=https://apps.powerhouse.io/alpha/makerdao/switchboard/d/monetalis"
docker_options: "--build-arg BASE_PATH=/alpha/makerdao/connect --build-arg VITE_BASE_HREF=/alpha/makerdao/connect/ --build-arg VITE_ROUTER_BASENAME=/alpha/makerdao/connect --build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }} --build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }} --build-arg VITE_DEFAULT_DRIVE_URL=https://apps.powerhouse.io/alpha/makerdao/switchboard/d/monetalis --build-arg VITE_CREATE_DOCUMENT_ALLOW_LIST=${{secrets.VITE_CREATE_DOCUMENT_ALLOW_LIST}}"
process_type: web
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ENV VITE_SENTRY_ENV=${VITE_SENTRY_ENV}
ARG VITE_DEFAULT_DRIVE_URL=""
ENV VITE_DEFAULT_DRIVE_URL=${VITE_DEFAULT_DRIVE_URL}

ARG VITE_ENABLED_EDITORS=undefined
ARG VITE_ENABLED_EDITORS="*"
ENV VITE_ENABLED_EDITORS=${VITE_ENABLED_EDITORS}

ARG VITE_DISABLE_ADD_PUBLIC_DRIVES=false
Expand All @@ -44,9 +44,12 @@ ENV VITE_DISABLE_DELETE_CLOUD_DRIVES=${VITE_DISABLE_DELETE_CLOUD_DRIVES}
ARG VITE_DISABLE_DELETE_LOCAL_DRIVES=false
ENV VITE_DISABLE_DELETE_LOCAL_DRIVES=${VITE_DISABLE_DELETE_LOCAL_DRIVES}

ARG VITE_LOCAL_DRIVES_ENABLED=true
ARG VITE_LOCAL_DRIVES_ENABLED=false
ENV VITE_LOCAL_DRIVES_ENABLED=${VITE_LOCAL_DRIVES_ENABLED}

ARG VITE_CREATE_DOCUMENT_ALLOW_LIST=""
ENV VITE_CREATE_DOCUMENT_ALLOW_LIST=${VITE_CREATE_DOCUMENT_ALLOW_LIST}

WORKDIR /opt/app
COPY . .
RUN npm install -g husky vite
Expand Down
27 changes: 14 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@
"xvfb-maybe": "^0.2.1"
},
"dependencies": {
"@powerhousedao/design-system": "1.0.0-alpha.97",
"@powerhousedao/design-system": "1.0.0-alpha.100",
"@sentry/react": "^7.109.0",
"did-key-creator": "^1.2.0",
"document-drive": "1.0.0-alpha.41",
"document-model": "^1.0.51",
"document-drive": "^1.0.0-alpha.46",
"document-model": "^1.0.52",
"document-model-libs": "^1.36.0",
"electron-is-dev": "^3.0.1",
"electron-squirrel-startup": "^1.0.0",
Expand Down
5 changes: 4 additions & 1 deletion src/components/modal/modals/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
Button,
ClearStorageSettingsRow,
SettingsModal as ConnectSettingsModal,
DocumentSelectSettingsRow,
DependencyVersions,
DocumentSelectSettingsRow
} from '@powerhousedao/design-system';
import { DocumentModel } from 'document-model/document';
import React, { useState } from 'react';
Expand All @@ -17,6 +18,7 @@ import {
useFilteredDocumentModels,
} from 'src/store/document-model';
import { useUser } from 'src/store/user';
import packageJson from '../../../../package.json';
import { Login } from '../../login';

const mapDocumentModelsToOptions = (documentModels: DocumentModel[]) =>
Expand Down Expand Up @@ -138,6 +140,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = props => {
'modals.connectSettings.clearStorage.description',
)}
/>
<DependencyVersions packageJson={packageJson} />
</ConnectSettingsModal>
);
};
17 changes: 11 additions & 6 deletions src/hooks/useDocumentDrives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,21 @@ export function useDocumentDrives(server: IDocumentDriveServer) {
);

const refreshDocumentDrives = useCallback(async () => {
const documentDrives: DocumentDriveDocument[] = [];
try {
const driveIds = await server.getDrives();
const drives = await Promise.all(
driveIds.map(id => server.getDrive(id)),
);

setDocumentDrives(drives);
for (const id of driveIds) {
try {
const drive = await server.getDrive(id);
documentDrives.push(drive);
} catch (error) {
console.error(error);
}
}
} catch (error) {
console.error(error);
setDocumentDrives([]);
} finally {
setDocumentDrives(documentDrives);
}
}, [server]);

Expand Down
5 changes: 0 additions & 5 deletions src/hooks/useIsAllowedToCreateDocuments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ export function useIsAllowedToCreateDocuments() {
const createDocumentAllowList =
createDocumentAllowListEnvString?.split(',');
if (createDocumentAllowList === undefined) {
console.warn(`
WARNING: The VITE_CREATE_DOCUMENT_ALLOW_LIST environment variable is not set.
This means that _any_ users will be allowed to create documents.
`);

return true;
}

Expand Down
6 changes: 5 additions & 1 deletion src/store/document-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ export const useGetDocumentModel = () => {
* @returns {Array<DocumentModel>} The filtered document models.
*/
export const useFilteredDocumentModels = () => {
const documentModels = useDocumentModels();
const _documentModels = useDocumentModels();
const { config } = useFeatureFlag();
const { enabledEditors, disabledEditors } = config.editors;

const documentModels = _documentModels.filter(
model => model.documentModel.id !== 'powerhouse/document-drive',
);

if (enabledEditors === '*') {
return documentModels;
}
Expand Down
18 changes: 14 additions & 4 deletions src/store/user.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { useEffect, useState } from 'react';
import { atom, useAtom } from 'jotai';
import { useEffect } from 'react';
import { useRenown } from 'src/hooks/useRenown';
import type { User } from 'src/services/renown/types';

let userInit = false;

const userAtom = atom<User | undefined>(undefined);

export const useUser = () => {
const [user, setUser] = useState<User | undefined>(undefined);
const [user, setUser] = useAtom(userAtom);
const renown = useRenown();

useEffect(() => {
if (userInit) return;
userInit = true;
renown
?.user()
.then(user => {
Expand All @@ -20,8 +27,11 @@ export const useUser = () => {
setUser(user);
});

return unsub;
}, [renown]);
return () => {
unsub?.();
userInit = false;
};
}, [renown, userInit]);

return user;
};

0 comments on commit 2c40c7f

Please sign in to comment.