Skip to content

Commit 2fd4777

Browse files
committed
Merge branch 'main' of https://github.com/codex-team/notes.web into fix/note-title-composer
2 parents fb5f32a + 5f27bc9 commit 2fd4777

File tree

6 files changed

+151
-12
lines changed

6 files changed

+151
-12
lines changed

.github/workflows/npm-publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish CodeX UI to NPM
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '@codexteam/ui/**'
9+
10+
jobs:
11+
publish-ui:
12+
name: Publish @codexteam/ui package
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Setup Node.js from .nvmrc
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version-file: '.nvmrc'
23+
24+
- name: Install dependencies
25+
working-directory: '@codexteam/ui'
26+
run: yarn install
27+
28+
- name: Build package
29+
working-directory: '@codexteam/ui'
30+
run: yarn build
31+
32+
- name: Publish package to npm
33+
working-directory: '@codexteam/ui'
34+
run: yarn publish --access=public
35+
env:
36+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
37+
38+
notify:
39+
name: Notify in CodexBot
40+
needs: publish-ui
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v3
46+
47+
- name: Get UI package info
48+
id: ui-package
49+
uses: codex-team/action-nodejs-package-info@v1
50+
with:
51+
package_json_path: '@codexteam/ui/package.json'
52+
53+
- name: Send a message
54+
uses: codex-team/action-codexbot-notify@v1
55+
with:
56+
webhook: ${{ secrets.CODEX_BOT_WEBHOOK_HAWK }}
57+
message: |
58+
[${{ steps.ui-package.outputs.name }}](${{ steps.ui-package.outputs.npmjs-link }}) v${{ steps.ui-package.outputs.version }} was published
59+
parse_mode: markdown
60+
disable_web_page_preview: true

src/application/services/useNote.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ interface UseNoteComposableState {
7272
*/
7373
unlinkParent: () => Promise<void>;
7474

75+
/**
76+
* Returns an array of note parents for the current note.
77+
*/
78+
noteParents: Ref<Note[]>;
79+
7580
/**
7681
* Defines if user can edit note
7782
*/
@@ -165,6 +170,12 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
165170
*/
166171
const parentNote = ref<Note | undefined>(undefined);
167172

173+
/**
174+
* Note parents of the actual note
175+
*
176+
* Actual note by default
177+
*/
178+
const noteParents = ref<Note[]>([]);
168179
/**
169180
* Note hierarchy
170181
*
@@ -194,6 +205,7 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
194205
canEdit.value = response.accessRights.canEdit;
195206
noteTools.value = response.tools;
196207
parentNote.value = response.parentNote;
208+
noteParents.value = response.parents;
197209
void getNoteHierarchy(id);
198210
} catch (error) {
199211
deleteOpenedPageByUrl(route.path);
@@ -399,6 +411,7 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
399411
resolveToolsByContent,
400412
save,
401413
unlinkParent,
414+
noteParents,
402415
parentNote,
403416
noteHierarchy,
404417
};

src/domain/entities/NoteDTO.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ export interface NoteDTO {
2525
* Editor tools
2626
*/
2727
tools: EditorTool[];
28+
29+
/**
30+
* Note parents
31+
*/
32+
parents: Note[];
2833
}

src/infrastructure/transport/notes-api/types/GetNoteResponsePayload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export type GetNoteResponsePayload = {
1010
accessRights: NoteAccessRights;
1111
parentNote: Note | undefined;
1212
tools: EditorTool[];
13+
parents: Note[];
1314
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<template>
2+
<RouterLink
3+
v-for="(parent, index) in displayedParents"
4+
:key="index"
5+
:to="{ path: parent.id ? `/note/${parent.id}` : '' }"
6+
class="breadcrumb"
7+
>
8+
{{ parent.content ? getTitle(parent.content) : '...' }}
9+
<Icon
10+
v-if="index < displayedParents.length - 1"
11+
name="ChevronRight"
12+
/>
13+
</RouterLink>
14+
</template>
15+
16+
<script setup lang="ts">
17+
18+
import { getTitle } from '@/infrastructure/utils/note.ts';
19+
import { RouterLink } from 'vue-router';
20+
import { computed } from 'vue';
21+
import { Note } from '@/domain/entities/Note.ts';
22+
import { Icon } from '@codexteam/ui/vue';
23+
24+
const props = defineProps<{
25+
noteParents: Note[];
26+
}>();
27+
/**
28+
* Note parents hierarchy
29+
* If there are more than 3, only the closest & the furthest ones are shown
30+
*/
31+
const displayedParents = computed(() => {
32+
if (props.noteParents.length > 3) {
33+
return [
34+
props.noteParents[0],
35+
{ id: '',
36+
content: null },
37+
props.noteParents[props.noteParents.length - 1],
38+
];
39+
}
40+
41+
return props.noteParents;
42+
});
43+
</script>
44+
45+
<style scoped>
46+
.breadcrumb {
47+
display: inline-flex;
48+
align-items: center;
49+
}
50+
</style>

src/presentation/pages/Note.vue

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
:style="{ '--opacity': id && note ? 1 : 0 }"
55
>
66
<template #left>
7-
{{
8-
note && 'updatedAt' in note && note.updatedAt
9-
? t('note.lastEdit') + ' ' + getTimeFromNow(note.updatedAt)
10-
: t('note.lastEdit') + ' ' + 'a few seconds ago'
11-
}}
7+
<BreadCrumbs
8+
:note-parents="noteParents"
9+
/>
1210
</template>
1311
<template #right>
12+
<div class="last_edit">
13+
{{
14+
note && 'updatedAt' in note && note.updatedAt
15+
? t('note.lastEdit') + ' ' + getTimeFromNow(note.updatedAt)
16+
: t('note.lastEdit') + ' ' + 'a few seconds ago'
17+
}}
18+
</div>
1419
<!-- @todo when user clicks on + button to add new note the user should see the previous note heirarchy -->
1520
<Button
1621
v-if="canEdit"
@@ -60,18 +65,19 @@
6065

6166
<script lang="ts" setup>
6267
import { computed, ref, toRef, watch } from 'vue';
63-
import { Button, Editor, type VerticalMenuItem, VerticalMenu, PageBlock } from '@codexteam/ui/vue';
68+
import { Button, Editor, PageBlock, VerticalMenu, type VerticalMenuItem } from '@codexteam/ui/vue';
6469
import useNote from '@/application/services/useNote';
6570
import { useRoute, useRouter } from 'vue-router';
6671
import { NoteContent } from '@/domain/entities/Note';
6772
import { useHead } from 'unhead';
6873
import { useI18n } from 'vue-i18n';
69-
import { getTimeFromNow } from '@/infrastructure/utils/date';
7074
import { makeElementScreenshot } from '@/infrastructure/utils/screenshot';
7175
import useNoteSettings from '@/application/services/useNoteSettings';
7276
import { useNoteEditor } from '@/application/services/useNoteEditor';
7377
import NoteHeader from '@/presentation/components/note-header/NoteHeader.vue';
78+
import BreadCrumbs from '@/presentation/components/breadcrumbs/BreadCrumbs.vue';
7479
import { NoteHierarchy } from '@/domain/entities/NoteHierarchy';
80+
import { getTimeFromNow } from '@/infrastructure/utils/date.ts';
7581
7682
const { t } = useI18n();
7783
@@ -93,7 +99,7 @@ const props = defineProps<{
9399
94100
const noteId = toRef(props, 'id');
95101
96-
const { note, noteTools, save, noteTitle, canEdit, noteHierarchy } = useNote({
102+
const { note, noteTools, save, noteTitle, canEdit, noteParents, noteHierarchy } = useNote({
97103
id: noteId,
98104
});
99105
@@ -164,7 +170,7 @@ async function noteChanged(data: NoteContent): Promise<void> {
164170
});
165171
}
166172
if (updatedNoteCover !== null && props.id !== null) {
167-
updateCover(props.id, updatedNoteCover);
173+
await updateCover(props.id, updatedNoteCover);
168174
}
169175
}
170176
}
@@ -173,6 +179,7 @@ async function noteChanged(data: NoteContent): Promise<void> {
173179
* Recursively transform the note hierarchy into a VerticalMenuItem
174180
*
175181
* @param noteHierarchyObj - note hierarchy data
182+
* @param currentNoteTitle - actual title of note
176183
* @returns menuItem - VerticalMenuItem
177184
*/
178185
@@ -186,16 +193,14 @@ function transformNoteHierarchy(noteHierarchyObj: NoteHierarchy | null, currentN
186193
}
187194
188195
// Transform the current note into a VerticalMenuItem
189-
const menuItem: VerticalMenuItem = {
196+
return {
190197
title: noteHierarchyObj?.noteTitle || 'Untitled',
191198
isActive: route.path === `/note/${noteHierarchyObj.noteId}`,
192199
items: noteHierarchyObj.childNotes ? noteHierarchyObj.childNotes.map(child => transformNoteHierarchy(child, currentNoteTitle)) : undefined,
193200
onActivate: () => {
194201
void router.push(`/note/${noteHierarchyObj.noteId}`);
195202
},
196203
};
197-
198-
return menuItem;
199204
}
200205
201206
const verticalMenuItems = computed<VerticalMenuItem>(() => {
@@ -231,4 +236,9 @@ watch(noteTitle, () => {
231236
height: fit-content;
232237
width: auto;
233238
}
239+
240+
.last_edit {
241+
color: var(--base--text-secondary);
242+
padding-right: var(--h-padding);
243+
}
234244
</style>

0 commit comments

Comments
 (0)