Skip to content
Open
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
26 changes: 18 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: v22.12.0
- name: Create .npmrc
node-version: v24.12.0
- name: Enable Corepack
run: corepack enable
- name: Create .yarnrc.yml
run: |
echo "@OrdinarySMP:registry=https://npm.pkg.github.com" > .npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
echo "nodeLinker: node-modules" > .yarnrc.yml
echo "npmScopes:" >> .yarnrc.yml
echo " OrdinarySMP:" >> .yarnrc.yml
echo " npmRegistryServer: "https://npm.pkg.github.com"" >> .yarnrc.yml
echo " npmAuthToken: ${{ secrets.GITHUB_TOKEN }}" >> .yarnrc.yml
- name: Install commitlint
run: yarn add commitlint@latest conventional-changelog-conventionalcommits @commitlint/config-conventional
- name: Validate current commit (last commit) with commitlint
Expand All @@ -45,11 +50,16 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: v22.12.0
- name: Create .npmrc
node-version: v24.12.0
- name: Enable Corepack
run: corepack enable
- name: Create .yarnrc.yml
run: |
echo "@OrdinarySMP:registry=https://npm.pkg.github.com" > .npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
echo "nodeLinker: node-modules" > .yarnrc.yml
echo "npmScopes:" >> .yarnrc.yml
echo " OrdinarySMP:" >> .yarnrc.yml
echo " npmRegistryServer: "https://npm.pkg.github.com"" >> .yarnrc.yml
echo " npmAuthToken: ${{ secrets.GITHUB_TOKEN }}" >> .yarnrc.yml
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run typecheck
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: v22.12.0
- name: Create .npmrc
node-version: v24.12.0
- name: Enable Corepack
run: corepack enable
- name: Create .yarnrc.yml
run: |
echo "@OrdinarySMP:registry=https://npm.pkg.github.com" > .npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
echo "nodeLinker: node-modules" > .yarnrc.yml
echo "npmScopes:" >> .yarnrc.yml
echo " OrdinarySMP:" >> .yarnrc.yml
echo " npmRegistryServer: "https://npm.pkg.github.com"" >> .yarnrc.yml
echo " npmAuthToken: ${{ secrets.GITHUB_TOKEN }}" >> .yarnrc.yml
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run build
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ logs
.env.*
!.env.example
.npmrc
.yarnrc.yml
.yarn
2 changes: 1 addition & 1 deletion app/components/card/application.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { data } = await useApi<FullResponse<ApplicationSubmissionData[]>>(
</script>

<template>
<UCard v-if="hasPermissionTo('applicationSubmission.read')" variant="subtle">
<UCard variant="subtle">
<template #header>
Pending Applications
<UBadge variant="subtle">{{ data?.data?.length }}</UBadge>
Expand Down
2 changes: 1 addition & 1 deletion app/components/card/bot-token.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const copyBotToken = () => {
</script>

<template>
<UCard v-if="hasPermissionTo('owner')" variant="subtle">
<UCard variant="subtle">
<template #header>
<p>Bot token</p>
</template>
Expand Down
2 changes: 1 addition & 1 deletion app/components/card/ticket.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { data } = await useApi<FullResponse<TicketData[]>>("/ticket", {
</script>

<template>
<UCard v-if="hasPermissionTo('ticket.read')" variant="subtle">
<UCard variant="subtle">
<template #header>
Open Tickets
<UBadge variant="subtle">{{ data?.data?.length }}</UBadge>
Expand Down
4 changes: 3 additions & 1 deletion app/components/ticket/action-cell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ const closeTicket = async () => {
<template>
<div class="space-x-2">
<UButton
v-if="hasPermissionTo('ticketTranscript.read')"
v-if="
hasPermissionTo(['ticketTranscript.read', 'ticketTranscript.read-own'])
"
label="Transcript"
size="md"
icon="material-symbols:drive-file-rename-outline-outline"
Expand Down
11 changes: 6 additions & 5 deletions app/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ const items: NavigationMenuItem[] = [
label: "Tickets",
icon: "famicons:ticket-outline",
to: "/ticket",
permission: "ticket.read",
permission: ["ticket.read", "ticket.read-own"],
children: [
{
label: "Current tickets",
label: "All tickets",
to: "/ticket",
permission: "ticket.read",
permission: ["ticket.read", "ticket.read-own"],
},
{
label: "Config",
Expand Down Expand Up @@ -98,13 +98,14 @@ const filteredItems = items
return navigation;
}
navigation.children = navigation.children.filter((child) =>
hasPermissionTo(child.permission),
child.permission ? hasPermissionTo(child.permission) : true,
);
return navigation;
})
.filter(
(navigation) =>
hasPermissionTo(navigation.permission) || navigation.children?.length,
(navigation.permission ? hasPermissionTo(navigation.permission) : true) ||
navigation.children?.length,
);

const footerItems: NavigationMenuItem[] = [
Expand Down
2 changes: 1 addition & 1 deletion app/pages/discord/callback.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { onMounted } from "vue";

const route = useRoute();
const { refreshIdentity } = useSanctumAuth();
const value = null;
const value = ref(null);

onMounted(async () => {
const { error } = await useApi("/discord/callback", {
Expand Down
8 changes: 5 additions & 3 deletions app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ useHead({
<template #body>
<p class="text-2xl">Hello {{ user?.nickname }}</p>
<div class="columns-1 md:columns-2 gap-4 space-y-4">
<CardApplication />
<CardTicket />
<CardBotToken />
<CardApplication v-if="hasPermissionTo('applicationSubmission.read')" />
<CardTicket
v-if="hasPermissionTo(['ticket.read', 'ticket.read-own'])"
/>
<CardBotToken v-if="hasPermissionTo('owner')" />
</div>
</template>
</UDashboardPanel>
Expand Down
2 changes: 1 addition & 1 deletion app/pages/ticket/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ watch(page, loadTickets);

definePageMeta({
permission: {
permission: "ticket.read",
permission: ["ticket.read", "ticket.read-own"],
},
});

Expand Down
2 changes: 1 addition & 1 deletion app/pages/ticket/transcript/[ticket_id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ticket.value = data.value?.data[0];

definePageMeta({
permission: {
permission: "ticketTranscript.read",
permission: ["ticketTranscript.read", "ticketTranscript.read-own"],
},
});

Expand Down
11 changes: 9 additions & 2 deletions app/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ export const parseRouteParameter = (
return Number.isNaN(value) ? 0 : value;
};

export const hasPermissionTo = (permission: string): boolean => {
export const hasPermissionTo = (permission: string | string[]): boolean => {
const user = useCurrentUser().value;
if (!user) {
return false;
}
return user.permissions.includes(permission) || user.is_owner;

if (user.is_owner) {
return true;
}

const permissions = Array.isArray(permission) ? permission : [permission];

return permissions.some((p) => user.permissions.includes(p));
};

// replace with enum from api
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
"@headlessui/vue": "^1.7.22",
"@heroicons/vue": "^2.1.4",
"@nuxt/ui": "^4.2.1",
"@tiptap/extensions": "^3.16.0",
"@vee-validate/zod": "^4.12.4",
"@vueuse/core": "^12.3.0",
"dayjs": "^1.11.13",
"esbuild": "^0.25.8",
"nuxt": "^4.2.1",
"nuxt": "^4.2.2",
"nuxt-auth-sanctum": "1.4.3",
"vee-validate": "^4.12.4",
"vue": "^3.4.29",
Expand All @@ -40,5 +41,5 @@
"typescript": "5.6.2",
"vue-tsc": "2.0.29"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
"packageManager": "yarn@4.12.0"
}
Loading