Merge remote-tracking branch 'refs/remotes/misskey-original/develop' into develop
This commit is contained in:
commit
72aaffdd37
29 changed files with 256 additions and 136 deletions
|
|
@ -125,6 +125,35 @@ export function file(isSensitive = false) {
|
|||
};
|
||||
}
|
||||
|
||||
export function federationInstance(): entities.FederationInstance {
|
||||
return {
|
||||
id: 'someinstanceid',
|
||||
firstRetrievedAt: '2021-01-01T00:00:00.000Z',
|
||||
host: 'misskey-hub.net',
|
||||
usersCount: 10,
|
||||
notesCount: 20,
|
||||
followingCount: 5,
|
||||
followersCount: 15,
|
||||
isNotResponding: false,
|
||||
isSuspended: false,
|
||||
suspensionState: 'none',
|
||||
isBlocked: false,
|
||||
softwareName: 'misskey',
|
||||
softwareVersion: '2024.5.0',
|
||||
openRegistrations: false,
|
||||
name: 'Misskey Hub',
|
||||
description: '',
|
||||
maintainerName: '',
|
||||
maintainerEmail: '',
|
||||
isSilenced: false,
|
||||
iconUrl: 'https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/about-icon.png?raw=true',
|
||||
faviconUrl: '',
|
||||
themeColor: '',
|
||||
infoUpdatedAt: '',
|
||||
latestRequestReceivedAt: '',
|
||||
};
|
||||
}
|
||||
|
||||
export function userDetailed(id = 'someuserid', username = 'miskist', host = 'misskey-hub.net', name = 'Misskey User'): entities.UserDetailed {
|
||||
return {
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -403,6 +403,7 @@ function toStories(component: string): Promise<string> {
|
|||
glob('src/components/MkSignupServerRules.vue'),
|
||||
glob('src/components/MkUserSetupDialog.vue'),
|
||||
glob('src/components/MkUserSetupDialog.*.vue'),
|
||||
glob('src/components/MkInstanceCardMini.vue'),
|
||||
glob('src/components/MkInviteCode.vue'),
|
||||
glob('src/pages/user/home.vue'),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ function getChartArray(seed: string, limit: number, option?: { accumulate?: bool
|
|||
return array;
|
||||
}
|
||||
|
||||
function getChartResolver(fields: string[], option?: { accumulate?: boolean, mulMap?: Record<string, number> }): HttpResponseResolver<PathParams, DefaultBodyType, JsonBodyType> {
|
||||
export function getChartResolver(fields: string[], option?: { accumulate?: boolean, mulMap?: Record<string, number> }): HttpResponseResolver<PathParams, DefaultBodyType, JsonBodyType> {
|
||||
return ({ request }) => {
|
||||
action(`GET ${request.url}`)();
|
||||
const limitParam = new URL(request.url).searchParams.get('limit');
|
||||
|
|
@ -76,6 +76,7 @@ const Base = {
|
|||
args: {
|
||||
src: 'federation',
|
||||
span: 'hour',
|
||||
nowForChromatic: 1716263640000,
|
||||
},
|
||||
parameters: {
|
||||
layout: 'centered',
|
||||
|
|
@ -100,18 +101,21 @@ const Base = {
|
|||
export const FederationChart = {
|
||||
...Base,
|
||||
args: {
|
||||
...Base.args,
|
||||
src: 'federation',
|
||||
},
|
||||
} satisfies StoryObj<typeof MkChart>;
|
||||
export const NotesTotalChart = {
|
||||
...Base,
|
||||
args: {
|
||||
...Base.args,
|
||||
src: 'notes-total',
|
||||
},
|
||||
} satisfies StoryObj<typeof MkChart>;
|
||||
export const DriveChart = {
|
||||
...Base,
|
||||
args: {
|
||||
...Base.args,
|
||||
src: 'drive',
|
||||
},
|
||||
} satisfies StoryObj<typeof MkChart>;
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ const props = withDefaults(defineProps<{
|
|||
stacked?: boolean;
|
||||
bar?: boolean;
|
||||
aspectRatio?: number | null;
|
||||
nowForChromatic?: number;
|
||||
}>(), {
|
||||
args: undefined,
|
||||
limit: 90,
|
||||
|
|
@ -84,6 +85,13 @@ const props = withDefaults(defineProps<{
|
|||
stacked: false,
|
||||
bar: false,
|
||||
aspectRatio: null,
|
||||
|
||||
/**
|
||||
* @desc Overwrites current date to fix background lines of chart.
|
||||
* @ignore Only used for Chromatic. Don't use this for production.
|
||||
* @see https://github.com/misskey-dev/misskey/pull/13830#issuecomment-2155886151
|
||||
*/
|
||||
nowForChromatic: undefined,
|
||||
});
|
||||
|
||||
const legendEl = shallowRef<InstanceType<typeof MkChartLegend>>();
|
||||
|
|
@ -106,7 +114,8 @@ const getColor = (i) => {
|
|||
return colorSets[i % colorSets.length];
|
||||
};
|
||||
|
||||
const now = new Date();
|
||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||
const now = props.nowForChromatic != null ? new Date(props.nowForChromatic) : new Date();
|
||||
let chartInstance: Chart | null = null;
|
||||
let chartData: {
|
||||
series: {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
import { StoryObj } from '@storybook/vue3';
|
||||
import { HttpResponse, http } from 'msw';
|
||||
import { federationInstance } from '../../.storybook/fakes.js';
|
||||
import { commonHandlers } from '../../.storybook/mocks.js';
|
||||
import MkInstanceCardMini from './MkInstanceCardMini.vue';
|
||||
import { getChartResolver } from './MkChart.stories.impl.js';
|
||||
export const Default = {
|
||||
render(args) {
|
||||
return {
|
||||
components: {
|
||||
MkInstanceCardMini,
|
||||
},
|
||||
setup() {
|
||||
return {
|
||||
args,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
props() {
|
||||
return {
|
||||
...this.args,
|
||||
};
|
||||
},
|
||||
},
|
||||
template: '<MkInstanceCardMini v-bind="props" />',
|
||||
};
|
||||
},
|
||||
args: {
|
||||
instance: federationInstance(),
|
||||
},
|
||||
parameters: {
|
||||
layout: 'centered',
|
||||
msw: {
|
||||
handlers: [
|
||||
...commonHandlers,
|
||||
http.get('/undefined/preview.webp', async ({ request }) => {
|
||||
const urlStr = new URL(request.url).searchParams.get('url');
|
||||
if (urlStr == null) {
|
||||
return new HttpResponse(null, { status: 404 });
|
||||
}
|
||||
const url = new URL(urlStr);
|
||||
|
||||
if (url.href.startsWith('https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/')) {
|
||||
const image = await (await fetch(`client-assets/${url.pathname.split('/').pop()}`)).blob();
|
||||
return new HttpResponse(image, {
|
||||
headers: {
|
||||
'Content-Type': 'image/jpeg',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
return new HttpResponse(null, { status: 404 });
|
||||
}
|
||||
}),
|
||||
http.get('/api/charts/instance', getChartResolver(['requests.received'])),
|
||||
],
|
||||
},
|
||||
},
|
||||
} satisfies StoryObj<typeof MkInstanceCardMini>;
|
||||
|
|
@ -29,8 +29,8 @@ const chartValues = ref<number[] | null>(null);
|
|||
|
||||
misskeyApiGet('charts/instance', { host: props.instance.host, limit: 16 + 1, span: 'day' }).then(res => {
|
||||
// 今日のぶんの値はまだ途中の値であり、それも含めると大抵の場合前日よりも下降しているようなグラフになってしまうため今日は弾く
|
||||
res['requests.received'].splice(0, 1);
|
||||
chartValues.value = res['requests.received'];
|
||||
res.requests.received.splice(0, 1);
|
||||
chartValues.value = res.requests.received;
|
||||
});
|
||||
|
||||
function getInstanceIcon(instance): string {
|
||||
|
|
|
|||
|
|
@ -109,6 +109,15 @@ definePageMetadata(() => ({
|
|||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
.fadeEnterActive,
|
||||
.fadeLeaveActive {
|
||||
transition: opacity 0.125s ease;
|
||||
}
|
||||
.fadeEnterFrom,
|
||||
.fadeLeaveTo {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.announcement {
|
||||
padding: 16px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@
|
|||
],
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom"
|
||||
"dom",
|
||||
"dom.iterable"
|
||||
],
|
||||
"jsx": "preserve"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {type UserConfig, defineConfig} from 'vite';
|
|||
|
||||
import locales from '../../locales/index.js';
|
||||
import meta from '../../package.json';
|
||||
import packageInfo from './package.json' assert { type: 'json' };
|
||||
import packageInfo from './package.json' with { type: 'json' };
|
||||
import pluginUnwindCssModuleClassName from './lib/rollup-plugin-unwind-css-module-class-name.js';
|
||||
import pluginJson5 from './vite.json5.js';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue