added new sample teams-conversation view
added new sample teams-conversation view Co-Authored-By: Kunj Balkrishna Sangani <Sangani.kunj@gmail.com>
This commit is contained in:
parent
5dd0a074a0
commit
62b1a28dd5
|
@ -0,0 +1,352 @@
|
||||||
|
require('@rushstack/eslint-config/patch/modern-module-resolution');
|
||||||
|
module.exports = {
|
||||||
|
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'],
|
||||||
|
parserOptions: { tsconfigRootDir: __dirname },
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ['*.ts', '*.tsx'],
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
'parserOptions': {
|
||||||
|
'project': './tsconfig.json',
|
||||||
|
'ecmaVersion': 2018,
|
||||||
|
'sourceType': 'module'
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
// Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin
|
||||||
|
'@rushstack/no-new-null': 1,
|
||||||
|
// Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin
|
||||||
|
'@rushstack/hoist-jest-mock': 1,
|
||||||
|
// Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security
|
||||||
|
'@rushstack/security/no-unsafe-regexp': 1,
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
'@typescript-eslint/adjacent-overload-signatures': 1,
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
//
|
||||||
|
// CONFIGURATION: By default, these are banned: String, Boolean, Number, Object, Symbol
|
||||||
|
'@typescript-eslint/ban-types': [
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
'extendDefaults': false,
|
||||||
|
'types': {
|
||||||
|
'String': {
|
||||||
|
'message': 'Use \'string\' instead',
|
||||||
|
'fixWith': 'string'
|
||||||
|
},
|
||||||
|
'Boolean': {
|
||||||
|
'message': 'Use \'boolean\' instead',
|
||||||
|
'fixWith': 'boolean'
|
||||||
|
},
|
||||||
|
'Number': {
|
||||||
|
'message': 'Use \'number\' instead',
|
||||||
|
'fixWith': 'number'
|
||||||
|
},
|
||||||
|
'Object': {
|
||||||
|
'message': 'Use \'object\' instead, or else define a proper TypeScript type:'
|
||||||
|
},
|
||||||
|
'Symbol': {
|
||||||
|
'message': 'Use \'symbol\' instead',
|
||||||
|
'fixWith': 'symbol'
|
||||||
|
},
|
||||||
|
'Function': {
|
||||||
|
'message': 'The \'Function\' type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with \'new\'.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// RATIONALE: Code is more readable when the type of every variable is immediately obvious.
|
||||||
|
// Even if the compiler may be able to infer a type, this inference will be unavailable
|
||||||
|
// to a person who is reviewing a GitHub diff. This rule makes writing code harder,
|
||||||
|
// but writing code is a much less important activity than reading it.
|
||||||
|
//
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
'@typescript-eslint/explicit-function-return-type': [
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
'allowExpressions': true,
|
||||||
|
'allowTypedFunctionExpressions': true,
|
||||||
|
'allowHigherOrderFunctions': false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
// Rationale to disable: although this is a recommended rule, it is up to dev to select coding style.
|
||||||
|
// Set to 1 (warning) or 2 (error) to enable.
|
||||||
|
'@typescript-eslint/explicit-member-accessibility': 0,
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
'@typescript-eslint/no-array-constructor': 1,
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
//
|
||||||
|
// RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript.
|
||||||
|
// This rule should be suppressed only in very special cases such as JSON.stringify()
|
||||||
|
// where the type really can be anything. Even if the type is flexible, another type
|
||||||
|
// may be more appropriate such as "unknown", "{}", or "Record<k,V>".
|
||||||
|
'@typescript-eslint/no-explicit-any': 1,
|
||||||
|
// RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch()
|
||||||
|
// handler. Thus wherever a Promise arises, the code must either append a catch handler,
|
||||||
|
// or else return the object to a caller (who assumes this responsibility). Unterminated
|
||||||
|
// promise chains are a serious issue. Besides causing errors to be silently ignored,
|
||||||
|
// they can also cause a NodeJS process to terminate unexpectedly.
|
||||||
|
'@typescript-eslint/no-floating-promises': 2,
|
||||||
|
// RATIONALE: Catches a common coding mistake.
|
||||||
|
'@typescript-eslint/no-for-in-array': 2,
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
'@typescript-eslint/no-misused-new': 2,
|
||||||
|
// RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks
|
||||||
|
// a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler
|
||||||
|
// optimizations. If you are declaring loose functions/variables, it's better to make them
|
||||||
|
// static members of a class, since classes support property getters and their private
|
||||||
|
// members are accessible by unit tests. Also, the exercise of choosing a meaningful
|
||||||
|
// class name tends to produce more discoverable APIs: for example, search+replacing
|
||||||
|
// the function "reverse()" is likely to return many false matches, whereas if we always
|
||||||
|
// write "Text.reverse()" is more unique. For large scale organization, it's recommended
|
||||||
|
// to decompose your code into separate NPM packages, which ensures that component
|
||||||
|
// dependencies are tracked more conscientiously.
|
||||||
|
//
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
'@typescript-eslint/no-namespace': [
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
'allowDeclarations': false,
|
||||||
|
'allowDefinitionFiles': false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)"
|
||||||
|
// that avoids the effort of declaring "title" as a field. This TypeScript feature makes
|
||||||
|
// code easier to write, but arguably sacrifices readability: In the notes for
|
||||||
|
// "@typescript-eslint/member-ordering" we pointed out that fields are central to
|
||||||
|
// a class's design, so we wouldn't want to bury them in a constructor signature
|
||||||
|
// just to save some typing.
|
||||||
|
//
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
// Set to 1 (warning) or 2 (error) to enable the rule
|
||||||
|
'@typescript-eslint/no-parameter-properties': 0,
|
||||||
|
// RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code
|
||||||
|
// may impact performance.
|
||||||
|
//
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
'@typescript-eslint/no-unused-vars': [
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
'vars': 'all',
|
||||||
|
// Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code,
|
||||||
|
// the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures
|
||||||
|
// that are overriding a base class method or implementing an interface.
|
||||||
|
'args': 'none'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
'@typescript-eslint/no-use-before-define': [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
'functions': false,
|
||||||
|
'classes': true,
|
||||||
|
'variables': true,
|
||||||
|
'enums': true,
|
||||||
|
'typedefs': true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// Disallows require statements except in import statements.
|
||||||
|
// In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports.
|
||||||
|
'@typescript-eslint/no-var-requires': 'error',
|
||||||
|
// RATIONALE: The "module" keyword is deprecated except when describing legacy libraries.
|
||||||
|
//
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
'@typescript-eslint/prefer-namespace-keyword': 1,
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
// Rationale to disable: it's up to developer to decide if he wants to add type annotations
|
||||||
|
// Set to 1 (warning) or 2 (error) to enable the rule
|
||||||
|
'@typescript-eslint/no-inferrable-types': 0,
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
// Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios
|
||||||
|
'@typescript-eslint/no-empty-interface': 0,
|
||||||
|
// RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake.
|
||||||
|
'accessor-pairs': 1,
|
||||||
|
// RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking.
|
||||||
|
'dot-notation': [
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
'allowPattern': '^_'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// RATIONALE: Catches code that is likely to be incorrect
|
||||||
|
'eqeqeq': 1,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'for-direction': 1,
|
||||||
|
// RATIONALE: Catches a common coding mistake.
|
||||||
|
'guard-for-in': 2,
|
||||||
|
// RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time
|
||||||
|
// to split up your code.
|
||||||
|
'max-lines': ['warn', { max: 2000 }],
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-async-promise-executor': 2,
|
||||||
|
// RATIONALE: Deprecated language feature.
|
||||||
|
'no-caller': 2,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-compare-neg-zero': 2,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-cond-assign': 2,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-constant-condition': 1,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-control-regex': 2,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-debugger': 1,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-delete-var': 2,
|
||||||
|
// RATIONALE: Catches code that is likely to be incorrect
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-duplicate-case': 2,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-empty': 1,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-empty-character-class': 2,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-empty-pattern': 1,
|
||||||
|
// RATIONALE: Eval is a security concern and a performance concern.
|
||||||
|
'no-eval': 1,
|
||||||
|
// RATIONALE: Catches code that is likely to be incorrect
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-ex-assign': 2,
|
||||||
|
// RATIONALE: System types are global and should not be tampered with in a scalable code base.
|
||||||
|
// If two different libraries (or two versions of the same library) both try to modify
|
||||||
|
// a type, only one of them can win. Polyfills are acceptable because they implement
|
||||||
|
// a standardized interoperable contract, but polyfills are generally coded in plain
|
||||||
|
// JavaScript.
|
||||||
|
'no-extend-native': 1,
|
||||||
|
// Disallow unnecessary labels
|
||||||
|
'no-extra-label': 1,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-fallthrough': 2,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-func-assign': 1,
|
||||||
|
// RATIONALE: Catches a common coding mistake.
|
||||||
|
'no-implied-eval': 2,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-invalid-regexp': 2,
|
||||||
|
// RATIONALE: Catches a common coding mistake.
|
||||||
|
'no-label-var': 2,
|
||||||
|
// RATIONALE: Eliminates redundant code.
|
||||||
|
'no-lone-blocks': 1,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-misleading-character-class': 2,
|
||||||
|
// RATIONALE: Catches a common coding mistake.
|
||||||
|
'no-multi-str': 2,
|
||||||
|
// RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to
|
||||||
|
// a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()",
|
||||||
|
// or else implies that the constructor is doing nontrivial computations, which is often
|
||||||
|
// a poor class design.
|
||||||
|
'no-new': 1,
|
||||||
|
// RATIONALE: Obsolete language feature that is deprecated.
|
||||||
|
'no-new-func': 2,
|
||||||
|
// RATIONALE: Obsolete language feature that is deprecated.
|
||||||
|
'no-new-object': 2,
|
||||||
|
// RATIONALE: Obsolete notation.
|
||||||
|
'no-new-wrappers': 1,
|
||||||
|
// RATIONALE: Catches code that is likely to be incorrect
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-octal': 2,
|
||||||
|
// RATIONALE: Catches code that is likely to be incorrect
|
||||||
|
'no-octal-escape': 2,
|
||||||
|
// RATIONALE: Catches code that is likely to be incorrect
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-regex-spaces': 2,
|
||||||
|
// RATIONALE: Catches a common coding mistake.
|
||||||
|
'no-return-assign': 2,
|
||||||
|
// RATIONALE: Security risk.
|
||||||
|
'no-script-url': 1,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-self-assign': 2,
|
||||||
|
// RATIONALE: Catches a common coding mistake.
|
||||||
|
'no-self-compare': 2,
|
||||||
|
// RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use
|
||||||
|
// commas to create compound expressions. In general code is more readable if each
|
||||||
|
// step is split onto a separate line. This also makes it easier to set breakpoints
|
||||||
|
// in the debugger.
|
||||||
|
'no-sequences': 1,
|
||||||
|
// RATIONALE: Catches code that is likely to be incorrect
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-shadow-restricted-names': 2,
|
||||||
|
// RATIONALE: Obsolete language feature that is deprecated.
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-sparse-arrays': 2,
|
||||||
|
// RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception,
|
||||||
|
// such flexibility adds pointless complexity, by requiring every catch block to test
|
||||||
|
// the type of the object that it receives. Whereas if catch blocks can always assume
|
||||||
|
// that their object implements the "Error" contract, then the code is simpler, and
|
||||||
|
// we generally get useful additional information like a call stack.
|
||||||
|
'no-throw-literal': 2,
|
||||||
|
// RATIONALE: Catches a common coding mistake.
|
||||||
|
'no-unmodified-loop-condition': 1,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-unsafe-finally': 2,
|
||||||
|
// RATIONALE: Catches a common coding mistake.
|
||||||
|
'no-unused-expressions': 1,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-unused-labels': 1,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-useless-catch': 1,
|
||||||
|
// RATIONALE: Avoids a potential performance problem.
|
||||||
|
'no-useless-concat': 1,
|
||||||
|
// RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior.
|
||||||
|
// Always use "let" or "const" instead.
|
||||||
|
//
|
||||||
|
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||||
|
'no-var': 2,
|
||||||
|
// RATIONALE: Generally not needed in modern code.
|
||||||
|
'no-void': 1,
|
||||||
|
// RATIONALE: Obsolete language feature that is deprecated.
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'no-with': 2,
|
||||||
|
// RATIONALE: Makes logic easier to understand, since constants always have a known value
|
||||||
|
// @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js
|
||||||
|
'prefer-const': 1,
|
||||||
|
// RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused.
|
||||||
|
'promise/param-names': 2,
|
||||||
|
// RATIONALE: Catches code that is likely to be incorrect
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'require-atomic-updates': 2,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'require-yield': 1,
|
||||||
|
// "Use strict" is redundant when using the TypeScript compiler.
|
||||||
|
'strict': [
|
||||||
|
2,
|
||||||
|
'never'
|
||||||
|
],
|
||||||
|
// RATIONALE: Catches code that is likely to be incorrect
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
'use-isnan': 2,
|
||||||
|
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||||
|
// Set to 1 (warning) or 2 (error) to enable.
|
||||||
|
// Rationale to disable: !!{}
|
||||||
|
'no-extra-boolean-cast': 0,
|
||||||
|
// ====================================================================
|
||||||
|
// @microsoft/eslint-plugin-spfx
|
||||||
|
// ====================================================================
|
||||||
|
'@microsoft/spfx/import-requires-chunk-name': 1,
|
||||||
|
'@microsoft/spfx/no-require-ensure': 2,
|
||||||
|
'@microsoft/spfx/pair-react-dom-render-unmount': 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// For unit tests, we can be a little bit less strict. The settings below revise the
|
||||||
|
// defaults specified in the extended configurations, as well as above.
|
||||||
|
files: [
|
||||||
|
// Test files
|
||||||
|
'*.test.ts',
|
||||||
|
'*.test.tsx',
|
||||||
|
'*.spec.ts',
|
||||||
|
'*.spec.tsx',
|
||||||
|
|
||||||
|
// Facebook convention
|
||||||
|
'**/__mocks__/*.ts',
|
||||||
|
'**/__mocks__/*.tsx',
|
||||||
|
'**/__tests__/*.ts',
|
||||||
|
'**/__tests__/*.tsx',
|
||||||
|
|
||||||
|
// Microsoft convention
|
||||||
|
'**/test/*.ts',
|
||||||
|
'**/test/*.tsx'
|
||||||
|
],
|
||||||
|
rules: {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Build generated files
|
||||||
|
dist
|
||||||
|
lib
|
||||||
|
release
|
||||||
|
solution
|
||||||
|
temp
|
||||||
|
*.sppkg
|
||||||
|
.heft
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
|
||||||
|
# OSX
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Visual Studio files
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
.vs
|
||||||
|
bin
|
||||||
|
obj
|
||||||
|
|
||||||
|
# Resx Generated Code
|
||||||
|
*.resx.ts
|
||||||
|
|
||||||
|
# Styles Generated Code
|
||||||
|
*.scss.ts
|
|
@ -0,0 +1,16 @@
|
||||||
|
!dist
|
||||||
|
config
|
||||||
|
|
||||||
|
gulpfile.js
|
||||||
|
|
||||||
|
release
|
||||||
|
src
|
||||||
|
temp
|
||||||
|
|
||||||
|
tsconfig.json
|
||||||
|
tslint.json
|
||||||
|
|
||||||
|
*.log
|
||||||
|
|
||||||
|
.yo-rc.json
|
||||||
|
.vscode
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"@microsoft/generator-sharepoint": {
|
||||||
|
"plusBeta": false,
|
||||||
|
"isCreatingSolution": true,
|
||||||
|
"nodeVersion": "16.19.0",
|
||||||
|
"sdksVersions": {
|
||||||
|
"@microsoft/microsoft-graph-client": "3.0.2",
|
||||||
|
"@microsoft/teams-js": "2.4.1"
|
||||||
|
},
|
||||||
|
"version": "1.16.1",
|
||||||
|
"libraryName": "react-tab-conversationview",
|
||||||
|
"libraryId": "e17df70b-eff1-405c-ab34-4640d61c0050",
|
||||||
|
"environment": "spo",
|
||||||
|
"packageManager": "npm",
|
||||||
|
"solutionName": "react-tab-conversationview",
|
||||||
|
"solutionShortDescription": "react-tab-conversationview description",
|
||||||
|
"skipFeatureDeployment": true,
|
||||||
|
"isDomainIsolated": false,
|
||||||
|
"componentType": "webpart"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
declare module 'react-read-more-less';
|
|
@ -0,0 +1,112 @@
|
||||||
|
# react-tab-conversationview
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
Have you ever struggled to find or search the conversations from Microsoft Team's channel ?
|
||||||
|
|
||||||
|
This sample webpart is developed to display the Microsoft Team's channel's conversation in a simpler way which makes easy to search and filters the new conversations and its replies. Please note that this webpart is designed to use in Microsoft Teams only.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- SPFx based Team's tab.
|
||||||
|
- Displays all the New(Parent) Conversations on the top
|
||||||
|
- Ablity to view all the replies of particular conversation
|
||||||
|
- Option to go to message or reply
|
||||||
|
- Find messages based on diffrent filters
|
||||||
|
- Body search(free text)
|
||||||
|
- Based on sender(from)
|
||||||
|
- Based on mentions(who all were mentioned in that message)
|
||||||
|
- From and To date
|
||||||
|
- With Attachments
|
||||||
|
- Display options - Chat format vs Tabular view
|
||||||
|
- Ability to use same filters on all the replies
|
||||||
|
- Icon on message where current user is mentioned.
|
||||||
|
|
||||||
|
|
||||||
|
![Main View](./assets/1.png)
|
||||||
|
|
||||||
|
![Tabular View](./assets/2.png)
|
||||||
|
|
||||||
|
![View Replies](./assets/3.png)
|
||||||
|
|
||||||
|
## Used SharePoint Framework Version
|
||||||
|
|
||||||
|
![version](https://img.shields.io/badge/version-1.16.1-green.svg)
|
||||||
|
|
||||||
|
## Applies to
|
||||||
|
|
||||||
|
- [SharePoint Framework](https://aka.ms/spfx)
|
||||||
|
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||||
|
|
||||||
|
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- As we are using MGT-Toolkit for SPFx, we need to make sure below SPPKG solution is deployed on tenant before current package can be used.
|
||||||
|
|
||||||
|
[MGT SPFx](https://learn.microsoft.com/en-us/graph/toolkit/get-started/mgt-spfx#prerequisites)
|
||||||
|
|
||||||
|
[Download Latest Package](https://github.com/microsoftgraph/microsoft-graph-toolkit/releases)
|
||||||
|
|
||||||
|
> Following Microsoft Graph permissions needs to be approved after uploading the package in the App Catalog
|
||||||
|
|
||||||
|
| Permissions |
|
||||||
|
|---------------------|
|
||||||
|
| ChannelMessage.Read.All |
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
| Solution | Author(s) |
|
||||||
|
| ----------- | ------------------------------------------------------- |
|
||||||
|
| react-tab-conversationview | [Siddharth Vaghasia](https://github.com/siddharth-vaghasia) |
|
||||||
|
| react-tab-conversationview | [Kunj Sangani](https://github.com/kunj-sangani) |
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
| Version | Date | Comments |
|
||||||
|
| ------- | ---------------- | --------------- |
|
||||||
|
| 1.0 | March 1st , 2023 | Initial release |
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
**THIS CODE IS PROVIDED _AS IS_ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Minimal Path to Awesome
|
||||||
|
|
||||||
|
- Clone this repository
|
||||||
|
- Ensure that you are at the solution folder
|
||||||
|
- in the command-line run:
|
||||||
|
- **npm install**
|
||||||
|
- **gulp serve**
|
||||||
|
|
||||||
|
As this SPFx webpart only works with in Teams's context, please follow below links to deploy it to tenant and make it available in Microsoft Teams
|
||||||
|
|
||||||
|
[Package and Deploy](https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-web-part-as-ms-teams-tab#package-and-deploy-your-web-part-to-sharepoint)
|
||||||
|
|
||||||
|
[Making the web part available in Teams](https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-web-part-as-ms-teams-tab#make-the-web-part-available-in-microsoft-teams)
|
||||||
|
|
||||||
|
if you want to use ready made package solution you can download it from [here](./assets/tab-conversations.sppkg)
|
||||||
|
|
||||||
|
## Concept Explored
|
||||||
|
|
||||||
|
This extension illustrates the following concepts:
|
||||||
|
|
||||||
|
- Developing Team's Tab with SPFx
|
||||||
|
- Usage of Graph Toolkit in SPFx
|
||||||
|
- Usage of React North Start library SPFx
|
||||||
|
- Calling Graph API in SPFx
|
||||||
|
- Concept of using Teams's Aware Logic in SPFx
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||||
|
- [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
|
||||||
|
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
|
||||||
|
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
|
||||||
|
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
|
||||||
|
- [Build Microsoft Teams tab using SharePoint Framework - Tutorial](https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-web-part-as-ms-teams-tab)
|
||||||
|
- [Using MGT Toolkit in SPFx](https://learn.microsoft.com/en-us/graph/toolkit/get-started/mgt-spfx)
|
||||||
|
|
||||||
|
![](https://pnptelemetry.azurewebsites.net/sp-dev-fx-webparts/samples/react-teams-conversationview)
|
Binary file not shown.
After Width: | Height: | Size: 128 KiB |
Binary file not shown.
After Width: | Height: | Size: 107 KiB |
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||||
|
"version": "2.0",
|
||||||
|
"bundles": {
|
||||||
|
"all-conversations-web-part": {
|
||||||
|
"components": [
|
||||||
|
{
|
||||||
|
"entrypoint": "./lib/webparts/allConversations/AllConversationsWebPart.js",
|
||||||
|
"manifest": "./src/webparts/allConversations/AllConversationsWebPart.manifest.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"externals": {},
|
||||||
|
"localizedResources": {
|
||||||
|
"AllConversationsWebPartStrings": "lib/webparts/allConversations/loc/{locale}.js"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||||
|
"workingDir": "./release/assets/",
|
||||||
|
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||||
|
"container": "react-tab-conversationview",
|
||||||
|
"accessKey": "<!-- ACCESS KEY -->"
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||||
|
"solution": {
|
||||||
|
"name": "react-tab-conversationview-client-side-solution",
|
||||||
|
"id": "e17df70b-eff1-405c-ab34-4640d61c0050",
|
||||||
|
"version": "1.0.0.1",
|
||||||
|
"includeClientSideAssets": true,
|
||||||
|
"skipFeatureDeployment": true,
|
||||||
|
"isDomainIsolated": false,
|
||||||
|
"developer": {
|
||||||
|
"name": "",
|
||||||
|
"websiteUrl": "",
|
||||||
|
"privacyUrl": "",
|
||||||
|
"termsOfUseUrl": "",
|
||||||
|
"mpnId": "Undefined-1.16.1"
|
||||||
|
},
|
||||||
|
"webApiPermissionRequests": [{
|
||||||
|
"resource": "Microsoft Graph",
|
||||||
|
"scope": "ChannelMessage.Read.All"
|
||||||
|
}],
|
||||||
|
"metadata": {
|
||||||
|
"shortDescription": {
|
||||||
|
"default": "react-tab-conversationview description"
|
||||||
|
},
|
||||||
|
"longDescription": {
|
||||||
|
"default": "react-tab-conversationview description"
|
||||||
|
},
|
||||||
|
"screenshotPaths": [],
|
||||||
|
"videoUrl": "",
|
||||||
|
"categories": []
|
||||||
|
},
|
||||||
|
"features": [{
|
||||||
|
"title": "react-tab-conversationview Feature",
|
||||||
|
"description": "The feature that activates elements of the react-tab-conversationview solution.",
|
||||||
|
"id": "bd9341cb-ae86-4cbf-b8e0-4caf2cbdd641",
|
||||||
|
"version": "1.0.0.0"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"zippedPackage": "solution/react-tab-conversationview.sppkg"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
|
||||||
|
"port": 4321,
|
||||||
|
"https": true,
|
||||||
|
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||||
|
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const build = require('@microsoft/sp-build-web');
|
||||||
|
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||||
|
|
||||||
|
var getTasks = build.rig.getTasks;
|
||||||
|
build.rig.getTasks = function () {
|
||||||
|
var result = getTasks.call(build.rig);
|
||||||
|
|
||||||
|
result.set('serve', result.get('serve-deprecated'));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
build.initialize(require('gulp'));
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,45 @@
|
||||||
|
{
|
||||||
|
"name": "react-tab-conversationview",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.13.0 <17.0.0"
|
||||||
|
},
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "gulp bundle",
|
||||||
|
"clean": "gulp clean",
|
||||||
|
"test": "gulp test"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fluentui/react-northstar": "^0.65.0",
|
||||||
|
"@microsoft/mgt-react": "^2.9.0",
|
||||||
|
"@microsoft/mgt-spfx": "^2.9.0",
|
||||||
|
"@microsoft/microsoft-graph-types": "^2.26.0",
|
||||||
|
"@microsoft/sp-core-library": "1.16.1",
|
||||||
|
"@microsoft/sp-lodash-subset": "1.16.1",
|
||||||
|
"@microsoft/sp-office-ui-fabric-core": "1.16.1",
|
||||||
|
"@microsoft/sp-property-pane": "1.16.1",
|
||||||
|
"@microsoft/sp-webpart-base": "1.16.1",
|
||||||
|
"office-ui-fabric-react": "^7.199.1",
|
||||||
|
"react": "17.0.1",
|
||||||
|
"react-dom": "17.0.1",
|
||||||
|
"react-read-more-less": "^0.1.6",
|
||||||
|
"tslib": "2.3.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@microsoft/eslint-config-spfx": "1.16.1",
|
||||||
|
"@microsoft/eslint-plugin-spfx": "1.16.1",
|
||||||
|
"@microsoft/rush-stack-compiler-4.5": "0.2.2",
|
||||||
|
"@microsoft/sp-build-web": "1.16.1",
|
||||||
|
"@microsoft/sp-module-interfaces": "1.16.1",
|
||||||
|
"@rushstack/eslint-config": "2.5.1",
|
||||||
|
"@types/react": "17.0.45",
|
||||||
|
"@types/react-dom": "17.0.17",
|
||||||
|
"@types/webpack-env": "~1.15.2",
|
||||||
|
"ajv": "^6.12.5",
|
||||||
|
"eslint-plugin-react-hooks": "4.3.0",
|
||||||
|
"gulp": "4.0.2",
|
||||||
|
"typescript": "4.5.5"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { ChatMessage } from "@microsoft/microsoft-graph-types";
|
||||||
|
|
||||||
|
export interface ITeamsMessage{
|
||||||
|
value: ChatMessage[];
|
||||||
|
['@odata.context']:string;
|
||||||
|
['@odata.count']:number;
|
||||||
|
['@odata.nextLink']?:string;
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
import { WebPartContext } from "@microsoft/sp-webpart-base";
|
||||||
|
import { MSGraphClientV3 } from "@microsoft/sp-http";
|
||||||
|
import { ITeamsMessage } from "../model/ITeamsMessage";
|
||||||
|
|
||||||
|
export interface IGraphService {
|
||||||
|
spcontext: WebPartContext;
|
||||||
|
IntializeGraphClient: () => Promise<void>;
|
||||||
|
getMessages: (teamsId: string, channelId: string) => Promise<ITeamsMessage>;
|
||||||
|
getNextData: (nextURL: string) => Promise<ITeamsMessage>;
|
||||||
|
getMessagesReplies: (teamsId: string, channelId: string, messageId: string) => Promise<ITeamsMessage>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GraphService implements IGraphService {
|
||||||
|
private _graphClient: MSGraphClientV3;
|
||||||
|
public spcontext: WebPartContext;
|
||||||
|
public constructor(spcontext: WebPartContext) {
|
||||||
|
this.spcontext = spcontext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntializeGraphClient = async (): Promise<void> => {
|
||||||
|
this._graphClient = await this.spcontext.msGraphClientFactory.getClient("3"); //TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public getMessages = async (teamsId: string, channelId: string): Promise<ITeamsMessage> => {
|
||||||
|
let messageResponse = [];
|
||||||
|
try {
|
||||||
|
messageResponse = await this._graphClient.api('teams/' + teamsId + '/channels/' + channelId + '/messages').top(45).version('v1.0').get();
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Unable to get teams', error);
|
||||||
|
}
|
||||||
|
return messageResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getNextData = async (nextURL: string): Promise<ITeamsMessage> => {
|
||||||
|
let messageResponse = [];
|
||||||
|
try {
|
||||||
|
messageResponse = await this._graphClient.api(nextURL).top(45).version('v1.0').get();
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Unable to get teams', error);
|
||||||
|
}
|
||||||
|
return messageResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getMessagesReplies = async (teamsId: string, channelId: string,messageId: string): Promise<ITeamsMessage> => {
|
||||||
|
let repliesResponse = [];
|
||||||
|
try {
|
||||||
|
repliesResponse = await this._graphClient.api('teams/' + teamsId + '/channels/' + channelId + '/messages/' + messageId + '/replies').top(45).version('v1.0').get();
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Unable to get teams', error);
|
||||||
|
}
|
||||||
|
return repliesResponse;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||||
|
"id": "e17df70b-eff1-405c-ab34-4640d61c0050",
|
||||||
|
"alias": "AllConversationsWebPart",
|
||||||
|
"componentType": "WebPart",
|
||||||
|
|
||||||
|
// The "*" signifies that the version should be taken from the package.json
|
||||||
|
"version": "*",
|
||||||
|
"manifestVersion": 2,
|
||||||
|
|
||||||
|
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||||
|
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||||
|
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||||
|
"requiresCustomScript": false,
|
||||||
|
"supportedHosts": ["TeamsTab"],
|
||||||
|
"supportsThemeVariants": true,
|
||||||
|
|
||||||
|
"preconfiguredEntries": [{
|
||||||
|
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
|
||||||
|
"group": { "default": "Advanced" },
|
||||||
|
"title": { "default": "AllConversations" },
|
||||||
|
"description": { "default": "AllConversations description" },
|
||||||
|
"officeFabricIconFontName": "Page",
|
||||||
|
"properties": {
|
||||||
|
"description": "AllConversations"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import * as ReactDom from 'react-dom';
|
||||||
|
import { Version } from '@microsoft/sp-core-library';
|
||||||
|
import {
|
||||||
|
IPropertyPaneConfiguration,
|
||||||
|
PropertyPaneTextField
|
||||||
|
} from '@microsoft/sp-property-pane';
|
||||||
|
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||||
|
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||||
|
|
||||||
|
import * as strings from 'AllConversationsWebPartStrings';
|
||||||
|
import AllConversations from './components/AllConversations';
|
||||||
|
import { IAllConversationsProps } from './components/IAllConversationsProps';
|
||||||
|
import { GraphService, IGraphService } from '../../service/GraphService';
|
||||||
|
import { Providers, SharePointProvider } from '@microsoft/mgt-spfx';
|
||||||
|
import { initializeIcons } from 'office-ui-fabric-react';
|
||||||
|
|
||||||
|
export interface IAllConversationsWebPartProps {
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class AllConversationsWebPart extends BaseClientSideWebPart<IAllConversationsWebPartProps> {
|
||||||
|
|
||||||
|
private _isDarkTheme: boolean = false;
|
||||||
|
private _environmentMessage: string = '';
|
||||||
|
public _graphService: IGraphService;
|
||||||
|
|
||||||
|
public render(): void {
|
||||||
|
const element: React.ReactElement<IAllConversationsProps> = React.createElement(
|
||||||
|
AllConversations,
|
||||||
|
{
|
||||||
|
description: this.properties.description,
|
||||||
|
isDarkTheme: this._isDarkTheme,
|
||||||
|
environmentMessage: this._environmentMessage,
|
||||||
|
hasTeamsContext: !!this.context.sdks.microsoftTeams,
|
||||||
|
userDisplayName: this.context.pageContext.user.displayName,
|
||||||
|
graphService: this._graphService
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ReactDom.render(element, this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async onInit(): Promise<void> {
|
||||||
|
this._graphService = new GraphService(this.context);
|
||||||
|
await this._graphService.IntializeGraphClient();
|
||||||
|
if (!Providers.globalProvider) {
|
||||||
|
Providers.globalProvider = new SharePointProvider(this.context);
|
||||||
|
}
|
||||||
|
if(this.context.sdks.microsoftTeams){
|
||||||
|
initializeIcons();
|
||||||
|
}
|
||||||
|
return this._getEnvironmentMessage().then(message => {
|
||||||
|
this._environmentMessage = message;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private _getEnvironmentMessage(): Promise<string> {
|
||||||
|
if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook
|
||||||
|
return this.context.sdks.microsoftTeams.teamsJs.app.getContext()
|
||||||
|
.then(context => {
|
||||||
|
let environmentMessage: string = '';
|
||||||
|
switch (context.app.host.name) {
|
||||||
|
case 'Office': // running in Office
|
||||||
|
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment;
|
||||||
|
break;
|
||||||
|
case 'Outlook': // running in Outlook
|
||||||
|
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment;
|
||||||
|
break;
|
||||||
|
case 'Teams': // running in Teams
|
||||||
|
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error('Unknown host');
|
||||||
|
}
|
||||||
|
|
||||||
|
return environmentMessage;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
|
||||||
|
if (!currentTheme) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._isDarkTheme = !!currentTheme.isInverted;
|
||||||
|
const {
|
||||||
|
semanticColors
|
||||||
|
} = currentTheme;
|
||||||
|
|
||||||
|
if (semanticColors) {
|
||||||
|
this.domElement.style.setProperty('--bodyText', semanticColors.bodyText || null);
|
||||||
|
this.domElement.style.setProperty('--link', semanticColors.link || null);
|
||||||
|
this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered || null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onDispose(): void {
|
||||||
|
ReactDom.unmountComponentAtNode(this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get dataVersion(): Version {
|
||||||
|
return Version.parse('1.0');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||||
|
return {
|
||||||
|
pages: [
|
||||||
|
{
|
||||||
|
header: {
|
||||||
|
description: strings.PropertyPaneDescription
|
||||||
|
},
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
groupName: strings.BasicGroupName,
|
||||||
|
groupFields: [
|
||||||
|
PropertyPaneTextField('description', {
|
||||||
|
label: strings.DescriptionFieldLabel
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
@import '~@fluentui/react/dist/sass/References.scss';
|
||||||
|
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||||
|
.allConversations {
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 1em;
|
||||||
|
color: "[theme:bodyText, default: #323130]";
|
||||||
|
color: var(--bodyText);
|
||||||
|
&.teams {
|
||||||
|
font-family: $ms-font-family-fallbacks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.loadMoreWrapper {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
column-gap: 10px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.PrimaryButtonNext {
|
||||||
|
font-size: 11px;
|
||||||
|
background: #444791;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.docWrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
|
@ -0,0 +1,185 @@
|
||||||
|
import 'office-ui-fabric-react/dist/css/fabric.css';
|
||||||
|
import { PrimaryButton } from 'office-ui-fabric-react';
|
||||||
|
import { User } from "@microsoft/microsoft-graph-types";
|
||||||
|
import * as React from 'react';
|
||||||
|
import { ITeamsMessage } from '../../../model/ITeamsMessage';
|
||||||
|
import styles from './AllConversations.module.scss';
|
||||||
|
import { IAllConversationsProps } from './IAllConversationsProps';
|
||||||
|
import { IAllConversationsState, ViewName } from './IAllConversationsState';
|
||||||
|
import { ArrowLeftIcon, Button, Provider, teamsTheme } from '@fluentui/react-northstar';
|
||||||
|
import { Filter } from './filter/Filter';
|
||||||
|
import { MessageView } from './messageView/MessageView';
|
||||||
|
import { TableView } from './tableView/TableView';
|
||||||
|
import { HeaderButton } from './headerButton/HeaderButton';
|
||||||
|
|
||||||
|
|
||||||
|
export default class AllConversations extends React.Component<IAllConversationsProps, IAllConversationsState> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
public constructor(props: IAllConversationsProps) {
|
||||||
|
super(props);
|
||||||
|
// eslint-disable-next-line no-void
|
||||||
|
void this.getTeamsMessages();
|
||||||
|
this.state={
|
||||||
|
allChatMessage:[],
|
||||||
|
filteredMessage:[],
|
||||||
|
nextLink:'',
|
||||||
|
expandedMessageId:'',
|
||||||
|
allRepliedMessage:[],
|
||||||
|
filteredRepliedMessage:[],
|
||||||
|
isFilterOpen: true,
|
||||||
|
viewName: ViewName.Grid,
|
||||||
|
isLoading: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* function to set the view name
|
||||||
|
* @param viewName name of the view to be set
|
||||||
|
*/
|
||||||
|
public setView = (viewName:ViewName):void =>{
|
||||||
|
this.setState({viewName:viewName});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To open close the filter panel
|
||||||
|
*/
|
||||||
|
public flipFilterPanel = (isOpen:boolean):void => {
|
||||||
|
this.setState({isFilterOpen: isOpen});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the Messages when clicked on load more
|
||||||
|
*/
|
||||||
|
private getLoadMoreData = async (): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const initialMessage:ITeamsMessage = await this.props.graphService.getNextData(this.state.nextLink);
|
||||||
|
console.log(initialMessage);
|
||||||
|
if(!!initialMessage['@odata.nextLink']){
|
||||||
|
this.setState({nextLink:initialMessage['@odata.nextLink']});
|
||||||
|
await this.getLoadMoreData();
|
||||||
|
}else{
|
||||||
|
this.setState({nextLink:'', isLoading:false});
|
||||||
|
}
|
||||||
|
if(initialMessage.value.length > 0){
|
||||||
|
let tempAllChatMessage = this.state.allChatMessage;
|
||||||
|
tempAllChatMessage = tempAllChatMessage.concat(initialMessage.value);
|
||||||
|
this.setState({allChatMessage:tempAllChatMessage});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the initial Message and not on load more
|
||||||
|
*/
|
||||||
|
private getTeamsMessages = async (): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const groupId = this.props.graphService.spcontext.sdks.microsoftTeams.context.groupId;
|
||||||
|
const channelId = this.props.graphService.spcontext.sdks.microsoftTeams.context.channelId;
|
||||||
|
const initialMessage:ITeamsMessage = await this.props.graphService.getMessages(groupId, channelId);
|
||||||
|
console.log(initialMessage);
|
||||||
|
if(!!initialMessage['@odata.nextLink']){
|
||||||
|
this.setState({nextLink:initialMessage['@odata.nextLink']});
|
||||||
|
await this.getLoadMoreData();
|
||||||
|
}else{
|
||||||
|
this.setState({nextLink:'', isLoading: false})
|
||||||
|
}
|
||||||
|
if(initialMessage.value.length > 0){
|
||||||
|
this.setState({allChatMessage:initialMessage.value, filteredMessage: initialMessage.value});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the replies for the selected message
|
||||||
|
* @param messageId selected message to get replies
|
||||||
|
*/
|
||||||
|
private getMessageReply = async (messageId:string): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const groupId = this.props.graphService.spcontext.sdks.microsoftTeams.context.groupId;
|
||||||
|
const channelId = this.props.graphService.spcontext.sdks.microsoftTeams.context.channelId;
|
||||||
|
const initialReplies:ITeamsMessage = await this.props.graphService.getMessagesReplies(groupId, channelId, messageId);
|
||||||
|
console.log(initialReplies);
|
||||||
|
this.setState({expandedMessageId:messageId,allRepliedMessage:initialReplies.value, filteredRepliedMessage: initialReplies.value})
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For filtering the data based on the selected filters
|
||||||
|
* @param searchText
|
||||||
|
*/
|
||||||
|
private onFilter = (searchText:string,fromDate: Date, toDate: Date, onlyAttachment: boolean,
|
||||||
|
fromUser:Array<User>, mentionedUser:Array<User>):void => {
|
||||||
|
let tempMessages = !!this.state.expandedMessageId ? this.state.allRepliedMessage : this.state.allChatMessage;
|
||||||
|
if(!!searchText){
|
||||||
|
tempMessages = tempMessages.filter(t=>t.body.content.includes(searchText));
|
||||||
|
}
|
||||||
|
if(!!fromDate){
|
||||||
|
tempMessages = tempMessages.filter(t=>new Date(t.createdDateTime) >= fromDate);
|
||||||
|
}
|
||||||
|
if(!!toDate){
|
||||||
|
tempMessages = tempMessages.filter(t=>new Date(t.createdDateTime) <= toDate);
|
||||||
|
}
|
||||||
|
if(onlyAttachment){
|
||||||
|
tempMessages = tempMessages.filter(t=>t.attachments.length > 0);
|
||||||
|
}
|
||||||
|
if(fromUser.length > 0){
|
||||||
|
fromUser.map(u=>{
|
||||||
|
tempMessages = tempMessages.filter(t=> t.from && t.from.user && t.from.user.id===u.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(mentionedUser.length > 0){
|
||||||
|
mentionedUser.map(u=>{
|
||||||
|
tempMessages = tempMessages.filter(t=> t.mentions.length > 0 && t.mentions.findIndex(m=> m.mentioned && m.mentioned.user
|
||||||
|
&& m.mentioned.user.id===u.id) > -1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(!!this.state.expandedMessageId){
|
||||||
|
this.setState({filteredRepliedMessage:tempMessages});
|
||||||
|
}else{
|
||||||
|
this.setState({filteredMessage:tempMessages});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): React.ReactElement<IAllConversationsProps> {
|
||||||
|
const {
|
||||||
|
hasTeamsContext
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
const dtaaFilteredMessage = !!this.state.expandedMessageId ? this.state.filteredRepliedMessage : this.state.filteredMessage;
|
||||||
|
const dtaaFilteredMessageData = !!this.state.expandedMessageId ?
|
||||||
|
this.state.allChatMessage.filter(t=>t.id===this.state.expandedMessageId) : [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Provider theme={teamsTheme}>
|
||||||
|
<section className={`${styles.allConversations} ${hasTeamsContext ? styles.teams : ''}`} >
|
||||||
|
<HeaderButton flipFilterPanel={this.flipFilterPanel} setView={this.setView} />
|
||||||
|
<Filter allChatMessage={dtaaFilteredMessage} onFilter={this.onFilter}
|
||||||
|
isOpen={this.state.isFilterOpen} flipFilterPanel={this.flipFilterPanel} />
|
||||||
|
{!!this.state.expandedMessageId &&
|
||||||
|
<Button icon={<ArrowLeftIcon />} content="Back"
|
||||||
|
onClick={()=>this.setState({expandedMessageId:'',allRepliedMessage:[],filteredRepliedMessage:[]})} text />}
|
||||||
|
{this.state.viewName === ViewName.Grid && <MessageView dtaaFilteredMessage={dtaaFilteredMessage}
|
||||||
|
dtaaFilteredMessageData={dtaaFilteredMessageData} graphService={this.props.graphService} expandedMessageId={this.state.expandedMessageId}
|
||||||
|
getMessageReply={this.getMessageReply} />}
|
||||||
|
{this.state.viewName === ViewName.Table && <TableView dtaaFilteredMessage={dtaaFilteredMessage}
|
||||||
|
dtaaFilteredMessageData={dtaaFilteredMessageData} graphService={this.props.graphService} expandedMessageId={this.state.expandedMessageId}
|
||||||
|
getMessageReply={this.getMessageReply}/>}
|
||||||
|
{!!this.state.nextLink && !this.state.expandedMessageId && !this.state.isLoading &&
|
||||||
|
<div className={styles.loadMoreWrapper}>
|
||||||
|
<PrimaryButton text="Load More" onClick={() => this.getLoadMoreData()} className={styles.PrimaryButtonNext} />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</section>
|
||||||
|
</Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { IGraphService } from "../../../service/GraphService";
|
||||||
|
|
||||||
|
export interface IAllConversationsProps {
|
||||||
|
description: string;
|
||||||
|
isDarkTheme: boolean;
|
||||||
|
environmentMessage: string;
|
||||||
|
hasTeamsContext: boolean;
|
||||||
|
userDisplayName: string;
|
||||||
|
graphService : IGraphService;
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { ChatMessage } from "@microsoft/microsoft-graph-types";
|
||||||
|
|
||||||
|
export interface IAllConversationsState{
|
||||||
|
allChatMessage : ChatMessage[];
|
||||||
|
filteredMessage : ChatMessage[];
|
||||||
|
nextLink:string;
|
||||||
|
expandedMessageId: string;
|
||||||
|
allRepliedMessage: ChatMessage[];
|
||||||
|
filteredRepliedMessage: ChatMessage[];
|
||||||
|
isFilterOpen: boolean;
|
||||||
|
viewName:ViewName;
|
||||||
|
isLoading: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ViewName{
|
||||||
|
"Grid",
|
||||||
|
"Table"
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import { Text, Button, Flex} from '@fluentui/react-northstar';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { DatePicker, DayOfWeek, SearchBox, Checkbox } from 'office-ui-fabric-react';
|
||||||
|
import { PeoplePicker } from '@microsoft/mgt-react/dist/es6/spfx';
|
||||||
|
import { ChatMessage as GraphChatMessage, User } from "@microsoft/microsoft-graph-types";
|
||||||
|
|
||||||
|
export interface IFilterProps {
|
||||||
|
allChatMessage:GraphChatMessage[];
|
||||||
|
onFilter:(searchText: string, fromDate: Date, toDate: Date, onlyAttachment:boolean,
|
||||||
|
fromUser:Array<User>, mentionedUser:Array<User>) => void;
|
||||||
|
isOpen: boolean;
|
||||||
|
flipFilterPanel: (isOpen: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const Filter: React.FunctionComponent<IFilterProps> = (props: React.PropsWithChildren<IFilterProps>) => {
|
||||||
|
const [searchText, setSearchText] = useState('');
|
||||||
|
const [fromUser, setFromUser] = useState<Array<User>>([]);
|
||||||
|
const [mentionedUser, setMentionedUser] = useState<Array<User>>([]);
|
||||||
|
const [fromDate, setFromDate] = useState<Date>();
|
||||||
|
const [toDate, setToDate] = useState<Date>();
|
||||||
|
const [onlyAttachment, setOnlyAttachment] = useState(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function on click of submit
|
||||||
|
*/
|
||||||
|
const onSubmit = ():void => {
|
||||||
|
props.onFilter(searchText, fromDate, toDate, onlyAttachment, fromUser, mentionedUser);
|
||||||
|
props.flipFilterPanel(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function on click of reset
|
||||||
|
*/
|
||||||
|
const onReset = ():void => {
|
||||||
|
setSearchText('');
|
||||||
|
setFromUser([]);
|
||||||
|
setMentionedUser([]);
|
||||||
|
setFromDate(null);
|
||||||
|
setToDate(null);
|
||||||
|
setOnlyAttachment(false);
|
||||||
|
props.onFilter('', null, null,false,[],[]);
|
||||||
|
props.flipFilterPanel(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* display filter and reset button in panel
|
||||||
|
* @returns JSX element for footer in the panel
|
||||||
|
*/
|
||||||
|
const onRenderFooterContent = ():JSX.Element => {
|
||||||
|
return (
|
||||||
|
<Flex gap="gap.smaller" vAlign='end'>
|
||||||
|
<Button content="Apply" primary onClick={onSubmit} />
|
||||||
|
<Button content="Reset" onClick={onReset}/>
|
||||||
|
</Flex>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Flex gap="gap.small">
|
||||||
|
{/* <Panel
|
||||||
|
headerText="Filter panel"
|
||||||
|
isOpen={props.isOpen}
|
||||||
|
onDismiss={()=>props.flipFilterPanel(false)}
|
||||||
|
closeButtonAriaLabel="Close"
|
||||||
|
onRenderFooterContent={onRenderFooterContent}
|
||||||
|
isFooterAtBottom={true}
|
||||||
|
> */}
|
||||||
|
<Flex column gap='gap.medium'>
|
||||||
|
<Flex gap='gap.medium' style={{justifyContent:'center', alignItems:'center'}}>
|
||||||
|
<Text content="Body Search" />
|
||||||
|
<SearchBox placeholder="Search" value={searchText} style={{minWidth:250}} onChange={(_,newValue)=>setSearchText(newValue)} />
|
||||||
|
<Text content="From" />
|
||||||
|
<div style={{minWidth:250}}>
|
||||||
|
<PeoplePicker userIds={props.allChatMessage.filter(t=>t.from && t.from.user).map((t)=>t.from.user.id)}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
selectionChanged={(e:any)=>setFromUser(e.target.selectedPeople)} selectedPeople={fromUser} />
|
||||||
|
</div>
|
||||||
|
<Text content="Mentions" />
|
||||||
|
<div style={{minWidth:250}}>
|
||||||
|
<PeoplePicker userIds={[].concat(...props.allChatMessage.filter(t=>t.mentions.length > 0).map((t)=>t.mentions.filter(m=>m.mentioned.user).map((m)=>m.mentioned.user.id)))}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
selectionChanged={(e:any)=>setMentionedUser(e.target.selectedPeople)} selectedPeople={mentionedUser} />
|
||||||
|
</div>
|
||||||
|
</Flex>
|
||||||
|
<Flex gap='gap.medium' style={{marginBottom:10, justifyContent:'center', alignItems:'center'}}>
|
||||||
|
<Text content="From Date" />
|
||||||
|
<DatePicker firstDayOfWeek={DayOfWeek.Monday} placeholder="Select a From date..."
|
||||||
|
onSelectDate={(date)=>setFromDate(date)} initialPickerDate={fromDate} value={fromDate} style={{minWidth:250}} />
|
||||||
|
<Text content="To Date" />
|
||||||
|
<DatePicker firstDayOfWeek={DayOfWeek.Monday} placeholder="Select a To date..."
|
||||||
|
onSelectDate={(date)=>setToDate(date)} initialPickerDate={toDate} value={toDate} style={{minWidth:250}} />
|
||||||
|
<Checkbox label="Attachments" checked={onlyAttachment} onChange={(_,checked)=>setOnlyAttachment(checked)} />
|
||||||
|
{onRenderFooterContent()}
|
||||||
|
</Flex>
|
||||||
|
</Flex>
|
||||||
|
{/* </Panel> */}
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1,40 @@
|
||||||
|
import { Button, Flex, FlexItem, GridIcon, TableIcon } from '@fluentui/react-northstar';
|
||||||
|
import * as React from 'react';
|
||||||
|
import { ViewName } from '../IAllConversationsState';
|
||||||
|
|
||||||
|
export interface IHeaderButtonProps {
|
||||||
|
flipFilterPanel: (isOpen: boolean) => void;
|
||||||
|
setView: (viewName: ViewName) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const HeaderButton: React.FunctionComponent<IHeaderButtonProps> = (props: React.PropsWithChildren<IHeaderButtonProps>) => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Flex gap="gap.small">
|
||||||
|
{/* <FlexItem>
|
||||||
|
<Button icon={<FilterIcon/>} content="Filter" onClick={()=>props.flipFilterPanel(true)} />
|
||||||
|
</FlexItem> */}
|
||||||
|
<h1>Search conversation</h1>
|
||||||
|
<FlexItem push>
|
||||||
|
<Button.Group
|
||||||
|
buttons={[
|
||||||
|
{
|
||||||
|
icon: <GridIcon />,
|
||||||
|
key: 'Gallery',
|
||||||
|
iconOnly: true,
|
||||||
|
title: 'Gallery View',
|
||||||
|
onClick:()=>props.setView(ViewName.Grid)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: <TableIcon />,
|
||||||
|
key: 'Table',
|
||||||
|
iconOnly: true,
|
||||||
|
title: 'Table View',
|
||||||
|
onClick:()=>props.setView(ViewName.Table)
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</FlexItem>
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1,139 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import { ViewType } from '@microsoft/mgt-spfx';
|
||||||
|
import { Person } from '@microsoft/mgt-react/dist/es6/spfx';
|
||||||
|
import { ChatMessage as GraphChatMessage, ChatMessageAttachment } from "@microsoft/microsoft-graph-types";
|
||||||
|
import { Chat, ChatItem, ChatMessage, ExpandIcon,
|
||||||
|
MentionIcon, ReplyIcon} from '@fluentui/react-northstar';
|
||||||
|
import { IGraphService } from '../../../../service/GraphService';
|
||||||
|
import styles from '.././AllConversations.module.scss';
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
import ReadMoreAndLess from 'react-read-more-less';
|
||||||
|
|
||||||
|
export interface IMessageViewProps {
|
||||||
|
expandedMessageId:string;
|
||||||
|
graphService : IGraphService;
|
||||||
|
getMessageReply: (messageId: string) => Promise<void>;
|
||||||
|
dtaaFilteredMessage: GraphChatMessage[];
|
||||||
|
dtaaFilteredMessageData: GraphChatMessage[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MessageView: React.FunctionComponent<IMessageViewProps> = (props: React.PropsWithChildren<IMessageViewProps>) => {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* converts message body to string
|
||||||
|
* @param html input body of message
|
||||||
|
* @returns string formated text
|
||||||
|
*/
|
||||||
|
const convertToPlain = (html:string):string => {
|
||||||
|
const tempDivElement = document.createElement("div");
|
||||||
|
tempDivElement.innerHTML = html;
|
||||||
|
return tempDivElement.textContent || tempDivElement.innerText || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='ms-Grid'>
|
||||||
|
<div className="ms-Grid-row">
|
||||||
|
{!!props.expandedMessageId &&
|
||||||
|
props.dtaaFilteredMessageData.map((chatMessage:GraphChatMessage,index:number)=>
|
||||||
|
chatMessage.from && chatMessage.from.user && <Chat>
|
||||||
|
<ChatItem
|
||||||
|
key={index}
|
||||||
|
message={
|
||||||
|
<ChatMessage
|
||||||
|
actionMenu={{
|
||||||
|
iconOnly: true,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
key: 'naviagateToMessage',
|
||||||
|
icon: <ExpandIcon onClick={()=> props.graphService.spcontext
|
||||||
|
.sdks.microsoftTeams.teamsJs.app.openLink(chatMessage.webUrl)} />,
|
||||||
|
title: 'naviagateToMessage',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'viewReplies',
|
||||||
|
icon: <ReplyIcon onClick={()=>props.getMessageReply(chatMessage.id)} />,
|
||||||
|
title: 'viewReplies',
|
||||||
|
},
|
||||||
|
].filter(t=>!!props.expandedMessageId ? t.key!=='viewReplies' : true)
|
||||||
|
}}
|
||||||
|
author={chatMessage.from.user.displayName}
|
||||||
|
content={
|
||||||
|
<div><ReadMoreAndLess
|
||||||
|
className="read-more-content"
|
||||||
|
charLimit={100}
|
||||||
|
readMoreText="Read more"
|
||||||
|
readLessText=" Read less"
|
||||||
|
>
|
||||||
|
{convertToPlain(chatMessage.body.content)}
|
||||||
|
</ReadMoreAndLess>
|
||||||
|
<div className={styles.docWrapper}>
|
||||||
|
{
|
||||||
|
chatMessage.attachments && chatMessage.attachments.map((at:ChatMessageAttachment,
|
||||||
|
attachmentIndex:number) =>
|
||||||
|
<a key ={`attachment${index}-${attachmentIndex}`} style={{cursor:'pointer'}} onClick={() =>
|
||||||
|
props.graphService.spcontext.sdks.microsoftTeams.teamsJs.app.openLink(at.contentUrl)} >{at.name}</a>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>} timestamp={chatMessage.createdDateTime} badge={chatMessage.mentions.length > 0 &&
|
||||||
|
{icon: <MentionIcon />}} />
|
||||||
|
}
|
||||||
|
gutter={<Person userId={chatMessage.from.user.id} view={ViewType.image} />}
|
||||||
|
/>
|
||||||
|
</Chat>)}
|
||||||
|
{props.dtaaFilteredMessage.map((chatMessage:GraphChatMessage,index:number)=>
|
||||||
|
chatMessage.from && chatMessage.from.user && <Chat density="compact">
|
||||||
|
<ChatItem
|
||||||
|
key={index}
|
||||||
|
message={
|
||||||
|
<ChatMessage
|
||||||
|
actionMenu={{
|
||||||
|
iconOnly: true,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
key: 'naviagateToMessage',
|
||||||
|
icon: <ExpandIcon onClick={()=> props.graphService.spcontext
|
||||||
|
.sdks.microsoftTeams.teamsJs.app.openLink(chatMessage.webUrl)} />,
|
||||||
|
title: 'naviagateToMessage',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'viewReplies',
|
||||||
|
icon: <ReplyIcon onClick={()=>props.getMessageReply(chatMessage.id)} />,
|
||||||
|
title: 'viewReplies',
|
||||||
|
},
|
||||||
|
].filter(t=>!!props.expandedMessageId ? t.key!=='viewReplies' : true)
|
||||||
|
}}
|
||||||
|
author={chatMessage.from.user.displayName}
|
||||||
|
content={
|
||||||
|
<div><ReadMoreAndLess
|
||||||
|
className="read-more-content"
|
||||||
|
charLimit={100}
|
||||||
|
readMoreText="Read more"
|
||||||
|
readLessText=" Read less"
|
||||||
|
>
|
||||||
|
{convertToPlain(chatMessage.body.content)}
|
||||||
|
</ReadMoreAndLess>
|
||||||
|
<div className={styles.docWrapper}>
|
||||||
|
{
|
||||||
|
chatMessage.attachments && chatMessage.attachments.map((at:ChatMessageAttachment,
|
||||||
|
attachmentIndex:number) =>
|
||||||
|
<a key ={`attachment${index}-${attachmentIndex}`} style={{cursor:'pointer'}} onClick={() =>
|
||||||
|
props.graphService.spcontext.sdks.microsoftTeams.teamsJs.app.openLink(at.contentUrl)} >{at.name}</a>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>}
|
||||||
|
timestamp={new Date(chatMessage.createdDateTime).toLocaleString("en-us")}
|
||||||
|
badge={chatMessage.mentions.length > 0 && chatMessage.mentions.filter(t=>t.mentioned && t.mentioned.user &&
|
||||||
|
t.mentioned.user.id===props.graphService.spcontext.sdks.microsoftTeams.context.userObjectId).length > 0 &&
|
||||||
|
{icon: <MentionIcon />}} />
|
||||||
|
}
|
||||||
|
gutter={<Person key={`personKey${index}`} userId={chatMessage.from.user.id} view={ViewType.image} />}
|
||||||
|
/>
|
||||||
|
</Chat>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1,133 @@
|
||||||
|
import { IColumn, SelectionMode, DetailsList } from 'office-ui-fabric-react';
|
||||||
|
import * as React from 'react';
|
||||||
|
import { ChatMessage as GraphChatMessage, ChatMessageAttachment } from "@microsoft/microsoft-graph-types";
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
import ReadMoreAndLess from 'react-read-more-less';
|
||||||
|
import { ViewType } from '@microsoft/mgt-spfx';
|
||||||
|
import { Person } from '@microsoft/mgt-react/dist/es6/spfx';
|
||||||
|
import { IGraphService } from '../../../../service/GraphService';
|
||||||
|
import styles from '.././AllConversations.module.scss';
|
||||||
|
import { ExpandIcon, ReplyIcon } from '@fluentui/react-northstar';
|
||||||
|
|
||||||
|
export interface ITableViewProps {
|
||||||
|
expandedMessageId:string;
|
||||||
|
graphService : IGraphService;
|
||||||
|
getMessageReply: (messageId: string) => Promise<void>;
|
||||||
|
dtaaFilteredMessage: GraphChatMessage[];
|
||||||
|
dtaaFilteredMessageData: GraphChatMessage[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TableView: React.FunctionComponent<ITableViewProps> = (props: React.PropsWithChildren<ITableViewProps>) => {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* converts message body to string
|
||||||
|
* @param html input body of message
|
||||||
|
* @returns string formated text
|
||||||
|
*/
|
||||||
|
const convertToPlain = (html:string):string => {
|
||||||
|
const tempDivElement = document.createElement("div");
|
||||||
|
tempDivElement.innerHTML = html;
|
||||||
|
return tempDivElement.textContent || tempDivElement.innerText || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns: IColumn[] = [
|
||||||
|
{
|
||||||
|
key: 'column1',
|
||||||
|
name: 'From',
|
||||||
|
minWidth: 200,
|
||||||
|
maxWidth: 200,
|
||||||
|
isResizable: true,
|
||||||
|
isCollapsible: true,
|
||||||
|
onRender: (chatMessage: GraphChatMessage) => (
|
||||||
|
<Person userId={chatMessage.from.user.id} view={ViewType.oneline} />
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'column2',
|
||||||
|
name: 'Message',
|
||||||
|
minWidth: 300,
|
||||||
|
maxWidth: 300,
|
||||||
|
|
||||||
|
isResizable: false,
|
||||||
|
isCollapsible: true,
|
||||||
|
onRender: (chatMessage: GraphChatMessage) => (
|
||||||
|
<ReadMoreAndLess
|
||||||
|
className="read-more-content"
|
||||||
|
charLimit={50}
|
||||||
|
readMoreText="Read more"
|
||||||
|
readLessText=" Read less"
|
||||||
|
>
|
||||||
|
{convertToPlain(chatMessage.body.content)}
|
||||||
|
</ReadMoreAndLess>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'column3',
|
||||||
|
name: 'Message Date',
|
||||||
|
fieldName: 'createdDateTime',
|
||||||
|
minWidth: 100,
|
||||||
|
maxWidth: 100,
|
||||||
|
isResizable: true,
|
||||||
|
isCollapsible: true,
|
||||||
|
onRender :(chatMessage: GraphChatMessage) => (
|
||||||
|
<div>{new Date(chatMessage.createdDateTime).toLocaleString("en-us")}</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'column4',
|
||||||
|
name: 'Attachment',
|
||||||
|
minWidth: 100,
|
||||||
|
maxWidth: 100,
|
||||||
|
isResizable: true,
|
||||||
|
isCollapsible: true,
|
||||||
|
onRender: (chatMessage: GraphChatMessage) => (
|
||||||
|
<div className={styles.docWrapper}>
|
||||||
|
{
|
||||||
|
chatMessage.attachments && chatMessage.attachments.map((at:ChatMessageAttachment,
|
||||||
|
attachmentIndex:number) =>
|
||||||
|
<a key ={`attachment${attachmentIndex}`} style={{cursor:'pointer',
|
||||||
|
textDecoration:'underline', color:'blue'}} onClick={() =>
|
||||||
|
props.graphService.spcontext.sdks.microsoftTeams.teamsJs.app.openLink(at.contentUrl)} >{at.name}</a>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'column5',
|
||||||
|
name: 'View Replies',
|
||||||
|
minWidth: 100,
|
||||||
|
maxWidth: 100,
|
||||||
|
isResizable: true,
|
||||||
|
isCollapsible: true,
|
||||||
|
onRender: (chatMessage: GraphChatMessage) => (
|
||||||
|
!props.expandedMessageId && <ReplyIcon onClick={()=>props.getMessageReply(chatMessage.id)} />
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'column6',
|
||||||
|
name: 'Go to Message',
|
||||||
|
minWidth: 100,
|
||||||
|
maxWidth: 100,
|
||||||
|
isResizable: true,
|
||||||
|
isCollapsible: true,
|
||||||
|
onRender: (chatMessage: GraphChatMessage) => (
|
||||||
|
<ExpandIcon onClick={()=> props.graphService.spcontext
|
||||||
|
.sdks.microsoftTeams.teamsJs.app.openLink(chatMessage.webUrl)} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{!!props.expandedMessageId && props.dtaaFilteredMessageData.length > 0 && <DetailsList
|
||||||
|
items={props.dtaaFilteredMessageData}
|
||||||
|
columns={columns} selectionMode={SelectionMode.none} />}
|
||||||
|
{props.dtaaFilteredMessage.length > 0 &&
|
||||||
|
<DetailsList
|
||||||
|
items={props.dtaaFilteredMessage.filter(t=>t.from && t.from.user)}
|
||||||
|
columns={columns} selectionMode={SelectionMode.none} />}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
15
samples/react-teams-conversationview/src/webparts/allConversations/loc/en-us.js
vendored
Normal file
15
samples/react-teams-conversationview/src/webparts/allConversations/loc/en-us.js
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
define([], function() {
|
||||||
|
return {
|
||||||
|
"PropertyPaneDescription": "Description",
|
||||||
|
"BasicGroupName": "Group Name",
|
||||||
|
"DescriptionFieldLabel": "Description Field",
|
||||||
|
"AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part",
|
||||||
|
"AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app",
|
||||||
|
"AppLocalEnvironmentOffice": "The app is running on your local environment in office.com",
|
||||||
|
"AppLocalEnvironmentOutlook": "The app is running on your local environment in Outlook",
|
||||||
|
"AppSharePointEnvironment": "The app is running on SharePoint page",
|
||||||
|
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams",
|
||||||
|
"AppOfficeEnvironment": "The app is running in office.com",
|
||||||
|
"AppOutlookEnvironment": "The app is running in Outlook"
|
||||||
|
}
|
||||||
|
});
|
18
samples/react-teams-conversationview/src/webparts/allConversations/loc/mystrings.d.ts
vendored
Normal file
18
samples/react-teams-conversationview/src/webparts/allConversations/loc/mystrings.d.ts
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
declare interface IAllConversationsWebPartStrings {
|
||||||
|
PropertyPaneDescription: string;
|
||||||
|
BasicGroupName: string;
|
||||||
|
DescriptionFieldLabel: string;
|
||||||
|
AppLocalEnvironmentSharePoint: string;
|
||||||
|
AppLocalEnvironmentTeams: string;
|
||||||
|
AppLocalEnvironmentOffice: string;
|
||||||
|
AppLocalEnvironmentOutlook: string;
|
||||||
|
AppSharePointEnvironment: string;
|
||||||
|
AppTeamsTabEnvironment: string;
|
||||||
|
AppOfficeEnvironment: string;
|
||||||
|
AppOutlookEnvironment: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'AllConversationsWebPartStrings' {
|
||||||
|
const strings: IAllConversationsWebPartStrings;
|
||||||
|
export = strings;
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
After Width: | Height: | Size: 542 B |
Binary file not shown.
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.8/MicrosoftTeams.schema.json",
|
||||||
|
"manifestVersion": "1.8",
|
||||||
|
"packageName": "AllConversations",
|
||||||
|
"id": "e17df70b-eff1-405c-ab34-4640d61c0050",
|
||||||
|
"version": "1.0.0.1",
|
||||||
|
"developer": {
|
||||||
|
"name": "SPFx + Teams Dev",
|
||||||
|
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
|
||||||
|
"privacyUrl": "https://privacy.microsoft.com/en-us/privacystatement",
|
||||||
|
"termsOfUseUrl": "https://www.microsoft.com/en-us/servicesagreement"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"short": "AllConversations"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"short": "AllConversations",
|
||||||
|
"full": "AllConversations"
|
||||||
|
},
|
||||||
|
"icons": {
|
||||||
|
"outline": "73727f41-acf2-4a97-9b29-8d911e9fdf34_outline.png",
|
||||||
|
"color": "73727f41-acf2-4a97-9b29-8d911e9fdf34_color.png"
|
||||||
|
},
|
||||||
|
"accentColor": "#004578",
|
||||||
|
"configurableTabs": [{
|
||||||
|
"configurationUrl": "https://{teamSiteDomain}{teamSitePath}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/teamshostedapp.aspx%3FopenPropertyPane=true%26teams%26componentId=e17df70b-eff1-405c-ab34-4640d61c0050%26forceLocale={locale}",
|
||||||
|
"canUpdateConfiguration": true,
|
||||||
|
"scopes": [
|
||||||
|
"team"
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
|
||||||
|
"validDomains": [
|
||||||
|
"*.login.microsoftonline.com",
|
||||||
|
"*.sharepoint.com",
|
||||||
|
"*.sharepoint-df.com",
|
||||||
|
"spoppe-a.akamaihd.net",
|
||||||
|
"spoprod-a.akamaihd.net",
|
||||||
|
"resourceseng.blob.core.windows.net",
|
||||||
|
"msft.spoppe.com"
|
||||||
|
],
|
||||||
|
"webApplicationInfo": {
|
||||||
|
"resource": "https://{teamSiteDomain}",
|
||||||
|
"id": "00000003-0000-0ff1-ce00-000000000000"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"extends": "./node_modules/@microsoft/rush-stack-compiler-4.5/includes/tsconfig-web.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"jsx": "react",
|
||||||
|
"declaration": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"outDir": "lib",
|
||||||
|
"inlineSources": false,
|
||||||
|
"strictNullChecks": false,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types",
|
||||||
|
"./node_modules/@microsoft",
|
||||||
|
"./@types"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"webpack-env"
|
||||||
|
],
|
||||||
|
"lib": [
|
||||||
|
"es5",
|
||||||
|
"dom",
|
||||||
|
"es2015.collection",
|
||||||
|
"es2015.promise"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts",
|
||||||
|
"src/**/*.tsx"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue