Skip to content

Commit

Permalink
CRISTAL-257: The edit button is presented even if the current user do…
Browse files Browse the repository at this point in the history
…es not have edit rights

* Fix rights for FileSystem/GitHub/Nextcloud
* Enable edit buttons on non-existing pages
  • Loading branch information
pjeanjean committed Dec 23, 2024
1 parent 3668cf9 commit a7f4c2d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions core/backends/backend-github/src/githubStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class GitHubStorage extends AbstractStorage {
pageContentData.syntax = "md";
pageContentData.css = [];
pageContentData.version = this.hashCode(content);
pageContentData.canEdit = false;
return pageContentData;
}

Expand Down
1 change: 1 addition & 0 deletions core/backends/backend-nextcloud/src/nextcloudStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class NextcloudStorage extends AbstractStorage {
headlineRaw: json.name,
lastAuthor: lastAuthor,
lastModificationDate: lastModificationDate,
canEdit: true,
};
} else {
return undefined;
Expand Down
1 change: 1 addition & 0 deletions electron/storage/src/electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ async function readPage(
lastAuthor: { name: os.userInfo().username },
lastModificationDate: new Date(pageStats.mtimeMs),
id: relative(HOME_PATH_FULL, dirname(path)),
canEdit: true,
},
};
} else {
Expand Down
11 changes: 4 additions & 7 deletions skin/src/vue/c-content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,13 @@ onUpdated(() => {
</template>
<template #doc-page-actions>
<div class="doc-page-actions">
<!-- We need to enable the edit button when the page does not exist,
or when it exists and is editable by the current user. -->
<router-link
v-if="!currentPageRevision && currentPage?.canEdit"
v-if="!currentPageRevision && (!currentPage || currentPage?.canEdit)"
:to="{ name: 'edit', params: { page: currentPageName } }"
>
<x-btn
size="small"
:disabled="
currentPageRevision !== undefined || !currentPage?.canEdit
"
>
<x-btn size="small">
<c-icon name="pencil" :size="Size.Small"></c-icon>
Edit
</x-btn>
Expand Down

0 comments on commit a7f4c2d

Please sign in to comment.