Skip to content

Commit

Permalink
Merge pull request Ruruke#4 from Ruruke/feature/signup-custmize
Browse files Browse the repository at this point in the history
singinをToggleで非表示に。
  • Loading branch information
Ruruke authored and 4ster1sk committed Dec 12, 2024
1 parent fc65b04 commit ee8e106
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 2 deletions.
10 changes: 10 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10635,6 +10635,16 @@ export interface Locale extends ILocale {
*/
"sent": string;
};
"_customizeFeature": {
/**
* 独自機能
*/
"title": string;
/**
* Signupの無効化
*/
"disableSignup": string;
};
}
declare const locales: {
[lang: string]: Locale;
Expand Down
4 changes: 4 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2835,3 +2835,7 @@ _selfXssPrevention:
_followRequest:
recieved: "受け取った申請"
sent: "送った申請"

_customizeFeature:
title: "独自機能"
disableSignup: "Signupの無効化"
16 changes: 16 additions & 0 deletions packages/backend/migration/1733996957482-signinButtonToToggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: ruru
* SPDX-License-Identifier: AGPL-3.0-only
*/

export class SigninButtonToToggle1733996957482 {
name = 'SigninButtonToToggle1733996957482'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "disableSignup" boolean NOT NULL DEFAULT false`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "disableSignup"`);
}
}
1 change: 1 addition & 0 deletions packages/backend/src/core/entities/MetaEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class MetaEntityService {
enableTestcaptcha: instance.enableTestcaptcha,
swPublickey: instance.swPublicKey,
themeColor: instance.themeColor,
disableSignup: instance.disableSignup,
mascotImageUrl: instance.mascotImageUrl ?? '/assets/ai.png',
bannerUrl: instance.bannerUrl,
infoImageUrl: instance.infoImageUrl,
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,4 +658,9 @@ export class MiMeta {
default: '{}',
})
public federationHosts: string[];

@Column('boolean', {
default: false,
})
public disableSignup: boolean;
}
4 changes: 4 additions & 0 deletions packages/backend/src/models/json-schema/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export const packedMetaLiteSchema = {
type: 'boolean',
optional: false, nullable: false,
},
disableSignup: {
type: 'boolean',
optional: false, nullable: false,
},
emailRequiredForSignup: {
type: 'boolean',
optional: false, nullable: false,
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export const meta = {
type: 'object',
optional: false, nullable: false,
properties: {
disableSignup: {
type: 'boolean',
optional: false, nullable: false,
},
cacheRemoteFiles: {
type: 'boolean',
optional: false, nullable: false,
Expand Down Expand Up @@ -559,6 +563,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
impressumUrl: instance.impressumUrl,
privacyPolicyUrl: instance.privacyPolicyUrl,
inquiryUrl: instance.inquiryUrl,
disableSignup: instance.disableSignup,
disableRegistration: instance.disableRegistration,
emailRequiredForSignup: instance.emailRequiredForSignup,
enableHcaptcha: instance.enableHcaptcha,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export const paramDef = {
type: 'string',
},
},
disableSignup: { type: 'boolean' },
},
required: [],
} as const;
Expand Down Expand Up @@ -307,6 +308,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
set.cacheRemoteFiles = ps.cacheRemoteFiles;
}

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

if (ps.cacheRemoteSensitiveFiles !== undefined) {
set.cacheRemoteSensitiveFiles = ps.cacheRemoteSensitiveFiles;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkVisitorDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInfo warn>{{ i18n.ts.invitationRequiredToRegister }}</MkInfo>
</div>
<div class="_gaps_s" :class="$style.mainActions">
<MkButton :class="$style.mainAction" full rounded gradate data-cy-signup style="margin-right: 12px;" @click="signup()">{{ i18n.ts.joinThisServer }}</MkButton>
<MkButton v-if="!instance.disableSignup" :class="$style.mainAction" full rounded gradate data-cy-signup style="margin-right: 12px;" @click="signup()">{{ i18n.ts.joinThisServer }}</MkButton>
<MkButton :class="$style.mainAction" full rounded link to="https://misskey-hub.net/servers/">{{ i18n.ts.exploreOtherServers }}</MkButton>
<MkButton :class="$style.mainAction" full rounded data-cy-signin @click="signin()">{{ i18n.ts.login }}</MkButton>
</div>
Expand Down
24 changes: 24 additions & 0 deletions packages/frontend/src/pages/admin/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,21 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkButton primary @click="chooseProxyAccount">{{ i18n.ts.selectAccount }}</MkButton>
</div>
</MkFolder>

<MkFolder>
<template #icon><i class="ti ti-cloud"></i></template>
<template #label>{{ i18n.ts._customizeFeature.title }}</template>
<template v-if="customFeatureForm.modified.value" #footer>
<MkFormFooter :form="customFeatureForm"/>
</template>

<div class="_gaps">
<MkSwitch v-model="customFeatureForm.state.disableSignup">
<template #label>{{ i18n.ts._customizeFeature.disableSignup }}<span v-if="customFeatureForm.state.disableSignup" class="_modified">{{ i18n.ts.modified }}</span></template>
<template #caption>Wip.</template>
</MkSwitch>
</div>
</MkFolder>
</div>
</MkSpacer>
</MkStickyContainer>
Expand Down Expand Up @@ -326,6 +341,15 @@ const filesForm = useForm({
fetchInstance(true);
});

const customFeatureForm = useForm({
disableSignup: meta.disableSignup,
}, async (state) => {
await os.apiWithDialog('admin/update-meta', {
disableSignup: state.disableSignup,
});
fetchInstance(true);
});

const serviceWorkerForm = useForm({
enableServiceWorker: meta.enableServiceWorker,
swPublicKey: meta.swPublickey ?? '',
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/ui/visitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts" setup>
import { onMounted, provide, ref, computed } from 'vue';
import XCommon from './_common_/common.vue';
import { instanceName } from '@@/js/config.js';
import XCommon from './_common_/common.vue';
import * as os from '@/os.js';
import { instance } from '@/instance.js';
import XSigninDialog from '@/components/MkSigninDialog.vue';
Expand Down
3 changes: 3 additions & 0 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4976,6 +4976,7 @@ export type components = {
defaultDarkTheme: string | null;
defaultLightTheme: string | null;
disableRegistration: boolean;
disableSignup: boolean;
emailRequiredForSignup: boolean;
enableHcaptcha: boolean;
hcaptchaSiteKey: string | null;
Expand Down Expand Up @@ -5105,6 +5106,7 @@ export type operations = {
200: {
content: {
'application/json': {
disableSignup: boolean;
cacheRemoteFiles: boolean;
cacheRemoteSensitiveFiles: boolean;
emailRequiredForSignup: boolean;
Expand Down Expand Up @@ -9603,6 +9605,7 @@ export type operations = {
/** @enum {string} */
federation?: 'all' | 'none' | 'specified';
federationHosts?: string[];
disableSignup?: boolean;
};
};
};
Expand Down

0 comments on commit ee8e106

Please sign in to comment.