Skip to content

Commit

Permalink
Refactor logo usage
Browse files Browse the repository at this point in the history
Also:
* Move logos to a central location
* Make the loading spinner color-scheme-aware
* Recreate `OverviewPageHeader`, `HomeIcon`, `HeaderLogo`, `SolutionTitle`, `Welcome`, `Overview` tests
* Enhance `ExitFullScreenButton`, `Header` tests
* Tinified favicon assets

Signed-off-by: Miki <[email protected]>
  • Loading branch information
AMoo-Miki committed Aug 9, 2023
1 parent 4bc1f55 commit 9605792
Show file tree
Hide file tree
Showing 102 changed files with 3,658 additions and 8,008 deletions.
100 changes: 100 additions & 0 deletions packages/osd-dev-utils/src/serializers/flat_object_serializer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

const walk = (value: any, path: string[] = [], collector: string[] = []) => {
let objValue;
switch (Object.prototype.toString.call(value)) {
case '[object Map]':
case '[object WeakMap]':
objValue = Object.fromEntries(value);
break;

case '[object Set]':
case '[object WeakSet]':
objValue = Array.from(value);
break;

case '[object Object]':
case '[object Array]':
objValue = value;
break;

case '[object RegExp]':
case '[object Function]':
case '[object Date]':
case '[object Boolean]':
case '[object Number]':
case '[object Symbol]':
case '[object Error]':
collector.push(`${path.join('.')} = ${value.toString()}`);
break;

case '[object Null]':
collector.push(`${path.join('.')} = null`);
break;

case '[object Undefined]':
collector.push(`${path.join('.')} = undefined`);
break;

case '[object String]':
collector.push(`${path.join('.')} = ${JSON.stringify(value)}`);
break;

case '[object BigInt]':
collector.push(`${path.join('.')} = ${value.toString()}n`);
break;

default:
if (value instanceof Object.getPrototypeOf(Uint8Array)) {
objValue = Array.from(value);
}
}

if (!objValue) return collector;

if (Array.isArray(objValue)) {
objValue.forEach((v, i) => {
walk(v, [...path, i.toString()], collector);
});
} else {
// eslint-disable-next-line guard-for-in
for (const key in objValue) {
walk(objValue[key], [...path, key], collector);
}
}

return collector;
};
export const flatObjectSerializer = {
test: (value: any) =>
['[object Object]', '[object Array]'].includes(Object.prototype.toString.call(value)),
serialize: (value: any) => walk(value).sort().join('\n'),
};
1 change: 1 addition & 0 deletions packages/osd-dev-utils/src/serializers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ export * from './recursive_serializer';
export * from './any_instance_serizlizer';
export * from './replace_serializer';
export * from './strip_promises_serizlizer';
export * from './flat_object_serializer';
6 changes: 6 additions & 0 deletions src/core/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './logos';
Loading

0 comments on commit 9605792

Please sign in to comment.