Skip to content

Commit

Permalink
Workspace history
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-7 committed Oct 21, 2024
1 parent c27c342 commit 1b7eb16
Show file tree
Hide file tree
Showing 20 changed files with 570 additions and 27 deletions.
6 changes: 3 additions & 3 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@types/luxon": "^3.3.4",
"axios": "^1.7.4",
"luxon": "^3.4.4",
"megashark-lib": "git+https://github.com/Scille/megashark-lib.git#7f7201e1895f328a0af0de3e9b2544782a270024",
"megashark-lib": "git+https://github.com/Scille/megashark-lib.git#cec6e1c2e2a8e0628eae8627d98bf70c6c15fb48",
"qrcode-vue3": "^1.6.8",
"uuid": "^9.0.1",
"vue": "^3.3.8",
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/files/FileCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:current-path="currentPath"
@files-added="$emit('filesAdded', $event)"
:is-reader="isWorkspaceReader"
@drop-as-reader="$emit('dropAsReader')"
>
<div class="card-checkbox">
<!-- eslint-disable vue/no-mutating-props -->
Expand Down Expand Up @@ -101,6 +102,7 @@ const emits = defineEmits<{
(e: 'click', event: Event, entry: EntryModel): void;
(e: 'menuClick', event: Event, entry: EntryModel, onFinished: () => void): void;
(e: 'filesAdded', imports: FileImportTuple[]): void;
(e: 'dropAsReader'): void;
}>();
defineExpose({
Expand Down
15 changes: 4 additions & 11 deletions client/src/components/files/FileDropZone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import { DocumentImport, MsImage } from 'megashark-lib';
import { FileImportTuple, getFilesFromDrop } from '@/components/files/utils';
import { FsPath } from '@/parsec';
import { IonLabel } from '@ionic/vue';
import { computed, inject, onMounted, onUnmounted, ref } from 'vue';
import { Information, InformationLevel, InformationManager, InformationManagerKey, PresentationMode } from '@/services/informationManager';
import { computed, onMounted, onUnmounted, ref } from 'vue';
defineExpose({
reset,
Expand All @@ -50,10 +49,10 @@ const props = defineProps<{
const emits = defineEmits<{
(e: 'filesAdded', imports: FileImportTuple[]): void;
(e: 'dropAsReader'): void;
}>();
const dragEnterCount = ref(0);
const informationManager: InformationManager = inject(InformationManagerKey)!;
const isActive = computed(() => {
return !props.disabled && !props.isReader && dragEnterCount.value > 0;
Expand All @@ -77,19 +76,13 @@ onUnmounted(() => {
async function onDrop(event: DragEvent): Promise<void> {
if (props.isReader) {
await informationManager.present(
new Information({
message: 'FoldersPage.ImportFile.noDropForReader',
level: InformationLevel.Error,
}),
PresentationMode.Toast,
);
event.stopPropagation();
emits('dropAsReader');
return;
}
if (props.disabled) {
return;
}
event.stopPropagation();
dragEnterCount.value = 0;
const imports = await getFilesFromDrop(event, props.currentPath);
if (imports.length) {
Expand Down
4 changes: 4 additions & 0 deletions client/src/components/files/FileGridDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:show-drop-message="true"
@files-added="$emit('filesAdded', $event)"
:is-reader="ownRole === WorkspaceRole.Reader"
@drop-as-reader="$emit('dropAsReader')"
>
<div
class="scroll"
Expand All @@ -24,6 +25,7 @@
@menu-click="(event, entry, onFinished) => $emit('menuClick', event, entry, onFinished)"
@files-added="onFilesAdded"
:is-workspace-reader="ownRole === WorkspaceRole.Reader"
@drop-as-reader="$emit('dropAsReader')"
/>
<file-card
class="folder-grid-item"
Expand All @@ -35,6 +37,7 @@
@click="$emit('click', file, $event)"
@menu-click="(event, entry, onFinished) => $emit('menuClick', event, entry, onFinished)"
@files-added="onFilesAdded"
@drop-as-reader="$emit('dropAsReader')"
/>

<file-card-processing
Expand Down Expand Up @@ -73,6 +76,7 @@ const emits = defineEmits<{
(e: 'menuClick', event: Event, entry: EntryModel, onFinished: () => void): void;
(e: 'globalMenuClick', event: Event): void;
(e: 'filesAdded', imports: FileImportTuple[]): void;
(e: 'dropAsReader'): void;
}>();
onMounted(async () => {
Expand Down
4 changes: 4 additions & 0 deletions client/src/components/files/FileListDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@files-added="$emit('filesAdded', $event)"
:show-drop-message="true"
:is-reader="ownRole === WorkspaceRole.Reader"
@drop-as-reader="$emit('dropAsReader')"
>
<div
class="scroll"
Expand Down Expand Up @@ -54,6 +55,7 @@
@selected-change="onSelectedChange"
@files-added="onFilesAdded"
:is-workspace-reader="ownRole === WorkspaceRole.Reader"
@drop-as-reader="$emit('dropAsReader')"
/>
<file-list-item
v-for="file in files.getEntries()"
Expand All @@ -65,6 +67,7 @@
@menu-click="(event, entry, onFinished) => $emit('menuClick', event, entry, onFinished)"
@selected-change="onSelectedChange"
@files-added="onFilesAdded"
@drop-as-reader="$emit('dropAsReader')"
/>
<file-list-item-processing
v-for="op in operationsInProgress"
Expand Down Expand Up @@ -103,6 +106,7 @@ const emits = defineEmits<{
(e: 'menuClick', event: Event, entry: EntryModel, onFinished: () => void): void;
(e: 'globalMenuClick', event: Event): void;
(e: 'filesAdded', imports: FileImportTuple[]): void;
(e: 'dropAsReader'): void;
}>();
const fileDropZoneRef = ref();
Expand Down
16 changes: 13 additions & 3 deletions client/src/components/files/FileListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

<template>
<file-drop-zone
:disabled="entry.isFile()"
:disabled="disableDrop ||entry.isFile()"
:current-path="currentPath"
@files-added="$emit('filesAdded', $event)"
:is-reader="isWorkspaceReader"
class="drop-zone-item"
@drop-as-reader="$emit('dropAsReader')"
>
<ion-item
button
Expand Down Expand Up @@ -43,6 +44,7 @@
{{ entry.name }}
</ion-label>
<ion-icon
v-show="!hideSyncStatus"
class="cloud-overlay"
:class="isFileSynced() ? 'cloud-overlay-ok' : 'cloud-overlay-ko'"
:icon="isFileSynced() ? cloudDone : cloudOffline"
Expand All @@ -62,7 +64,10 @@
</div>

<!-- last update -->
<div class="file-lastUpdate">
<div
class="file-lastUpdate"
v-show="!hideLastUpdate"
>
<ion-label class="label-last-update cell">
{{ $msTranslate(formatTimeSince(entry.updated, '--', 'short')) }}
</ion-label>
Expand All @@ -82,7 +87,7 @@
<div class="file-options ion-item-child-clickable">
<ion-button
fill="clear"
v-show="isHovered || menuOpened"
v-show="!hideMenu && (isHovered || menuOpened)"
class="options-button"
@click.stop="onOptionsClick($event)"
@dblclick.stop
Expand Down Expand Up @@ -118,13 +123,18 @@ const props = defineProps<{
entry: EntryModel;
showCheckbox: boolean;
isWorkspaceReader?: boolean;
disableDrop?: boolean;
hideSyncStatus?: boolean;
hideLastUpdate?: boolean;
hideMenu?: boolean;
}>();
const emits = defineEmits<{
(e: 'click', event: Event, entry: EntryModel): void;
(e: 'menuClick', event: Event, entry: EntryModel, onFinished: () => void): void;
(e: 'selectedChange', entry: EntryModel, checked: boolean): void;
(e: 'filesAdded', imports: FileImportTuple[]): void;
(e: 'dropAsReader'): void;
}>();
defineExpose({
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/header/HeaderBreadcrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ const props = withDefaults(
pathNodes: RouterPathNode[];
itemsBeforeCollapse?: number;
itemsAfterCollapse?: number;
maxShown?: number;
}>(),
{
itemsBeforeCollapse: 2,
itemsAfterCollapse: 2,
maxShown: 4,
},
);
Expand All @@ -68,11 +70,11 @@ const emits = defineEmits<{
// Using a computed to reset maxBreadcrumbs value automatically
const fullPath = computed(() => {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
maxBreadcrumbs.value = 4;
maxBreadcrumbs.value = props.maxShown;
return props.pathNodes;
});
const maxBreadcrumbs: Ref<number | undefined> = ref(4);
const maxBreadcrumbs: Ref<number | undefined> = ref(props.maxShown);
let ignoreNextEvent = false;
function expandCollapsed(): void {
Expand Down
17 changes: 17 additions & 0 deletions client/src/components/workspaces/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import { Information, InformationLevel, InformationManager, PresentationMode } f
import { StorageManager } from '@/services/storageManager';
import WorkspaceContextMenu, { WorkspaceAction } from '@/views/workspaces/WorkspaceContextMenu.vue';
import WorkspaceSharingModal from '@/views/workspaces/WorkspaceSharingModal.vue';
import WorkspaceHistoryModal from '@/views/workspaces/WorkspaceHistoryModal.vue';
import { modalController, popoverController } from '@ionic/vue';
import { Clipboard, DisplayState, Translatable, getTextFromUser } from 'megashark-lib';
import { navigateTo, Routes } from '@/router';

export const WORKSPACES_PAGE_DATA_KEY = 'WorkspacesPage';

Expand Down Expand Up @@ -152,6 +154,9 @@ export async function openWorkspaceContextMenu(
case WorkspaceAction.Favorite:
await toggleFavorite(workspace, favorites, eventDistributor, storageManager);
break;
case WorkspaceAction.ShowHistory:
await navigateTo(Routes.History, { query: { documentPath: '/', workspaceHandle: workspace.handle } })
break;
default:
console.warn('No WorkspaceAction match found');
}
Expand Down Expand Up @@ -260,6 +265,18 @@ async function copyLinkToClipboard(workspace: WorkspaceInfo, informationManager:
}
}

// async function openWorkspaceHistoryModal(workspace: WorkspaceInfo): Promise<void> {
// const modal = await modalController.create({
// component: WorkspaceHistoryModal,
// componentProps: {
// workspace: workspace,
// },
// cssClass: 'workspace-history-modal',
// });
// await modal.present();
// await modal.onWillDismiss();
// }

/**
*
* @param role1 A workspace role
Expand Down
3 changes: 2 additions & 1 deletion client/src/parsec/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export async function entryStat(workspaceHandle: WorkspaceHandle, path: FsPath):
export async function statFolderChildren(
workspaceHandle: WorkspaceHandle,
path: FsPath,
atDateTime?: DateTime,
): Promise<Result<Array<EntryStat>, WorkspaceStatFolderChildrenError>> {
if (!needsMocks()) {
const watchResult = await libparsec.workspaceWatchEntryOneshot(workspaceHandle, path);
Expand Down Expand Up @@ -214,7 +215,7 @@ export async function statFolderChildren(

const FILE_PREFIX = 'File_';
const FOLDER_PREFIX = 'Dir_';
const fileCount = 2;
const fileCount = 3;
const folderCount = 2;

function generateEntryName(prefix: string = '', addExtension = false): string {
Expand Down
3 changes: 2 additions & 1 deletion client/src/router/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function currentRouteIsOrganizationManagementRoute(): boolean {
}

export function currentRouteIsFileRoute(): boolean {
return currentRouteIsOneOf([Routes.Documents, Routes.Workspaces]);
return currentRouteIsOneOf([Routes.Documents, Routes.Workspaces, Routes.History]);
}

export function currentRouteIsLoggedRoute(): boolean {
Expand All @@ -66,5 +66,6 @@ export function currentRouteIsLoggedRoute(): boolean {
Routes.About,
Routes.MyProfile,
Routes.RecoveryExport,
Routes.History,
]);
}
2 changes: 1 addition & 1 deletion client/src/router/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getWorkspaceHandle(): WorkspaceHandle | undefined {
const router = getRouter();
const currentRoute = router.currentRoute.value;

if (currentRoute && currentRoute.name === Routes.Documents && currentRoute.query && 'workspaceHandle' in currentRoute.query) {
if (currentRoute && currentRoute.query && 'workspaceHandle' in currentRoute.query) {
return parseInt(currentRoute.query.workspaceHandle as string) as WorkspaceHandle;
}
return undefined;
Expand Down
6 changes: 6 additions & 0 deletions client/src/router/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum Routes {
Loading = 'loading',
ClientAreaLogin = 'clientLogin',
ClientArea = 'clientArea',
History = 'history',
}

const routes: Array<RouteRecordRaw> = [
Expand Down Expand Up @@ -76,6 +77,11 @@ const routes: Array<RouteRecordRaw> = [
name: Routes.Documents,
component: () => import('@/views/files/FoldersPage.vue'),
},
{
path: `/:handle(\\d+)/${Routes.History}`,
name: Routes.History,
component: () => import('@/views/workspaces/WorkspaceHistoryPage.vue'),
}
],
},
{
Expand Down
Loading

0 comments on commit 1b7eb16

Please sign in to comment.