-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* prepare release 1.2.0 * Support array schemas * notification popup * rewrite identites overview to new DataGrid
- Loading branch information
Showing
16 changed files
with
1,312 additions
and
396 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { | ||
MessageBar, | ||
MessageBarActions, | ||
MessageBarTitle, | ||
MessageBarBody, | ||
MessageBarGroup, | ||
Button, | ||
Link, | ||
MessageBarIntent, | ||
} from "@fluentui/react-components"; | ||
import { DismissRegular } from "@fluentui/react-icons"; | ||
import React, { useEffect, useState } from "react"; | ||
|
||
interface Message { | ||
intent: MessageBarIntent; | ||
title: string; | ||
content?: JSX.Element; | ||
} | ||
|
||
interface InternalMessage extends Message { | ||
id: number; | ||
removeAfterSeconds: number; | ||
} | ||
|
||
type MessageConfig = { | ||
message: Message; | ||
removeAfterSeconds: number; | ||
} | ||
|
||
|
||
export class MessageService { | ||
|
||
private static _instance: MessageService; | ||
|
||
private eventQueue: InternalMessage[] = []; | ||
private id: number = 0; | ||
|
||
public dispatchMessage(message: MessageConfig): void { | ||
const msg: InternalMessage = { | ||
id: this.id++, | ||
content: message.message.content, | ||
intent: message.message.intent, | ||
title: message.message.title, | ||
removeAfterSeconds: message.removeAfterSeconds | ||
}; | ||
|
||
|
||
this.eventQueue.push(msg) | ||
window.dispatchEvent(new Event("new_event_dispatched")); | ||
} | ||
|
||
public getAndCleanMessages(): InternalMessage[] { | ||
const data = this.eventQueue; | ||
this.eventQueue = [] | ||
return data; | ||
} | ||
|
||
private constructor() { | ||
|
||
} | ||
|
||
|
||
|
||
public static get Instance() { | ||
return this._instance || (this._instance = new this()); | ||
} | ||
|
||
} | ||
|
||
export function MessageBarComponent() { | ||
|
||
const [messages, setMessages] = useState<InternalMessage[]>([]); | ||
const dismissMessage = (messageId: number) => | ||
setMessages((s) => s.filter((entry) => entry.id !== messageId)); | ||
|
||
function handleWindowClick() { | ||
const newMessages = MessageService.Instance.getAndCleanMessages(); | ||
setMessages(messages.concat(newMessages)); | ||
|
||
|
||
newMessages.forEach(newMessage => { | ||
setTimeout(() => { | ||
dismissMessage(newMessage.id) | ||
}, newMessage.removeAfterSeconds * 1000) | ||
}) | ||
} | ||
|
||
useEffect(() => { | ||
window.addEventListener('new_event_dispatched', handleWindowClick); | ||
return () => { | ||
window.removeEventListener("new_event_dispatched", handleWindowClick); | ||
} | ||
}, []) | ||
|
||
return ( | ||
<MessageBarGroup animate="both" style={{ | ||
position: "absolute", | ||
top: 70, | ||
right: 0 | ||
}}> | ||
{messages.map(({ intent, id, title, content }) => ( | ||
<MessageBar key={`${intent}-${id}`} intent={intent}> | ||
<MessageBarBody> | ||
<MessageBarTitle>{title}</MessageBarTitle> | ||
{content} | ||
</MessageBarBody> | ||
<MessageBarActions | ||
containerAction={ | ||
<Button | ||
onClick={() => dismissMessage(id)} | ||
aria-label="dismiss" | ||
appearance="transparent" | ||
icon={<DismissRegular />} | ||
/> | ||
} | ||
/> | ||
</MessageBar> | ||
))} | ||
</MessageBarGroup> | ||
) | ||
|
||
} | ||
|
||
|
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,88 @@ | ||
import { Button, Input, Tooltip } from "@fluentui/react-components"; | ||
import { Add12Filled, Delete12Filled } from "@fluentui/react-icons"; | ||
import { useEffect, useState } from "react" | ||
import { FluentUIInputDataType } from "../../service/schema-service"; | ||
|
||
|
||
interface MultilineEditProps { | ||
defaultData?: any[] | ||
datatype: FluentUIInputDataType; | ||
dataChanged(any: any[]): void; | ||
name: string; | ||
} | ||
|
||
export function MultilineEdit(props: MultilineEditProps) { | ||
|
||
const [data, setData] = useState<any[]>([]); | ||
|
||
useEffect(() => { | ||
if (props.defaultData && props.defaultData.length > 0) { | ||
if (JSON.stringify(data) !== JSON.stringify(props.defaultData)) { | ||
setData(props.defaultData) | ||
} | ||
} else { | ||
setData([""]) | ||
} | ||
}, []) | ||
|
||
|
||
return ( | ||
<> | ||
{data.map((value, index) => { | ||
return ( | ||
<div key={index} style={{ | ||
display: "flex", | ||
alignItems: "center", | ||
paddingBottom: 5 | ||
}}> | ||
<Input | ||
style={{ | ||
flexGrow: 2 | ||
}} | ||
type={props.datatype} | ||
onChange={(ev, inputData) => { | ||
data[index] = inputData.value | ||
props.dataChanged(data) | ||
}} | ||
defaultValue={value} | ||
name={props.name + "_" + index} | ||
></Input> | ||
<div> | ||
<Tooltip | ||
content="Add another line" relationship="description"> | ||
<Button | ||
style={{ | ||
marginLeft: 5 | ||
}} | ||
size="small" | ||
icon={<Add12Filled></Add12Filled>} | ||
onClick={(event => { | ||
setData(data.concat("")) | ||
})} | ||
></Button> | ||
</Tooltip> | ||
<Tooltip | ||
content={"Remove line"} relationship="description"> | ||
<Button | ||
style={{ | ||
marginLeft: 5 | ||
}} | ||
disabled={data.length === 1} | ||
size="small" | ||
icon={<Delete12Filled></Delete12Filled>} | ||
onClick={(event => { | ||
setData(data.filter((arrayvalue, arrayIndex) => { | ||
return arrayIndex !== index | ||
})) | ||
props.dataChanged(data) | ||
})} | ||
></Button> | ||
</Tooltip> | ||
</div> | ||
</div> | ||
) | ||
})} | ||
</> | ||
) | ||
|
||
} |
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
Oops, something went wrong.