refactor: rename externalUrls to externalLinks
This commit is contained in:
@@ -88,7 +88,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Config do
|
||||
get_in(Application.get_env(:web_push_encryption, :vapid_details), [:public_key])
|
||||
|
||||
%{
|
||||
external_urls: Config.external_urls(),
|
||||
external_links: Config.external_links(),
|
||||
name: Config.instance_name(),
|
||||
registrations_open: Config.instance_registrations_open?(),
|
||||
registrations_moderation: Config.instance_registrations_moderation?(),
|
||||
|
||||
@@ -160,19 +160,19 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
|
||||
|
||||
field(:instance_languages, list_of(:string), description: "The instance's languages")
|
||||
|
||||
field(:external_urls, list_of(:external_url),
|
||||
field(:external_links, list_of(:external_link),
|
||||
description: "List of URL that will be shown to users"
|
||||
)
|
||||
end
|
||||
|
||||
object :external_url do
|
||||
object :external_link do
|
||||
meta(:authorize, :all)
|
||||
field(:label, non_null(:string), description: "A human-readable label for the external URL")
|
||||
field(:url, non_null(:string), description: "The actual external URL")
|
||||
field(:enabled, non_null(:boolean), description: "Whether the external URL is enabled")
|
||||
field(:label, non_null(:string), description: "A human-readable label for the external link")
|
||||
field(:url, non_null(:string), description: "The external link URL")
|
||||
field(:enabled, non_null(:boolean), description: "Whether the link URL is enabled")
|
||||
end
|
||||
|
||||
input_object :external_url_input do
|
||||
input_object :external_link_input do
|
||||
meta(:authorize, :administrator)
|
||||
field(:label, non_null(:string))
|
||||
field(:url, non_null(:string))
|
||||
@@ -494,8 +494,8 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
|
||||
|
||||
arg(:instance_languages, list_of(:string), description: "The instance's languages")
|
||||
|
||||
arg(:external_urls, list_of(:external_url_input),
|
||||
description: "Array of external URLs with label, status, and id"
|
||||
arg(:external_links, list_of(:external_link_input),
|
||||
description: "Array of external links with label, status, and id"
|
||||
)
|
||||
|
||||
middleware(Rajska.QueryAuthorization, permit: :administrator)
|
||||
|
||||
@@ -104,7 +104,7 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
|
||||
|
||||
field(:search, :search_settings, description: "The instance's search settings")
|
||||
|
||||
field(:external_urls, list_of(:external_url),
|
||||
field(:external_links, list_of(:external_link),
|
||||
description: "List of URL that will be shown to users"
|
||||
)
|
||||
end
|
||||
|
||||
@@ -59,13 +59,13 @@ defmodule Mobilizon.Config do
|
||||
instance_config()[:name]
|
||||
)
|
||||
|
||||
@spec external_urls :: String.t()
|
||||
def external_urls do
|
||||
config_cached_value("instance", "external_urls", [])
|
||||
|> Enum.map(&transform_external_url/1)
|
||||
@spec external_links :: String.t()
|
||||
def external_links do
|
||||
config_cached_value("instance", "external_links", [])
|
||||
|> Enum.map(&transform_external_link/1)
|
||||
end
|
||||
|
||||
def transform_external_url(map) do
|
||||
def transform_external_link(map) do
|
||||
%{
|
||||
enabled: Map.fetch!(map, "enabled"),
|
||||
label: Map.fetch!(map, "label"),
|
||||
@@ -490,7 +490,7 @@ defmodule Mobilizon.Config do
|
||||
instance_privacy_policy_url: instance_privacy_url(),
|
||||
instance_rules: instance_rules(),
|
||||
instance_languages: instance_languages(),
|
||||
external_urls: external_urls()
|
||||
external_links: external_links()
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
>{{ t("Register") }}</router-link
|
||||
>
|
||||
</li>
|
||||
<li v-for="(link, index) in externalURLSConfig" :key="index">
|
||||
<li v-for="(link, index) in externalLinksConfig" :key="index">
|
||||
<a
|
||||
:href="link.url"
|
||||
v-if="link.enabled"
|
||||
@@ -279,7 +279,7 @@ import { useLazyQuery, useMutation } from "@vue/apollo-composable";
|
||||
import { UPDATE_DEFAULT_ACTOR } from "@/graphql/actor";
|
||||
import { changeIdentity } from "@/utils/identity";
|
||||
import {
|
||||
useExternalURLSConfig,
|
||||
useExternalLinksConfig,
|
||||
useRegistrationConfig,
|
||||
} from "@/composition/apollo/config";
|
||||
import { useOruga } from "@oruga-ui/oruga-next";
|
||||
@@ -296,7 +296,7 @@ const { identities } = useCurrentUserIdentities();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const { externalURLSConfig } = useExternalURLSConfig();
|
||||
const { externalLinksConfig } = useExternalLinksConfig();
|
||||
const { registrationsOpen, registrationsAllowlist, databaseLogin } =
|
||||
useRegistrationConfig();
|
||||
|
||||
|
||||
@@ -32,20 +32,20 @@ export function useAnonymousParticipationConfig() {
|
||||
return { anonymousParticipationConfig, error, loading };
|
||||
}
|
||||
|
||||
export function useExternalURLSConfig() {
|
||||
export function useExternalLinksConfig() {
|
||||
const {
|
||||
result: configResult,
|
||||
error,
|
||||
loading,
|
||||
} = useQuery<{
|
||||
config: Pick<IConfig, "externalUrls">;
|
||||
config: Pick<IConfig, "externalLinks">;
|
||||
}>(CONFIG);
|
||||
|
||||
const externalURLSConfig = computed(
|
||||
() => configResult.value?.config?.externalUrls
|
||||
const externalLinksConfig = computed(
|
||||
() => configResult.value?.config?.externalLinks
|
||||
);
|
||||
|
||||
return { externalURLSConfig, error, loading };
|
||||
return { externalLinksConfig, error, loading };
|
||||
}
|
||||
|
||||
export function useAnonymousReportsConfig() {
|
||||
|
||||
@@ -200,7 +200,7 @@ export const ADMIN_SETTINGS_FRAGMENT = gql`
|
||||
instanceLongDescription
|
||||
instanceSlogan
|
||||
contact
|
||||
externalUrls {
|
||||
externalLinks {
|
||||
label
|
||||
url
|
||||
enabled
|
||||
@@ -251,7 +251,7 @@ export const SAVE_ADMIN_SETTINGS = gql`
|
||||
$instanceLongDescription: String
|
||||
$instanceSlogan: String
|
||||
$contact: String
|
||||
$externalUrls: [ExternalUrlInput]
|
||||
$externalLinks: [ExternalLinkInput]
|
||||
$instanceLogo: MediaInput
|
||||
$instanceFavicon: MediaInput
|
||||
$defaultPicture: MediaInput
|
||||
@@ -274,7 +274,7 @@ export const SAVE_ADMIN_SETTINGS = gql`
|
||||
instanceLongDescription: $instanceLongDescription
|
||||
instanceSlogan: $instanceSlogan
|
||||
contact: $contact
|
||||
externalUrls: $externalUrls
|
||||
externalLinks: $externalLinks
|
||||
instanceLogo: $instanceLogo
|
||||
instanceFavicon: $instanceFavicon
|
||||
defaultPicture: $defaultPicture
|
||||
|
||||
@@ -20,7 +20,7 @@ export const CONFIG = gql`
|
||||
languages
|
||||
primaryColor
|
||||
secondaryColor
|
||||
externalUrls {
|
||||
externalLinks {
|
||||
label
|
||||
url
|
||||
enabled
|
||||
|
||||
@@ -28,7 +28,7 @@ export interface IAdminSettings {
|
||||
contact: string;
|
||||
instanceLogo: IMedia | null;
|
||||
instanceFavicon: IMedia | null;
|
||||
externalUrls: { url: string; label: string; enabled: boolean }[];
|
||||
externalLinks: { url: string; label: string; enabled: boolean }[];
|
||||
defaultPicture: IMedia | null;
|
||||
primaryColor: string;
|
||||
secondaryColor: string;
|
||||
|
||||
@@ -37,7 +37,7 @@ export interface IConfig {
|
||||
longDescription: string;
|
||||
contact: string;
|
||||
slogan: string;
|
||||
externalUrls: { url: string; label: string; enabled: boolean }[];
|
||||
externalLinks: { url: string; label: string; enabled: boolean }[];
|
||||
instanceLogo: { url: string };
|
||||
defaultPicture: { url: string };
|
||||
primaryColor: string;
|
||||
|
||||
@@ -472,11 +472,11 @@
|
||||
</o-field>
|
||||
<div
|
||||
class="mt-5 grid lg:grid-cols-[repeat(auto-fit,minmax(250px,0.5fr))] grid-cols-[repeat(auto-fit,minmax(250px,1fr))] gap-2"
|
||||
v-if="settingsToWrite.externalUrls.length > 0"
|
||||
v-if="settingsToWrite.externalLinks.length > 0"
|
||||
>
|
||||
<div
|
||||
class="bg-mbz-yellow-alt-100 p-5"
|
||||
v-for="(link, index) in settingsToWrite.externalUrls"
|
||||
v-for="(link, index) in settingsToWrite.externalLinks"
|
||||
:key="index"
|
||||
>
|
||||
<o-field :label="t('URL')" class="!mt-0"
|
||||
@@ -556,7 +556,7 @@ const defaultAdminSettings: IAdminSettings = {
|
||||
registrationsOpen: false,
|
||||
registrationsModeration: false,
|
||||
instanceLanguages: [],
|
||||
externalUrls: [],
|
||||
externalLinks: [],
|
||||
};
|
||||
|
||||
const { onResult: onAdminSettingsResult } = useQuery<{
|
||||
@@ -598,15 +598,15 @@ useHead({
|
||||
const settingsToWrite = ref<IAdminSettings>(defaultAdminSettings);
|
||||
|
||||
watch(adminSettings, () => {
|
||||
// We need to use structuredClone to clone deep properties of adminSettings (like externalUrls)
|
||||
// {... } only shadow clone, so externalUrls is not reactive doing this
|
||||
// We need to use structuredClone to clone deep properties of adminSettings (like externalLinks)
|
||||
// {... } only shadow clone, so externalLinks is not reactive doing this
|
||||
if (adminSettings.value) {
|
||||
settingsToWrite.value = structuredClone(toRaw(adminSettings.value));
|
||||
}
|
||||
});
|
||||
|
||||
const addLink = () => {
|
||||
settingsToWrite.value.externalUrls.push({
|
||||
settingsToWrite.value.externalLinks.push({
|
||||
url: "",
|
||||
label: "",
|
||||
enabled: false,
|
||||
@@ -614,7 +614,7 @@ const addLink = () => {
|
||||
};
|
||||
|
||||
const deleteLink = (index: number) => {
|
||||
settingsToWrite.value.externalUrls.splice(index, 1);
|
||||
settingsToWrite.value.externalLinks.splice(index, 1);
|
||||
};
|
||||
|
||||
const filteredLanguages = ref<string[]>([]);
|
||||
|
||||
Reference in New Issue
Block a user