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

Redesign crud tables #566

Merged
merged 8 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion e2e/tests/admin/alerts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.describe("The Admin Alerts Page", () => {

await ap.goto();

const title = ap.page.locator("h1");
const title = ap.page.locator('[data-testid="tablenav-title"]');
await expect(title).toHaveText("Alerts");
});
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/admin/apikeys.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.describe("The Admin API Keys Page", () => {

await ap.goto();

const title = ap.page.locator("h1");
const title = ap.page.locator('[data-testid="tablenav-title"]');
await expect(title).toHaveText("API Keys");
});
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/admin/organizations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.describe("The Admin Organizations Page", () => {

await ap.goto();

const title = ap.page.locator("h1");
const title = ap.page.locator('[data-testid="tablenav-title"]');
await expect(title).toHaveText("Organizations");
});
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/admin/poker-games.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.describe("The Admin Poker Games Page", () => {

await ap.goto();

const title = ap.page.locator("h1");
const title = ap.page.locator('[data-testid="tablenav-title"]');
await expect(title).toHaveText("Battles");
});
});
Expand Down
4 changes: 3 additions & 1 deletion e2e/tests/admin/team.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ test.describe("The Admin Team Page", () => {
const team = await registeredPage.createTeam(testTeamName);

await ap.goto(team.id);
await expect(ap.page.locator("h1")).toContainText(testTeamName);
await expect(
ap.page.locator('[data-testid="tablenav-title"]').nth(0),
).toContainText(testTeamName);
});
});
});
2 changes: 1 addition & 1 deletion e2e/tests/admin/teams.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.describe("The Admin Teams Page", () => {

await ap.goto();

const title = ap.page.locator("h1");
const title = ap.page.locator('[data-testid="tablenav-title"]');
await expect(title).toHaveText("Teams");
});
});
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/admin/users.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ test.describe("The Admin Users Page", () => {

await ap.goto();

const title = ap.page.locator("h1");
await expect(title).toHaveText("Users");
const title = ap.page.locator('[data-testid="tablenav-title"]');
await expect(title).toHaveText("Registered Users");
});
});
});
24 changes: 18 additions & 6 deletions e2e/tests/teams.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ test.describe("Teams page", () => {
await teamsPage.goto();

await expect(
teamsPage.page.locator("h2", { hasText: "Organizations" }),
teamsPage.page.locator('[data-testid="tablenav-title"]', {
hasText: "Organizations",
}),
).toBeVisible();
await expect(
teamsPage.page.locator("h2", { hasText: "Teams" }),
teamsPage.page.locator('[data-testid="tablenav-title"]', {
hasText: "Teams",
}),
).toBeVisible();
});

Expand All @@ -38,13 +42,19 @@ test.describe("Teams page", () => {
});

await expect(
teamsPage.page.locator("h2", { hasText: "Departments" }),
teamsPage.page.locator('[data-testid="tablenav-title"]', {
hasText: "Departments",
}),
).toBeVisible();
await expect(
teamsPage.page.locator("h2", { hasText: "Teams" }),
teamsPage.page.locator('[data-testid="tablenav-title"]', {
hasText: "Teams",
}),
).toBeVisible();
await expect(
teamsPage.page.locator("h2", { hasText: "Users" }),
teamsPage.page.locator('[data-testid="tablenav-title"]', {
hasText: "Users",
}),
).toBeVisible();
});
});
Expand All @@ -68,7 +78,9 @@ test.describe("Teams page", () => {
teamsPage.page.locator("h2", { hasText: "Storyboards" }),
).toBeVisible();
await expect(
teamsPage.page.locator("h2", { hasText: "Users" }),
teamsPage.page.locator('[data-testid="tablenav-title"]', {
hasText: "Users",
}),
).toBeVisible();
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { AppConfig, appRoutes } from '../../config';
import LL from '../../i18n/i18n-svelte';
import { AppConfig, appRoutes } from '../config';
import LL from '../i18n/i18n-svelte';

export let activePage = 'admin';

Expand Down
16 changes: 0 additions & 16 deletions ui/src/components/global/table/HeadCol.svelte

This file was deleted.

19 changes: 0 additions & 19 deletions ui/src/components/global/table/Table.svelte

This file was deleted.

10 changes: 0 additions & 10 deletions ui/src/components/global/table/TableRow.svelte

This file was deleted.

18 changes: 18 additions & 0 deletions ui/src/components/icons/EyeIcon.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script lang="ts">
let klass = 'w-6 h-6';
export { klass as class };
</script>

<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
class="{klass}"
>
<path d="M12 15a3 3 0 100-6 3 3 0 000 6z"></path>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 010-1.113zM17.25 12a5.25 5.25 0 11-10.5 0 5.25 5.25 0 0110.5 0z"
></path>
</svg>
44 changes: 44 additions & 0 deletions ui/src/components/table/CrudActions.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<script lang="ts">
import LL from '../../i18n/i18n-svelte';
import EditIcon from '../icons/EditIcon.svelte';
import TrashIcon from '../icons/TrashIcon.svelte';
import EyeIcon from '../icons/EyeIcon.svelte';

export let detailsLink = '';
export let editBtnEnabled = true;
export let editBtnClickHandler = () => {};
export let editBtnTestId = 'edit';
export let deleteBtnEnabled = true;
export let deleteBtnClickHandler = () => {};
export let deleteBtnTestId = 'delete';
</script>

<div class="flex gap-2 justify-end items-center">
<slot />
{#if detailsLink !== ''}
<a href="{detailsLink}" class="hover:text-blue-500">
<EyeIcon />
<span class="sr-only">View Details</span>
</a>
{/if}
{#if editBtnEnabled}
<button
on:click="{editBtnClickHandler}"
class="hover:text-green-500"
data-testid="{editBtnTestId}"
>
<span class="sr-only">{$LL.edit()}</span>
<EditIcon />
</button>
{/if}
{#if deleteBtnEnabled}
<button
on:click="{deleteBtnClickHandler}"
class="hover:text-red-500"
data-testid="{deleteBtnTestId}"
>
<span class="sr-only">{$LL.delete()}</span>
<TrashIcon />
</button>
{/if}
</div>
13 changes: 13 additions & 0 deletions ui/src/components/table/HeadCol.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script lang="ts">
export let type = 'default';
</script>

{#if type === 'default'}
<th scope="col" class="p-4">
<slot />
</th>
{:else if type === 'action'}
<th scope="col" class="relative px-2 py-2">
<slot />
</th>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
</script>

{#if type === 'default'}
<td class="px-6 py-4 whitespace-nowrap">
<td class="px-4 py-3 whitespace-nowrap font-medium">
<slot />
</td>
{:else if type === 'action'}
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<td class="px-4 py-3 whitespace-nowrap text-right font-medium">
<slot />
</td>
{/if}
10 changes: 10 additions & 0 deletions ui/src/components/table/Table.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="overflow-x-auto">
<table class="w-full text-sm text-left text-gray-700 dark:text-gray-200">
<thead
class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400"
>
<slot name="header" />
</thead>
<slot name="body" />
</table>
</div>
5 changes: 5 additions & 0 deletions ui/src/components/table/TableContainer.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div
class="bg-white dark:bg-gray-800 relative shadow-md sm:rounded-lg overflow-hidden"
>
<slot />
</div>
Loading