Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Server rules #10660

Merged
merged 32 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3c74109
enhance(frontend): サーバールールのデザイン調整
EbiseLutica Apr 14, 2023
6adc7de
enhance(frontend): i18n
EbiseLutica Apr 14, 2023
555fe1c
enhance(frontend): 利用規約URLの設定を「モデレーション」ページへ移動
EbiseLutica Apr 14, 2023
65034a9
enhance(frontend): サーバールールのデザイン調整
EbiseLutica Apr 14, 2023
9579de9
Update CHANGELOG.md
EbiseLutica Apr 14, 2023
9f7b30e
不要な差分を削除
EbiseLutica Apr 14, 2023
1e89887
fix(frontend): lint
EbiseLutica Apr 14, 2023
b3705fd
Merge branch 'develop' into feature/serverRules
EbiseLutica Apr 16, 2023
8f7bb03
Merge branch 'develop' into pr/10633
syuilo Apr 17, 2023
6e6af04
ui tweak
syuilo Apr 17, 2023
d243ccf
test: add stories
acid-chicken Apr 17, 2023
c847381
tweak
syuilo Apr 17, 2023
d1d5ae4
Merge branch 'server-rules' of https://github.com/misskey-dev/misskey…
syuilo Apr 17, 2023
37e45d1
test: bind args
acid-chicken Apr 17, 2023
317a552
Merge branch 'server-rules' of https://github.com/misskey-dev/misskey…
acid-chicken Apr 17, 2023
99fb538
test: add interaction tests
acid-chicken Apr 17, 2023
15b8b95
fix bug
syuilo Apr 17, 2023
a78b5fb
Update packages/frontend/src/pages/admin/server-rules.vue
syuilo Apr 17, 2023
021cb5d
Update misskey-js.api.md
syuilo Apr 19, 2023
82cdce1
chore: windowを明示
syuilo Apr 19, 2023
13dbedd
Merge branch 'develop' into server-rules
syuilo Apr 19, 2023
bdce901
:art:
syuilo Apr 19, 2023
e73607c
refactor
syuilo Apr 19, 2023
d07e523
:art:
syuilo Apr 19, 2023
eb42dd6
:art:
syuilo Apr 19, 2023
180bc27
Merge branch 'develop' into server-rules
syuilo Apr 19, 2023
e30f2b7
fix e2e test
syuilo Apr 19, 2023
286262b
Merge branch 'develop' into server-rules
syuilo Apr 19, 2023
8a6464b
:art:
syuilo Apr 19, 2023
f40bcb0
:art:
syuilo Apr 19, 2023
a81162a
fix icon
syuilo Apr 19, 2023
8ca436b
fix e2e
syuilo Apr 19, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Node.js 18.6.0以上が必要になりました

### General
- 新規登録前に簡潔なルールをユーザーに表示できる、サーバールール機能を追加
- ユーザーへの自分用メモ機能
* ユーザーに対して、自分だけが見られるメモを追加できるようになりました。
(自分自身に対してもメモを追加できます。)
Expand Down
12 changes: 12 additions & 0 deletions cypress/e2e/basic.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ describe('After setup instance', () => {
cy.intercept('POST', '/api/signup').as('signup');

cy.get('[data-cy-signup]').click();
cy.get('[data-cy-signup-rules-continue]').should('be.disabled');
cy.get('[data-cy-signup-rules-notes] [data-cy-folder-header]').click();
cy.get('[data-cy-signup-rules-notes-agree] [data-cy-switch-toggle]').click();
cy.get('[data-cy-signup-rules-continue]').should('not.be.disabled');
cy.get('[data-cy-signup-rules-continue]').click();

cy.get('[data-cy-signup-submit]').should('be.disabled');
cy.get('[data-cy-signup-username] input').type('alice');
cy.get('[data-cy-signup-submit]').should('be.disabled');
Expand All @@ -71,6 +77,12 @@ describe('After setup instance', () => {

// ユーザー名が重複している場合の挙動確認
cy.get('[data-cy-signup]').click();
cy.get('[data-cy-signup-rules-continue]').should('be.disabled');
cy.get('[data-cy-signup-rules-notes] [data-cy-folder-header]').click();
cy.get('[data-cy-signup-rules-notes-agree] [data-cy-switch-toggle]').click();
cy.get('[data-cy-signup-rules-continue]').should('not.be.disabled');
cy.get('[data-cy-signup-rules-continue]').click();

cy.get('[data-cy-signup-username] input').type('alice');
cy.get('[data-cy-signup-password] input').type('alice1234');
cy.get('[data-cy-signup-password-retype] input').type('alice1234');
Expand Down
9 changes: 8 additions & 1 deletion locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,10 @@ noMoreHistory: "これより過去の履歴はありません"
startMessaging: "チャットを開始"
nUsersRead: "{n}人が読みました"
agreeTo: "{0}に同意"
agree: "同意する"
agreeBelow: "下記に同意する"
basicNotesBeforeCreateAccount: "基本的な注意事項"
tos: "利用規約"
termsOfService: "利用規約"
start: "始める"
home: "ホーム"
remoteUserCaution: "リモートユーザーのため、情報が不完全です。"
Expand Down Expand Up @@ -1010,6 +1011,12 @@ stackAxis: "スタック方向"
vertical: "縦"
horizontal: "横"
position: "位置"
serverRules: "サーバールール"
pleaseConfirmBelowBeforeSignup: "このサーバーに登録する前に、以下を確認してください。"
continue: "続ける"

_serverRules:
description: "新規登録前に表示する、サーバーの簡潔なルールを設定します。内容は利用規約の要約とすることを推奨します。"

_accountMigration:
moveTo: "このアカウントを新しいアカウントに引っ越す"
Expand Down
11 changes: 11 additions & 0 deletions packages/backend/migration/1681400427971-serverRules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class ServerRules1681400427971 {
name = 'ServerRules1681400427971'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "serverRules" character varying(280) array NOT NULL DEFAULT '{}'`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "serverRules"`);
}
}
7 changes: 7 additions & 0 deletions packages/backend/src/models/entities/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,11 @@ export class Meta {
default: { },
})
public policies: Record<string, any>;

@Column('varchar', {
length: 280,
array: true,
default: '{}',
})
public serverRules: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const paramDef = {
enableActiveEmailValidation: { type: 'boolean' },
enableChartsForRemoteUser: { type: 'boolean' },
enableChartsForFederatedInstances: { type: 'boolean' },
serverRules: { type: 'array', items: { type: 'string' } },
},
required: [],
} as const;
Expand Down Expand Up @@ -387,6 +388,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
set.enableChartsForFederatedInstances = ps.enableChartsForFederatedInstances;
}

