feat: このユーザーのノートを検索, クエリに基づく検索の初期値 & ノート検索のUI改善 (#14128)

* refactor(frontend): noteSearchAvailableをaccountsに移動

* feat: searchページでのクエリの受取りとtypeによる表示タブの変更

* user検索でsearchの親から受け取った値を基に入力値を初期化

* feat(frontend): ノート検索で親(search)からの情報を基にユーザー情報を取得

* feat(frontend): ユーザーのノートを検索するページに遷移するボタン

* feat(frontend): ノート検索にホスト名指定のオプション追加
also 🎨

* style: ただ照会部分を囲っただけ(可読性確保のために)

* refactor: remove unneed import
defineProps and withDefaults are compiler micro when using `<script setup>`
FYI: https://vuejs.org/api/sfc-script-setup.html#defineprops-defineemits:~:text=defineProps%20and%20defineEmits%20are%20compiler%20macros%20only%20usable%20inside%20%3Cscript%20setup%3E.%20They%20do%20not%20need%20to%20be%20imported%2C%20and%20are%20compiled%20away%20when%20%3Cscript%20setup%3E%20is%20processed.

* Update CHANGELOG

* Fix: ノート検索の初期値が常にホスト指定になってしまう

* notesSearchAvailableをaccountに持たせるのをやめる

* SDPX-Licence-Identifier

* Fix: Vitest fails due to instance.policies being undefined

* Add Storybook for search

* Fix(storybook): ノート検索が利用できないと出てしまう問題

* storybookでユーザー選択ができないのを修正

* feat: ノート検索で自分を選択可能に
& 🎨

* feat(background): api/metaで検索可能なノートのスコープを参照できるように

* globalのノートが検索不可能な場合、検索オプションを表示しないように

* Update CHANGELOG.md

* config.meilisearch.scopeがstring[]を取ることがあるので修正

* meilisearchを利用かつscopeがlocalの場合、リモートユーザーのメニューで「このユーザーのノートを検索」を出さないように

* hostが空文字の時の挙動を修正

* ローカルのみしかノートがインデックスされていない場合、リモートユーザーも選択できなくした
This commit is contained in:
taichan
2024-07-30 15:51:08 +09:00
committed by GitHub
parent 7e9c38d6fb
commit bff813042e
16 changed files with 327 additions and 37 deletions

View File

@@ -9,8 +9,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkHorizontalSwipe v-model:tab="tab" :tabs="headerTabs">
<MkSpacer v-if="tab === 'note'" key="note" :contentMax="800">
<div v-if="notesSearchAvailable">
<XNote/>
<div v-if="notesSearchAvailable || ignoreNotesSearchAvailable">
<XNote v-bind="props"/>
</div>
<div v-else>
<MkInfo warn>{{ i18n.ts.notesSearchNotAvailable }}</MkInfo>
@@ -18,27 +18,43 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkSpacer>
<MkSpacer v-else-if="tab === 'user'" key="user" :contentMax="800">
<XUser/>
<XUser v-bind="props"/>
</MkSpacer>
</MkHorizontalSwipe>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { computed, defineAsyncComponent, ref } from 'vue';
import { computed, defineAsyncComponent, ref, toRef } from 'vue';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { $i } from '@/account.js';
import { instance } from '@/instance.js';
import { notesSearchAvailable } from '@/scripts/check-permissions.js';
import MkInfo from '@/components/MkInfo.vue';
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
const props = withDefaults(defineProps<{
query?: string,
userId?: string,
username?: string,
host?: string | null,
type?: 'note' | 'user',
origin?: 'combined' | 'local' | 'remote',
// For storybook only
ignoreNotesSearchAvailable?: boolean,
}>(), {
query: '',
userId: undefined,
username: undefined,
host: undefined,
type: 'note',
origin: 'combined',
ignoreNotesSearchAvailable: false,
});
const XNote = defineAsyncComponent(() => import('./search.note.vue'));
const XUser = defineAsyncComponent(() => import('./search.user.vue'));
const tab = ref('note');
const notesSearchAvailable = (($i == null && instance.policies.canSearchNotes) || ($i != null && $i.policies.canSearchNotes));
const tab = ref(toRef(props, 'type').value);
const headerActions = computed(() => []);