Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev-v0.2.15 #53

Merged
merged 8 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions addon/components/file-icon.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import getWithDefault from '@fleetbase/ember-core/utils/get-with-default';
import isModel from '@fleetbase/ember-core/utils/is-model';
import isUploadFile from '../utils/is-upload-file';

export default class FileIconComponent extends Component {
@tracked file;
Expand All @@ -16,18 +18,29 @@ export default class FileIconComponent extends Component {
}

getExtension(file) {
if (!file || (!file.original_filename && !file.url && !file.path)) {
let filename;

if (isModel(file)) {
filename = file.original_filename ?? file.url ?? file.path;
}

if (isUploadFile(file)) {
filename = file.file ? file.file.name : null;
}

if (typeof filename !== 'string') {
return null;
}

// Prefer to use the original filename if available, then URL, then path
const filename = file.original_filename || file.url || file.path;
const extensionMatch = filename.match(/\.(.+)$/);
return extensionMatch ? extensionMatch[1] : null;
}

getIcon(file) {
const extension = this.getExtension(file);
if (!extension) {
return 'file-alt';
}

return getWithDefault(
{
Expand Down
10 changes: 8 additions & 2 deletions addon/services/modals-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,20 @@ export default class ModalsManagerService extends Service {
* Retrieves an option
*
* @param {String} key
* @param {Mixed} defaultValue
* @return {Mixed}
*/
@action getOption(key) {
@action getOption(key, defaultValue = null) {
if (isArray(key)) {
return this.getOptions(key);
}

return get(this.options, key);
const value = get(this.options, key);
if (value === undefined) {
return defaultValue;
}

return value;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion addon/styles/layout/legacy.css
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ body[data-theme='dark'] .overlay-panel-section-title {

#console-loader,
.overloader {
@apply absolute inset-0 w-full h-full bg-gray-100 text-gray-800 flex items-center justify-center bg-opacity-10;
@apply absolute inset-0 w-full h-full text-gray-800 flex items-center justify-center bg-opacity-10;
z-index: 9999999999;
}

Expand Down
17 changes: 17 additions & 0 deletions addon/styles/layout/next.css
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,10 @@ body[data-theme='dark'] .next-sidebar .next-sidebar-panel-container > .next-side
background-color: #ffffff;
}

body[data-theme="dark"] .next-sidebar .next-sidebar-panel-container > .next-sidebar-panel > .next-content-panel > .next-content-panel-body .next-nav-item.next-nav-item-with-dropdown:hover .ember-basic-dropdown-trigger > span.btn-wrapper > button.btn:hover {
background-color: #374151;
}

.next-sidebar .next-sidebar-panel-container > .next-sidebar-panel > .next-content-panel > .next-content-panel-body .next-nav-item.next-nav-item-with-dropdown:hover .ember-basic-dropdown-trigger > span.btn-wrapper > button.btn {
color: #000000;
}
Expand Down Expand Up @@ -1890,6 +1894,19 @@ a.text-danger:hover {
animation: rotation 1s linear infinite;
}

.overloader > .loader-container {
background: rgba(243, 244, 246, .25);
border: 1px solid #d1d5db;
backdrop-filter: blur(3.5px);
border-radius: .5rem;
padding: .25rem .85rem;
}

body[data-theme="dark"] .overloader > .loader-container {
background: rgb(31, 41, 55, .25);
border: 1px solid rgba(15, 23, 42, .25);
}

@keyframes rotation {
0% {
transform: rotate(0deg);
Expand Down
5 changes: 5 additions & 0 deletions addon/utils/is-upload-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { UploadFile } from 'ember-file-upload';

export default function isUploadFile(file) {
return file instanceof UploadFile;
}
1 change: 1 addition & 0 deletions app/utils/is-upload-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@fleetbase/ember-ui/utils/is-upload-file';
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/ember-ui",
"version": "0.2.14",
"version": "0.2.15",
"description": "Fleetbase UI provides all the interface components, helpers, services and utilities for building a Fleetbase extension into the Console.",
"keywords": [
"fleetbase-ui",
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/utils/is-upload-file-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// import isUploadFile from 'dummy/utils/is-upload-file';
import { module, test } from 'qunit';

module('Unit | Utility | is-upload-file', function () {
test('it works', function (assert) {
// let result = isUploadFile();
assert.ok(true);
});
});
Loading