Skip to content

Commit

Permalink
feat(config): configure the default delete-after-reading button state (
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinTh authored Oct 2, 2024
1 parent 29fca75 commit 9badc59
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/app-client/src/modules/config/config.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export const buildTimeConfig: Config = {
documentationBaseUrl: import.meta.env.VITE_DOCUMENTATION_BASE_URL ?? 'https://docs.enclosed.cc',
enclosedVersion: import.meta.env.VITE_ENCLOSED_VERSION ?? '0.0.0',
isAuthenticationRequired: import.meta.env.VITE_IS_AUTHENTICATION_REQUIRED === 'true',
defaultDeleteNoteAfterReading: import.meta.env.VITE_DEFAULT_DELETE_NOTE_AFTER_READING === 'true',
};
1 change: 1 addition & 0 deletions packages/app-client/src/modules/config/config.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export type Config = {
documentationBaseUrl: string;
isAuthenticationRequired: boolean;
enclosedVersion: string;
defaultDeleteNoteAfterReading: boolean;
};
14 changes: 6 additions & 8 deletions packages/app-client/src/modules/notes/pages/create-note.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,22 @@ import { useNoteContext } from '../notes.context';
import { encryptAndCreateNote } from '../notes.usecases';

export const CreateNotePage: Component = () => {
const config = getConfig();
const { t } = useI18n();
const navigate = useNavigate();
const { onResetNoteForm, removeResetNoteFormHandler } = useNoteContext();

const [getContent, setContent] = createSignal('');
const [getPassword, setPassword] = createSignal('');
const [getNoteUrl, setNoteUrl] = createSignal('');
const [getError, setError] = createSignal<{ message: string; details?: string } | null>(null);
const [getIsNoteCreated, setIsNoteCreated] = createSignal(false);
const [getIsPublic, setIsPublic] = createSignal(true);
const [getTtlInSeconds, setTtlInSeconds] = createSignal(3600);
const [getDeleteAfterReading, setDeleteAfterReading] = createSignal(false);
const [getDeleteAfterReading, setDeleteAfterReading] = createSignal(config.defaultDeleteNoteAfterReading);
const [getUploadedFiles, setUploadedFiles] = createSignal<File[]>([]);
const [getIsNoteCreating, setIsNoteCreating] = createSignal(false);

const { t } = useI18n();

const config = getConfig();
const navigate = useNavigate();

const { onResetNoteForm, removeResetNoteFormHandler } = useNoteContext();

function resetNoteForm() {
setContent('');
setPassword('');
Expand Down
11 changes: 11 additions & 0 deletions packages/app-server/src/modules/app/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ export const configDefinition = {
default: 'false',
env: 'PUBLIC_IS_AUTHENTICATION_REQUIRED',
},
defaultDeleteNoteAfterReading: {
doc: 'The default value for the `Delete note after reading` checkbox in the note creation form',
schema: z
.string()
.trim()
.toLowerCase()
.transform(x => x === 'true')
.pipe(z.boolean()),
default: 'false',
env: 'PUBLIC_DEFAULT_DELETE_NOTE_AFTER_READING',
},
},
authentication: {
jwtSecret: {
Expand Down

0 comments on commit 9badc59

Please sign in to comment.