Skip to content

Commit

Permalink
chire: hide "delete project" functionality behind a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mois-ilya committed Aug 27, 2024
1 parent 6912059 commit 4667088
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ VITE_TONAPI_TESTNET_BASE_URL=https://testnet.tonapi.io/v2/
# NOTE THAT IT HAS IP AND DOMAIN LIMIT RESTRICTIONS.
# THE USE OF THIS TOKEN IS NOT PERMITTED IN YOUR PROJECT. YOU HAVE TO CREATE YOUR OWN TOKEN.
VITE_TONAPI_TOKEN=AEW557REB3RXFIQAAAAPCJMD5KWORXNJ3XGLMQNGJB2EVS2QXO7VDFMLCOX4CFPEI43U3QI

# FEATURE FLAGS
VITE_AVAILABLE_DELETE_PROJECT=true
2 changes: 1 addition & 1 deletion src/features/analytics/model/analytics-query.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function isStrictDecimal(value: string): boolean {

async function downloadAndParseCSV(url: string): Promise<Record<string, number>[]> {
const preFetched = await fetch(url);
console.log(preFetched.headers.get('content-length')); // TODO check content-length
// console.log(preFetched.headers.get('content-length')); // TODO check content-length

const result = await preFetched.text();

Expand Down
43 changes: 25 additions & 18 deletions src/pages/settings/edit-project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { toJS } from 'mobx';
import { CopyPad, H4, Overlay } from 'src/shared';
import { observer } from 'mobx-react-lite';

const availableDeleteProject = import.meta.env.VITE_AVAILABLE_DELETE_PROJECT === 'true';

const EditProjectPage: FunctionComponent = () => {
const formId = 'edit-project-form';
const selectedProject = projectsStore.selectedProject;
Expand Down Expand Up @@ -90,24 +92,29 @@ const EditProjectPage: FunctionComponent = () => {
>
Save
</Button>
<Button
w="100%"
colorScheme="red"
isLoading={projectsStore.deleteProject.isLoading}
onClick={() => setDeleteConfirmationIsOpen(true)}
>
Delete project
</Button>
<DeleteProjectConfirmation
isOpen={deleteConfirmationIsOpen}
onClose={() => setDeleteConfirmationIsOpen(false)}
projectName={selectedProject.name}
onConfirm={() =>
projectsStore
.deleteProject(selectedProject.id)
.then(() => setDeleteConfirmationIsOpen(false))
}
/>

{availableDeleteProject && (
<>
<Button
w="100%"
colorScheme="red"
isLoading={projectsStore.deleteProject.isLoading}
onClick={() => setDeleteConfirmationIsOpen(true)}
>
Delete project
</Button>
<DeleteProjectConfirmation
isOpen={deleteConfirmationIsOpen}
onClose={() => setDeleteConfirmationIsOpen(false)}
projectName={selectedProject.name}
onConfirm={() =>
projectsStore
.deleteProject(selectedProject.id)
.then(() => setDeleteConfirmationIsOpen(false))
}
/>
</>
)}
</Flex>
</Center>
</Overlay>
Expand Down

0 comments on commit 4667088

Please sign in to comment.