if (ps.serverRules !== undefined) {
set.serverRules = ps.serverRules;
}

await this.metaService.update(set);
this.moderationLogService.insertModerationLog(me, 'updateMeta');
});
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/api/endpoints/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {

translatorAvailable: instance.deeplAuthKey != null,

serverRules: instance.serverRules,

policies: { ...DEFAULT_POLICIES, ...instance.policies },

mediaProxy: this.config.mediaProxy,
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/.storybook/generate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ Promise.all([
glob('src/components/global/*.vue'),
glob('src/components/Mk{A,B}*.vue'),
glob('src/components/MkGalleryPostPreview.vue'),
glob('src/components/MkSignupServerRules.vue'),
glob('src/pages/user/home.vue'),
])
.then((globs) => globs.flat())
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/components/MkFolder.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div ref="rootEl" :class="$style.root">
<div ref="rootEl" :class="$style.root" role="group" :aria-expanded="opened">
<MkStickyContainer>
<template #header>
<div :class="[$style.header, { [$style.opened]: opened }]" class="_button" @click="toggle">
<div :class="[$style.header, { [$style.opened]: opened }]" class="_button" role="button" data-cy-folder-header @click="toggle">
<div :class="$style.headerIcon"><slot name="icon"></slot></div>
<div :class="$style.headerText">
<div :class="$style.headerTextMain">
Expand All @@ -20,7 +20,7 @@
</div>
</template>

<div v-if="openedAtLeastOnce" :class="[$style.body, { [$style.bgSame]: bgSame }]" :style="{ maxHeight: maxHeight ? `${maxHeight}px` : null, overflow: maxHeight ? `auto` : null }">
<div v-if="openedAtLeastOnce" :class="[$style.body, { [$style.bgSame]: bgSame }]" :style="{ maxHeight: maxHeight ? `${maxHeight}px` : null, overflow: maxHeight ? `auto` : null }" :aria-hidden="!opened">
<Transition
:enter-active-class="defaultStore.state.animation ? $style.transition_toggle_enterActive : ''"
:leave-active-class="defaultStore.state.animation ? $style.transition_toggle_leaveActive : ''"
Expand Down Expand Up @@ -196,7 +196,7 @@ onMounted(() => {

.headerRight {
margin-left: auto;
opacity: 0.7;
color: var(--fgTransparentWeak);
white-space: nowrap;
}

Expand Down
6 changes: 0 additions & 6 deletions packages/frontend/src/components/MkModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,10 @@ defineExpose({
right: 0;
margin: auto;
padding: 32px;
// TODO: mask-imageはiOSだとやたら重い。なんとかしたい
-webkit-mask-image: linear-gradient(0deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 32px, rgba(0,0,0,1) calc(100% - 32px), rgba(0,0,0,0) 100%);
mask-image: linear-gradient(0deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 32px, rgba(0,0,0,1) calc(100% - 32px), rgba(0,0,0,0) 100%);
overflow: auto;
display: flex;

@media (max-width: 500px) {
padding: 16px;
-webkit-mask-image: linear-gradient(0deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 16px, rgba(0,0,0,1) calc(100% - 16px), rgba(0,0,0,0) 100%);
mask-image: linear-gradient(0deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 16px, rgba(0,0,0,1) calc(100% - 16px), rgba(0,0,0,0) 100%);
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions packages/frontend/src/components/MkModalWindow.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<MkModal ref="modal" :prefer-type="'dialog'" @click="onBgClick" @closed="$emit('closed')">
<div ref="rootEl" class="ebkgoccj" :style="{ width: `${width}px`, height: scroll ? (height ? `${height}px` : null) : (height ? `min(${height}px, 100%)` : '100%') }" @keydown="onKeydown">
<div ref="rootEl" class="ebkgoccj" :style="{ width: `${width}px`, height: height ? `${height}px` : null }" @keydown="onKeydown">
<div ref="headerEl" class="header">
<button v-if="withOkButton" class="_button" @click="$emit('close')"><i class="ti ti-x"></i></button>
<span class="title">
Expand All @@ -25,13 +25,11 @@ const props = withDefaults(defineProps<{
okButtonDisabled: boolean;
width: number;
height: number | null;
scroll: boolean;
}>(), {
withOkButton: false,
okButtonDisabled: false,
width: 400,
height: null,
scroll: true,
});

const emit = defineEmits<{
Expand Down Expand Up @@ -86,6 +84,7 @@ defineExpose({
<style lang="scss" scoped>
.ebkgoccj {
margin: auto;
max-height: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
Expand Down
Loading