-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'camilla-ett/alert_other_host' into develop
- Loading branch information
Showing
18 changed files
with
311 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/backend/migration/1711008460816-external-website-warn.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
export class ExternalWebsiteWarn1711008460816 { | ||
name = 'ExternalWebsiteWarn1711008460816' | ||
|
||
async up(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "meta" ADD "trustedLinkUrlPatterns" character varying(3072) array NOT NULL DEFAULT '{}'`); | ||
} | ||
|
||
async down(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "trustedLinkUrlPatterns"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
packages/frontend/src/components/MkUrlWarningDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: syuilo and misskey-project | ||
SPDX-License-Identifier: AGPL-3.0-only | ||
--> | ||
|
||
<template> | ||
<MkModal ref="modal" :preferType="'dialog'" :zPriority="'high'" @click="done(true)" @closed="emit('closed')"> | ||
<div :class="$style.root" class="_gaps"> | ||
<div class="_gaps_s"> | ||
<div :class="$style.header"> | ||
<div :class="$style.icon"> | ||
<i class="ti ti-alert-triangle"></i> | ||
</div> | ||
<div :class="$style.title">{{ i18n.ts._externalNavigationWarning.title }}</div> | ||
</div> | ||
<div><Mfm :text="i18n.tsx._externalNavigationWarning.description({ host: instanceName })"/></div> | ||
<div class="_monospace" :class="$style.urlAddress">{{ url }}</div> | ||
<div> | ||
<MkSwitch v-model="trustThisDomain">{{ i18n.ts._externalNavigationWarning.trustThisDomain }}</MkSwitch> | ||
</div> | ||
</div> | ||
<div :class="$style.buttons"> | ||
<MkButton data-cy-modal-dialog-cancel inline rounded @click="cancel">{{ i18n.ts.cancel }}</MkButton> | ||
<MkButton data-cy-modal-dialog-ok inline primary rounded @click="ok"><i class="ti ti-external-link"></i> {{ i18n.ts.open }}</MkButton> | ||
</div> | ||
</div> | ||
</MkModal> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { onBeforeUnmount, onMounted, ref, shallowRef, computed } from 'vue'; | ||
import MkModal from '@/components/MkModal.vue'; | ||
import MkButton from '@/components/MkButton.vue'; | ||
import MkSwitch from '@/components/MkSwitch.vue'; | ||
import { i18n } from '@/i18n.js'; | ||
import { defaultStore } from '@/store.js'; | ||
import { instanceName } from '@/config'; | ||
type Result = string | number | true | null; | ||
const props = defineProps<{ | ||
url: string; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(ev: 'done', v: { canceled: true } | { canceled: false, result: Result }): void; | ||
(ev: 'closed'): void; | ||
}>(); | ||
const modal = shallowRef<InstanceType<typeof MkModal>>(); | ||
const trustThisDomain = ref(false); | ||
const domain = computed(() => new URL(props.url).hostname); | ||
// overload function を使いたいので lint エラーを無視する | ||
function done(canceled: true): void; | ||
function done(canceled: false, result: Result): void; // eslint-disable-line no-redeclare | ||
function done(canceled: boolean, result?: Result): void { // eslint-disable-line no-redeclare | ||
emit('done', { canceled, result } as { canceled: true } | { canceled: false, result: Result }); | ||
modal.value?.close(); | ||
} | ||
async function ok() { | ||
const result = true; | ||
if (!defaultStore.state.trustedDomains.includes(domain.value) && trustThisDomain.value) { | ||
await defaultStore.set('trustedDomains', defaultStore.state.trustedDomains.concat(domain.value)); | ||
} | ||
done(false, result); | ||
} | ||
function cancel() { | ||
done(true); | ||
} | ||
/* | ||
function onBgClick() { | ||
if (props.cancelableByBgClick) cancel(); | ||
} | ||
*/ | ||
function onKeydown(evt: KeyboardEvent) { | ||
if (evt.key === 'Escape') cancel(); | ||
} | ||
onMounted(() => { | ||
document.addEventListener('keydown', onKeydown); | ||
}); | ||
onBeforeUnmount(() => { | ||
document.removeEventListener('keydown', onKeydown); | ||
}); | ||
</script> | ||
|
||
<style lang="scss" module> | ||
.root { | ||
position: relative; | ||
margin: auto; | ||
padding: 32px; | ||
width: 100%; | ||
min-width: 320px; | ||
max-width: 480px; | ||
box-sizing: border-box; | ||
background: var(--panel); | ||
border-radius: 16px; | ||
} | ||
.header { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.75em; | ||
} | ||
.icon { | ||
font-size: 18px; | ||
color: var(--warn); | ||
} | ||
.title { | ||
font-weight: bold; | ||
font-size: 1.1em; | ||
} | ||
.urlAddress { | ||
padding: 10px 14px; | ||
border-radius: 8px; | ||
border: 1px solid var(--divider); | ||
overflow-x: auto; | ||
white-space: nowrap; | ||
} | ||
.buttons { | ||
display: flex; | ||
gap: 8px; | ||
flex-wrap: wrap; | ||
justify-content: right; | ||
} | ||
</style> |
Oops, something went wrong.
8742609
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chromatic detects changes. Please review the changes on Chromatic.