Skip to content

Commit

Permalink
refactor: format all
Browse files Browse the repository at this point in the history
  • Loading branch information
z0gSh1u committed Aug 28, 2024
1 parent c2a58b6 commit 273cb3e
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 276 deletions.
4 changes: 2 additions & 2 deletions packages/secretnote-lite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alipay/secretnote-lite",
"version": "0.0.38",
"version": "0.0.40",
"license": "Apache-2.0",
"author": "vectorse@126.com",
"repository": "https://github.com/secretflow/secretnote/tree/main/packages/secretnote",
Expand Down Expand Up @@ -81,4 +81,4 @@
"publishConfig": {
"registry": "https://registry.antgroup-inc.cn"
}
}
}
8 changes: 2 additions & 6 deletions packages/secretnote-lite/src/components/ribbon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ function Ribbon(props: RibbonProps) {
const { items, value, onChange } = props;

const handleChange = (tag: string, checked: boolean) => {
const nextSelectedTags = checked
? [...value, tag]
: value.filter((t) => t !== tag);
const nextSelectedTags = checked ? [...value, tag] : value.filter((t) => t !== tag);
if (onChange) {
onChange(nextSelectedTags);
}
Expand All @@ -42,9 +40,7 @@ function Ribbon(props: RibbonProps) {
overlayClassName="secretnote-ribbon-popover"
content={
<>
<div className="title">
{l10n.t('下面是将要执行该代码的节点列表')}:
</div>
<div className="title">{l10n.t('下面是将要执行该代码的节点列表')}:</div>
<Space size={[0, 8]} wrap>
{items.map((item) => (
<CheckableTag
Expand Down
25 changes: 5 additions & 20 deletions packages/secretnote-lite/src/modules/editor/cell/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ const SecretNoteCodeCellComponent = forwardRef<HTMLDivElement>((props, ref) => {
const { partyList, parties } = instance;

return (
<div
className={instance.className}
ref={ref}
tabIndex={10}
onBlur={instance.blur}
>
<div className={instance.className} ref={ref} tabIndex={10} onBlur={instance.blur}>
<Ribbon
items={partyList.map((name) => ({ label: name, key: name }))}
value={parties}
Expand Down Expand Up @@ -119,9 +114,7 @@ export class SecretNoteCodeCellView extends JupyterCodeCellView {
const cellModel = this.model;
const kernels = this.getUsableKernels();
if (kernels.length === 0) {
message.info(
l10n.t('无可用的 Kernel 连接,请检查是否存在并选中可用节点'),
);
message.info(l10n.t('无可用的 Kernel 连接,请检查是否存在并选中可用节点'));
return false;
}

Expand Down Expand Up @@ -201,14 +194,10 @@ export class SecretNoteCodeCellView extends JupyterCodeCellView {
* `executing` means the application is executing the cell.
* `kernelExecuting` means some kernel is executing the cell.
*/
updateExecutionStatus(status: {
executing?: boolean;
kernelExecuting?: boolean;
}) {
updateExecutionStatus(status: { executing?: boolean; kernelExecuting?: boolean }) {
const { executing, kernelExecuting } = status;
!isUndefined(executing) && (this.model.executing = executing);
!isUndefined(kernelExecuting) &&
(this.model.kernelExecuting = kernelExecuting);
!isUndefined(kernelExecuting) && (this.model.kernelExecuting = kernelExecuting);
}

/**
Expand All @@ -217,11 +206,7 @@ export class SecretNoteCodeCellView extends JupyterCodeCellView {
* `start` is the time when the kernel starts to execute the code.
* `end` is the time when the kernel finishes the execution.
*/
updateExecutionTime(times: {
toExecute?: string;
start?: string;
end?: string;
}) {
updateExecutionTime(times: { toExecute?: string; start?: string; end?: string }) {
const meta = this.model.metadata.execution as ExecutionMeta;
if (meta) {
const { start, end, toExecute } = times;
Expand Down
18 changes: 3 additions & 15 deletions packages/secretnote-lite/src/modules/editor/output/outputarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ export class SecretNoteOutputArea extends LibroOutputArea {
// this event is fired inside `cell/view.tsx`
// about messaging, see https://jupyter-client.readthedocs.io/en/latest/messaging.html
cellModel.msgChangeEmitter.event(
({
kernel,
msg,
}: {
kernel: IKernelConnection;
msg: KernelMessage.IMessage;
}) => {
({ kernel, msg }: { kernel: IKernelConnection; msg: KernelMessage.IMessage }) => {
// ignore heartbeat messages
if (msg.header.msg_type === 'status') {
return;
Expand Down Expand Up @@ -120,16 +114,10 @@ export class SecretNoteOutputArea extends LibroOutputArea {

const lastIndex = outputs.length - 1;
const preOutput = outputs[lastIndex];
if (
isStream(output) &&
isStream(preOutput) &&
output.name === preOutput.name
) {
if (isStream(output) && isStream(preOutput) && output.name === preOutput.name) {
// merge two continuous outputs to the same stream
// handle backspace and carriage-return, concat the text
output.text = removeOverwrittenChars(
preOutput.text + normalize(output.text),
);
output.text = removeOverwrittenChars(preOutput.text + normalize(output.text));
// just replace the previous output, don't push new
outputs[lastIndex] = output;
this.flushOutputs();
Expand Down
98 changes: 0 additions & 98 deletions packages/secretnote-lite/src/modules/file/csv-preview-contrib.tsx

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions packages/secretnote-lite/src/modules/file/log-preview-contrib.tsx

This file was deleted.

16 changes: 3 additions & 13 deletions packages/secretnote-lite/src/modules/layout/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,11 @@ const AboutBarComponent = () => {
const fmtPackageVersions = instance.fmtPackageVersions;

return (
<Space
direction="horizontal"
align="center"
size="large"
className="about-bar"
>
<Space direction="horizontal" align="center" size="large" className="about-bar">
<Typography.Link href="https://www.secretflow.org.cn/" target="_blank">
SecretFlow
</Typography.Link>
<Typography.Link
href="https://github.com/secretflow/secretnote"
target="_blank"
>
<Typography.Link href="https://github.com/secretflow/secretnote" target="_blank">
SecretNote
</Typography.Link>
<div className="icon-container">
Expand Down Expand Up @@ -89,9 +81,7 @@ export const SideBar: React.FC = () => {
const instance = useInject<SideBarView>(ViewInstance);
const providers = instance.providers.getContributions();
providers.sort((a, b) => a.order - b.order);
const defaultActiveKey = providers
.filter((p) => !!p.defaultOpen)
.map((p) => p.key);
const defaultActiveKey = providers.filter((p) => !!p.defaultOpen).map((p) => p.key);

const items = providers
.sort((a, b) => a.order - b.order)
Expand Down
18 changes: 3 additions & 15 deletions packages/secretnote-lite/src/modules/markdown-editor/view.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import type { CellCollapsible } from '@difizen/libro-jupyter';
import { LibroEditorCellView } from '@difizen/libro-jupyter';
import {
prop,
transient,
useInject,
view,
ViewInstance,
} from '@difizen/mana-app';
import { prop, transient, useInject, view, ViewInstance } from '@difizen/mana-app';
import { forwardRef } from 'react';

import { Editor } from '@/components/markdown-editor';
Expand All @@ -24,10 +18,7 @@ export const MarkdownCell = forwardRef<HTMLDivElement>((props, ref) => {
instance.focus(true);
}}
onBlur={(e) => {
if (
typeof ref !== 'function' &&
!ref?.current?.contains(e.relatedTarget)
) {
if (typeof ref !== 'function' && !ref?.current?.contains(e.relatedTarget)) {
instance.blur();
}
}}
Expand All @@ -46,10 +37,7 @@ MarkdownCell.displayName = 'MarkdownCell';

@transient()
@view('markdown-cell-view')
export class MarkdownCellView
extends LibroEditorCellView
implements CellCollapsible
{
export class MarkdownCellView extends LibroEditorCellView implements CellCollapsible {
view = MarkdownCell;

@prop()
Expand Down
4 changes: 1 addition & 3 deletions packages/secretnote-lite/src/modules/metrics/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ const MetricsComponent = () => {
Object.entries(metrics).map(([id, v]) => (
<div key={id} className="kernel-status-item">
<div className="server-name">{v.name}</div>
<Tag style={{ fontFamily: 'monospace, monospace' }}>
{formatMetric(v)}
</Tag>
<Tag style={{ fontFamily: 'monospace, monospace' }}>{formatMetric(v)}</Tag>
</div>
))
) : (
Expand Down
Loading

0 comments on commit 273cb3e

Please sign in to comment.