Skip to content

Note hierarchy appreance #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions migrations/tenant/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DO $$
BEGIN
IF NOT EXISTS (
SELECT *
FROM information_schema.columns
WHERE table_name = 'note_settings' AND column_name = 'show_note_hierarchy'
) THEN
ALTER TABLE "public"."note_settings"
ADD COLUMN "show_note_hierarchy" BOOLEAN NOT NULL DEFAULT false;
END IF;
END $$;
8 changes: 7 additions & 1 deletion src/domain/entities/noteSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ export default interface NoteSettings {
* Team members. Team is empty by default because note creator is not stored in team
*/
team?: Team;

/**
* Note Heirarchy display
*/
showNoteHierarchy: boolean;
}

/**
* Attributes of public note settings
*/
type NoteSettingsPublicProperties = 'customHostname' | 'isPublic' | 'invitationHash' | 'team' | 'cover' ;
type NoteSettingsPublicProperties = 'customHostname' | 'isPublic' | 'invitationHash' | 'team' | 'cover' | 'showNoteHierarchy' ;

export interface NoteSettingsPublic extends Pick<NoteSettings, NoteSettingsPublicProperties> {}

Expand All @@ -63,6 +68,7 @@ export function definePublicNoteSettings(noteSettings: NoteSettings): NoteSettin
invitationHash: noteSettings.invitationHash,
team: noteSettings.team,
cover: noteSettings.cover,
showNoteHierarchy: noteSettings.showNoteHierarchy,
};
}

Expand Down
1 change: 1 addition & 0 deletions src/domain/service/noteSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default class NoteSettingsService {
noteId: noteId,
isPublic: isPublic,
invitationHash: createInvitationHash(),
showNoteHierarchy: false,
});
}

Expand Down
5 changes: 3 additions & 2 deletions src/presentation/http/router/noteSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const NoteSettingsRouter: FastifyPluginCallback<NoteSettingsRouterOptions> = (fa
* Patch noteSettings by note id
*/
fastify.patch<{
Body: Pick<NoteSettings, 'customHostname' | 'isPublic' | 'cover'>;
Body: Pick<NoteSettings, 'customHostname' | 'isPublic' | 'cover' | 'showNoteHierarchy'>;
Params: {
notePublicId: NotePublicId;
};
Expand Down Expand Up @@ -263,12 +263,13 @@ const NoteSettingsRouter: FastifyPluginCallback<NoteSettingsRouterOptions> = (fa
/**
* @todo validate data
*/
const { customHostname, isPublic, cover } = request.body;
const { customHostname, isPublic, cover, showNoteHierarchy } = request.body;

const updatedNoteSettings = await noteSettingsService.patchNoteSettingsByNoteId(noteId, {
customHostname,
isPublic,
cover,
showNoteHierarchy,
});

if (updatedNoteSettings === null) {
Expand Down
4 changes: 4 additions & 0 deletions src/presentation/http/schema/NoteSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,9 @@ export const NoteSettingsSchema = {
role: {
type: 'number',
},
showNoteHierarchy: {
type: 'boolean',
default: false,
},
},
};
12 changes: 12 additions & 0 deletions src/repository/storage/postgres/orm/sequelize/noteSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export class NoteSettingsModel extends Model<InferAttributes<NoteSettingsModel>,
* Id of the cover file
*/
public declare cover: CreationOptional<NoteSettings['cover']>;

/**
* Note heirarchy
*/
public declare showNoteHierarchy: NoteSettings['showNoteHierarchy'];
}

/**
Expand Down Expand Up @@ -105,6 +110,11 @@ export default class NoteSettingsSequelizeStorage {
type: DataTypes.STRING,
allowNull: true,
},
showNoteHierarchy: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
}, {
tableName: this.tableName,
sequelize: this.database,
Expand Down Expand Up @@ -194,13 +204,15 @@ export default class NoteSettingsSequelizeStorage {
customHostname,
isPublic,
invitationHash,
showNoteHierarchy,
}: NoteSettingsCreationAttributes
): Promise<NoteSettings> {
const settings = await this.model.create({
noteId,
customHostname,
isPublic,
invitationHash,
showNoteHierarchy,
});

return settings;
Expand Down
Loading