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

BC-8396 - Adjust BoardTile design (2) #3470

Merged
merged 53 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
20905f8
extract RoomMenu component
odalys-dataport Nov 26, 2024
b2d33b6
separate RoomDetailsPage from switch logic
odalys-dataport Nov 26, 2024
71594eb
adjust room variable usage
odalys-dataport Nov 28, 2024
3b6ddb4
Merge branch 'main' into BC-8396-board-card-design
odalys-dataport Nov 28, 2024
afbfdef
remove RoomDetails component
odalys-dataport Nov 28, 2024
462537b
adjust boardtile design
odalys-dataport Nov 28, 2024
8c3ca7d
emit events in RoomMenu instead of linking directly
odalys-dataport Nov 29, 2024
94e64be
solve merge conflict in RoomDetailsPage
odalys-dataport Nov 29, 2024
b10b3da
keep loading state in RoomDetailsSwitchPage
odalys-dataport Nov 29, 2024
83b93f3
add sidebar highlight for room boards
odalys-dataport Nov 29, 2024
961286a
two columns for tablet sizes
odalys-dataport Nov 29, 2024
a8a0d05
fix board-tile-title data-testid index
odalys-dataport Nov 29, 2024
b7822a3
fix routing bug & rename route
odalys-dataport Dec 2, 2024
53680f1
add id regex to room routes
odalys-dataport Dec 2, 2024
c3098e7
correct router import
odalys-dataport Dec 2, 2024
768ac34
use card variants instead of classes
odalys-dataport Dec 2, 2024
0c78095
use bg-surface-light
odalys-dataport Dec 2, 2024
f47a645
fix RoomColor enum imports
odalys-dataport Dec 4, 2024
59c158d
Merge branch 'main' into BC-8396-board-card-design
odalys-dataport Dec 4, 2024
8f33964
Merge branch 'BC-8396-board-card-design' of https://github.com/hpi-sc…
odalys-dataport Dec 4, 2024
95f424f
adjust opacity
odalys-dataport Dec 4, 2024
accf780
use line clamp component
odalys-dataport Dec 4, 2024
0342763
use LineClamp on RoomTile
odalys-dataport Dec 4, 2024
c12de91
solve merge conflicts
odalys-dataport Dec 5, 2024
1919d79
solve merge conflicts part 2
odalys-dataport Dec 5, 2024
8a6d02b
remove double script in LineClamp
odalys-dataport Dec 5, 2024
82c18f0
Merge branch 'main' into BC-8396-board-card-design-2
odalys-dataport Dec 6, 2024
521ae96
Adjust RoomMenu and BoardTile tests
odalys-dataport Dec 6, 2024
fd9f4b5
fix SidebarSelection composable tests
odalys-dataport Dec 6, 2024
c17aef7
sort out roomdetails page tests
odalys-dataport Dec 8, 2024
694d2b7
solve merge conflicts
odalys-dataport Dec 10, 2024
d3fb346
rename roomFactory
odalys-dataport Dec 10, 2024
3216f9d
adjusted mounting tests & started menu tests
odalys-dataport Dec 10, 2024
5a49c45
little cleanup
odalys-dataport Dec 11, 2024
f5e5049
Merge branch 'main' of https://github.com/hpi-schul-cloud/nuxt-client…
odalys-dataport Dec 11, 2024
f1ae7eb
add speed dial menu tests to room details page
odalys-dataport Dec 11, 2024
dc85c77
add RoomDetailsSwitchPage unit tests
odalys-dataport Dec 12, 2024
fc5f56e
add data test id to custom dialog
odalys-dataport Dec 13, 2024
2877a2c
remove obsolete setup config in RoomMenu unit tests
odalys-dataport Dec 13, 2024
5d8f734
remove LineClamp from RoomTile
odalys-dataport Dec 13, 2024
74087d9
adjust roomFactory schoolId
odalys-dataport Dec 13, 2024
8e44ed5
Merge branch 'main' into BC-8396-board-card-design-2
odalys-dataport Dec 13, 2024
2d6ad46
refactor room board creation
uidp Dec 15, 2024
bc9da83
fix tests
uidp Dec 15, 2024
43728dd
npm audit fix
uidp Dec 15, 2024
ad830cd
add test for board creation
uidp Dec 16, 2024
369f3cf
fix room create permission
uidp Dec 16, 2024
4463893
Merge branch 'main' into BC-8396-board-card-design-2
uidp Dec 16, 2024
548e13d
fix test
uidp Dec 16, 2024
e847fa8
Merge branch 'BC-8396-board-card-design-2' of github.com:hpi-schul-cl…
uidp Dec 16, 2024
e35a599
Revert "npm audit fix"
uidp Dec 16, 2024
ec97e81
Merge branch 'main' into BC-8396-board-card-design-2
MartinSchuhmacher Dec 16, 2024
a99831e
Merge branch 'main' into BC-8396-board-card-design-2
odalys-dataport Dec 16, 2024
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
1 change: 1 addition & 0 deletions config/webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ module.exports = {
"@ui-kebab-menu": getDir("src/modules/ui/kebab-menu"),
"@ui-layout": getDir("src/modules/ui/layout"),
"@ui-light-box": getDir("src/modules/ui/light-box"),
"@ui-line-clamp": getDir("src/modules/ui/line-clamp"),
"@ui-preview-image": getDir("src/modules/ui/preview-image"),
"@ui-room-details": getDir("src/modules/ui/room-details"),
"@ui-skip-link": getDir("src/modules/ui/skip-link"),
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/vCustomDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@click:outside="closeDialog"
@keydown.esc="closeDialog"
>
<v-card :ripple="false">
<v-card :ripple="false" data-testid="dialog-content">
<v-card-title data-testid="dialog-title" class="dialog-title px-6 pt-4">
<slot name="title" />
</v-card-title>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/data/board/Board.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export const useBoardStore = defineStore("boardStore", () => {
const deleteBoardSuccess = (payload: DeleteBoardSuccessPayload) => {
if (payload.isOwnAction === true) {
router.replace({
name: "rooms-id",
name: "room-details",
params: { id: roomId.value },
});
return;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/data/board/Board.store.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ describe("BoardStore", () => {
});

expect(router.replace).toHaveBeenCalledWith({
name: "rooms-id",
name: "room-details",
params: { id: "roomId" },
});
});
Expand Down
6 changes: 3 additions & 3 deletions src/modules/data/room/RoomCreate.state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RoomApiFactory, RoomColor } from "@/serverApi/v3";
import { RoomCreateParams, RoomItem } from "@/types/room/Room";
import { RoomApiFactory } from "@/serverApi/v3";
import { RoomCreateParams, RoomItem, RoomColorEnum } from "@/types/room/Room";
import { $axios, mapAxiosErrorToResponseError } from "@/utils/api";
import { ref } from "vue";

Expand All @@ -9,7 +9,7 @@ export const useRoomCreateState = () => {

const roomData = ref<RoomCreateParams>({
name: "",
color: RoomColor.BlueGrey,
color: RoomColorEnum.BlueGrey,
startDate: undefined,
endDate: undefined,
});
Expand Down
4 changes: 2 additions & 2 deletions src/modules/data/room/RoomCreate.state.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useApplicationError } from "@/composables/application-error.composable"
import { initializeAxios, mapAxiosErrorToResponseError } from "@/utils/api";
import setupStores from "@@/tests/test-utils/setupStores";
import ApplicationErrorModule from "@/store/application-error";
import { RoomCreateParams } from "@/types/room/Room";
import { RoomCreateParams, RoomColorEnum } from "@/types/room/Room";
import { ref } from "vue";
import {
apiResponseErrorFactory,
Expand Down Expand Up @@ -73,7 +73,7 @@ describe("useRoomCreateState", () => {
describe("createRoom", () => {
const roomData = ref<RoomCreateParams>({
name: "Room 1",
color: serverApi.RoomColor.BlueGrey,
color: RoomColorEnum.BlueGrey,
startDate: undefined,
endDate: undefined,
});
Expand Down
26 changes: 25 additions & 1 deletion src/modules/data/room/RoomDetails.store.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { RoomBoardItem, RoomDetails } from "@/types/room/Room";
import { ref } from "vue";
import { defineStore } from "pinia";
import { RoomApiFactory } from "@/serverApi/v3";
import {
BoardApiFactory,
BoardLayout,
BoardParentType,
CreateBoardBodyParams,
RoomApiFactory,
} from "@/serverApi/v3";
import { $axios, mapAxiosErrorToResponseError } from "@/utils/api";
import { createApplicationError } from "@/utils/create-application-error.factory";

Expand All @@ -17,6 +23,7 @@ export const useRoomDetailsStore = defineStore("roomDetailsStore", () => {
const roomBoards = ref<RoomBoardItem[]>([]);

const roomApi = RoomApiFactory(undefined, "/v3", $axios);
const boardApi = BoardApiFactory(undefined, "/v3", $axios);

const fetchRoom = async (id: string) => {
try {
Expand All @@ -38,6 +45,22 @@ export const useRoomDetailsStore = defineStore("roomDetailsStore", () => {
}
};

const createBoard = async (
roomId: string,
layout: BoardLayout,
title: string
) => {
const params: CreateBoardBodyParams = {
title: title,
parentId: roomId,
parentType: BoardParentType.Room,
layout,
};
const boardId = (await boardApi.boardControllerCreateBoard(params)).data.id;

return boardId;
};

const resetState = () => {
isLoading.value = true;
room.value = undefined;
Expand All @@ -51,6 +74,7 @@ export const useRoomDetailsStore = defineStore("roomDetailsStore", () => {
return {
deactivateRoom,
fetchRoom,
createBoard,
isLoading,
resetState,
room,
Expand Down
30 changes: 30 additions & 0 deletions src/modules/data/room/RoomDetails.store.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { initializeAxios, mapAxiosErrorToResponseError } from "@/utils/api";
import {
apiResponseErrorFactory,
axiosErrorFactory,
mockApiResponse,
} from "@@/tests/test-utils";

jest.mock("@/utils/api");
Expand Down Expand Up @@ -35,12 +36,14 @@ const setupErrorResponse = (message = "NOT_FOUND", code = 404) => {

describe("useRoomDetailsStore", () => {
let roomApiMock: DeepMocked<serverApi.RoomApiInterface>;
let boardApiMock: DeepMocked<serverApi.BoardApiInterface>;
let axiosMock: DeepMocked<AxiosInstance>;
let mockedCreateApplicationErrorCalls: ReturnType<typeof useApplicationError>;

beforeEach(() => {
setActivePinia(createPinia());
roomApiMock = createMock<serverApi.RoomApiInterface>();
boardApiMock = createMock<serverApi.BoardApiInterface>();
axiosMock = createMock<AxiosInstance>();
mockedCreateApplicationErrorCalls =
createMock<ReturnType<typeof useApplicationError>>();
Expand All @@ -49,6 +52,7 @@ describe("useRoomDetailsStore", () => {
);

jest.spyOn(serverApi, "RoomApiFactory").mockReturnValue(roomApiMock);
jest.spyOn(serverApi, "BoardApiFactory").mockReturnValue(boardApiMock);
initializeAxios(axiosMock);
});

Expand Down Expand Up @@ -135,4 +139,30 @@ describe("useRoomDetailsStore", () => {
expect(store.room).toBeUndefined();
});
});

describe("createBoard", () => {
it("should call createBoard api", async () => {
const { store } = setup();
const boardId = "board-id";
const roomId = "room-id";
const layout = serverApi.BoardLayout.Columns;
const title = "title";

boardApiMock.boardControllerCreateBoard.mockResolvedValue(
mockApiResponse({
data: { id: boardId },
})
);

const result = await store.createBoard(roomId, layout, title);

expect(result).toBe(boardId);
expect(boardApiMock.boardControllerCreateBoard).toHaveBeenCalledWith({
title,
parentId: roomId,
parentType: serverApi.BoardParentType.Room,
layout,
});
});
});
});
10 changes: 7 additions & 3 deletions src/modules/data/room/RoomEdit.state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { RoomApiFactory, RoomColor } from "@/serverApi/v3";
import { RoomDetails, RoomUpdateParams } from "@/types/room/Room";
import { RoomApiFactory } from "@/serverApi/v3";
import {
RoomDetails,
RoomUpdateParams,
RoomColorEnum,
} from "@/types/room/Room";
import { $axios, mapAxiosErrorToResponseError } from "@/utils/api";
import { createApplicationError } from "@/utils/create-application-error.factory";
import { ref } from "vue";
Expand All @@ -19,7 +23,7 @@ export const useRoomEditState = () => {

const roomData = ref<RoomUpdateParams>({
name: "",
color: RoomColor.BlueGrey,
color: RoomColorEnum.BlueGrey,
startDate: undefined,
endDate: undefined,
});
Expand Down
5 changes: 3 additions & 2 deletions src/modules/data/room/RoomEdit.state.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
apiResponseErrorFactory,
axiosErrorFactory,
} from "@@/tests/test-utils";
import { RoomColorEnum } from "@/types/room/Room";

jest.mock("@/utils/api");
const mockedMapAxiosErrorToResponseError = jest.mocked(
Expand Down Expand Up @@ -105,7 +106,7 @@ describe("useRoomEditState", () => {
expect(isLoading.value).toBe(true);
const params = {
name: "room-name",
color: serverApi.RoomColor.BlueGrey,
color: RoomColorEnum.BlueGrey,
};

await updateRoom("room-id", params);
Expand All @@ -123,7 +124,7 @@ describe("useRoomEditState", () => {
const { updateRoom, isLoading } = setup();
const params = {
name: "room-name",
color: serverApi.RoomColor.BlueGrey,
color: RoomColorEnum.BlueGrey,
};
roomApiMock.roomControllerUpdateRoom.mockRejectedValue({ code: 404 });

Expand Down
3 changes: 2 additions & 1 deletion src/modules/data/room/Rooms.state.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
apiResponseErrorFactory,
axiosErrorFactory,
} from "@@/tests/test-utils";
import { RoomColorEnum } from "@/types/room/Room";

jest.mock("@/utils/api");
const mockedMapAxiosErrorToResponseError = jest.mocked(
Expand Down Expand Up @@ -125,7 +126,7 @@ describe("useRoomsState", () => {
{
id: "1",
name: "Room 1",
color: serverApi.RoomColor.BlueGrey,
color: RoomColorEnum.BlueGrey,
schoolId: "6749dd4e657d98af622e370c",
createdAt: "2024.11.18",
updatedAt: "2024.11.18",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/feature/board/board/Board.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ describe("Board", () => {

expect(wrapperVM.isBoardVisible).toBe(false);
expect(router.replace).toHaveBeenCalledWith({
name: "rooms-id",
name: "room-details",
params: { id: mockRoomId },
});
expect(
Expand Down
2 changes: 1 addition & 1 deletion src/modules/feature/board/board/Board.vue
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ watch(
setAlert();

if (!(isBoardVisible.value || isTeacher)) {
router.replace({ name: "rooms-id", params: { id: roomId.value } });
router.replace({ name: "room-details", params: { id: roomId.value } });
applicationErrorModule.setError(
createApplicationError(
HttpStatusCode.Forbidden,
Expand Down
1 change: 1 addition & 0 deletions src/modules/feature/room/BoardGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
v-for="(board, index) in boards"
:key="board.id"
cols="12"
sm="6"
md="4"
xl="3"
>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/feature/room/BoardTile.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe("@feature-room/BoardTile", () => {
it("should display tile in draft style", () => {
const { wrapper } = setup({ board: mockBoard, index: 0 });

expect(wrapper.classes()).toContain("board-is-draft");
expect(wrapper.classes()).toContain("opacity-70");
});
});
});
39 changes: 15 additions & 24 deletions src/modules/feature/room/BoardTile.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
<template>
<VCard
class="board-tile"
:class="{ 'board-is-draft': isDraft }"
hover
:data-testid="`board-tile-${props.index}`"
:class="isDraft ? 'opacity-70' : 'bg-surface-light'"
:variant="isDraft ? 'outlined' : 'flat'"
draggable="false"
:data-testid="`board-tile-${index}`"
:to="boardPath"
>
<VCardSubtitle
class="board-tile-subtitle mt-4"
:data-testid="`board-tile-subtitle-${props.index}`"
class="mt-4 d-flex align-center"
:class="{ 'opacity-100': isDraft }"
:data-testid="`board-tile-subtitle-${index}`"
>
<VIcon size="14" class="mr-1" :icon="subtitleIcon" />
{{ subtitleText }}
</VCardSubtitle>
<VCardTitle
class="board-tile-title text-h6 my-2"
:data-testid="`board-tile-title-${props.index}`"
class="board-tile-title text-body-1 font-weight-bold my-2"
:data-testid="`board-tile-title-${index}`"
>
{{ board.title }}
<LineClamp>
{{ board.title }}
</LineClamp>
</VCardTitle>
</VCard>
</template>
Expand All @@ -28,14 +31,14 @@ import { RoomBoardItem } from "@/types/room/Room";
import { mdiViewAgendaOutline, mdiViewDashboardOutline } from "@icons/material";
import { computed, PropType, toRef } from "vue";
import { useI18n } from "vue-i18n";
import { LineClamp } from "@ui-line-clamp";

const props = defineProps({
board: { type: Object as PropType<RoomBoardItem>, required: true },
index: { type: Number, required: true },
});

const { t } = useI18n();

const board = toRef(props, "board");

const isListBoard = computed(() => {
Expand All @@ -50,6 +53,7 @@ const subtitleIcon = computed(() => {
const icon = isListBoard.value
? mdiViewAgendaOutline
: mdiViewDashboardOutline;

return icon;
});

Expand All @@ -62,24 +66,11 @@ const subtitleText = computed(() => {
const suffix = ` - ${t("common.words.draft")}`;
return text + suffix;
}

return text;
});

const boardPath = computed(() => {
return `/boards/${board.value.id}`;
});
</script>

<style lang="scss" scoped>
@import "@/styles/settings.scss";

.board-tile {
background-color: map-get($grey, lighten-5);
border: 1px solid map-get($grey, lighten-2);

&.board-is-draft .board-tile-subtitle,
&.board-is-draft .board-tile-title {
opacity: 0.5;
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { mount } from "@vue/test-utils";
import { ComponentProps } from "vue-component-type-helpers";
import RoomColorPicker from "./RoomColorPicker.vue";
import { RoomColor } from "@/serverApi/v3";
import { RoomColorEnum } from "@/types/room/Room";

describe("@feature-room/RoomColorPicker", () => {
const setup = (props?: ComponentProps<typeof RoomColorPicker>) => {
Expand Down Expand Up @@ -42,7 +42,7 @@ describe("@feature-room/RoomColorPicker", () => {

describe("when a color is given", () => {
it("should render given color as selected", () => {
const { wrapper } = setup({ color: RoomColor.Red });
const { wrapper } = setup({ color: RoomColorEnum.Red });

const selectedColor = wrapper.findComponent(
"[data-testid=color-swatch-red]"
Expand Down
Loading
Loading