-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow configuring user/org socials on profile page (implements #…
- Loading branch information
1 parent
5c1ea91
commit d81b824
Showing
14 changed files
with
2,290 additions
and
1,783 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
backend/src/main/java/io/papermc/hangar/model/internal/api/requests/UserProfileSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package io.papermc.hangar.model.internal.api.requests; | ||
|
||
public record UserProfileSettings(String tagline, String[][] socials) {} | ||
import java.util.Map; | ||
|
||
public record UserProfileSettings(String tagline, Map<String, String> socials) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
backend/src/main/resources/db/migration/V1.16.0__socials_logged_action.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TYPE logged_action_type ADD VALUE 'user_socials_changed' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script lang="ts" setup> | ||
const { t } = useI18n(); | ||
const notification = useNotificationStore(); | ||
const socials = defineModel<Record<string, string>>({ required: true }); | ||
const linkType = ref<string>(); | ||
const linkTypes = [ | ||
{ value: "discord", text: "Discord" }, | ||
{ value: "github", text: "GitHub" }, | ||
{ value: "twitter", text: "Twitter" }, | ||
{ value: "youtube", text: "YouTube" }, | ||
{ value: "website", text: "Website" }, | ||
]; | ||
function addLink() { | ||
if (!linkType.value) { | ||
return notification.error("You have to select a type"); | ||
} | ||
if (Object.keys(socials.value).includes(linkType.value)) { | ||
return notification.error("You already have a link of that type added"); | ||
} | ||
socials.value[linkType.value] = ""; | ||
} | ||
function removeLink(type: string) { | ||
delete socials.value[type]; | ||
} | ||
</script> | ||
|
||
<template> | ||
<div v-for="(_, type) in socials" :key="type" class="flex items-center mt-2"> | ||
<span class="w-25">{{ linkTypes.find((e) => e.value === type)?.text }}</span> | ||
<div class="w-75"> | ||
<InputText v-if="type === 'website'" v-model="socials[type]" label="URL" :rules="[required(), validUrl()]" /> | ||
<InputText v-else v-model="socials[type]" :label="t('auth.settings.account.username')" :rules="[required()]" /> | ||
</div> | ||
<IconMdiBin class="ml-2 w-6 h-6 cursor-pointer hover:color-red" @click="removeLink(type)" /> | ||
</div> | ||
<div class="flex items-center mt-2"> | ||
<div class="w-25"> | ||
<Button button-type="secondary" @click.prevent="addLink">Add link</Button> | ||
</div> | ||
<div class="w-75"> | ||
<InputSelect v-model="linkType" :values="linkTypes" :label="t('project.settings.links.typeField')" /> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script lang="ts" setup> | ||
import type { JsonNode } from "~/types/backend"; | ||
const props = defineProps<{ | ||
socials: JsonNode; | ||
action: string; | ||
}>(); | ||
const newSocials = ref(props.socials); | ||
const router = useRouter(); | ||
const i18n = useI18n(); | ||
const loading = ref(false); | ||
async function save() { | ||
loading.value = true; | ||
try { | ||
await useInternalApi(props.action, "post", newSocials.value); | ||
router.go(0); | ||
} catch (err) { | ||
handleRequestError(err); | ||
} | ||
loading.value = false; | ||
} | ||
</script> | ||
|
||
<template> | ||
<Modal :title="i18n.t('author.editSocials')" window-classes="w-200 text-lg"> | ||
<SocialForm v-model="newSocials" /> | ||
<Button class="mt-3" @click="save">{{ i18n.t("general.change") }}</Button> | ||
<template #activator="{ on }"> | ||
<Button size="small" class="ml-2 inline-flex text-lg" v-on="on"> | ||
<IconMdiPencil /> | ||
</Button> | ||
</template> | ||
</Modal> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.