diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2025-05-12 13:56:29 -0400 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-05-23 10:22:26 -0400 |
| commit | 460442f75d4db8bcf2582294d116218d57b978de (patch) | |
| tree | 3c93e91b51ebf72ba869477c42533dee4873ed13 | |
| parent | fix policy check for unspecified "local" property in polls/recommendation end... (diff) | |
| download | sharkey-460442f75d4db8bcf2582294d116218d57b978de.tar.gz sharkey-460442f75d4db8bcf2582294d116218d57b978de.tar.bz2 sharkey-460442f75d4db8bcf2582294d116218d57b978de.zip | |
check permission in frontend before display trending polls
| -rw-r--r-- | locales/index.d.ts | 8 | ||||
| -rw-r--r-- | packages/frontend/src/pages/explore.featured.vue | 36 | ||||
| -rw-r--r-- | sharkey-locales/en-US.yml | 2 |
3 files changed, 33 insertions, 13 deletions
diff --git a/locales/index.d.ts b/locales/index.d.ts index bd0d718c13..55beb291bb 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -13082,6 +13082,14 @@ export interface Locale extends ILocale { */ "pollsExpired": string; /** + * Trending polls are disabled on this instance. + */ + "trendingPollsDisabled": string; + /** + * Please log in to view trending polls. + */ + "trendingPollsDisabledLogIn": string; + /** * Silenced */ "silenced": string; diff --git a/packages/frontend/src/pages/explore.featured.vue b/packages/frontend/src/pages/explore.featured.vue index 2c54d0d49c..82badd40b3 100644 --- a/packages/frontend/src/pages/explore.featured.vue +++ b/packages/frontend/src/pages/explore.featured.vue @@ -11,32 +11,42 @@ SPDX-License-Identifier: AGPL-3.0-only </MkTab> <MkNotes v-if="tab === 'notes'" :pagination="paginationForNotes"/> <div v-else-if="tab === 'polls'"> - <MkFoldableSection class="_margin"> - <template #header><i class="ph-house ph-bold ph-lg" style="margin-right: 0.5em;"></i>{{ i18n.tsx.pollsOnLocal({ name: instance.name ?? host }) }}</template> - <MkNotes :pagination="paginationForPollsLocal" :disableAutoLoad="true"/> - </MkFoldableSection> + <template v-if="ltlAvailable || gtlAvailable"> + <MkFoldableSection v-if="ltlAvailable" class="_margin"> + <template #header><i class="ph-house ph-bold ph-lg" style="margin-right: 0.5em;"></i>{{ i18n.tsx.pollsOnLocal({ name: instance.name ?? host }) }}</template> + <MkNotes :pagination="paginationForPollsLocal" :disableAutoLoad="true"/> + </MkFoldableSection> - <MkFoldableSection class="_margin"> - <template #header><i class="ph-globe ph-bold ph-lg" style="margin-right: 0.5em;"></i>{{ i18n.ts.pollsOnRemote }}</template> - <MkNotes :pagination="paginationForPollsRemote" :disableAutoLoad="true"/> - </MkFoldableSection> + <MkFoldableSection v-if="gtlAvailable" class="_margin"> + <template #header><i class="ph-globe ph-bold ph-lg" style="margin-right: 0.5em;"></i>{{ i18n.ts.pollsOnRemote }}</template> + <MkNotes :pagination="paginationForPollsRemote" :disableAutoLoad="true"/> + </MkFoldableSection> - <MkFoldableSection class="_margin"> - <template #header><i class="ph-timer ph-bold ph-lg" style="margin-right: 0.5em;"></i>{{ i18n.ts.pollsExpired }}</template> - <MkNotes :pagination="paginationForPollsExpired" :disableAutoLoad="true"/> - </MkFoldableSection> + <MkFoldableSection v-if="gtlAvailable" class="_margin"> + <template #header><i class="ph-timer ph-bold ph-lg" style="margin-right: 0.5em;"></i>{{ i18n.ts.pollsExpired }}</template> + <MkNotes :pagination="paginationForPollsExpired" :disableAutoLoad="true"/> + </MkFoldableSection> + </template> + <template v-else> + <div v-if="$i"><i class="ti ti-alert-triangle"></i>{{ i18n.ts.trendingPollsDisabled }}</div> + <div v-else><i class="ti ti-alert-triangle"></i>{{ i18n.ts.trendingPollsDisabledLogIn }}</div> + </template> </div> </div> </template> <script lang="ts" setup> -import { ref } from 'vue'; +import { computed, ref } from 'vue'; import { host } from '@@/js/config.js'; import MkNotes from '@/components/MkNotes.vue'; import MkTab from '@/components/MkTab.vue'; import { i18n } from '@/i18n.js'; import MkFoldableSection from '@/components/MkFoldableSection.vue'; import { instance } from '@/instance.js'; +import { $i } from '@/i'; + +const ltlAvailable = computed(() => $i?.policies.ltlAvailable ?? instance.policies.ltlAvailable); +const gtlAvailable = computed(() => $i?.policies.gtlAvailable ?? instance.policies.gtlAvailable); const paginationForNotes = { endpoint: 'notes/featured' as const, diff --git a/sharkey-locales/en-US.yml b/sharkey-locales/en-US.yml index ca7c4ea717..dd03edbf81 100644 --- a/sharkey-locales/en-US.yml +++ b/sharkey-locales/en-US.yml @@ -575,6 +575,8 @@ popularUsersLocal: "Users popular on {name}" pollsOnLocal: "Polls trending on {name}" pollsOnRemote: "Polls trending on the global network" pollsExpired: "Polls that have ended recently" +trendingPollsDisabled: "Trending polls are disabled on this instance." +trendingPollsDisabledLogIn: "Please log in to view trending polls." silenced: "Silenced" totalFollowers: "Total followers" |