Skip to content
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

CRISTAL-304: Remove mock element from the early prototype #518

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions core/attachments/attachments-ui/src/AttachmentsInfoAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ export class AttachmentsInfoAction implements InfoAction {
page || this.cristalApp.getCurrentPage(),
);
}

async enabled(): Promise<boolean> {
return true;
}
}
6 changes: 6 additions & 0 deletions core/info-actions/info-actions-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ interface InfoAction {
* @since 0.10
*/
refresh?(page?: string): Promise<void>;

/**
* Compute whether the InfoAction should be displayed or not.
* @since 0.13
*/
enabled(): Promise<boolean>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { injectable, multiInject } from "inversify";
import { sortBy } from "lodash";

/**
* Default implementation of InfoActionsService. Returns the list of available
* Default implementation of InfoActionsService. Returns the list of enabled
* info action components sorted by ascending order.
*
* @since 0.9
Expand All @@ -36,6 +36,12 @@ export class DefaultInfoActionsService implements InfoActionsService {
constructor(@multiInject("InfoAction") private infoActions: InfoAction[]) {}

async list(): Promise<InfoAction[]> {
return sortBy(this.infoActions, ["order"]);
const enabledInfoActions: boolean[] = await Promise.all(
this.infoActions.map(async (tab) => tab.enabled()),
);
return sortBy(
this.infoActions.filter((_, i) => enabledInfoActions[i]),
["order"],
);
}
}
1 change: 1 addition & 0 deletions skin/langs/translation-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"page.creation.menu.submit": "Create",
"page.creation.menu.title": "New Page",
"information.extraTabs.title": "Information",
"help.label": "Help",
"history.alert.content": "You are currently viewing version {revision} of {pageName}. Edition is disabled.",
"history.alert.link.label": "Click here to go back to the latest version.",
"article.loading": "Loading..."
Expand Down
1 change: 1 addition & 0 deletions skin/langs/translation-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"page.creation.menu.submit": "Créer",
"page.creation.menu.title": "Nouvelle page",
"information.extraTabs.title": "Informations",
"help.label": "Aide",
"history.alert.content": "Vous consultez actuellement la version {revision} de {pageName}. L'édition est désactivée.",
"history.alert.link.label": "Ciquez ici pour retourner à la dernière version."
}
5 changes: 5 additions & 0 deletions skin/src/components/InformationTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class InformationExtraTab extends AbstractExtraTab {
async panel(): Promise<Component> {
return InformationTab;
}

override async enabled(): Promise<boolean> {
// TODO: Fix CRISTAL-372 to enable it.
return false;
}
}

export { InformationExtraTab };
5 changes: 5 additions & 0 deletions skin/src/components/info-actions/commentsInfoAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ export class CommentsInfoAction implements InfoAction {
async counter() {
return ref(99);
}

async enabled(): Promise<boolean> {
// TODO: Fix CRISTAL-47 to enable it.
return false;
}
}
5 changes: 5 additions & 0 deletions skin/src/components/info-actions/likesInfoAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ export class LikesInfoAction implements InfoAction {
async counter() {
return ref(99);
}

async enabled(): Promise<boolean> {
// TODO: Fix CRISTAL-370 to enable it.
return false;
}
}
13 changes: 1 addition & 12 deletions skin/src/vue/c-article.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<script setup lang="ts">
import xavatarImg from "../images/no-one.svg";
import messages from "../translations";
import { AlertsToasts } from "@xwiki/cristal-alerts-ui";
import { PageData } from "@xwiki/cristal-api";
import { ExtraTabs } from "@xwiki/cristal-extra-tabs-ui";
import { CIcon } from "@xwiki/cristal-icons";
import { InfoActions } from "@xwiki/cristal-info-actions-ui";
import { UIExtensions } from "@xwiki/cristal-uiextension-ui";
import { Ref, inject, ref, watch } from "vue";
Expand All @@ -15,7 +13,6 @@ import type {
PageHierarchyResolverProvider,
} from "@xwiki/cristal-hierarchy-api";

const avImg = xavatarImg;
const { t } = useI18n({
messages,
});
Expand Down Expand Up @@ -68,22 +65,14 @@ watch(

<div class="page-header">
<XBreadcrumb class="breadcrumb" :items="breadcrumbItems"></XBreadcrumb>
<x-btn circle size="small" variant="primary" color="primary">
<c-icon
class="new-page"
name="plus"
:label="t('page.actions.create.label')"
></c-icon>
</x-btn>
</div>

<div class="doc-header">
<div class="doc-header-inner">
<slot name="title"></slot>
<div class="info-wrapper">
<span class="doc-author">
<x-avatar class="avatar" :image="avImg" size="2rem"></x-avatar>
User Name edited on 12/12/2024 at 12:00
<!-- Add last edition information (CRISTAL-371). -->
</span>
<!-- TODO: add a way to inject those by extension
and provide one for the number of attachments.
Expand Down
18 changes: 16 additions & 2 deletions skin/src/vue/c-help.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,27 @@ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<script setup lang="ts">
import messages from "../translations";
import { CIcon } from "@xwiki/cristal-icons";
import { useI18n } from "vue-i18n";

const { t } = useI18n({
messages,
});

function onClick() {
// TODO: Add an actual Help section (CRISTAL-373).
window.open(
"https://cristal.xwiki.org/xwiki/bin/view/Documentation/UserGuide/",
pjeanjean marked this conversation as resolved.
Show resolved Hide resolved
"_blank",
);
}
</script>
<template>
<div class="help-button">
<x-btn pill size="small">
<x-btn pill size="small" @click="onClick">
<c-icon name="question-circle"></c-icon>
XWiki Help
{{ t("help.label") }}
</x-btn>
</div>
</template>
Expand Down
3 changes: 0 additions & 3 deletions skin/src/vue/c-sidebar-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<script setup lang="ts">
import { CIcon, Size } from "@xwiki/cristal-icons";

defineProps<{
name: string;
}>();
Expand All @@ -28,7 +26,6 @@ defineProps<{
<div class="c-sidebar-panel">
<div class="header">
<span class="title">{{ name }}</span>
<c-icon name="list-nested" :size="Size.Small"></c-icon>
</div>
<div class="sidebar-content">
<slot></slot>
Expand Down
7 changes: 2 additions & 5 deletions skin/src/vue/c-sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,14 @@ function onClickOutsideMainSidebar() {
<u-i-extensions uix-name="sidebar.actions"></u-i-extensions>
</suspense>
</div>
<div class="search">
<x-search></x-search>
</div>
<div class="panel-container">
<c-sidebar-panel name="Wiki Name">
<!-- TODO: Use wiki name as panel name (CRISTAL-374). -->
<c-sidebar-panel :name="cristal.getWikiConfig().name">
pjeanjean marked this conversation as resolved.
Show resolved Hide resolved
<c-page-creation-menu
:current-page="currentPage!"
></c-page-creation-menu>
<XNavigationTree :current-page="currentPage"></XNavigationTree>
</c-sidebar-panel>
<c-sidebar-panel name="Applications"></c-sidebar-panel>
<UIX uixname="sidebar.after" />
</div>
<c-help></c-help>
Expand Down
Loading